OSM: minor fixes
This commit is contained in:
parent
ad1408c944
commit
9f51613d26
|
@ -1,5 +1,9 @@
|
||||||
# OpenStreetMap Tool
|
# OpenStreetMap Tool
|
||||||
|
|
||||||
|
**0.2.1:**
|
||||||
|
- Only print secondary results if they exist.
|
||||||
|
- Remove extraneous print logging.
|
||||||
|
|
||||||
**0.2.0:**
|
**0.2.0:**
|
||||||
- Include Ways as secondary information for improved search results.
|
- Include Ways as secondary information for improved search results.
|
||||||
- Added searching for swimming and recreational areas.
|
- Added searching for swimming and recreational areas.
|
||||||
|
|
37
osm.py
37
osm.py
|
@ -2,7 +2,7 @@
|
||||||
title: OpenStreetMap Tool
|
title: OpenStreetMap Tool
|
||||||
author: projectmoon
|
author: projectmoon
|
||||||
author_url: https://git.agnos.is/projectmoon/open-webui-filters
|
author_url: https://git.agnos.is/projectmoon/open-webui-filters
|
||||||
version: 0.2.0
|
version: 0.2.1
|
||||||
license: AGPL-3.0+
|
license: AGPL-3.0+
|
||||||
required_open_webui_version: 0.3.9
|
required_open_webui_version: 0.3.9
|
||||||
"""
|
"""
|
||||||
|
@ -173,7 +173,7 @@ class OsmSearcher:
|
||||||
{search}
|
{search}
|
||||||
);
|
);
|
||||||
out qt;
|
out qt;
|
||||||
"""
|
"""'
|
||||||
print(query)
|
print(query)
|
||||||
data = { "data": query }
|
data = { "data": query }
|
||||||
response = requests.get(url, params=data, headers=headers)
|
response = requests.get(url, params=data, headers=headers)
|
||||||
|
@ -219,14 +219,10 @@ class OsmSearcher:
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes, ways = self.overpass_search(place, tags, bbox, limit, radius)
|
nodes, ways = self.overpass_search(place, tags, bbox, limit, radius)
|
||||||
print(nodes)
|
|
||||||
print(ways)
|
|
||||||
|
|
||||||
# use results from overpass, but if they do not exist,
|
# use results from overpass, but if they do not exist,
|
||||||
# fall back to the nominatim result. we can get away
|
# fall back to the nominatim result. this may or may
|
||||||
# with this because we're not digging through the
|
# not be a good idea.
|
||||||
# objects themselves (as long as they have lat/lon, we
|
|
||||||
# are good).
|
|
||||||
things_nearby = (nodes
|
things_nearby = (nodes
|
||||||
if len(nodes) > 0
|
if len(nodes) > 0
|
||||||
else OsmSearcher.fallback(nominatim_result))
|
else OsmSearcher.fallback(nominatim_result))
|
||||||
|
@ -235,7 +231,6 @@ class OsmSearcher:
|
||||||
things_nearby = sort_by_closeness(origin, things_nearby)
|
things_nearby = sort_by_closeness(origin, things_nearby)
|
||||||
things_nearby = things_nearby[:limit]
|
things_nearby = things_nearby[:limit]
|
||||||
other_results = ways[:(limit+5)]
|
other_results = ways[:(limit+5)]
|
||||||
print(other_results)
|
|
||||||
|
|
||||||
if not things_nearby or len(things_nearby) == 0:
|
if not things_nearby or len(things_nearby) == 0:
|
||||||
return NO_RESULTS
|
return NO_RESULTS
|
||||||
|
@ -243,6 +238,17 @@ class OsmSearcher:
|
||||||
tag_type_str = ", ".join(tags)
|
tag_type_str = ", ".join(tags)
|
||||||
example_link = "https://www.openstreetmap.org/#map=19/<lat>/<lon>"
|
example_link = "https://www.openstreetmap.org/#map=19/<lat>/<lon>"
|
||||||
|
|
||||||
|
if len(other_results) > 0:
|
||||||
|
extra_info = (
|
||||||
|
"\n\n----------\n\n"
|
||||||
|
f"Additionally, here are some other results that might be useful. "
|
||||||
|
"The exact distance from the requested location is not known. "
|
||||||
|
"The seconary results are below."
|
||||||
|
"\n\n----------\n\n"
|
||||||
|
f"{str(other_results)}")
|
||||||
|
else:
|
||||||
|
extra_info = ""
|
||||||
|
|
||||||
return (
|
return (
|
||||||
f"These are some of the {tag_type_str} points of interest nearby. "
|
f"These are some of the {tag_type_str} points of interest nearby. "
|
||||||
"These are the results known to be closest to the requested location. "
|
"These are the results known to be closest to the requested location. "
|
||||||
|
@ -261,13 +267,12 @@ class OsmSearcher:
|
||||||
"\n\nAnd so on.\n\n"
|
"\n\nAnd so on.\n\n"
|
||||||
"Only use relevant results. If there are no relevant results, "
|
"Only use relevant results. If there are no relevant results, "
|
||||||
"say so. Do not make up answers or hallucinate."
|
"say so. Do not make up answers or hallucinate."
|
||||||
f"The primary results are below.\n\n"
|
"The primary results are below. "
|
||||||
"----------"
|
"Remember that the CLOSEST result is first, and you should use "
|
||||||
f"\n\n{str(things_nearby)}\n\n"
|
"that result first."
|
||||||
"----------\n\n"
|
"\n\n----------\n\n"
|
||||||
f"Additionally, here are some other results that might be useful. "
|
f"{str(things_nearby)}"
|
||||||
"The exact distance to these from the requested location is not known."
|
f"{extra_info}"
|
||||||
f"\n\n{str(other_results)}"
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return NO_RESULTS
|
return NO_RESULTS
|
||||||
|
|
Loading…
Reference in New Issue