various provider fixes (#1205)

* improve CRS detection for STAC item

* fix ES id ref
This commit is contained in:
Tom Kralidis
2023-04-06 12:20:59 -04:00
committed by GitHub
parent 48b5b3b163
commit f92ca98765
3 changed files with 25 additions and 6 deletions
+10 -2
View File
@@ -277,7 +277,11 @@ def _describe_file(filepath):
with MemoryFile(filepath) as memfile:
with memfile.open() as d:
scrs = CRS(d.crs)
if scrs.to_epsg() not in [None, 4326]:
LOGGER.debug(f'CRS: {d.crs}')
LOGGER.debug(f'bounds: {d.bounds}')
LOGGER.debug(f'Is geographic: {scrs.is_geographic}')
if not scrs.is_geographic:
LOGGER.debug('Reprojecting coordinates')
tcrs = CRS.from_epsg(4326)
bnds = transform_bounds(scrs, tcrs,
d.bounds[0], d.bounds[1],
@@ -309,7 +313,11 @@ def _describe_file(filepath):
LOGGER.debug('Testing vector data detection')
d = fiona.open(filepath)
scrs = CRS(d.crs)
if scrs.to_epsg() not in [None, 4326]:
LOGGER.debug(f'CRS: {d.crs}')
LOGGER.debug(f'bounds: {d.bounds}')
LOGGER.debug(f'Is geographic: {scrs.is_geographic}')
if not scrs.is_geographic:
LOGGER.debug('Reprojecting coordinates')
tcrs = CRS.from_epsg(4326)
bnds = transform_bounds(scrs, tcrs,
d.bounds[0], d.bounds[1],
+3 -2
View File
@@ -359,7 +359,7 @@ class ElasticsearchProvider(BaseProvider):
result = self.es.get(index=self.index_name, id=identifier)
LOGGER.debug('Serializing feature')
feature_ = self.esdoc2geojson(result)
except exceptions.NotFoundError as err:
except Exception as err:
LOGGER.debug(f'Not found via ES id query: {err}')
LOGGER.debug('Trying via a real query')
@@ -368,13 +368,14 @@ class ElasticsearchProvider(BaseProvider):
'bool': {
'filter': [{
'match_phrase': {
'id': identifier
'_id': identifier
}
}]
}
}
}
LOGGER.debug(f'Query: {query}')
try:
result = self.es.search(index=self.index_name, **query)
if len(result['hits']['hits']) == 0:
+12 -2
View File
@@ -271,7 +271,11 @@ def _describe_file(filepath):
LOGGER.debug('Testing raster data detection')
d = rasterio.open(filepath)
scrs = CRS(d.crs)
if scrs.to_epsg() not in [None, 4326]:
LOGGER.debug(f'CRS: {d.crs}')
LOGGER.debug(f'bounds: {d.bounds}')
LOGGER.debug(f'Is geographic: {scrs.is_geographic}')
if not scrs.is_geographic:
LOGGER.debug('Reprojecting coordinates')
tcrs = CRS.from_epsg(4326)
bnds = transform_bounds(scrs, tcrs,
d.bounds[0], d.bounds[1],
@@ -301,8 +305,14 @@ def _describe_file(filepath):
try:
LOGGER.debug('Testing vector data detection')
d = fiona.open(filepath)
LOGGER.debug(f'CRS: {d.crs}')
LOGGER.debug(f'bounds: {d.bounds}')
scrs = CRS(d.crs)
if scrs.to_epsg() not in [None, 4326]:
LOGGER.debug(f'CRS: {d.crs}')
LOGGER.debug(f'bounds: {d.bounds}')
LOGGER.debug(f'Is geographic: {scrs.is_geographic}')
if not scrs.is_geographic:
LOGGER.debug('Reprojecting coordinates')
tcrs = CRS.from_epsg(4326)
bnds = transform_bounds(scrs, tcrs,
d.bounds[0], d.bounds[1],