use of com.vividsolutions.jts.geom.Coordinate in project osm4j-geometry by topobyte.
the class CoordinateSequencesBuilder method addToResult.
private void addToResult(GeometryFactory factory, WayBuilderResult result, List<Coordinate> coords) {
if (coords.size() == 1) {
result.getCoordinates().add(coords.get(0));
} else {
CoordinateSequence cs = factory.getCoordinateSequenceFactory().create(coords.toArray(new Coordinate[0]));
result.getLineStrings().add(factory.createLineString(cs));
}
}
use of com.vividsolutions.jts.geom.Coordinate in project coastal-hazards by USGS-CIDA.
the class Bbox method envelopeToPolygon.
public static Polygon envelopeToPolygon(Envelope e) {
GeometryFactory factory = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING_SINGLE), SRID);
Coordinate coordA = new Coordinate(e.getMinX(), e.getMinY());
Coordinate coordB = new Coordinate(e.getMinX(), e.getMaxY());
Coordinate coordC = new Coordinate(e.getMaxX(), e.getMaxY());
Coordinate coordD = new Coordinate(e.getMaxX(), e.getMinY());
Coordinate coordE = coordA;
Polygon bboxPoly = factory.createPolygon(new Coordinate[] { coordA, coordB, coordC, coordD, coordE });
return bboxPoly;
}
use of com.vividsolutions.jts.geom.Coordinate 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.Coordinate in project onebusaway-application-modules by camsys.
the class EnterpriseFilteredGeocoderBase method filterResultsByWktPolygon.
protected List<EnterpriseGeocoderResult> filterResultsByWktPolygon(List<EnterpriseGeocoderResult> input) {
if (_wktFilterPolygon == null) {
return input;
}
List<EnterpriseGeocoderResult> output = new ArrayList<EnterpriseGeocoderResult>();
for (EnterpriseGeocoderResult result : input) {
Coordinate coordinate = new Coordinate(result.getLongitude(), result.getLatitude());
Geometry point = _geometryFactory.createPoint(coordinate);
if (_wktFilterPolygon.intersects(point)) {
output.add(result);
}
}
return output;
}
use of com.vividsolutions.jts.geom.Coordinate in project onebusaway-application-modules by camsys.
the class GtfsStopsInPolygonMain method readPoints.
private static Geometry readPoints(String arg) throws NumberFormatException, IOException {
BufferedReader reader = new BufferedReader(new FileReader(arg));
String line = null;
List<Coordinate> points = new ArrayList<Coordinate>();
while ((line = reader.readLine()) != null) {
String[] tokens = line.trim().split("[,\\s]+");
double lat = Double.parseDouble(tokens[0]);
double lon = Double.parseDouble(tokens[1]);
points.add(new Coordinate(lat, lon));
}
points.add(points.get(0));
LinearRing ring = _factory.createLinearRing(points.toArray(new Coordinate[points.size()]));
return _factory.createPolygon(ring, new LinearRing[0]);
}
Aggregations