Do you know java open source geofence library (Determining Whether A Point Is Inside A Complex Polygon) like Google play services for Android ?
Geofence library in Java
8.4k views Asked by sytolk At
3
There are 3 answers
3
On
use a open source library call "utils" http://www.geotelematic.com/javadocs/org/opengts/util/package-summary.html
boolean isPointInside(GeoPoint gp) Returns true if the specified point is inside the polygon
. include in OpenGts Proyect : http://www.opengts.org/
import org.opengts.util.GeoPoint;
import org.opengts.util.GeoPolygon;
use this snipet to check if Point is inside a Polygon
GeoPolygon fence = new GeoPolygon( // Define a Fence Polygon
new GeoPoint(-31.414547, -64.488178),
new GeoPoint(-31.415579, -64.496261),
new GeoPoint(-31.411513, -64.495720),
new GeoPoint(-31.408726, -64.489549),
new GeoPoint(-31.411898, -64.484406)
);
GeoPoint testgp1 = new GeoPoint(-31.411753, -64.489922);// Point1 inside
GeoPoint testgp2 = new GeoPoint(-31.413962, -64.486445);// Point2 outside
boolean inzone = fence.isPointInside(testgp1);
System.out.println ("Point1 is inside of polygon= "+inzone);
inzone = fence.isPointInside(testgp2);
System.out.println ("Point2 is inside of polygon= "+inzone);
result:
Point1 is inside of polygon= true
Point1 is inside of polygon= false
Take a look https://code.google.com/p/openmap/source/browse/src/openmap/com/bbn/openmap/geo/Intersection.java