GPS Coordinate within an Area - Suitable C++ Library suggestions

Just wondering if anyone has some good suggestions for a C++ library or example code to calculate if a GPS coordinate is ‘within’ a defined area (polygon preferred but rectangle would be a good basic alternative).

I’ve been looking around and haven’t found much luck.

There are a few good articles and stackoverflow posts, but nothing jumped out as tested and compelling.
(Ray tracing approach in particular has edge cases where it can fail).

Any tips would be greatly appreciated!

you might find something useful from an old project tango public park/zoo mapping project or vuforia project. the plane fitting example here,


might yield some clues.

1 Like

@Cameron Curious what the edge cases where the ray tracing approach may fail.

I have asset tracking devices that notify when they enter or exit a predefined region so…
I developed a Javascript process to do exactly what you’re looking for. I can translate to C++ but, if the ray tracing approach won’t work, it might not be much help.

Thanks, very kind offer. Ray tracing can have issues along border edges. Happy to give the code a shot and try it out to see if it does have border detection issues.

I had done some reading (can’t find the link anymore, dang it) which did mention the issues with border detection. The work around there may be to just add an extra few meters to the drawn border as a buffer.

Did your code end up handling a large array set with the polygon? I’m assuming you send an array into the method? :slight_smile:

Thanks again!

How complex should your polygons be?
Will your polygons have concave sections?
How do you intend to treat self-intersecting polygons?

They may have concave sections, I can use the UI to prevent intersecting polygons and concave. :slight_smile:

What were you thinking in particular? :slight_smile:

I wasn’t really thinking about a solution for your problem but rather inquesting about the extent of your problem so that others can base their feedback on it :wink: