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:
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user