geometry-api-java icon indicating copy to clipboard operation
geometry-api-java copied to clipboard

PolygonUtils not in Jar

Open SiefSeif opened this issue 7 years ago • 5 comments

I need to use PolygonUtils but it's not in the released Jar.. how can i use it?..thank you.

SiefSeif avatar Oct 15 '17 10:10 SiefSeif

Hi, which methods do you want to use?

alocke avatar Oct 16 '17 17:10 alocke

I want to use functions for geofencing, PolygonUtils.isPointInPolygon2D()

SiefSeif avatar Oct 17 '17 07:10 SiefSeif

Will OperatorDisjoint work for you? Here is an example of how to use it.

Point point = new Point(1, 1);
Polygon polygon = new Polygon();
polygon.startPath(0, 0);
polygon.lineTo(0, 3);
polygon.lineTo(3, 3);
polygon.lineTo(3, 0);

SpatialReference spatialRef = SpatialReference.create(4326);

// Returns false in this case meaning that the point is in the polygon
boolean disjoint = OperatorDisjoint.local().execute(point, polygon, spatialRef, null);

alocke avatar Oct 17 '17 17:10 alocke

Yes, this works for me, thank you. but is it the best and fastest way? because i'm working on bigdata use case... will PolygonUtils be faster?

SiefSeif avatar Oct 18 '17 09:10 SiefSeif

@SiefSeif Use OperatorDisjoint. Avoid creating objects in a loop, you could also move OperatorDisjoint.local() call outside of the loop. The spatial reference is used to extract a tolerance value of about 1 mm and is used close to polygon borders, you can pass null spatial reference if you don't care about the tolerance.

stolstov avatar Oct 18 '17 17:10 stolstov