use of com.vividsolutions.jts.geom.impl.CoordinateArraySequence in project activityinfo by bedatadriven.
the class MySqlUpdateTest method updateGeometry.
@Test
public void updateGeometry() throws SQLException {
userId = 3;
ResourceId formId = CuidAdapter.adminLevelFormClass(1);
ResourceId recordId = entity(1);
ResourceId fieldId = CuidAdapter.field(formId, CuidAdapter.GEOMETRY_FIELD);
Optional<FormStorage> storage = catalog.getForm(formId);
GeometryFactory factory = new GeometryFactory();
Polygon polygon = new Polygon(new LinearRing(new CoordinateArraySequence(new Coordinate[] { new Coordinate(100, 0), new Coordinate(101, 0), new Coordinate(101, 1), new Coordinate(100, 1), new Coordinate(100, 0) }), factory), new LinearRing[0], factory);
storage.get().updateGeometry(recordId, fieldId, polygon);
query(formId, "_id", "ST_XMIN(boundary)", "ST_XMAX(boundary)");
}
use of com.vividsolutions.jts.geom.impl.CoordinateArraySequence in project OpenTripPlanner by opentripplanner.
the class ConcaveHull method transformIntoPointGeometryCollection.
/**
* Transform into GeometryCollection.
*
* @param geom
* input geometry
* @return
* a geometry collection
*/
private static GeometryCollection transformIntoPointGeometryCollection(Geometry geom) {
UniqueCoordinateArrayFilter filter = new UniqueCoordinateArrayFilter();
geom.apply(filter);
Coordinate[] coord = filter.getCoordinates();
Geometry[] geometries = new Geometry[coord.length];
for (int i = 0; i < coord.length; i++) {
Coordinate[] c = new Coordinate[] { coord[i] };
CoordinateArraySequence cs = new CoordinateArraySequence(c);
geometries[i] = new Point(cs, geom.getFactory());
}
return new GeometryCollection(geometries, geom.getFactory());
}
use of com.vividsolutions.jts.geom.impl.CoordinateArraySequence in project coastal-hazards by USGS-CIDA.
the class CRSUtils method buildLineString.
private static LineString buildLineString(List<Coordinate> coords) {
LineString line;
try {
CoordinateSequence seq = new CoordinateArraySequence(coords.toArray(new Coordinate[coords.size()]));
line = new LineString(seq, geometryFactory);
} catch (Exception e) {
LOGGER.error("Failed to build line string from list of coordinates", e);
line = null;
}
return line;
}
use of com.vividsolutions.jts.geom.impl.CoordinateArraySequence in project OpenTripPlanner by opentripplanner.
the class ConcaveHull method transformIntoPointGeometryCollection.
/**
* Transform into GeometryCollection.
*
* @param geom
* input geometry
* @return
* a geometry collection
*/
private static GeometryCollection transformIntoPointGeometryCollection(GeometryCollection gc) {
UniqueCoordinateArrayFilter filter = new UniqueCoordinateArrayFilter();
gc.apply(filter);
Coordinate[] coord = filter.getCoordinates();
Geometry[] geometries = new Geometry[coord.length];
for (int i = 0; i < coord.length; i++) {
Coordinate[] c = new Coordinate[] { coord[i] };
CoordinateArraySequence cs = new CoordinateArraySequence(c);
geometries[i] = new Point(cs, gc.getFactory());
}
return new GeometryCollection(geometries, gc.getFactory());
}
Aggregations