Search in sources :

Example 6 with PrecisionModel

use of org.locationtech.jts.geom.PrecisionModel in project arctic-sea by 52North.

the class MultiPointCoverage method getExtent.

/**
 * Get the extent of all {@link Point}s
 *
 * @return The extent as {@link Polygon}
 */
public Polygon getExtent() {
    if (isSetValue()) {
        int srid = -1;
        List<Coordinate> coordinates = Lists.newLinkedList();
        for (PointValuePair pointValuePair : getValue()) {
            Point point = pointValuePair.getPoint();
            coordinates.add(point.getCoordinate());
            if (point.getSRID() != srid) {
                srid = point.getSRID();
            }
        }
        GeometryFactory geometryFactory;
        if (srid > 0) {
            geometryFactory = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING), srid);
        } else {
            geometryFactory = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING));
        }
        return geometryFactory.createPolygon(coordinates.toArray(new Coordinate[coordinates.size()]));
    }
    return null;
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Coordinate(org.locationtech.jts.geom.Coordinate) PrecisionModel(org.locationtech.jts.geom.PrecisionModel) Point(org.locationtech.jts.geom.Point) Point(org.locationtech.jts.geom.Point) PointValuePair(org.n52.shetland.ogc.om.PointValuePair)

Aggregations

GeometryFactory (org.locationtech.jts.geom.GeometryFactory)6 PrecisionModel (org.locationtech.jts.geom.PrecisionModel)6 Coordinate (org.locationtech.jts.geom.Coordinate)4 Geometry (org.locationtech.jts.geom.Geometry)2 ParseException (org.locationtech.jts.io.ParseException)2 WKTReader (org.locationtech.jts.io.WKTReader)2 HashSet (java.util.HashSet)1 TreeMap (java.util.TreeMap)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Point (org.locationtech.jts.geom.Point)1 WKTWriter (org.locationtech.jts.io.WKTWriter)1 ReferenceType (org.n52.shetland.ogc.gml.ReferenceType)1 Time (org.n52.shetland.ogc.gml.time.Time)1 PointValuePair (org.n52.shetland.ogc.om.PointValuePair)1 GeometryValue (org.n52.shetland.ogc.om.values.GeometryValue)1