Listing

class geodetic_engine.catalog.Listing[source]

Bases: Sequence, Generic

The entries one listing function found.

A listing is lazy: the database is read, and the filters that need PROJ for each entry are applied, the first time it is iterated, indexed, measured or exported. The entries are then kept, so iterating again reads nothing. limit and offset are applied after every filter, so pages are consistent, and iteration stops once limit entries are found.

Entries are ordered by authority, then by code, numerically where the code is a number.

A listing belongs to the database it was made for. Once PROJ’s database has been switched, a listing not yet read refuses to be read, and any listing refuses to be exported as JSON, since the export names the database that answered. Entries already read stay as they were read.

Example

>>> from geodetic_engine import catalog
>>> found = catalog.crs(authority="EPSG", name="UTM zone 32N", kind="projected")
>>> found.first().name
'ELD79 / UTM zone 32N'
>>> "EPSG:25832" in [entry.authority_code for entry in found]
True

Wrap a listing; the listing functions build these.

Parameters:
__init__(kind, filters, produce, *, columns, databases, limit=None, offset=0)[source]

Wrap a listing; the listing functions build these.

Parameters:
property kind: str

What is listed, as "crs", "operations", "datums" and so on.

property filters: Mapping[str, Any]

The filters this listing was asked for, as JSON values.

A copy, lists and all: changing it does not change the listing.

first()[source]

The first entry, or None when there is none.

Return type:

TypeVar(E, bound= CatalogEntry) | None

one()[source]

The only entry.

Raises:
Return type:

TypeVar(E, bound= CatalogEntry)

to_list()[source]

The entries as a list.

Return type:

list[TypeVar(E, bound= CatalogEntry)]

to_dataframe()[source]

The entries as a table, one row per entry.

References are given as "name (AUTH:CODE)", enumerations by value, and the first area of use as area_of_use with its west, south, east and north bounds. The columns are the same when the listing is empty.

Return type:

DataFrame

to_json_dict(*, include_definitions=False)[source]

The listing as JSON, with the database that answered it.

Every item is the entry’s to_summary_dict(). The whole validates against listing_schema().

Parameters:

include_definitions (bool, default: False) – Add each entry’s full PROJJSON as definition. Builds every object through PROJ, so it takes longer on a large listing.

Raises:

CatalogError – If PROJ’s database was switched after the listing was made, whether or not its entries were read before. The export would name a database that did not answer.

Return type:

dict[str, Any]

to_json(*, include_definitions=False, indent=2)[source]

to_json_dict() as text.

Parameters:
  • include_definitions (bool, default: False) – See to_json_dict().

  • indent (int | None, default: 2) – Indentation, or None for one line.

Return type:

str