Search in sources :

Example 6 with MultiLineString

use of com.vividsolutions.jts.geom.MultiLineString in project series-rest-api by 52North.

the class GeoJSONTest method testMultiLineStringWithZCoordinate.

@Test
public void testMultiLineStringWithZCoordinate() {
    MultiLineString geometry = randomMultiLineString(CRSUtils.EPSG_WGS84);
    geometry.apply(new RandomZCoordinateFilter());
    geometry.geometryChanged();
    readWriteTest(geometry);
}
Also used : MultiLineString(com.vividsolutions.jts.geom.MultiLineString) Test(org.junit.Test)

Example 7 with MultiLineString

use of com.vividsolutions.jts.geom.MultiLineString in project series-rest-api by 52North.

the class GeoJSONDecoder method decodeMultiLineString.

protected MultiLineString decodeMultiLineString(JsonNode node, GeometryFactory fac) throws GeoJSONException {
    JsonNode coordinates = requireCoordinates(node);
    LineString[] lineStrings = new LineString[coordinates.size()];
    for (int i = 0; i < coordinates.size(); ++i) {
        JsonNode coords = coordinates.get(i);
        lineStrings[i] = fac.createLineString(decodeCoordinates(coords));
    }
    return fac.createMultiLineString(lineStrings);
}
Also used : LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) JsonNode(com.fasterxml.jackson.databind.JsonNode) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint)

Example 8 with MultiLineString

use of com.vividsolutions.jts.geom.MultiLineString in project ddf by codice.

the class TestWfs10JTStoGML200Converter method testGMLToMultiLineStringType.

@Test
public void testGMLToMultiLineStringType() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    String multiLineStringGML = Wfs10JTStoGML200Converter.convertGeometryToGML(getGeometryFromWkt(MULTILINESTRING));
    MultiLineStringType multiLineStringType = (MultiLineStringType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(multiLineStringGML, Wfs10Constants.MULTI_LINESTRING);
    List<JAXBElement<? extends GeometryAssociationType>> jaxbElements = multiLineStringType.getGeometryMember();
    assertThat(jaxbElements.isEmpty(), is(Boolean.FALSE));
    assertThat(jaxbElements.size() == 2, is(Boolean.TRUE));
    String coordinates1 = extractLineStringMemberCoordinates(jaxbElements.get(0));
    assertThat(coordinates1.isEmpty(), is(Boolean.FALSE));
    assertThat(MULTILINESTRING_COORD1.equals(coordinates1), is(Boolean.TRUE));
    String coordinates2 = extractLineStringMemberCoordinates(jaxbElements.get(1));
    assertThat(coordinates2.isEmpty(), is(Boolean.FALSE));
    assertThat(MULTILINESTRING_COORD2.equals(coordinates2), is(Boolean.TRUE));
}
Also used : GeometryAssociationType(ogc.schema.opengis.gml.v_2_1_2.GeometryAssociationType) MultiLineStringType(ogc.schema.opengis.gml.v_2_1_2.MultiLineStringType) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) JAXBElement(javax.xml.bind.JAXBElement) Test(org.junit.Test)

Example 9 with MultiLineString

use of com.vividsolutions.jts.geom.MultiLineString in project ddf by codice.

the class TestWfs10JTStoGML200Converter method testMultiLineStringTypeToJAXB.

@Test
public void testMultiLineStringTypeToJAXB() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    String multiLineString = Wfs10JTStoGML200Converter.convertGeometryToGML(getGeometryFromWkt(MULTILINESTRING));
    MultiLineStringType multiLineStringType = (MultiLineStringType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(multiLineString, Wfs10Constants.MULTI_LINESTRING);
    JAXBElement<MultiLineStringType> multiLineStringTypeJAXBElement = (JAXBElement<MultiLineStringType>) Wfs10JTStoGML200Converter.convertGeometryTypeToJAXB(multiLineStringType);
    JAXB.marshal(multiLineStringTypeJAXBElement, writer);
    String xml = writer.toString();
    Diff diff = XMLUnit.compareXML(xml, MULTILINESTRING_GML);
    assertTrue(XMLUNIT_SIMILAR, diff.similar());
    assertThat(diff.similar(), is(Boolean.TRUE));
    assertThat(diff.identical(), is(Boolean.FALSE));
}
Also used : Diff(org.custommonkey.xmlunit.Diff) MultiLineStringType(ogc.schema.opengis.gml.v_2_1_2.MultiLineStringType) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) JAXBElement(javax.xml.bind.JAXBElement) Test(org.junit.Test)

Example 10 with MultiLineString

use of com.vividsolutions.jts.geom.MultiLineString in project ddf by codice.

the class Wfs20JTStoGML321Converter method convertToMultiLineStringType.

// MultiLineStringType maps to MultiCurveType in opengis API
public static MultiCurveType convertToMultiLineStringType(MultiLineString multiLineString, String srsName) {
    final MultiCurveType multiCurveType = GML320_OBJECT_FACTORY.createMultiCurveType();
    for (int index = 0; index < multiLineString.getNumGeometries(); index++) {
        final LineString lineString = (LineString) multiLineString.getGeometryN(index);
        multiCurveType.getCurveMember().add(createCurvePropertyType(lineString));
    }
    multiCurveType.setSrsName(srsName);
    return multiCurveType;
}
Also used : MultiCurveType(net.opengis.gml.v_3_2_1.MultiCurveType) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint)

Aggregations

MultiLineString (com.vividsolutions.jts.geom.MultiLineString)10 LineString (com.vividsolutions.jts.geom.LineString)8 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)5 Point (com.vividsolutions.jts.geom.Point)5 Test (org.junit.Test)4 GeometryCollection (com.vividsolutions.jts.geom.GeometryCollection)2 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)2 Polygon (com.vividsolutions.jts.geom.Polygon)2 JAXBElement (javax.xml.bind.JAXBElement)2 MultiCurveType (net.opengis.gml.v_3_2_1.MultiCurveType)2 MultiLineStringType (ogc.schema.opengis.gml.v_2_1_2.MultiLineStringType)2 Diff (org.custommonkey.xmlunit.Diff)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 ParseException (com.vividsolutions.jts.io.ParseException)1 GeometryPropertyType (net.opengis.gml.v_3_2_1.GeometryPropertyType)1 LineStringType (net.opengis.gml.v_3_2_1.LineStringType)1