I'm trying to figure out which ways are "the same". One metric I'd like to check is the angle between them: if two ways meet at a node at an angle pretty close to 180 degrees, that's an indication that they should be treated as the same for my purposes.
Specifically, I'd like to find the angle between ways that share a start/end node using the Overpass API.
So far, I've come up with this, which lets me find the adjacent nodes. From there, in principle I just need to do some trig, but that doesn't seem to be available. There's the angle()
evaluator, but that only works on nodes internal to a way, and I don't think it's possible to construct a synthetic way from a given set of points.
I've considered constructing the trig myself. I could use the taylor series for arctan, in theory, or I could take dot products and work with cosines instead of the angles directly. Since I only want to check if the angle is within a certain range, in principle that should work. But it seems frankly hideous. Also, to do this accurately, I'd need to be able to project to something where the x and y units are approximately equal (that is to say, I can't just use lat and lon).
I've considered doing this in post-processing, but the issue is that I want to check this inside a complete
block in Overpass. Doing this client-side would mean I need an arbitrary number of round-trips to the Overpass API.