APIs for Geofencing

Hi, I'm programming a drone tracking application and I would like to do a geofence. I can plot the drones and a boundary (using ellipse or polygons).

However I can't seem to find any methods to check if the drones are within the boundary. Have looked through the API documentation, but I can't find anything suitable. Any ideas?

Hi Samuel,

There’s Rectangle.contains, but besides rectangles, I don’t think we have anything that out of the box tests if a point is inside a boundary. You’ll probably have to do some math for ellipsoids or polygons. On the bright side, it’s definitive a solved problem, and there are some pretty fast algorithms out there for determining whether a point in inside or outside of a shape.

Hope that helps, thanks!

Gabby

Hi Samuel,

I've used this package to achieve what you're describing - https://github.com/substack/point-in-polygon

The only downside to using this is that it can't detect when the point you're tracking is on the edge of the polygon. Points on the edge are classified as either inside or outside. Other than that it works well.

Kind Regards,
Harry

Thanks Gabby and Harry for your replies.

I have solved the problem by switching to polygons only and using the point in polygon to check, but I forgot to check back.

@Harry, this package seems to do it better than the one you shared. https://github.com/mikolalysenko/robust-point-in-polygon

Glad you solved the problem.

And thanks for sharing the package, that may solve a problem I'm about to have!

Harry