I’m building an app that, while itself is not a router, needs to know about potential pedestrian-routable infrastructure in an area of user-supplied center and radius. Currently, the app gets this data with Overpass—the current query is defined here. Currently the app considers “potential pedestrian-routable infrastructure” to be ways with tags like highway=footway, highway=residential, railway=platform, etc., but not tags like access=private, foot=no, sidewalk=separate, etc. See the query for a full list. While the tag list may need to be adjusted, what tags should be considered “routable” is not the specific topic in question.
One way to construct an Overpass query for this is to list every possible combination of allowed/disallowed tags, like this, however with the number of allowed tags (18) combined with the number of disallowed tags (22), this query is quite unwieldy. Another method, which is what I use currently, is to use two subqueries, one for the allowed tags, and a second for the disallowed tags, then subtract the second from the first, like this.
I’ve been working on optimizing the query, in particular finding formulas for upper [maxsize:...] and [timeout:...] given the radius. I would guess that the “subtraction” method requires the server to load all allowed features, then to load all disallowed features, before doing the subtraction. I thought this wouldn’t be an issue since there would generally be far fewer disallowed objects than allowed ones, but isn’t always the case. In particular, this parking lot has over 22 thousand amenity=parking_space+access=private, which aren’t relevant to pedestrian routing, but they still get caught up in the query because of the access tag.
What do people think the best solution is? Some ideas:
- Limit the query’s memory usage so that queries in this particular parking lot don’t work.
- Raise the memory limit so that queries in the lot do work, but queries in other areas are slower.
- Use the harder-to-read, but more memory-efficient, “combinatorial” query.
- Refine the “disallowed” part of the query to only match
highwayways, like(way[highway][access!=private]; way[highway][foot!=no]; way[highway][sidewalk!=separate]; ...), resulting in allowing routing along otherwise disallowed non-highwayways, likerailway=platform+access=private. - Same as above, but exclude non-
highwaytags from the allowed tags, resulting in disallowing routing along e.g.railway=platform. - Use a query service other than Overpass.
- Remove the “disallowed” part of the query and filter down on the client side. I’d like to avoid this because I’d like the query to be user-configurable, and because it would require downloading the tags of all objects, while currently I only need the geometry.
Side note but I wish the Overpass API somehow returned the amount of memory and time it ended up needing to perform the query, so that I could use that to directly adjust [maxsize:...] and [timeout:...] without needing to guess-and-check.