@@ -141,16 +141,18 @@ def get_wkt2(self, asset=None):
141
141
else :
142
142
return asset .properties .get ('proj:wkt2' )
143
143
144
- def set_wkt2 (self , wkt2 , asset = None ):
144
+ def set_wkt2 (self , value , asset = None ):
145
145
"""Set an Item or an Asset wkt2.
146
146
147
147
If an Asset is supplied, sets the property on the Asset.
148
148
Otherwise sets the Item's value.
149
149
"""
150
- if asset is None :
151
- self .item .properties ['proj:wkt2' ] = wkt2
150
+ key = 'proj:wkt2'
151
+ target = self .item .properties if asset is None else asset .properties
152
+ if value is None :
153
+ target .pop (key , None )
152
154
else :
153
- asset . properties [ 'proj:wkt2' ] = wkt2
155
+ target [ key ] = value
154
156
155
157
@property
156
158
def projjson (self ):
@@ -188,16 +190,18 @@ def get_projjson(self, asset=None):
188
190
else :
189
191
return asset .properties .get ('proj:projjson' )
190
192
191
- def set_projjson (self , projjson , asset = None ):
193
+ def set_projjson (self , value , asset = None ):
192
194
"""Set an Item or an Asset projjson.
193
195
194
196
If an Asset is supplied, sets the property on the Asset.
195
197
Otherwise sets the Item's value.
196
198
"""
197
- if asset is None :
198
- self .item .properties ['proj:projjson' ] = projjson
199
+ key = 'proj:projjson'
200
+ target = self .item .properties if asset is None else asset .properties
201
+ if value is None :
202
+ target .pop (key , None )
199
203
else :
200
- asset . properties [ 'proj:projjson' ] = projjson
204
+ target [ key ] = value
201
205
202
206
@property
203
207
def geometry (self ):
@@ -233,16 +237,18 @@ def get_geometry(self, asset=None):
233
237
else :
234
238
return asset .properties .get ('proj:geometry' )
235
239
236
- def set_geometry (self , geometry , asset = None ):
240
+ def set_geometry (self , value , asset = None ):
237
241
"""Set an Item or an Asset projection geometry.
238
242
239
243
If an Asset is supplied, sets the property on the Asset.
240
244
Otherwise sets the Item's value.
241
245
"""
242
- if asset is None :
243
- self .item .properties ['proj:geometry' ] = geometry
246
+ key = 'proj:geometry'
247
+ target = self .item .properties if asset is None else asset .properties
248
+ if value is None :
249
+ target .pop (key , None )
244
250
else :
245
- asset . properties [ 'proj:geometry' ] = geometry
251
+ target [ key ] = value
246
252
247
253
@property
248
254
def bbox (self ):
@@ -279,16 +285,18 @@ def get_bbox(self, asset=None):
279
285
else :
280
286
return asset .properties .get ('proj:bbox' )
281
287
282
- def set_bbox (self , bbox , asset = None ):
288
+ def set_bbox (self , value , asset = None ):
283
289
"""Set an Item or an Asset projection bbox.
284
290
285
291
If an Asset is supplied, sets the property on the Asset.
286
292
Otherwise sets the Item's value.
287
293
"""
288
- if asset is None :
289
- self .item .properties ['proj:bbox' ] = bbox
294
+ key = 'proj:bbox'
295
+ target = self .item .properties if asset is None else asset .properties
296
+ if value is None :
297
+ target .pop (key , None )
290
298
else :
291
- asset . properties [ 'proj:bbox' ] = bbox
299
+ target [ key ] = value
292
300
293
301
@property
294
302
def centroid (self ):
@@ -324,16 +332,18 @@ def get_centroid(self, asset=None):
324
332
else :
325
333
return asset .properties .get ('proj:centroid' )
326
334
327
- def set_centroid (self , centroid , asset = None ):
335
+ def set_centroid (self , value , asset = None ):
328
336
"""Set an Item or an Asset centroid.
329
337
330
338
If an Asset is supplied, sets the property on the Asset.
331
339
Otherwise sets the Item's value.
332
340
"""
333
- if asset is None :
334
- self .item .properties ['proj:centroid' ] = centroid
341
+ key = 'proj:centroid'
342
+ target = self .item .properties if asset is None else asset .properties
343
+ if value is None :
344
+ target .pop (key , None )
335
345
else :
336
- asset . properties [ 'proj:centroid' ] = centroid
346
+ target [ key ] = value
337
347
338
348
@property
339
349
def shape (self ):
@@ -367,16 +377,18 @@ def get_shape(self, asset=None):
367
377
else :
368
378
return asset .properties .get ('proj:shape' )
369
379
370
- def set_shape (self , shape , asset = None ):
380
+ def set_shape (self , value , asset = None ):
371
381
"""Set an Item or an Asset shape.
372
382
373
383
If an Asset is supplied, sets the property on the Asset.
374
384
Otherwise sets the Item's value.
375
385
"""
376
- if asset is None :
377
- self .item .properties ['proj:shape' ] = shape
386
+ key = 'proj:shape'
387
+ target = self .item .properties if asset is None else asset .properties
388
+ if value is None :
389
+ target .pop (key , None )
378
390
else :
379
- asset . properties [ 'proj:shape' ] = shape
391
+ target [ key ] = value
380
392
381
393
@property
382
394
def transform (self ):
@@ -413,16 +425,18 @@ def get_transform(self, asset=None):
413
425
else :
414
426
return asset .properties .get ('proj:transform' )
415
427
416
- def set_transform (self , transform , asset = None ):
428
+ def set_transform (self , value , asset = None ):
417
429
"""Set an Item or an Asset transform.
418
430
419
431
If an Asset is supplied, sets the property on the Asset.
420
432
Otherwise sets the Item's value.
421
433
"""
422
- if asset is None :
423
- self .item .properties ['proj:transform' ] = transform
434
+ key = 'proj:transform'
435
+ target = self .item .properties if asset is None else asset .properties
436
+ if value is None :
437
+ target .pop (key , None )
424
438
else :
425
- asset . properties [ 'proj:transform' ] = transform
439
+ target [ key ] = value
426
440
427
441
@classmethod
428
442
def _object_links (cls ):
0 commit comments