Improve nearby search

* Use regular expression queries for place types
* Add more place types
* Add relations
* Only return results with a name
This commit is contained in:
2026-02-24 09:58:12 +04:00
parent ff01d54fdd
commit 361a826e4f
2 changed files with 24 additions and 7 deletions

View File

@@ -83,7 +83,7 @@ export default class PlaceDetails extends Component {
} }
parts.push(city); parts.push(city);
} }
// State + Country (if not already covered) // State + Country (if not already covered)
const state = get('addr:state', 'state'); const state = get('addr:state', 'state');
const country = get('addr:country', 'country'); const country = get('addr:country', 'country');
@@ -151,7 +151,7 @@ export default class PlaceDetails extends Component {
if (!id) return null; if (!id) return null;
return `https://www.google.com/maps/search/?api=1&query=${this.name}&query=${this.place.lat},${this.place.lon}`; return `https://www.google.com/maps/search/?api=1&query=${this.name}&query=${this.place.lat},${this.place.lon}`;
} }
get showDescription() { get showDescription() {
// If it's a Photon result, the description IS the address. // If it's a Photon result, the description IS the address.
// Since we are showing the address in the meta section (bottom), // Since we are showing the address in the meta section (bottom),

View File

@@ -24,14 +24,31 @@ export default class OsmService extends Service {
this.controller = new AbortController(); this.controller = new AbortController();
const signal = this.controller.signal; const signal = this.controller.signal;
const typeKeys = [
'amenity',
'amenity',
'shop',
'tourism',
'historic',
'leisure',
'office',
'craft',
'building',
'landuse',
'public_transport',
'aeroway'
]
const typeKeysQuery = [`~"^(${typeKeys.join("|")})$"~".*"`];
const query = ` const query = `
[out:json][timeout:25]; [out:json][timeout:25];
( (
nw["amenity"](around:${radius},${lat},${lon}); node(around:${radius},${lat},${lon})
nw["shop"](around:${radius},${lat},${lon}); [${typeKeysQuery}][name~"."];
nw["tourism"](around:${radius},${lat},${lon}); way(around:${radius},${lat},${lon})
nw["leisure"](around:${radius},${lat},${lon}); [${typeKeysQuery}][name~"."];
nw["historic"](around:${radius},${lat},${lon}); relation(around:${radius},${lat},${lon})
[${typeKeysQuery}][name~"."];
); );
out center; out center;
`.trim(); `.trim();