Skip to content

Commit 0c1918c

Browse files
Allow unset crs (#2031)
* allow unset crs in the spirit of the comment on the above line https://github.com/geopython/pygeoapi/blob/75f87393365b17245d8dd6ba88196636f922b445/pygeoapi/provider/parquet.py#L127 , allow 'crs' to be unset and set default. * set the correct default CRS per the geoparquet standard * add test for parquet file with no crs in metadata
1 parent 47b90b6 commit 0c1918c

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

pygeoapi/provider/parquet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ def __init__(self, provider_def):
125125
geo_metadata = json.loads(self.ds.schema.metadata[b'geo'])
126126
geom_column = geo_metadata['primary_column']
127127
# if the CRS is not set default to EPSG:4326, per geoparquet spec
128-
self.crs = (geo_metadata['columns'][geom_column]['crs']
129-
or 'EPSG:4326')
128+
self.crs = (geo_metadata['columns'][geom_column].get('crs')
129+
or 'OGC:CRS84')
130130

131131
def _read_parquet(self, return_scanner=False, **kwargs):
132132
"""

tests/data/random_nocrs.parquet

8.1 KB
Binary file not shown.

tests/test_parquet_provider.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
path_nogeom = get_test_file_path(
4141
'data/random_nogeom.parquet')
4242

43+
path_nocrs = get_test_file_path(
44+
'data/random_nocrs.parquet')
45+
4346

4447
@pytest.fixture()
4548
def config_parquet():
@@ -70,6 +73,22 @@ def config_parquet_nogeom_notime():
7073
}
7174

7275

76+
@pytest.fixture()
77+
def config_parquet_nocrs():
78+
return {
79+
'name': 'ParquetNoCrs',
80+
'type': 'feature',
81+
'data': {
82+
'source_type': 'Parquet',
83+
'source': path_nocrs,
84+
},
85+
'id_field': 'id',
86+
'time_field': 'time',
87+
'x_field': 'lon',
88+
'y_field': 'lat',
89+
}
90+
91+
7392
def test_get_fields(config_parquet):
7493
"""Testing field types"""
7594

@@ -209,3 +228,13 @@ def test_query_nogeom(config_parquet_nogeom_notime):
209228
assert len(feature_collection.get('features')) > 0
210229
for feature in feature_collection['features']:
211230
assert feature.get('geometry') is None
231+
232+
233+
def test_query_nocrs(config_parquet_nocrs):
234+
"""Testing a parquet provider without CRS"""
235+
236+
p = ParquetProvider(config_parquet_nocrs)
237+
results = p.get_fields()
238+
assert results['lat']['type'] == 'number'
239+
assert results['lon']['format'] == 'double'
240+
assert results['time']['format'] == 'date-time'

0 commit comments

Comments
 (0)