Filters¶
Every listing function takes keyword arguments only. Every filter given must hold, so filters combine by narrowing. The same filter means the same thing in every listing.
Free text and references¶
Free-text filters (name, area_name, projection_method) match a
substring, without case:
from geodetic_engine import catalog
[str(e) for e in catalog.ellipsoids(authority="EPSG", name="clarke 1880")]
['Clarke 1880 (Benoit) (EPSG:7010)',
'Clarke 1880 (IGN) (EPSG:7011)',
'Clarke 1880 (RGS) (EPSG:7012)',
'Clarke 1880 (Arc) (EPSG:7013)',
'Clarke 1880 (SGA 1922) (EPSG:7014)',
'Clarke 1880 (EPSG:7034)',
'Clarke 1880 (international foot) (EPSG:7055)']
Reference filters (datum, unit, ellipsoid, prime_meridian, method,
member_of, source_crs, target_crs, parameter, operation) name another
object: by code, by entry, or by a name or alias matched exactly but for case.
A name may match several objects; any of them qualifies:
same = [
catalog.crs(authority="EPSG", kind="geographic_2d", datum=d)
for d in ("EPSG:6258", "European Terrestrial Reference System 1989 ensemble")
]
[len(listing) for listing in same]
[1, 1]
A reference that names nothing of its kind is an error, not an empty listing. This catches the commonest slip, a CRS code given as a datum:
catalog.crs(datum="EPSG:4326")
---------------------------------------------------------------------------
InvalidFilterError Traceback (most recent call last)
Cell In[3], line 1
----> 1 catalog.crs(datum="EPSG:4326")
File /workspace/geodetic_engine/catalog/_crs.py:475, in crs(authority, name, code, kind, datum, unit, coordinate_system_kind, projection_method, area_of_interest, contains, area_name, bound, deprecated, limit, offset)
473 codes = _filters.codes(code, databases, authorities)
474 kinds = _filters.choices(kind, CrsKind, "CRS kind")
--> 475 datums = _filters.references(
476 datum,
477 "datum",
478 _filters.registered(_registry.DATUM_TABLES, databases),
479 databases,
480 )
481 units = _filters.references(
482 unit,
483 "unit",
484 _filters.registered(frozenset({"unit_of_measure"}), databases),
485 databases,
486 )
487 systems = _filters.choices(
488 coordinate_system_kind, CoordinateSystemKind, "coordinate system kind"
489 )
File /workspace/geodetic_engine/catalog/_filters.py:246, in references(value, what, known, databases)
244 raise InvalidFilterError(f"{item!r} is not a {what}")
245 if not matches:
--> 246 raise InvalidFilterError(f"{item} is not a {what} in the active database")
247 found |= matches
248 return frozenset(found)
InvalidFilterError: EPSG:4326 is not a datum in the active database
Kinds¶
kind takes one value or several, by enumeration member or by value without
case:
from geodetic_engine.catalog import CrsKind
len(catalog.crs(authority="EPSG", kind=[CrsKind.GEOGRAPHIC_2D, "Geographic_3D"]))
902
An unknown kind names the choices:
catalog.crs(kind="map")
---------------------------------------------------------------------------
InvalidFilterError Traceback (most recent call last)
Cell In[5], line 1
----> 1 catalog.crs(kind="map")
File /workspace/geodetic_engine/catalog/_crs.py:474, in crs(authority, name, code, kind, datum, unit, coordinate_system_kind, projection_method, area_of_interest, contains, area_name, bound, deprecated, limit, offset)
472 names = _filters.text(name, "name")
473 codes = _filters.codes(code, databases, authorities)
--> 474 kinds = _filters.choices(kind, CrsKind, "CRS kind")
475 datums = _filters.references(
476 datum,
477 "datum",
478 _filters.registered(_registry.DATUM_TABLES, databases),
479 databases,
480 )
481 units = _filters.references(
482 unit,
483 "unit",
484 _filters.registered(frozenset({"unit_of_measure"}), databases),
485 databases,
486 )
File /workspace/geodetic_engine/catalog/_filters.py:265, in choices(value, kinds, what)
263 member = by_value.get(str(item).strip().casefold())
264 if member is None:
--> 265 raise InvalidFilterError(
266 f"{item!r} is not a {what}; choose from "
267 f"{', '.join(repr(m.value) for m in kinds)}"
268 )
269 found.add(member)
270 return frozenset(found)
InvalidFilterError: 'map' is not a CRS kind; choose from 'geographic_2d', 'geographic_3d', 'geocentric', 'geodetic', 'projected', 'derived_projected', 'vertical', 'compound', 'engineering'
Ranges¶
Numeric filters take one number, matched exactly, or (low, high) with
None for an open end. An object without the value never matches:
[str(e) for e in catalog.ellipsoids(authority="EPSG", inverse_flattening=(299, None))]
['Zach 1812 (EPSG:1026)',
'Airy 1830 (EPSG:7001)',
'Airy Modified 1849 (EPSG:7002)',
'Bessel 1841 (EPSG:7004)',
'Bessel Modified (EPSG:7005)',
'Everest 1830 (1937 Adjustment) (EPSG:7015)',
'Everest 1830 (1967 Definition) (EPSG:7016)',
'Everest 1830 Modified (EPSG:7018)',
'Plessis 1817 (EPSG:7027)',
'Everest (1830 Definition) (EPSG:7042)',
'Everest 1830 (1962 Definition) (EPSG:7044)',
'Everest 1830 (1975 Definition) (EPSG:7045)',
'Bessel Namibia (GLM) (EPSG:7046)',
'Danish 1876 (EPSG:7051)',
'Everest 1830 (RSO 1969) (EPSG:7056)']
A listing’s JSON states an open end as null.
Areas of interest¶
West greater than east is an area across the antimeridian, as in PROJ.
Whether an area of use qualifies is decided exactly as PROJ decides it in its
own CRS search, so every listing agrees with
pyproj.database.query_crs_info().
An object with several usages qualifies when any of them does:
fiji = catalog.crs(
authority="EPSG", kind="projected", area_of_interest=(177.0, -19.0, -179.0, -16.0)
)
[str(e) for e in fiji][:6]
['Vanua Levu 1915 / Vanua Levu Grid (EPSG:3139)',
'Viti Levu 1912 / Viti Levu Grid (EPSG:3140)',
'Fiji 1956 / UTM zone 60S (EPSG:3141)',
'Fiji 1956 / UTM zone 1S (EPSG:3142)',
'WGS 84 / World Mercator (EPSG:3395)',
'NSIDC EASE-Grid South (EPSG:3409)']
Between two boxes that do not cross the antimeridian, touching edges count; when either crosses, they do not. That is PROJ’s rule, kept so that the listings agree.
Paging¶
limit and offset apply after every filter, so pages never overlap or skip,
and reading stops once limit entries are found:
first, second = (
catalog.crs(authority="EPSG", kind="vertical", limit=3, offset=offset)
for offset in (0, 3)
)
[str(e) for e in first], [str(e) for e in second]
(['EGM2008 height (EPSG:3855)',
'Fao 1979 height (EPSG:3886)',
'N2000 height (EPSG:3900)'],
['NZVD2009 height (EPSG:4440)',
'Dunedin-Bluff 1960 height (EPSG:4458)',
'KVD1964 height (EPSG:5193)'])
Errors¶
Error |
When |
|---|---|
|
|
A filter is malformed, or a reference names nothing of its kind |
|
|
|
|
|
|
|
Their base; also no |
The first two subclass ValueError, and the next two
LookupError, as well as CatalogError.