Skip to content

Commit 1ff693b

Browse files
committed
Omit crs from nested FeatureCollection features
1 parent 6925b18 commit 1ff693b

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/server.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def output(self, key, obj, **kwargs):
145145
])
146146

147147
# Feature
148-
geojson_feature = create_model(api, 'Feature', [
148+
geojson_feature = lambda with_crs: create_model(api, 'Feature', [
149149
['type', fields.String(required=True, description='Feature',
150150
example='Feature')],
151151
['id', FeatureId(required=True, description='Feature ID',
@@ -158,23 +158,24 @@ def output(self, key, obj, **kwargs):
158158
example={'name': 'Example', 'type': 2,
159159
'num': 4}
160160
)],
161-
['crs', fields.Nested(geojson_crs, required=False, allow_null=True,
162-
description='Coordinate reference system')],
163161
['bbox', fields.Raw(required=False, allow_null=True,
164162
description=(
165163
'Extent of feature as [minx, miny, maxx, maxy]'
166164
),
167165
example=[950598.0, 6003950.0, 950758.0, 6004010.0])]
168-
])
166+
] + ([
167+
['crs', fields.Nested(geojson_crs, required=False, allow_null=True,
168+
description='Coordinate reference system')]
169+
] if with_crs else []))
169170

170-
geojson_feature_request = api.inherit('Relation Feature', geojson_feature, {
171+
geojson_feature_request = api.inherit('Relation Feature', geojson_feature(True), {
171172
'defaultedProperties': fields.List(fields.String, required=False)
172173
})
173174

174175
geojson_feature_collection = create_model(api, 'FeatureCollection', [
175176
['type', fields.String(required=True, description='FeatureCollection',
176177
example='FeatureCollection')],
177-
['features', fields.List(fields.Nested(geojson_feature),
178+
['features', fields.List(fields.Nested(geojson_feature(False)),
178179
required=True, description='Features')],
179180
['crs', fields.Nested(geojson_crs, required=False, allow_null=True,
180181
description='Coordinate reference system')],
@@ -186,7 +187,7 @@ def output(self, key, obj, **kwargs):
186187
])
187188

188189
# Relations
189-
relation_feature = api.inherit('Relation Feature', geojson_feature, {
190+
relation_feature = api.inherit('Relation Feature', geojson_feature(True), {
190191
'__status__': fields.String(required=False, description='Feature status'),
191192
'error': fields.String(required=False, description='Commit error'),
192193
'error_details': fields.Raw(required=False, description='Commit error details properties')
@@ -202,7 +203,7 @@ def output(self, key, obj, **kwargs):
202203
['*', fields.Wildcard(fields.Nested(relation_table_features, required=False, description='Relation table features'))]
203204
])
204205

205-
geojson_feature_with_relvals = api.inherit('Feature with relation values', geojson_feature, {
206+
geojson_feature_with_relvals = api.inherit('Feature with relation values', geojson_feature(True), {
206207
'relationValues': KeepEmptyDict(relation_values,
207208
required=False,
208209
description='Relation table entry')
@@ -321,7 +322,7 @@ def get(self, dataset):
321322
@api.response(405, 'Dataset not creatable')
322323
@api.response(422, 'Feature validation failed', feature_validation_response)
323324
@api.expect(geojson_feature_request)
324-
@api.marshal_with(geojson_feature, code=201)
325+
@api.marshal_with(geojson_feature(True), code=201)
325326
@optional_auth
326327
def post(self, dataset):
327328
"""Create a new dataset feature
@@ -399,7 +400,7 @@ class Feature(Resource):
399400
@api.response(405, 'Dataset not readable')
400401
@api.param('crs', 'Client coordinate reference system')
401402
@api.expect(show_parser)
402-
@api.marshal_with(geojson_feature)
403+
@api.marshal_with(geojson_feature(True))
403404
@optional_auth
404405
def get(self, dataset, id):
405406
"""Get a dataset feature
@@ -426,7 +427,7 @@ def get(self, dataset, id):
426427
@api.response(405, 'Dataset not updatable')
427428
@api.response(422, 'Feature validation failed', feature_validation_response)
428429
@api.expect(geojson_feature_request)
429-
@api.marshal_with(geojson_feature)
430+
@api.marshal_with(geojson_feature(True))
430431
@optional_auth
431432
def put(self, dataset, id):
432433
"""Update a dataset feature

0 commit comments

Comments
 (0)