Skip to content

Commit 4f90235

Browse files
authored
Allow storage projections other than 4326 for Postgres Provider (#1953)
* Update postgresql.py * fix lint
1 parent f794d67 commit 4f90235

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pygeoapi/provider/postgresql.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ def __init__(self, provider_def):
108108
LOGGER.debug(f'ID field: {self.id_field}')
109109
LOGGER.debug(f'Geometry field: {self.geom}')
110110

111+
# conforming to the docs:
112+
# https://docs.pygeoapi.io/en/latest/data-publishing/ogcapi-features.html#connection-examples # noqa
113+
self.storage_crs = provider_def.get(
114+
'storage_crs',
115+
'https://www.opengis.net/def/crs/OGC/0/CRS84'
116+
)
117+
LOGGER.debug(f'Configured Storage CRS: {self.storage_crs}')
118+
111119
# Read table information from database
112120
options = None
113121
if provider_def.get('options'):
@@ -416,7 +424,7 @@ def _feature_to_sqlalchemy(self, json_data, identifier=None):
416424
# NOTE: for some reason, postgis in the github action requires
417425
# explicit crs information. i think it's valid to assume 4326:
418426
# https://portal.ogc.org/files/108198#feature-crs
419-
srid=4326
427+
srid=pyproj.CRS.from_user_input(self.storage_crs).to_epsg()
420428
)
421429
attributes[self.id_field] = identifier
422430

0 commit comments

Comments
 (0)