Search in sources :

Example 31 with DirectPositionType

use of org.geotoolkit.gml.xml.v321.DirectPositionType in project geotoolkit by Geomatys.

the class GmlXMLBindingTest method umarshallingTest.

@Test
public void umarshallingTest() throws Exception {
    LineStringSegmentType expResult = new LineStringSegmentType();
    DirectPositionListType posList = new DirectPositionListType();
    posList.setValue(Arrays.asList(1.0, 1.1, 1.2));
    expResult.setPosList(posList);
    String xml = "<gml:LineStringSegment xmlns:gml=\"http://www.opengis.net/gml\">" + '\n' + "  <gml:posList>1.0 1.1 1.2</gml:posList>" + '\n' + "</gml:LineStringSegment>" + '\n';
    Object result = unmarshaller.unmarshal(new StringReader(xml));
    if (result instanceof JAXBElement) {
        result = ((JAXBElement) result).getValue();
    }
    assertEquals(expResult, result);
    expResult = new LineStringSegmentType();
    DirectPositionType pos1 = new DirectPositionType(Arrays.asList(1.1, 1.2));
    DirectPositionType pos2 = new DirectPositionType(Arrays.asList(2.3, 48.1));
    expResult.getPos().add(pos1);
    expResult.getPos().add(pos2);
    xml = "<gml:LineStringSegment xmlns:gml=\"http://www.opengis.net/gml\">" + '\n' + "  <gml:pos>1.1 1.2</gml:pos>" + '\n' + "  <gml:pos>2.3 48.1</gml:pos>" + '\n' + "</gml:LineStringSegment>" + '\n';
    result = unmarshaller.unmarshal(new StringReader(xml));
    if (result instanceof JAXBElement) {
        result = ((JAXBElement) result).getValue();
    }
    assertEquals(expResult, result);
}
Also used : LineStringSegmentType(org.geotoolkit.gml.xml.v311.LineStringSegmentType) DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) DirectPositionListType(org.geotoolkit.gml.xml.v311.DirectPositionListType) StringReader(java.io.StringReader) JAXBElement(javax.xml.bind.JAXBElement)

Example 32 with DirectPositionType

use of org.geotoolkit.gml.xml.v321.DirectPositionType in project geotoolkit by Geomatys.

the class GmlXMLBindingTest method umarshallingTest.

@Test
public void umarshallingTest() throws Exception {
    LineStringSegmentType expResult = new LineStringSegmentType();
    DirectPositionListType posList = new DirectPositionListType();
    posList.setValue(Arrays.asList(1.0, 1.1, 1.2));
    expResult.setPosList(posList);
    String xml = "<gml:LineStringSegment xmlns:gml=\"http://www.opengis.net/gml/3.2\">" + '\n' + "    <gml:posList>1.0 1.1 1.2</gml:posList>" + '\n' + "</gml:LineStringSegment>" + '\n';
    Object result = unmarshaller.unmarshal(new StringReader(xml));
    if (result instanceof JAXBElement) {
        result = ((JAXBElement) result).getValue();
    }
    assertEquals(expResult, result);
    expResult = new LineStringSegmentType();
    DirectPositionType pos1 = new DirectPositionType(Arrays.asList(1.1, 1.2));
    DirectPositionType pos2 = new DirectPositionType(Arrays.asList(2.3, 48.1));
    expResult.getPos().add(pos1);
    expResult.getPos().add(pos2);
    xml = "<gml:LineStringSegment xmlns:gml=\"http://www.opengis.net/gml/3.2\">" + '\n' + "    <gml:pos>1.1 1.2</gml:pos>" + '\n' + "    <gml:pos>2.3 48.1</gml:pos>" + '\n' + "</gml:LineStringSegment>" + '\n';
    result = unmarshaller.unmarshal(new StringReader(xml));
    if (result instanceof JAXBElement) {
        result = ((JAXBElement) result).getValue();
    }
    assertEquals(expResult, result);
}
Also used : LineStringSegmentType(org.geotoolkit.gml.xml.v321.LineStringSegmentType) DirectPositionType(org.geotoolkit.gml.xml.v321.DirectPositionType) DirectPositionListType(org.geotoolkit.gml.xml.v321.DirectPositionListType) StringReader(java.io.StringReader) JAXBElement(javax.xml.bind.JAXBElement)

Example 33 with DirectPositionType

use of org.geotoolkit.gml.xml.v321.DirectPositionType in project geotoolkit by Geomatys.

the class GmlXMLBindingTest method marshallingTest.

/**
 * Test simple Record Marshalling.
 *
 * @throws JAXBException
 */
@Test
public void marshallingTest() throws Exception {
    DirectPositionType lower = new DirectPositionType(-30.711, 134.196);
    DirectPositionType upper = new DirectPositionType(-30.702, 134.205);
    EnvelopeType env = new EnvelopeType(lower, upper, "urn:ogc:def:crs:EPSG:6.8:4283");
    StringWriter sw = new StringWriter();
    marshaller.marshal(FACTORY.createEnvelope(env), sw);
    String result = sw.toString();
    // we remove the first line
    result = result.substring(result.indexOf("?>") + 2).trim();
    String expResult = "<gml:Envelope xmlns:gml=\"http://www.opengis.net/gml/3.2\" srsName=\"urn:ogc:def:crs:EPSG:6.8:4283\" >" + '\n' + "    <gml:lowerCorner>-30.711 134.196</gml:lowerCorner>" + '\n' + "    <gml:upperCorner>-30.702 134.205</gml:upperCorner>" + '\n' + "</gml:Envelope>" + '\n';
    DocumentComparator comparator = new DocumentComparator(expResult, result) {

        @Override
        protected strictfp void compareNames(Node expected, Node actual) {
            final String[] exArray = expected.getNodeName().split(":");
            final String[] acArray = actual.getNodeName().split(":");
            assertEquals(exArray.length, acArray.length);
            assertEquals(exArray[exArray.length - 1], acArray[acArray.length - 1]);
        }
    };
    comparator.ignoredAttributes.add("http://www.w3.org/2000/xmlns:*");
    comparator.compare();
    Duration d1 = javax.xml.datatype.DatatypeFactory.newInstance().newDuration("P2D");
    TimePeriodType tp = new TimePeriodType(d1);
    marshaller.marshal(FACTORY.createTimePeriod(tp), sw);
    TimePositionType tpos = new TimePositionType("2002-08-15");
    tp = new TimePeriodType(tpos);
    marshaller.marshal(FACTORY.createTimePeriod(tp), sw);
    // System.out.println(sw.toString());
    LineStringSegmentType ls = new LineStringSegmentType();
    DirectPositionListType posList = new DirectPositionListType();
    posList.setValue(Arrays.asList(1.0, 1.1, 1.2));
    ls.setPosList(posList);
    sw = new StringWriter();
    marshaller.marshal(FACTORY.createLineStringSegment(ls), sw);
    result = sw.toString();
    // we remove the first line
    result = result.substring(result.indexOf("?>") + 2).trim();
    expResult = "<gml:LineStringSegment xmlns:gml=\"http://www.opengis.net/gml/3.2\">" + '\n' + "    <gml:posList>1.0 1.1 1.2</gml:posList>" + '\n' + "</gml:LineStringSegment>" + '\n';
    comparator = new DocumentComparator(expResult, result) {

        @Override
        protected strictfp void compareNames(Node expected, Node actual) {
            final String[] exArray = expected.getNodeName().split(":");
            final String[] acArray = actual.getNodeName().split(":");
            assertEquals(exArray.length, acArray.length);
            assertEquals(exArray[exArray.length - 1], acArray[acArray.length - 1]);
        }
    };
    comparator.ignoredAttributes.add("http://www.w3.org/2000/xmlns:*");
    comparator.compare();
    ls = new LineStringSegmentType();
    DirectPositionType pos1 = new DirectPositionType(Arrays.asList(1.1, 1.2));
    DirectPositionType pos2 = new DirectPositionType(Arrays.asList(2.3, 48.1));
    ls.getPos().add(pos1);
    ls.getPos().add(pos2);
    sw = new StringWriter();
    marshaller.marshal(FACTORY.createLineStringSegment(ls), sw);
    result = sw.toString();
    // we remove the first line
    result = result.substring(result.indexOf("?>") + 2).trim();
    expResult = "<gml:LineStringSegment xmlns:gml=\"http://www.opengis.net/gml/3.2\">" + '\n' + "    <gml:pos>1.1 1.2</gml:pos>" + '\n' + "    <gml:pos>2.3 48.1</gml:pos>" + '\n' + "</gml:LineStringSegment>" + '\n';
    comparator = new DocumentComparator(expResult, result) {

        @Override
        protected strictfp void compareNames(Node expected, Node actual) {
            final String[] exArray = expected.getNodeName().split(":");
            final String[] acArray = actual.getNodeName().split(":");
            assertEquals(exArray.length, acArray.length);
            assertEquals(exArray[exArray.length - 1], acArray[acArray.length - 1]);
        }
    };
    comparator.ignoredAttributes.add("http://www.w3.org/2000/xmlns:*");
    comparator.compare();
}
Also used : EnvelopeType(org.geotoolkit.gml.xml.v321.EnvelopeType) LineStringSegmentType(org.geotoolkit.gml.xml.v321.LineStringSegmentType) DirectPositionType(org.geotoolkit.gml.xml.v321.DirectPositionType) Node(org.w3c.dom.Node) DirectPositionListType(org.geotoolkit.gml.xml.v321.DirectPositionListType) Duration(javax.xml.datatype.Duration) StringWriter(java.io.StringWriter) TimePeriodType(org.geotoolkit.gml.xml.v321.TimePeriodType) DocumentComparator(org.apache.sis.test.xml.DocumentComparator) TimePositionType(org.geotoolkit.gml.xml.v321.TimePositionType)

Example 34 with DirectPositionType

use of org.geotoolkit.gml.xml.v321.DirectPositionType in project ddf by codice.

the class Wfs20JTStoGML321Converter method convertToDirectPositionType.

public static DirectPositionType convertToDirectPositionType(Coordinate coordinate, String srsName) {
    DirectPositionType directPositionType = GML320_OBJECT_FACTORY.createDirectPositionType();
    directPositionType.getValue().add(Double.valueOf(coordinate.x));
    directPositionType.getValue().add(Double.valueOf(coordinate.y));
    directPositionType.setSrsName(srsName);
    if (!Double.isNaN(coordinate.z)) {
        directPositionType.getValue().add(Double.valueOf(coordinate.z));
    }
    return directPositionType;
}
Also used : DirectPositionType(net.opengis.gml.v_3_2_1.DirectPositionType)

Example 35 with DirectPositionType

use of org.geotoolkit.gml.xml.v321.DirectPositionType in project ddf by codice.

the class WfsFilterDelegateTest method testIntersectsAsBoundingBox.

@Test
public void testIntersectsAsBoundingBox() {
    WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.BBOX.getValue(), new LonLatCoordinateStrategy());
    FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
    assertThat(filter.getSpatialOps().getValue(), is(instanceOf(BBOXType.class)));
    assertThat(filter.isSetLogicOps(), is(false));
    BBOXType bboxType = (BBOXType) filter.getSpatialOps().getValue();
    EnvelopeType envelope = bboxType.getEnvelope().getValue();
    DirectPositionType lowerCorner = envelope.getLowerCorner();
    assertThat("The bounding box's lower corner was null.", lowerCorner, is(notNullValue()));
    assertThat(lowerCorner.getValue(), is(asList(10.0, -10.0)));
    DirectPositionType upperCorner = envelope.getUpperCorner();
    assertThat("The bounding box's upper corner was null.", upperCorner, is(notNullValue()));
    assertThat(upperCorner.getValue(), is(asList(40.0, 30.0)));
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType) EnvelopeType(net.opengis.gml.v_3_1_1.EnvelopeType) BBOXType(net.opengis.filter.v_1_1_0.BBOXType) DirectPositionType(net.opengis.gml.v_3_1_1.DirectPositionType) Test(org.junit.Test)

Aggregations

DirectPositionType (org.geotoolkit.gml.xml.v311.DirectPositionType)24 ArrayList (java.util.ArrayList)14 PointType (org.geotoolkit.gml.xml.v311.PointType)14 Test (org.junit.Test)11 StringWriter (java.io.StringWriter)10 DirectPositionType (net.opengis.gml.v_3_1_1.DirectPositionType)10 DirectPositionType (org.geotoolkit.gml.xml.v321.DirectPositionType)10 EnvelopeType (org.geotoolkit.gml.xml.v311.EnvelopeType)9 StringReader (java.io.StringReader)8 JAXBElement (javax.xml.bind.JAXBElement)8 EnvelopeType (net.opengis.gml.v_3_1_1.EnvelopeType)7 Geometry (org.locationtech.jts.geom.Geometry)7 Coordinate (org.locationtech.jts.geom.Coordinate)6 BBOXType (net.opengis.filter.v_1_1_0.BBOXType)5 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)5 DirectPositionType (net.opengis.gml.x32.DirectPositionType)4 FeaturePropertyType (org.geotoolkit.gml.xml.v311.FeaturePropertyType)4 SamplingPointType (org.geotoolkit.sampling.xml.v100.SamplingPointType)4 FilterType (net.opengis.filter.v_1_1_0.FilterType)3 DirectPositionType (net.opengis.gml.v_3_2_1.DirectPositionType)3