Listing¶
- class geodetic_engine.catalog.Listing[source]¶
-
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.
limitandoffsetare applied after every filter, so pages are consistent, and iteration stops oncelimitentries 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:
kind (
str) – What is listed, for example"crs".filters (
Mapping[str,Any]) – The filters asked for, as JSON values.produce (
Callable[[],Iterator[TypeVar(E, bound=CatalogEntry)]]) – Yields every entry that passes the filters, in order.columns (
tuple[str,...]) – The columns ofto_dataframe().databases (
tuple[tuple[str,int,int,int,int,int],...]) – The databases PROJ read when the filters were checked.limit (
int|None, default:None) – At most this many entries.offset (
int, default:0) – Skip this many entries first.
- __init__(kind, filters, produce, *, columns, databases, limit=None, offset=0)[source]¶
Wrap a listing; the listing functions build these.
- Parameters:
kind (
str) – What is listed, for example"crs".filters (
Mapping[str,Any]) – The filters asked for, as JSON values.produce (
Callable[[],Iterator[TypeVar(E, bound=CatalogEntry)]]) – Yields every entry that passes the filters, in order.columns (
tuple[str,...]) – The columns ofto_dataframe().databases (
tuple[tuple[str,int,int,int,int,int],...]) – The databases PROJ read when the filters were checked.limit (
int|None, default:None) – At most this many entries.offset (
int, default:0) – Skip this many entries first.
- 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:
NotFoundError – If there is none.
NotUniqueError – If there is more than one.
- 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 asarea_of_usewith itswest,south,eastandnorthbounds. The columns are the same when the listing is empty.- Return type:
- 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 againstlisting_schema().- Parameters:
include_definitions (
bool, default:False) – Add each entry’s full PROJJSON asdefinition. 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:
- to_json(*, include_definitions=False, indent=2)[source]¶
to_json_dict()as text.- Parameters:
include_definitions (
bool, default:False) – Seeto_json_dict().indent (
int|None, default:2) – Indentation, or None for one line.
- Return type: