example dataset for GeoJSON provider

This commit is contained in:
Matthew Perry
2018-03-06 13:50:30 -07:00
parent 3707f8a865
commit ba6b600055
3 changed files with 39 additions and 3 deletions
File diff suppressed because one or more lines are too long
+22
View File
@@ -90,3 +90,25 @@ datasets:
type: Elasticsearch
url: http://localhost:9200/index/type
id_field: id_
lakes:
type: Polygon
title: Large Lakes
abstract: lakes of the world, public domain
keywords: lakes
crs:
- CRS84
links:
- type: information
url: http://www.naturalearthdata.com/
- type: download
url: http://www.naturalearthdata.com/
extents:
spatial:
bbox: [-180,-90,180,90]
temporal:
begin: 2011-11-11
end: now # or empty
data:
type: GeoJSON
url: file://data/ne_110m_lakes.geojson
id_field: null # null indicates use feature enumeration
+16 -3
View File
@@ -96,9 +96,22 @@ class GeoJSONProvider(BaseProvider):
collection = EMPTY_COLLECTION.copy()
all_data = self._load()
for feature in all_data['features']:
if feature[self.id_field]:
collection['features'].append(feature)
if self.id_field:
# Use id field
for feature in all_data['features']:
if feature[self.id_field] == identifier:
collection['features'].append(feature)
else:
# Use enumeration, zero-indexed
for i, feature in enumerate(all_data['features']):
if i == identifier:
collection['features'].append(feature)
# assert that one and only one feature returned
n_features = len(collection['features'])
if n_features != 1:
raise RuntimeError('Expected 1 feature, got {}'.format(n_features))
return collection