Search in sources :

Example 11 with LineString

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

the class GeoJSONTest method testLineStringWithZCoordinate.

@Test
public void testLineStringWithZCoordinate() {
    LineString geometry = randomLineString(EPSG_4326);
    geometry.apply(new RandomZCoordinateFilter());
    geometry.geometryChanged();
    readWriteTest(geometry);
}
Also used : MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) Test(org.junit.Test)

Example 12 with LineString

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

the class GeoJSONTest method randomLineString.

private LineString randomLineString(int srid) {
    LineString geometry = geometryFactory.createLineString(new Coordinate[] { randomCoordinate(), randomCoordinate(), randomCoordinate() });
    geometry.setSRID(srid);
    return geometry;
}
Also used : MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString)

Example 13 with LineString

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

the class GeoJSONEncoder method encode.

protected ObjectNode encode(MultiLineString geometry, int parentSrid) {
    Preconditions.checkNotNull(geometry);
    ObjectNode json = jsonFactory.objectNode();
    ArrayNode list = json.put(JSONConstants.TYPE, JSONConstants.MULTI_LINE_STRING).putArray(JSONConstants.COORDINATES);
    for (int i = 0; i < geometry.getNumGeometries(); ++i) {
        list.add(encodeCoordinates((LineString) geometry.getGeometryN(i)));
    }
    encodeCRS(json, geometry, parentSrid);
    return json;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Point(org.locationtech.jts.geom.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint)

Aggregations

LineString (org.locationtech.jts.geom.LineString)13 Point (org.locationtech.jts.geom.Point)8 MultiLineString (org.locationtech.jts.geom.MultiLineString)7 Polygon (org.locationtech.jts.geom.Polygon)5 MultiPoint (org.locationtech.jts.geom.MultiPoint)4 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)3 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)3 DirectPositionListType (net.opengis.gml.x32.DirectPositionListType)2 XmlCursor (org.apache.xmlbeans.XmlCursor)2 Test (org.junit.Test)2 Coordinate (org.locationtech.jts.geom.Coordinate)2 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)2 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)2 InvalidSridException (org.n52.shetland.ogc.om.features.samplingFeatures.InvalidSridException)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 AbstractRingPropertyType (net.opengis.gml.AbstractRingPropertyType)1 AbstractRingType (net.opengis.gml.AbstractRingType)1 DirectPositionListType (net.opengis.gml.DirectPositionListType)1