Skip to content

Commit

Permalink
Allow storage projections other than 4326 for Postgres Provider (#1953)
Browse files Browse the repository at this point in the history
* Update postgresql.py

* fix lint
  • Loading branch information
vvmruder authored Mar 6, 2025
1 parent f794d67 commit 4f90235
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pygeoapi/provider/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ def __init__(self, provider_def):
LOGGER.debug(f'ID field: {self.id_field}')
LOGGER.debug(f'Geometry field: {self.geom}')

# conforming to the docs:
# https://docs.pygeoapi.io/en/latest/data-publishing/ogcapi-features.html#connection-examples # noqa
self.storage_crs = provider_def.get(
'storage_crs',
'https://www.opengis.net/def/crs/OGC/0/CRS84'
)
LOGGER.debug(f'Configured Storage CRS: {self.storage_crs}')

# Read table information from database
options = None
if provider_def.get('options'):
Expand Down Expand Up @@ -416,7 +424,7 @@ def _feature_to_sqlalchemy(self, json_data, identifier=None):
# NOTE: for some reason, postgis in the github action requires
# explicit crs information. i think it's valid to assume 4326:
# https://portal.ogc.org/files/108198#feature-crs
srid=4326
srid=pyproj.CRS.from_user_input(self.storage_crs).to_epsg()
)
attributes[self.id_field] = identifier

Expand Down

0 comments on commit 4f90235

Please sign in to comment.