use of org.geotools.geojson.geom.GeometryJSON in project dhis2-core by dhis2.
the class GeoUtilsTest method testVerifyPointIsWithinMultiPolygon.
@Test
void testVerifyPointIsWithinMultiPolygon() throws IOException {
String downtownOslo = TestResourceUtils.getFileContent("gis/brasilMultiPolygon.json");
Geometry g = new GeometryJSON().read(downtownOslo);
boolean result = GeoUtils.checkPointWithMultiPolygon(-43.96728515625, -16.699340234594537, g);
assertTrue(result);
result = GeoUtils.checkPointWithMultiPolygon(-43.681640625, -18.698285474146807, g);
assertFalse(result);
}
use of org.geotools.geojson.geom.GeometryJSON in project dhis2-core by dhis2.
the class GeoUtilsTest method testVerifyPointIsWithinPolygon.
@Test
void testVerifyPointIsWithinPolygon() throws IOException {
String downtownOslo = TestResourceUtils.getFileContent("gis/downtownOslo.json");
Geometry g = new GeometryJSON().read(downtownOslo);
boolean result = GeoUtils.checkPointWithMultiPolygon(10.746517181396484, 59.91080384720672, g);
assertTrue(result);
result = GeoUtils.checkPointWithMultiPolygon(10.755915641784668, 59.9139664757207, g);
assertFalse(result);
}
use of org.geotools.geojson.geom.GeometryJSON in project dhis2-core by dhis2.
the class GeoUtils method getGeometryFromCoordinatesAndType.
public static Geometry getGeometryFromCoordinatesAndType(FeatureType featureType, String coordinates) throws IOException {
GeometryJSON geometryJSON = new GeometryJSON();
if (featureType.equals(FeatureType.NONE) || featureType.equals(FeatureType.SYMBOL)) {
throw new IllegalArgumentException("Invalid featureType '" + featureType.value() + "'");
}
Geometry geometry = geometryJSON.read(String.format("{\"type\": \"%s\", \"coordinates\": %s}", featureType.value(), coordinates));
geometry.setSRID(SRID);
return geometry;
}
use of org.geotools.geojson.geom.GeometryJSON in project dhis2-core by dhis2.
the class GeoUtils method getGeoJsonPoint.
/**
* Get GeometryJSON point.
*
* @param longitude the longitude.
* @param latitude the latitude.
* @return the GeoJSON representation of the given point.
*/
public static Point getGeoJsonPoint(double longitude, double latitude) throws IOException {
Point point = new GeometryJSON().readPoint(new StringReader("{\"type\":\"Point\", \"coordinates\":[" + longitude + "," + latitude + "]}"));
point.setSRID(SRID);
return point;
}
use of org.geotools.geojson.geom.GeometryJSON in project dhis2-core by dhis2.
the class OrganisationUnitPolygonCoveringCoordinateFilterTest method verifyFilterIncludesOrgUnitFallingInsidePolygon.
@Test
void verifyFilterIncludesOrgUnitFallingInsidePolygon() throws IOException {
filter = new OrganisationUnitPolygonCoveringCoordinateFilter(10.746517181396484, 59.91080384720672);
Geometry ouGeometry = new GeometryJSON().read(DOWNTOWN_OSLO);
organisationUnit.setGeometry(ouGeometry);
assertTrue(filter.retain(organisationUnit));
}
Aggregations