Skip to content

Commit

Permalink
fix: If no config file is used, return the raw results
Browse files Browse the repository at this point in the history
  • Loading branch information
rsavoye committed Oct 15, 2023
1 parent b00ee79 commit 6aa2f5d
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions osm_rawdata/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,22 +352,31 @@ def queryLocal(
sql = f"DROP VIEW IF EXISTS relations_view;CREATE TEMP VIEW relations_view AS SELECT * FROM nodes WHERE ST_CONTAINS(ST_GeomFromEWKT('SRID=4326;{boundary.wkt}'), geom)"
self.dbcursor.execute(sql)

if query.find(" ways_poly ") > 0:
query = query.replace("ways_poly", "ways_view")
if query.find(" ways_line ") > 0:
query = query.replace("ways_line", "lines_view")
elif query.find(" nodes ") > 0:
query = query.replace("nodes", "nodes_view")
elif query.find(" relations ") > 0:
query = query.replace("relations", "relations_view")
features = list()
# log.debug(query)
if query.find(" ways_poly ") > 0:
query = query.replace("ways_poly", "ways_view")
elif query.find(" ways_line ") > 0:
query = query.replace("ways_line", "lines_view")
elif query.find(" nodes ") > 0:
query = query.replace("nodes", "nodes_view")
elif query.find(" relations ") > 0:
query = query.replace("relations", "relations_view")

log.debug(query)
self.dbcursor.execute(query)
result = self.dbcursor.fetchall()
log.info("SQL Query returned %d records" % len(result))
try:
result = self.dbcursor.fetchall()
log.debug("SQL Query returned %d records" % len(result))
except:
return FeatureCollection(features)

# If there is no config file, don't modify the results
if len(self.qc.config['where']['ways_poly']) == 0 and len(self.qc.config['where']['nodes']) == 0:
return result

for item in result:
if len(item) <= 1:
break
if len(item) <= 1 and len(result) == 1:
return result
# break
geom = wkt.loads(item[0])
tags = dict()
tags["id"] = item[1]
Expand Down

0 comments on commit 6aa2f5d

Please sign in to comment.