I'm looking for an accurate point in polygon algorithm using WGS84.
The problem:
Given the set of points that are the vertices of an arbitrary polygon drawn on the surface of the WGS84 reference spheroid, I need to determine if a point is located inside or outside of that polygon. This polygon might have the span of a few hundreds of kilometres.
So far I was able to find that using a spherical approximation of the Earth: my method uses ray casting: https://en.wikipedia.org/wiki/Point_in_polygon. Finding the crossing of the polygon border with a casted ray seems pretty straightforward. In a nutshell: I convert the polygon vertices location to vectors, then using their cross product I obtain the great circles crossing locations and I calculate which one of them is the right one. I derived that method from here: https://blog.mbedded.ninja/mathematics/geometry/spherical-geometry/finding-the-intersection-of-two-arcs-that-lie-on-a-sphere/.
The problem is the accuracy. I understand that when considering great circles on a geoid, they are not circles but ellipses. I imagine, that my method will no longer be accurate in that case. As I read at How accurate is approximating Earth as sphere?, the worst-case scenario error can be as big as 0.3%. This is not acceptable for me - I'd like to have the accuracy that would be in an order of magnitude of what can be obtained from the typical GPS receiver, so the error is not larger than say 10 - 20 meters.
I wonder if using some sort of zoning might be a solution, like UTM. Then, if I would convert my polygon vertices coordinates to that system, I could use euclidean geometry to calculate ray crossings. The problems are, that I do not know how to estimate the error, and what to do when the polygon would span over adjacent zones - I imagine, it would increase the error significantly.
I'm quite new to this topic.