Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pygeoapi/provider/csv_.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def _load(self, offset=0, limit=10, resulttype='results',
coordinates = None

feature = {'type': 'Feature'}
feature['id'] = row.pop(self.id_field)
feature['id'] = row[self.id_field]
if not skip_geometry:
feature['geometry'] = {
'type': 'Point',
Expand Down
2 changes: 1 addition & 1 deletion pygeoapi/provider/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ def _response_feature(self, row_data):
for (key, value) in row_data.items()
if key != "GEOMETRY"
}
feature["id"] = feature["properties"].pop(self.id_field)
feature["id"] = feature["properties"][self.id_field]

return feature
else:
Expand Down
2 changes: 1 addition & 1 deletion pygeoapi/provider/sensorthings.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def _make_feature(self, feature, select_properties=[], skip_geometry=False,

:returns: dict of GeoJSON Feature
"""
_ = feature.pop(self.id_field)
_ = feature[self.id_field]
id = f"'{_}'" if isinstance(_, str) else str(_)
f = {
'type': 'Feature', 'id': id, 'properties': {}, 'geometry': None
Expand Down
4 changes: 2 additions & 2 deletions pygeoapi/provider/socrata.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def query(self, offset=0, limit=10, resulttype='results',
params['limit'] = limit

def make_feature(f):
f['id'] = f['properties'].pop(self.id_field)
f['id'] = f['properties'][self.id_field]
if skip_geometry:
f['geometry'] = None
return f
Expand Down Expand Up @@ -178,7 +178,7 @@ def get(self, identifier, **kwargs):
LOGGER.debug('Sending query')
fc = self.client.get(self.resource_id, **params)
f = fc.get('features').pop()
f['id'] = f['properties'].pop(self.id_field)
f['id'] = f['properties'][self.id_field]
return f

def _make_fields(self, select_properties=[]):
Expand Down
2 changes: 0 additions & 2 deletions pygeoapi/provider/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,6 @@ def _sqlalchemy_to_feature(self, item, crs_transform_out=None,
if key in item_dict:
feature['properties'][key] = item_dict[key]

feature['properties'].pop(self.id_field, None)

return feature

def _feature_to_sqlalchemy(self, json_data, identifier=None):
Expand Down
2 changes: 1 addition & 1 deletion pygeoapi/provider/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def __response_feature(self, row_data, skip_geometry=False):
LOGGER.warning('Missing geometry')

feature['properties'] = rd
feature['id'] = feature['properties'].pop(self.id_field)
feature['id'] = feature['properties'][self.id_field]

return feature
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/provider/test_csv__provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_query(config):
assert len(results['features']) == 1
assert results['features'][0]['id'] == '238'

assert len(results['features'][0]['properties']) == 3
assert len(results['features'][0]['properties']) == 4

results = p.query(select_properties=['value'])
assert len(results['features'][0]['properties']) == 1
Expand Down
3 changes: 1 addition & 2 deletions tests/provider/test_oracle_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,7 @@ def test_query_can_mandate_properties_which_are_not_returned(config):
result = p.query(properties=[("name", "Aral Sea")])

(feature,) = result['features']
# id is handled separately, so only wiki link and not name must be here
assert feature['properties'].keys() == {"wiki_link"}
assert feature['properties'].keys() == {"id", "wiki_link"}


def test_query_mandatory_properties_must_be_specified(config):
Expand Down
5 changes: 3 additions & 2 deletions tests/provider/test_postgresql_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ def test_query(config):
assert properties is not None

properties_order = [
'name', 'waterway', 'covered', 'width', 'depth', 'layer', 'blockage',
'tunnel', 'natural', 'water', 'z_index'
'osm_id', 'name', 'waterway', 'covered', 'width', 'depth', 'layer',
'blockage', 'tunnel', 'natural', 'water', 'z_index'
]

assert list(properties.keys()) == properties_order
Expand Down Expand Up @@ -239,6 +239,7 @@ def test_query_with_config_properties(config):
"""
properties_subset = ['name', 'waterway', 'width', 'does_not_exist']
config.update({'properties': properties_subset})
properties_subset.append('osm_id') # id_field is always included
provider = PostgreSQLProvider(config)
assert provider.properties == properties_subset
result = provider.query()
Expand Down
2 changes: 1 addition & 1 deletion tests/provider/test_sensorthings_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_query_datastreams(config):
assert len(results['features']) == 1
assert results['features'][0]['id'] == '3'

assert len(results['features'][0]['properties']) == 18
assert len(results['features'][0]['properties']) == 19

results = p.query(bbox=[-109, 36, -106, 37])
assert results['numberReturned'] == 8
Expand Down
2 changes: 1 addition & 1 deletion tests/provider/test_socrata_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def test_query_properties(config, mock_socrata):
p = SODAServiceProvider(config)

results = p.query()
assert len(results['features'][0]['properties']) == 2
assert len(results['features'][0]['properties']) == 3

# Query by property
results = p.query(properties=[('region', 'Nevada'), ])
Expand Down
12 changes: 6 additions & 6 deletions tests/provider/test_socrata_provider_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,18 @@ def test_query_properties(config):
p = SODAServiceProvider(config)

results = p.query()
assert len(results['features'][0]['properties']) == 11
assert len(results['features'][0]['properties']) == 12

# Query by property
results = p.query(properties=[('region', 'Nevada'), ])
results = p.query(properties=[('region', 'Nevada')])
assert results['numberMatched'] == 19

results = p.query(properties=[('region', 'Northern California'), ])
assert results['numberMatched'] == 119

# Query for property
results = p.query(select_properties=['magnitude', ])
assert len(results['features'][0]['properties']) == 1
results = p.query(select_properties=['magnitude'])
assert len(results['features'][0]['properties']) == 2
assert 'magnitude' in results['features'][0]['properties']

# Query with configured properties
Expand All @@ -126,13 +126,13 @@ def test_query_properties(config):
results = p.query()
props = results['features'][0]['properties']
assert all(p in props for p in config['properties'])
assert len(props) == 3
assert len(props) == 4

results = p.query(properties=[('region', 'Central California'), ])
assert results['numberMatched'] == 92

results = p.query(select_properties=['region', ])
assert len(results['features'][0]['properties']) == 1
assert len(results['features'][0]['properties']) == 2


def test_query_sortby_datetime(config):
Expand Down