@@ -145,7 +145,7 @@ def output(self, key, obj, **kwargs):
145
145
])
146
146
147
147
# Feature
148
- geojson_feature = create_model (api , 'Feature' , [
148
+ geojson_feature = lambda with_crs : create_model (api , 'Feature' , [
149
149
['type' , fields .String (required = True , description = 'Feature' ,
150
150
example = 'Feature' )],
151
151
['id' , FeatureId (required = True , description = 'Feature ID' ,
@@ -158,23 +158,24 @@ def output(self, key, obj, **kwargs):
158
158
example = {'name' : 'Example' , 'type' : 2 ,
159
159
'num' : 4 }
160
160
)],
161
- ['crs' , fields .Nested (geojson_crs , required = False , allow_null = True ,
162
- description = 'Coordinate reference system' )],
163
161
['bbox' , fields .Raw (required = False , allow_null = True ,
164
162
description = (
165
163
'Extent of feature as [minx, miny, maxx, maxy]'
166
164
),
167
165
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 []))
169
170
170
- geojson_feature_request = api .inherit ('Relation Feature' , geojson_feature , {
171
+ geojson_feature_request = api .inherit ('Relation Feature' , geojson_feature ( True ) , {
171
172
'defaultedProperties' : fields .List (fields .String , required = False )
172
173
})
173
174
174
175
geojson_feature_collection = create_model (api , 'FeatureCollection' , [
175
176
['type' , fields .String (required = True , description = 'FeatureCollection' ,
176
177
example = 'FeatureCollection' )],
177
- ['features' , fields .List (fields .Nested (geojson_feature ),
178
+ ['features' , fields .List (fields .Nested (geojson_feature ( False ) ),
178
179
required = True , description = 'Features' )],
179
180
['crs' , fields .Nested (geojson_crs , required = False , allow_null = True ,
180
181
description = 'Coordinate reference system' )],
@@ -186,7 +187,7 @@ def output(self, key, obj, **kwargs):
186
187
])
187
188
188
189
# Relations
189
- relation_feature = api .inherit ('Relation Feature' , geojson_feature , {
190
+ relation_feature = api .inherit ('Relation Feature' , geojson_feature ( True ) , {
190
191
'__status__' : fields .String (required = False , description = 'Feature status' ),
191
192
'error' : fields .String (required = False , description = 'Commit error' ),
192
193
'error_details' : fields .Raw (required = False , description = 'Commit error details properties' )
@@ -202,7 +203,7 @@ def output(self, key, obj, **kwargs):
202
203
['*' , fields .Wildcard (fields .Nested (relation_table_features , required = False , description = 'Relation table features' ))]
203
204
])
204
205
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 ) , {
206
207
'relationValues' : KeepEmptyDict (relation_values ,
207
208
required = False ,
208
209
description = 'Relation table entry' )
@@ -321,7 +322,7 @@ def get(self, dataset):
321
322
@api .response (405 , 'Dataset not creatable' )
322
323
@api .response (422 , 'Feature validation failed' , feature_validation_response )
323
324
@api .expect (geojson_feature_request )
324
- @api .marshal_with (geojson_feature , code = 201 )
325
+ @api .marshal_with (geojson_feature ( True ) , code = 201 )
325
326
@optional_auth
326
327
def post (self , dataset ):
327
328
"""Create a new dataset feature
@@ -399,7 +400,7 @@ class Feature(Resource):
399
400
@api .response (405 , 'Dataset not readable' )
400
401
@api .param ('crs' , 'Client coordinate reference system' )
401
402
@api .expect (show_parser )
402
- @api .marshal_with (geojson_feature )
403
+ @api .marshal_with (geojson_feature ( True ) )
403
404
@optional_auth
404
405
def get (self , dataset , id ):
405
406
"""Get a dataset feature
@@ -426,7 +427,7 @@ def get(self, dataset, id):
426
427
@api .response (405 , 'Dataset not updatable' )
427
428
@api .response (422 , 'Feature validation failed' , feature_validation_response )
428
429
@api .expect (geojson_feature_request )
429
- @api .marshal_with (geojson_feature )
430
+ @api .marshal_with (geojson_feature ( True ) )
430
431
@optional_auth
431
432
def put (self , dataset , id ):
432
433
"""Update a dataset feature
0 commit comments