OsduCatalog

class geodetic_engine.osdudb.OsduCatalog[source]

Bases: object

An indexed OSDU manifest.

CRSs and coordinate operations are indexed separately. Their code spaces overlap in principle, and resolving a bound CRS’s source CRS against an operation of the same code would silently produce a different object.

Example

>>> catalog = OsduCatalog.from_file(Path("CRS_CT.json"))
>>> len(list(catalog.records(BOUND_CRS)))
1276
__init__(records, *, path=None)[source]
classmethod from_file(path)[source]

Read and index a manifest.

Parameters:

path (Path) – The manifest file.

Return type:

OsduCatalog

Returns:

The indexed catalogue.

Raises:

OsduCatalogError – If the file is unreadable, is not JSON, or has no ReferenceData array.

classmethod from_document(document, *, path=None)[source]

Index an already parsed manifest.

Parameters:
  • document (dict[str, Any]) – The decoded JSON of a CRS_CT.json manifest.

  • path (Path | None, default: None) – Where it was read from, used only in messages.

Return type:

OsduCatalog

Returns:

The catalogue, indexed by authority and code.

Raises:

OsduCatalogError – If the document has no ReferenceData array.

records(*types)[source]

Yield every record of the given types, in catalogue order.

Parameters:

*types (str) – CoordinateReferenceSystemType or CoordinateTransformationType values. With none given, every record is yielded.

Return type:

Iterator[Record]

crs(auth_name, code)[source]

Return the CRS with an authority and code, if the catalogue has it.

Parameters:
  • auth_name (str | None) – Authority, for example "OSDU".

  • code (str | None) – Code within that authority.

Return type:

Record | None

Returns:

The record, or None when it is absent or either key is missing.

operation(auth_name, code)[source]

Return the operation with an authority and code, if it is present.

Parameters:
  • auth_name (str | None) – Authority, for example "EPSG".

  • code (str | None) – Code within that authority.

Return type:

Record | None

Returns:

The record, or None when it is absent or either key is missing.