I am using Java Geotools library for check if a POINT(...) is contained in a POLYGON(...).
I have done it with:
Geometry sPG = reader.read(wktStartPoint); //startpointgeometry
Geometry sEG = reader.read(wktEndPoint);
if(wktLayerGeo.contains(sPG) || wktLayerGeo.contains(sEG)){
// do something
}
But now I have to set a tolerance: I would check if a point is contained in the polygon with a tolerance distance of 50 km for example.
Can I do it with GeoTools?
Thank you
You can use the JTS buffer
method on your Polygon geometry (API):
double yourToleranceDistance = 2;
int numberOfSegmentsPerQuadrant = 2;
// get the geometry with your tolerance
Polygon wktLayerGeoWithTolerance = (Polygon) wktLayerGeo.buffer(yourToleranceDistance, numberOfSegmentsPerQuadrant, BufferParameters.CAP_SQUARE);
// continue with your code...
if(wktLayerGeoWithTolerance.contains(sPG) || wktLayerGeoWithTolerance.contains(sEG)){
// do something
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With