Search in sources :

Example 16 with LineStringType

use of net.opengis.gml._3.LineStringType in project tiamat by entur.

the class LineStringConverterTest method convertToLineString.

@Test
public void convertToLineString() throws Exception {
    LineStringType lineStringType = new LineStringType().withId("LineString").withPosList(new DirectPositionListType().withSrsDimension(BigInteger.valueOf(2L)).withValue(71.1, 9.1, 4.1, 9.5));
    LineString lineString = lineStringConverter.convertTo(lineStringType, new TypeBuilder<LineString>() {
    }.build(), mappingContext);
    assertThat(lineString).isNotNull();
    assertThat(lineString.getCoordinates()).hasSize(2);
    assertThat(lineString.getCoordinates()[0].x).isEqualTo(lineStringType.getPosList().getValue().get(1));
    assertThat(lineString.getCoordinates()[0].y).isEqualTo(lineStringType.getPosList().getValue().get(0));
    assertThat(lineString.getCoordinates()[1].x).isEqualTo(lineStringType.getPosList().getValue().get(3));
    assertThat(lineString.getCoordinates()[1].y).isEqualTo(lineStringType.getPosList().getValue().get(2));
}
Also used : LineString(org.locationtech.jts.geom.LineString) TypeBuilder(ma.glasnost.orika.metadata.TypeBuilder) DirectPositionListType(net.opengis.gml._3.DirectPositionListType) LineStringType(net.opengis.gml._3.LineStringType) Test(org.junit.Test)

Example 17 with LineStringType

use of net.opengis.gml._3.LineStringType in project ddf by codice.

the class WfsFilterDelegateTest method testLineStringLatLonOrder.

@Test
public void testLineStringLatLonOrder() {
    final WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.INTERSECTS.getValue(), new LatLonCoordinateStrategy());
    final FilterType filter = delegate.intersects(Metacard.ANY_GEO, LINESTRING);
    assertThat(filter.getSpatialOps().getValue(), is(instanceOf(BinarySpatialOpType.class)));
    final BinarySpatialOpType binarySpatialOpType = (BinarySpatialOpType) filter.getSpatialOps().getValue();
    assertThat(binarySpatialOpType.getGeometry().getValue(), is(instanceOf(LineStringType.class)));
    final LineStringType lineStringType = (LineStringType) binarySpatialOpType.getGeometry().getValue();
    assertThat(lineStringType.getCoordinates().getValue(), is("10.0,30.0 30.0,10.0 40.0,50.0"));
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType) BinarySpatialOpType(net.opengis.filter.v_1_1_0.BinarySpatialOpType) LineStringType(net.opengis.gml.v_3_1_1.LineStringType) Test(org.junit.Test)

Example 18 with LineStringType

use of net.opengis.gml._3.LineStringType in project ddf by codice.

the class WfsFilterDelegateTest method testLineStringLonLatOrder.

@Test
public void testLineStringLonLatOrder() {
    final WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.INTERSECTS.getValue(), new LonLatCoordinateStrategy());
    final FilterType filter = delegate.intersects(Metacard.ANY_GEO, LINESTRING);
    assertThat(filter.getSpatialOps().getValue(), is(instanceOf(BinarySpatialOpType.class)));
    final BinarySpatialOpType binarySpatialOpType = (BinarySpatialOpType) filter.getSpatialOps().getValue();
    assertThat(binarySpatialOpType.getGeometry().getValue(), is(instanceOf(LineStringType.class)));
    final LineStringType lineStringType = (LineStringType) binarySpatialOpType.getGeometry().getValue();
    assertThat(lineStringType.getCoordinates().getValue(), is("30.0,10.0 10.0,30.0 50.0,40.0"));
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType) BinarySpatialOpType(net.opengis.filter.v_1_1_0.BinarySpatialOpType) LineStringType(net.opengis.gml.v_3_1_1.LineStringType) Test(org.junit.Test)

Example 19 with LineStringType

use of net.opengis.gml._3.LineStringType in project ddf by codice.

the class TestWfs10JTStoGML200Converter method testLineStringTypeToJAXB.

@Test
public void testLineStringTypeToJAXB() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    LineString lineString = (LineString) getGeometryFromWkt(LINESTRING);
    assertThat(lineString == null, is(Boolean.FALSE));
    String lineStringGML = Wfs10JTStoGML200Converter.convertGeometryToGML(lineString);
    LineStringType lineStringType = (LineStringType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(lineStringGML, Wfs10Constants.LINESTRING);
    JAXBElement<LineStringType> lineStringTypeJAXBElement = (JAXBElement<LineStringType>) Wfs10JTStoGML200Converter.convertGeometryTypeToJAXB(lineStringType);
    XMLUnit.setNormalizeWhitespace(Boolean.TRUE);
    JAXB.marshal(lineStringTypeJAXBElement, writer);
    String xml = writer.toString();
    Diff diff = XMLUnit.compareXML(xml, LINESTRING_GML);
    assertTrue(XMLUNIT_SIMILAR, diff.similar());
    assertThat(diff.similar(), is(Boolean.TRUE));
    assertThat(diff.identical(), is(Boolean.FALSE));
}
Also used : LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) Diff(org.custommonkey.xmlunit.Diff) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) JAXBElement(javax.xml.bind.JAXBElement) MultiLineStringType(ogc.schema.opengis.gml.v_2_1_2.MultiLineStringType) LineStringType(ogc.schema.opengis.gml.v_2_1_2.LineStringType) Test(org.junit.Test)

Example 20 with LineStringType

use of net.opengis.gml._3.LineStringType in project ddf by codice.

the class TestWfs10JTStoGML200Converter method testGMLToGeometryCollectionType.

@Test
public void testGMLToGeometryCollectionType() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    String geometryCollectionGML = Wfs10JTStoGML200Converter.convertGeometryToGML(getGeometryFromWkt(GEOMETRYCOLLECTION));
    GeometryCollectionType geometryCollectionType = (GeometryCollectionType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(geometryCollectionGML, Wfs10Constants.GEOMETRY_COLLECTION);
    assertFalse(geometryCollectionType == null);
    List<JAXBElement<? extends GeometryAssociationType>> geometryMembers = geometryCollectionType.getGeometryMember();
    assertThat(CollectionUtils.isEmpty(geometryMembers), is(Boolean.FALSE));
    assertThat(geometryMembers.size() == 2, is(Boolean.TRUE));
    GeometryAssociationType geometryAssociationType = geometryMembers.get(0).getValue();
    JAXBElement<? extends AbstractGeometryType> jaxbElement = geometryAssociationType.getGeometry();
    assertThat(Wfs10Constants.POINT.getLocalPart().equals(jaxbElement.getName().getLocalPart()), is(Boolean.TRUE));
    PointType pointType = (PointType) jaxbElement.getValue();
    assertThat(pointType == null, is(Boolean.FALSE));
    assertThat(GEOMETRYCOLLECTION_POINT_COORD.equals(pointType.getCoordinates().getValue().trim()), is(Boolean.TRUE));
    GeometryAssociationType geometryAssociationType2 = geometryMembers.get(1).getValue();
    JAXBElement<? extends AbstractGeometryType> jaxbElement2 = geometryAssociationType2.getGeometry();
    assertThat(Wfs10Constants.LINESTRING.getLocalPart().equals(jaxbElement2.getName().getLocalPart()), is(Boolean.TRUE));
    LineStringType lineStringType = (LineStringType) jaxbElement2.getValue();
    assertThat(lineStringType == null, is(Boolean.FALSE));
    assertThat(GEOMETRYCOLLECTION_LINESTRING_COORD.equals(lineStringType.getCoordinates().getValue().trim()), is(Boolean.TRUE));
}
Also used : GeometryAssociationType(ogc.schema.opengis.gml.v_2_1_2.GeometryAssociationType) GeometryCollectionType(ogc.schema.opengis.gml.v_2_1_2.GeometryCollectionType) PointType(ogc.schema.opengis.gml.v_2_1_2.PointType) MultiPointType(ogc.schema.opengis.gml.v_2_1_2.MultiPointType) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) JAXBElement(javax.xml.bind.JAXBElement) MultiLineStringType(ogc.schema.opengis.gml.v_2_1_2.MultiLineStringType) LineStringType(ogc.schema.opengis.gml.v_2_1_2.LineStringType) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)11 LineString (org.locationtech.jts.geom.LineString)9 Coordinate (org.locationtech.jts.geom.Coordinate)7 ArrayList (java.util.ArrayList)6 JAXBElement (javax.xml.bind.JAXBElement)6 Geometry (org.locationtech.jts.geom.Geometry)6 LineStringType (net.opengis.gml._3.LineStringType)5 LineStringType (net.opengis.gml.v_3_2_1.LineStringType)5 LineStringType (ogc.schema.opengis.gml.v_2_1_2.LineStringType)5 MultiLineStringType (ogc.schema.opengis.gml.v_2_1_2.MultiLineStringType)5 LineString (com.vividsolutions.jts.geom.LineString)4 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)4 List (java.util.List)4 DirectPositionListType (net.opengis.gml._3.DirectPositionListType)4 LineStringType (net.opengis.gml.v_3_1_1.LineStringType)3 LineStringType (org.geotoolkit.gml.xml.v311.LineStringType)3 MultiPoint (org.locationtech.jts.geom.MultiPoint)3 Point (org.locationtech.jts.geom.Point)3 BigDecimal (java.math.BigDecimal)2 TypeBuilder (ma.glasnost.orika.metadata.TypeBuilder)2