use of org.locationtech.jts.geom.Coordinate in project ddf by codice.
the class WfsFilterDelegate method getCoordinatesFromWkt.
private Coordinate[] getCoordinatesFromWkt(String wkt) {
Coordinate[] coordinates;
try {
Geometry geo = getGeometryFromWkt(wkt);
coordinates = geo.getCoordinates();
} catch (ParseException e) {
throw new IllegalArgumentException(UNABLE_TO_PARSE_WKT_STRING, e);
}
return coordinates;
}
use of org.locationtech.jts.geom.Coordinate in project ddf by codice.
the class WfsFilterDelegate method createCoordinates.
private CoordinatesType createCoordinates(Geometry geometry) {
CoordinatesType coords = gml320ObjectFactory.createCoordinatesType();
Coordinate[] coordinates = geometry.getCoordinates();
if (coordinates != null && coordinates.length > 0) {
StringBuffer coordString = new StringBuffer();
for (Coordinate coordinate : coordinates) {
coordString.append(coordinate.x).append(",").append(coordinate.y).append(" ");
}
coords.setValue(coordString.toString());
coords.setDecimal(".");
coords.setCs(",");
coords.setTs(" ");
coords.setValue(coordString.toString());
return coords;
} else {
throw new IllegalArgumentException("Unable to parse Geometry coordinates from WKT String");
}
}
use of org.locationtech.jts.geom.Coordinate in project ddf by codice.
the class GeoJsonInputTransformerTest method testLineStringGeo.
@Test
public void testLineStringGeo() throws IOException, CatalogTransformerException, ParseException {
InputStream inputStream = new ByteArrayInputStream(sampleLineStringJsonText().getBytes());
Metacard metacard = transformer.transform(inputStream);
verifyBasics(metacard);
WKTReader reader = new WKTReader();
Geometry geometry = reader.read(metacard.getLocation());
Coordinate[] coords = geometry.getCoordinates();
assertThat(coords[0].x, is(30.0));
assertThat(coords[0].y, is(10.0));
assertThat(coords[1].x, is(10.0));
assertThat(coords[1].y, is(30.0));
assertThat(coords[2].x, is(40.0));
assertThat(coords[2].y, is(40.0));
}
use of org.locationtech.jts.geom.Coordinate in project carbondata by apache.
the class QuadTreeCls method getPolygonByPointList.
/**
* Convert point object to polygon object in Geo
*
* @param polygon Area coordinates stored as a list
* @return JTS Polygon objects
*/
public static Polygon getPolygonByPointList(List<Point2D.Double> polygon) {
int size = polygon.size();
if (size < 3) {
return null;
} else {
Coordinate[] rect = new Coordinate[size + 1];
for (int i = 0; i < size; i++) {
rect[i] = new Coordinate(polygon.get(i).x, polygon.get(i).y);
}
// making a closed polygon by keeping first point and last point same
rect[size] = new Coordinate(polygon.get(0).x, polygon.get(0).y);
return geoFactory.createPolygon(rect);
}
}
use of org.locationtech.jts.geom.Coordinate in project thingsboard by thingsboard.
the class GeoUtil method buildPolygonFromCoordinates.
private static Geometry buildPolygonFromCoordinates(List<Coordinate> coordinates) {
if (coordinates.size() == 2) {
Coordinate a = coordinates.get(0);
Coordinate c = coordinates.get(1);
coordinates.clear();
Coordinate b = new Coordinate(a.x, c.y);
Coordinate d = new Coordinate(c.x, a.y);
coordinates.addAll(List.of(a, b, c, d, a));
}
CoordinateSequence coordinateSequence = jtsCtx.getShapeFactory().getGeometryFactory().getCoordinateSequenceFactory().create(coordinates.toArray(new Coordinate[0]));
return GeometryFixer.fix(jtsCtx.getShapeFactory().getGeometryFactory().createPolygon(coordinateSequence));
}
Aggregations