Skip to content

Commit 943308a

Browse files
Merge #38
38: fix wrong srs error (field access) r=michaelmattig a=ChristianBeilschmidt Co-authored-by: Christian Beilschmidt <[email protected]>
2 parents 63d2836 + e04bc7c commit 943308a

File tree

3 files changed

+38
-15
lines changed

3 files changed

+38
-15
lines changed

geoengine/types.py

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ class ResultDescriptor: # pylint: disable=too-few-public-methods
181181
Base class for result descriptors
182182
'''
183183

184+
__spatial_reference: str
185+
186+
def __init__(self, spatial_reference: str) -> None:
187+
self.__spatial_reference = spatial_reference
188+
184189
@staticmethod
185190
def from_response(response: Dict[str, Any]) -> None:
186191
'''
@@ -226,20 +231,25 @@ def is_plot_result(cls) -> bool:
226231

227232
return False
228233

234+
@property
235+
def spatial_reference(self) -> str:
236+
'''Return the spatial reference'''
237+
238+
return self.__spatial_reference
239+
229240

230241
class VectorResultDescriptor(ResultDescriptor):
231242
'''
232243
A vector result descriptor
233244
'''
234245

235246
__data_type: str
236-
__spatial_reference: str
237247
__columns: Dict[str, str]
238248

239249
def __init__(self, response: Dict[str, Any]) -> None:
240250
'''Initialize a new `VectorResultDescriptor`'''
251+
super().__init__(response['spatialReference'])
241252
self.__data_type = response['dataType']
242-
self.__spatial_reference = response['spatialReference']
243253
self.__columns = response['columns']
244254

245255
def __repr__(self) -> str:
@@ -269,7 +279,7 @@ def data_type(self) -> str:
269279
def spatial_reference(self) -> str:
270280
'''Return the spatial reference'''
271281

272-
return self.__spatial_reference
282+
return super().spatial_reference
273283

274284
@property
275285
def columns(self) -> Dict[str, str]:
@@ -284,14 +294,13 @@ class RasterResultDescriptor(ResultDescriptor):
284294
'''
285295

286296
__data_type: str
287-
__spatial_reference: str
288297
__measurement: str
289298
__no_data_value: str
290299

291300
def __init__(self, response: Dict[str, Any]) -> None:
292301
'''Initialize a new `RasterResultDescriptor`'''
302+
super().__init__(response['spatialReference'])
293303
self.__data_type = response['dataType']
294-
self.__spatial_reference = response['spatialReference']
295304
self.__measurement = response['measurement']
296305
self.__no_data_value = response['noDataValue']
297306

@@ -313,10 +322,6 @@ def is_raster_result(cls) -> bool:
313322
def data_type(self) -> str:
314323
return self.__data_type
315324

316-
@property
317-
def spatial_reference(self) -> str:
318-
return self.__spatial_reference
319-
320325
@property
321326
def measurement(self) -> str:
322327
return self.__measurement
@@ -325,15 +330,23 @@ def measurement(self) -> str:
325330
def no_data_value(self) -> str:
326331
return self.__no_data_value
327332

333+
@property
334+
def spatial_reference(self) -> str:
335+
'''Return the spatial reference'''
336+
337+
return super().spatial_reference
338+
328339

329340
class PlotResultDescriptor(ResultDescriptor):
330341
'''
331342
A plot result descriptor
332343
'''
333344

334-
def __init__(self, _response: Dict[str, Any]) -> None:
345+
def __init__(self, response: Dict[str, Any]) -> None:
335346
'''Initialize a new `PlotResultDescriptor`'''
336347

348+
super().__init__(response['spatialReference'])
349+
337350
def __repr__(self) -> str:
338351
'''Display representation of the plot result descriptor'''
339352
r = 'Plot Result'
@@ -344,6 +357,12 @@ def __repr__(self) -> str:
344357
def is_plot_result(cls) -> bool:
345358
return True
346359

360+
@property
361+
def spatial_reference(self) -> str:
362+
'''Return the spatial reference'''
363+
364+
return super().spatial_reference
365+
347366

348367
class VectorDataType(Enum):
349368
'''An enum of vector data types'''

geoengine/workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def save_as_dataset(self, bbox: QueryRectangle, name: str, description: str = ''
387387
if self.get_result_descriptor().spatial_reference != bbox.srs:
388388
raise SpatialReferenceMismatchException(
389389
self.get_result_descriptor().spatial_reference,
390-
bbox.spatial_reference
390+
bbox.srs
391391
)
392392

393393
session = get_session()

tests/test_plot.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def test_ndvi_histogram(self):
3232

3333
m.get('http://mock-instance/workflow/5b9508a8-bd34-5a1c-acd6-75bb832d2d38/metadata',
3434
json={
35-
"type": "plot"
35+
"type": "plot",
36+
"spatialReference": "EPSG:4326",
3637
},
3738
request_headers={'Authorization': 'Bearer c4983c3e-9b53-47ae-bda9-382223bd5081'})
3839

@@ -109,7 +110,8 @@ def test_result_descriptor(self):
109110

110111
m.get('http://mock-instance/workflow/5b9508a8-bd34-5a1c-acd6-75bb832d2d38/metadata',
111112
json={
112-
"type": "plot"
113+
"type": "plot",
114+
"spatialReference": "EPSG:4326",
113115
},
114116
request_headers={'Authorization': 'Bearer c4983c3e-9b53-47ae-bda9-382223bd5081'})
115117

@@ -154,7 +156,8 @@ def test_wrong_request(self):
154156

155157
m.get('http://mock-instance/workflow/5b9508a8-bd34-5a1c-acd6-75bb832d2d38/metadata',
156158
json={
157-
"type": "plot"
159+
"type": "plot",
160+
"spatialReference": "EPSG:4326",
158161
},
159162
request_headers={'Authorization': 'Bearer c4983c3e-9b53-47ae-bda9-382223bd5081'})
160163

@@ -195,7 +198,8 @@ def test_plot_error(self):
195198

196199
m.get('http://mock-instance/workflow/5b9508a8-bd34-5a1c-acd6-75bb832d2d38/metadata',
197200
json={
198-
"type": "plot"
201+
"type": "plot",
202+
"spatialReference": "EPSG:4326",
199203
},
200204
request_headers={'Authorization': 'Bearer c4983c3e-9b53-47ae-bda9-382223bd5081'})
201205

0 commit comments

Comments
 (0)