Search in sources :

Example 1 with CoordinateSequenceFactory

use of org.locationtech.jts.geom.CoordinateSequenceFactory in project hale by halestudio.

the class Line2D method toJTSLineString.

// functional methods ......................................................
/**
 * This method will return this Line as a Java Topology Suite LineString.
 *
 * @param geometryFactory the factory for JTS geometries
 * @return the converted LineString
 */
private org.locationtech.jts.geom.LineString toJTSLineString(GeometryFactory geometryFactory) {
    Coordinate[] coords = new Coordinate[this.getPoints().length];
    for (int i = 0; i < this.getPoints().length; i++) {
        coords[i] = new Coordinate(this.getPoints()[i].getX(), this.getPoints()[i].getY());
    }
    CoordinateSequenceFactory csf = CoordinateArraySequenceFactory.instance();
    CoordinateSequence cs = csf.create(coords);
    org.locationtech.jts.geom.LineString jts_ls = new org.locationtech.jts.geom.LineString(cs, geometryFactory);
    return jts_ls;
}
Also used : CoordinateSequence(org.locationtech.jts.geom.CoordinateSequence) Coordinate(org.locationtech.jts.geom.Coordinate) CoordinateSequenceFactory(org.locationtech.jts.geom.CoordinateSequenceFactory)

Aggregations

Coordinate (org.locationtech.jts.geom.Coordinate)1 CoordinateSequence (org.locationtech.jts.geom.CoordinateSequence)1 CoordinateSequenceFactory (org.locationtech.jts.geom.CoordinateSequenceFactory)1