+class DetailsResponse(GenericResponse):
+
+ def __init__(self, page, fmt='json', errorcode=200):
+ self.page = page
+ self.format = fmt
+ self.errorcode = errorcode
+ self.result = []
+ self.header = dict()
+
+ if errorcode == 200:
+ getattr(self, 'parse_' + fmt)()
+
+ def parse_json(self):
+ self.result = [json.JSONDecoder(object_pairs_hook=OrderedDict).decode(self.page)]
+
+
+class StatusResponse(GenericResponse):
+
+ def __init__(self, page, fmt='text', errorcode=200):
+ self.page = page
+ self.format = fmt
+ self.errorcode = errorcode
+
+ if errorcode == 200 and fmt != 'text':
+ getattr(self, 'parse_' + fmt)()
+
+ def parse_json(self):
+ self.result = [json.JSONDecoder(object_pairs_hook=OrderedDict).decode(self.page)]
+
+
+def geojson_result_to_json_result(geojson_result):
+ result = geojson_result['properties']
+ result['geojson'] = geojson_result['geometry']
+ if 'bbox' in geojson_result:
+ # bbox is minlon, minlat, maxlon, maxlat
+ # boundingbox is minlat, maxlat, minlon, maxlon
+ result['boundingbox'] = [
+ geojson_result['bbox'][1],
+ geojson_result['bbox'][3],
+ geojson_result['bbox'][0],
+ geojson_result['bbox'][2]
+ ]
+ return result
+
+
+def geojson_results_to_json_results(geojson_results):
+ if 'error' in geojson_results:
+ return
+ return list(map(geojson_result_to_json_result, geojson_results['features']))
+