mirror of
https://github.com/DerTyp7/osm-routing-backend-python.git
synced 2025-10-29 04:22:09 +01:00
moved from GitLab to GitHub manually
This commit is contained in:
24
utils/search.py
Normal file
24
utils/search.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from sql.handle_sql import SqlHandler
|
||||
from server import osmPath, dbPath
|
||||
|
||||
# Initalize global variables
|
||||
sql = ""
|
||||
|
||||
def search(wayName, limit):
|
||||
global sql
|
||||
formattedWays = []
|
||||
limit = int(limit)
|
||||
sql = SqlHandler(dbPath, osmPath)
|
||||
ways = sql.getWaysByNameWildcard(wayName)
|
||||
|
||||
for way in ways:
|
||||
formattedWays.append({'id': way, 'name': sql.getNameOfWay(way) + " (" + str(way) + ")"})
|
||||
|
||||
|
||||
|
||||
del sql
|
||||
|
||||
if len(formattedWays) >= limit:
|
||||
return formattedWays[:limit]
|
||||
else:
|
||||
return formattedWays
|
||||
Reference in New Issue
Block a user