From 7e7883bb76a9bdda02356a83bf7460457dff1a57 Mon Sep 17 00:00:00 2001 From: Marwin Hochfelsner <50826859+hlfan@users.noreply.github.com> Date: Thu, 5 Jun 2025 04:16:56 +0200 Subject: [PATCH] Simplify overpass query building --- app/assets/javascripts/index/query.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/index/query.js b/app/assets/javascripts/index/query.js index 85e3f44ef..681f47401 100644 --- a/app/assets/javascripts/index/query.js +++ b/app/assets/javascripts/index/query.js @@ -245,14 +245,12 @@ OSM.Query = function (map) { bbox = [bounds.getSouthWest(), bounds.getNorthEast()] .map(c => OSM.cropLocation(c, zoom)) .join(), - geombbox = "geom(" + bbox + ");", + geom = `geom(${bbox})`, radius = 10 * Math.pow(1.5, 19 - zoom), - around = "(around:" + radius + "," + lat + "," + lng + ")", - nodes = "node" + around, - ways = "way" + around, - relations = "relation" + around, - nearby = "(" + nodes + ";" + ways + ";);out tags " + geombbox + relations + ";out " + geombbox, - isin = "is_in(" + lat + "," + lng + ")->.a;way(pivot.a);out tags bb;out ids " + geombbox + "relation(pivot.a);out tags bb;"; + here = `(around:${radius},${lat},${lng})`, + enclosed = "(pivot.a);out tags bb", + nearby = `(node${here};way${here};);out tags ${geom};relation${here};out ${geom};`, + isin = `is_in(${lat},${lng})->.a;way${enclosed};out ids ${geom};relation${enclosed};`; $("#sidebar_content .query-intro") .hide(); -- 2.39.5