Commit 0e6f5dbf authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fixed missing data in DEM

misc.database_tools:
- get_pgSQL_geospatial_query_cond(): changed default queryfunc
- get_overlapping_MGRS_tiles(): replaced geo conditions by ST_Intersects
- updated __version__
Former-commit-id: d06817da
Former-commit-id: e0107c5c
parent 2636cfcb
......@@ -15,7 +15,7 @@ from . import config
from .processing.process_controller import process_controller
__version__ = '20170124.05'
__version__ = '20170124.06'
__author__ = 'Daniel Scheffler'
__all__ = ['algorithms',
'io',
......
......@@ -305,7 +305,7 @@ def create_record_in_postgreSQLdb(conn_params, tablename, vals2write_dict, timeo
def get_pgSQL_geospatial_query_cond(conn_params, table2query, geomCol2use='bounds', tgt_corners_lonlat=None,
scene_ID=None, queryfunc = 'ST_Overlaps'):
scene_ID=None, queryfunc = 'ST_Intersects'):
assert tgt_corners_lonlat if scene_ID is None else scene_ID, "Provide eihter scene_ID or tgt_corners_lonlat!"
if tgt_corners_lonlat:
......@@ -365,7 +365,7 @@ def get_overlapping_scenes_from_postgreSQLdb(conn_params, table='scenes_proc', s
refcond = ['scenes.datasetid = %s' %datasetid]
geocond = [get_pgSQL_geospatial_query_cond(conn_params, table, tgt_corners_lonlat=tgt_corners_lonlat,
scene_ID=scene_ID)]
scene_ID=scene_ID, queryfunc='ST_Intersects')]
join = "INNER JOIN scenes ON (%s.sceneid = scenes.id) " %table if table != 'scenes' and datasetids else ''
conditions = [c for c in conditions if not c.startswith('datasetid')]
......@@ -390,13 +390,16 @@ def get_overlapping_MGRS_tiles(conn_params, scene_ID=None, tgt_corners_lonlat=No
if connection is None: return 'database connection fault'
vals2get = ['grid100k', 'grid1mil', 'geom']
geocond1 = get_pgSQL_geospatial_query_cond(conn_params, 'mgrs_tiles', geomCol2use='geom', queryfunc='ST_Overlaps',
tgt_corners_lonlat=tgt_corners_lonlat, scene_ID=scene_ID)
geocond2 = get_pgSQL_geospatial_query_cond(conn_params, 'mgrs_tiles', geomCol2use='geom', queryfunc='ST_Contains',
tgt_corners_lonlat=tgt_corners_lonlat, scene_ID=scene_ID)
geocond3 = get_pgSQL_geospatial_query_cond(conn_params, 'mgrs_tiles', geomCol2use='geom', queryfunc='ST_Within',
tgt_corners_lonlat=tgt_corners_lonlat, scene_ID=scene_ID)
query = "SELECT %s FROM %s WHERE %s OR %s OR %s" % (', '.join(vals2get), 'mgrs_tiles', geocond1, geocond2,geocond3)
# geocond1 = get_pgSQL_geospatial_query_cond(conn_params, 'mgrs_tiles', geomCol2use='geom', queryfunc='ST_Overlaps',
# tgt_corners_lonlat=tgt_corners_lonlat, scene_ID=scene_ID) # FIXME this is covered by ST_Intersects
# geocond2 = get_pgSQL_geospatial_query_cond(conn_params, 'mgrs_tiles', geomCol2use='geom', queryfunc='ST_Contains',
# tgt_corners_lonlat=tgt_corners_lonlat, scene_ID=scene_ID)
# geocond3 = get_pgSQL_geospatial_query_cond(conn_params, 'mgrs_tiles', geomCol2use='geom', queryfunc='ST_Within',
# tgt_corners_lonlat=tgt_corners_lonlat, scene_ID=scene_ID)
geocond = get_pgSQL_geospatial_query_cond(conn_params, 'mgrs_tiles', geomCol2use='geom', queryfunc='ST_Intersects',
tgt_corners_lonlat=tgt_corners_lonlat, scene_ID=scene_ID)
#query = "SELECT %s FROM %s WHERE %s OR %s OR %s" % (', '.join(vals2get), 'mgrs_tiles', geocond1, geocond2,geocond3)
query = "SELECT %s FROM %s WHERE %s" % (', '.join(vals2get), 'mgrs_tiles', geocond)
cursor = connection.cursor()
execute_pgSQL_query(cursor, query)
records = cursor.fetchall()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment