GeorepositoryClient

class geodetic_engine.georepository.GeorepositoryClient[source]

Bases: object

Reads objects from a Georepository instance.

Example

>>> client = GeorepositoryClient(config)
>>> systems = list(
...     client.iter_collection("GeodeticCoordRefSystem")
... )
__init__(config, *, credential=None, transport=None)[source]
close()[source]

Close the HTTP connection pools.

Return type:

None

get_object(url)[source]

Fetch a single object by absolute URL, caching the result.

Scope, extent, unit and method objects are referenced by many parents; without caching the same object is refetched hundreds of times.

Parameters:

url (str) – Absolute URL, typically taken from a Links or href field.

Return type:

dict[str, Any]

Returns:

The decoded JSON object.

resolve(link)[source]

Follow a ChildLink-shaped reference.

Parameters:

link (dict[str, Any] | None) – A mapping with an href key, or None.

Return type:

dict[str, Any]

Returns:

The referenced object, or an empty mapping when there is no link. An empty mapping is returned only for an absent link; a link that cannot be fetched raises.

self_href(item)[source]

Return the canonical URL of an object, if it advertises one.

Parameters:

item (dict[str, Any]) – An object as returned by the API, with a Links array.

Return type:

str | None

Returns:

The self link, else the first link, else None.

aliases(item)[source]

Fetch the alias records of an object.

Every object type exposes {object}/alias. The detail representation sometimes carries an inline Alias array as well; that is preferred when present to avoid a round trip.

Parameters:

item (dict[str, Any]) – A detail object carrying Links and possibly Alias.

Return type:

list[dict[str, Any]]

Returns:

Details-shaped alias records, each with Alias and NamingSystem. An empty list when the object has no aliases.

detail(item)[source]

Fetch the full object behind a search result.

Collection endpoints return summaries; the fields needed to build a proj.db row only appear on the detail representation.

Parameters:

item (dict[str, Any]) – A search result carrying a Links array.

Return type:

dict[str, Any]

Returns:

The full object, or the input unchanged when it carries no link.

wkt(item)[source]

Export an object as WKT2.

The register’s own rendering is used rather than one rebuilt from the object’s fields, so that a CRS this workflow does not model in full still reaches PROJ exactly as the authority stated it.

Parameters:

item (dict[str, Any]) – A detail object carrying Links.

Return type:

str | None

Returns:

The WKT string, or None when the object advertises no link or the instance returns an empty body.

Raises:

GeorepositoryApiError – If the export request fails. A bound CRS is one such case: the endpoint exists but answers HTTP 501.

Example

>>> client.wkt(client.detail(item))
'GEOGCRS["ED50",DATUM[...'
iter_collection(endpoint, *, authorities=None)[source]

Yield every object in a collection endpoint, page by page.

Parameters:
  • endpoint (str) – Endpoint name such as Transformation.

  • authorities (frozenset[str] | None, default: None) – If given, only yield objects whose DataSource matches one of these names, compared case-insensitively. The API offers no server-side equivalent.

Yields:

Search result objects in server order.

Raises:

PaginationTruncatedError – If the server advertises more results than were collected, or repeats a page, which indicates the page parameter was ignored.

versions(*, custom_authority=None)[source]

The newest version of each dataset the register keeps.

A register versions two things separately and reports both on its own landing page: the EPSG dataset it carries, and the objects it defines itself. A version history entry states no DataSource, so the two series are told apart by code, EPSG’s running up from 1 and the register’s own from a fixed floor well above EPSG’s range.

Only the collection summaries are read, never the detail of each entry: there are hundreds of them, and a build needs this answer before it can decide anything else.

Parameters:

custom_authority (str | None, default: None) – Name to report the register’s own series under. Defaults to custom, since the register does not name it.

Return type:

dict[str, str]

Returns:

Version by dataset, such as {"EPSG" -- "12.053", "Example": "1.103"}. Empty when the instance exposes no version history.

latest_version()[source]

Return the newest Georepository version name, for provenance.

Return type:

str | None

Returns:

The Name of the most recent version history entry, or None when the instance exposes no version history.