Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bounding box approach does not work well for distant points and antipodes #1

Open
CapacitorSet opened this issue Jun 8, 2018 · 1 comment

Comments

@CapacitorSet
Copy link

Consider the following:

  • the shortest line between two points on a sphere is not a straight line on a map, not on a Mercator projection anyway.
  • the difference between a straight line and a geodesic gets larger and larger as points get more distant in longitude.
  • a bounding box does not accurately account for such a difference.

Suppose that one were to travel from Zurich to Vladivostok. A bounding box approach would get a significantly longer trip:

Zurich to Vladivostok

Furthermore, the bounding box can prove mildly inefficient for points which divide a geodesic into two roughly similar halves, like Zurich and the Bering Strait. The bounding box approach would search for a route that goes through the Pacific and Canada (i.e. to the west); however, there is a similar route that may prove more efficient, that goes through Asia (i.e. to the east). The difference between the two straight paths is insignificant (approx. 80 km).

Zurich to the Bering Strait

@denysvitali
Copy link
Owner

Actually, you're right. A Bounding Box within two geometrical coordinates (as seen here) is wrong, because will cause the bounding box to include elements that are geometrically inside a box that acts like if the plane was projected. The solution here would be to change the cast to geometry to a cast to geography - that way the bounding box will be drawn correctly over the sphere.
I'll fix this issue in gtfs-server queries.

I'll look into the second issue (even though our project isn't capable of handling such big distances), and report back 👍

Thank you for opening this issue 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants