Search in sources :

Example 1 with LineStringSegmentType

use of org.geotoolkit.gml.xml.v311.LineStringSegmentType in project geotoolkit by Geomatys.

the class GMLUtilities method getGMLFromISO.

/**
 * @param geometry The ISO geometry to convert.
 * @return A GML 3.1.1 geometry matching given geometry definition.
 * @deprecated This method should not be used for multiple reasons:
 * <ol>
 * <li>OpenGIS definition is based on an obsolete ISO-19107 draft</li>
 * <li>The GML version is fixed and obsolete</li>
 * <li>Only partial management of geometries</li>
 * </ol>
 */
public static AbstractGeometryType getGMLFromISO(final org.opengis.geometry.Geometry geometry) {
    if (geometry instanceof Point) {
        Point point = (Point) geometry;
        PointType gmlPoint = new PointType(null, point.getDirectPosition());
        return gmlPoint;
    } else if (geometry instanceof OrientableSurface) {
        OrientableSurface surface = (OrientableSurface) geometry;
        SurfaceBoundary boundary = surface.getBoundary();
        Ring exterior = boundary.getExterior();
        List<CurvePropertyType> curves = new ArrayList<CurvePropertyType>();
        for (Primitive p : exterior.getElements()) {
            curves.add(new CurvePropertyType((CurveType) getGMLFromISO(p)));
        }
        RingType gmlExterior = new RingType();
        gmlExterior.getCurveMember().addAll(curves);
        List<Ring> interiors = boundary.getInteriors();
        List<RingType> gmlInteriors = new ArrayList<RingType>();
        for (Ring interior : interiors) {
            List<CurvePropertyType> intcurves = new ArrayList<CurvePropertyType>();
            for (Primitive p : interior.getElements()) {
                intcurves.add(new CurvePropertyType((CurveType) getGMLFromISO(p)));
            }
            RingType gmlinterior = new RingType();
            gmlinterior.getCurveMember().addAll(intcurves);
            gmlInteriors.add(gmlinterior);
        }
        PolygonType poly = new PolygonType(gmlExterior, gmlInteriors);
        return poly;
    } else if (geometry instanceof MultiSurface) {
        MultiSurface multiPrim = (MultiSurface) geometry;
        List<PolygonPropertyType> geometries = new ArrayList<PolygonPropertyType>();
        for (Geometry prim : multiPrim.getElements()) {
            PolygonType element = (PolygonType) getGMLFromISO(prim);
            PolygonPropertyType gp = new PolygonPropertyType((PolygonType) element);
            geometries.add(gp);
        }
        MultiPolygonType gmlMulti = new MultiPolygonType(null, geometries);
        return gmlMulti;
    } else if (geometry instanceof MultiCurve) {
        MultiCurve multiPrim = (MultiCurve) geometry;
        List<CurvePropertyType> geometries = new ArrayList<CurvePropertyType>();
        for (OrientableCurve prim : multiPrim.getElements()) {
            AbstractCurveType element = (AbstractCurveType) getGMLFromISO(prim);
            CurvePropertyType gp = new CurvePropertyType((AbstractCurveType) element);
            geometries.add(gp);
        }
        MultiCurveType gmlMulti = new MultiCurveType(geometries);
        return gmlMulti;
    } else if (geometry instanceof MultiPoint) {
        MultiPoint multiPrim = (MultiPoint) geometry;
        List<PointPropertyType> geometries = new ArrayList<PointPropertyType>();
        for (Point prim : multiPrim.getElements()) {
            PointType element = (PointType) getGMLFromISO(prim);
            PointPropertyType gp = new PointPropertyType((PointType) element);
            geometries.add(gp);
        }
        MultiPointType gmlMulti = new MultiPointType(null, geometries);
        return gmlMulti;
    } else if (geometry instanceof MultiPrimitive) {
        MultiPrimitive multiPrim = (MultiPrimitive) geometry;
        List<GeometryPropertyType> geometries = new ArrayList<GeometryPropertyType>();
        for (Primitive prim : multiPrim.getElements()) {
            AbstractGMLType element = getGMLFromISO(prim);
            GeometryPropertyType gp = new GeometryPropertyType((AbstractGeometryType) element);
            geometries.add(gp);
        }
        MultiGeometryType gmlMulti = new MultiGeometryType(geometries);
        return gmlMulti;
    } else if (geometry instanceof Curve) {
        Curve curve = (Curve) geometry;
        List<? extends CurveSegment> segments = curve.getSegments();
        List<LineStringSegmentType> gmlSegments = new ArrayList<LineStringSegmentType>();
        for (CurveSegment segment : segments) {
            CurveInterpolationType interpolation = CurveInterpolationType.fromValue(segment.getInterpolation().identifier());
            PointArray array = GeometricUtilities.getSamplePoints(segment);
            List<DirectPosition> positions = new ArrayList<DirectPosition>();
            for (int i = 0; i < array.size(); i++) {
                positions.add(array.getDirectPosition(i, null));
            }
            LineStringSegmentType gmlSegment = new LineStringSegmentType(segment.getNumDerivativesAtStart(), segment.getNumDerivativesAtEnd(), segment.getNumDerivativesInterior(), interpolation, positions);
            gmlSegments.add(gmlSegment);
        }
        CurveType gmlCurve = new CurveType(gmlSegments);
        return gmlCurve;
    } else if (geometry instanceof LineString) {
        LineString line = (LineString) geometry;
        PointArray array = GeometricUtilities.getSamplePoints(line);
        List<DirectPosition> positions = new ArrayList<DirectPosition>();
        for (int i = 0; i < array.size(); i++) {
            positions.add(array.getDirectPosition(i, null));
        }
        LineStringType gmlLine = new LineStringType(positions);
        return gmlLine;
    } else if (geometry instanceof Polygon) {
        Polygon polygon = (Polygon) geometry;
        SurfaceBoundary boundary = polygon.getBoundary();
        Ring exterior = boundary.getExterior();
        List<CurvePropertyType> curves = new ArrayList<CurvePropertyType>();
        for (Primitive p : exterior.getElements()) {
            curves.add(new CurvePropertyType((CurveType) getGMLFromISO(p)));
        }
        RingType gmlExterior = new RingType();
        gmlExterior.getCurveMember().addAll(curves);
        List<Ring> interiors = boundary.getInteriors();
        List<RingType> gmlInteriors = new ArrayList<RingType>();
        for (Ring interior : interiors) {
            List<CurvePropertyType> intcurves = new ArrayList<CurvePropertyType>();
            for (Primitive p : interior.getElements()) {
                intcurves.add(new CurvePropertyType((CurveType) getGMLFromISO(p)));
            }
            RingType gmlinterior = new RingType();
            gmlinterior.getCurveMember().addAll(intcurves);
            gmlInteriors.add(gmlinterior);
        }
        PolygonType gmlPolygon = new PolygonType(gmlExterior, gmlInteriors);
        return gmlPolygon;
    } else if (geometry instanceof PolyhedralSurface) {
        PolyhedralSurface polySurface = (PolyhedralSurface) geometry;
        List<PolygonPatchType> gmlPatches = new ArrayList<PolygonPatchType>();
        List<? extends Polygon> patches = polySurface.getPatches();
        for (Polygon polygon : patches) {
            SurfaceInterpolationType interpolation = SurfaceInterpolationType.fromValue(polygon.getInterpolation().identifier());
            SurfaceBoundary boundary = polygon.getBoundary();
            Ring exterior = boundary.getExterior();
            List<CurvePropertyType> curves = new ArrayList<CurvePropertyType>();
            for (Primitive p : exterior.getElements()) {
                curves.add(new CurvePropertyType((CurveType) getGMLFromISO(p)));
            }
            RingType gmlExterior = new RingType();
            gmlExterior.getCurveMember().addAll(curves);
            List<Ring> interiors = boundary.getInteriors();
            List<RingType> gmlInteriors = new ArrayList<RingType>();
            for (Ring interior : interiors) {
                List<CurvePropertyType> intcurves = new ArrayList<CurvePropertyType>();
                for (Primitive p : interior.getElements()) {
                    intcurves.add(new CurvePropertyType((CurveType) getGMLFromISO(p)));
                }
                RingType gmlinterior = new RingType();
                gmlinterior.getCurveMember().addAll(intcurves);
                gmlInteriors.add(gmlinterior);
            }
            PolygonPatchType patche = new PolygonPatchType(interpolation, gmlExterior, gmlInteriors);
            gmlPatches.add(patche);
        }
        PolygonPatchArrayPropertyType pathArray = new PolygonPatchArrayPropertyType(gmlPatches);
        PolyhedralSurfaceType gmlPolySurface = new PolyhedralSurfaceType(pathArray);
        return gmlPolySurface;
    } else {
        System.out.println("unexpected iso geometry type:" + geometry.getClass().getName());
    }
    return null;
}
Also used : MultiPoint(org.opengis.geometry.aggregate.MultiPoint) DirectPosition(org.opengis.geometry.DirectPosition) MultiCurveType(org.geotoolkit.gml.xml.v311.MultiCurveType) OrientableSurface(org.opengis.geometry.primitive.OrientableSurface) ArrayList(java.util.ArrayList) MultiGeometryType(org.geotoolkit.gml.xml.v311.MultiGeometryType) MultiPrimitive(org.opengis.geometry.aggregate.MultiPrimitive) CurveSegment(org.opengis.geometry.primitive.CurveSegment) MultiCurve(org.opengis.geometry.aggregate.MultiCurve) ArrayList(java.util.ArrayList) List(java.util.List) CurvePropertyType(org.geotoolkit.gml.xml.v311.CurvePropertyType) Polygon(org.opengis.geometry.coordinate.Polygon) SurfaceBoundary(org.opengis.geometry.primitive.SurfaceBoundary) AbstractGeometryType(org.geotoolkit.gml.xml.v311.AbstractGeometryType) Curve(org.opengis.geometry.primitive.Curve) MultiCurve(org.opengis.geometry.aggregate.MultiCurve) OrientableCurve(org.opengis.geometry.primitive.OrientableCurve) PolygonType(org.geotoolkit.gml.xml.v311.PolygonType) MultiPolygonType(org.geotoolkit.gml.xml.v311.MultiPolygonType) OrientableCurve(org.opengis.geometry.primitive.OrientableCurve) LineStringType(org.geotoolkit.gml.xml.v311.LineStringType) MultiPointType(org.geotoolkit.gml.xml.v311.MultiPointType) CurveInterpolationType(org.geotoolkit.gml.xml.v311.CurveInterpolationType) RingType(org.geotoolkit.gml.xml.v311.RingType) PolyhedralSurfaceType(org.geotoolkit.gml.xml.v311.PolyhedralSurfaceType) LineStringSegmentType(org.geotoolkit.gml.xml.v311.LineStringSegmentType) MultiSurface(org.opengis.geometry.aggregate.MultiSurface) SurfaceInterpolationType(org.geotoolkit.gml.xml.v311.SurfaceInterpolationType) AbstractCurveType(org.geotoolkit.gml.xml.v311.AbstractCurveType) MultiCurveType(org.geotoolkit.gml.xml.v311.MultiCurveType) CurveType(org.geotoolkit.gml.xml.v311.CurveType) AbstractGMLType(org.geotoolkit.gml.xml.v311.AbstractGMLType) PolygonPatchArrayPropertyType(org.geotoolkit.gml.xml.v311.PolygonPatchArrayPropertyType) MultiPrimitive(org.opengis.geometry.aggregate.MultiPrimitive) Primitive(org.opengis.geometry.primitive.Primitive) MultiPolygonType(org.geotoolkit.gml.xml.v311.MultiPolygonType) PolygonPatchType(org.geotoolkit.gml.xml.v311.PolygonPatchType) Point(org.opengis.geometry.primitive.Point) MultiPoint(org.opengis.geometry.aggregate.MultiPoint) PointArray(org.opengis.geometry.coordinate.PointArray) Point(org.opengis.geometry.primitive.Point) MultiPoint(org.opengis.geometry.aggregate.MultiPoint) PolyhedralSurface(org.opengis.geometry.coordinate.PolyhedralSurface) Geometry(org.opengis.geometry.Geometry) AbstractCurveType(org.geotoolkit.gml.xml.v311.AbstractCurveType) LineString(org.opengis.geometry.coordinate.LineString) Ring(org.opengis.geometry.primitive.Ring) PolygonPropertyType(org.geotoolkit.gml.xml.v311.PolygonPropertyType) PointType(org.geotoolkit.gml.xml.v311.PointType) MultiPointType(org.geotoolkit.gml.xml.v311.MultiPointType) PointPropertyType(org.geotoolkit.gml.xml.v311.PointPropertyType) GeometryPropertyType(org.geotoolkit.gml.xml.v311.GeometryPropertyType)

Example 2 with LineStringSegmentType

use of org.geotoolkit.gml.xml.v311.LineStringSegmentType 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 3 with LineStringSegmentType

use of org.geotoolkit.gml.xml.v311.LineStringSegmentType 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 4 with LineStringSegmentType

use of org.geotoolkit.gml.xml.v311.LineStringSegmentType 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 5 with LineStringSegmentType

use of org.geotoolkit.gml.xml.v311.LineStringSegmentType 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("bound-1", 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=\"" + GML + '"' + " 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';
    assertXmlEquals(expResult, result, "xmlns:*");
    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=\"" + GML + "\">\n" + "  <gml:posList>1.0 1.1 1.2</gml:posList>" + '\n' + "</gml:LineStringSegment>" + '\n';
    assertXmlEquals(expResult, result, "xmlns:*");
    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=\"" + GML + "\">\n" + "  <gml:pos>1.1 1.2</gml:pos>" + '\n' + "  <gml:pos>2.3 48.1</gml:pos>" + '\n' + "</gml:LineStringSegment>" + '\n';
    assertXmlEquals(expResult, result, "xmlns:*");
}
Also used : EnvelopeType(org.geotoolkit.gml.xml.v311.EnvelopeType) LineStringSegmentType(org.geotoolkit.gml.xml.v311.LineStringSegmentType) DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) StringWriter(java.io.StringWriter) TimePeriodType(org.geotoolkit.gml.xml.v311.TimePeriodType) DirectPositionListType(org.geotoolkit.gml.xml.v311.DirectPositionListType) Duration(javax.xml.datatype.Duration) TimePositionType(org.geotoolkit.gml.xml.v311.TimePositionType)

Aggregations

LineStringSegmentType (org.geotoolkit.gml.xml.v311.LineStringSegmentType)3 StringReader (java.io.StringReader)2 StringWriter (java.io.StringWriter)2 JAXBElement (javax.xml.bind.JAXBElement)2 Duration (javax.xml.datatype.Duration)2 DirectPositionListType (org.geotoolkit.gml.xml.v311.DirectPositionListType)2 DirectPositionType (org.geotoolkit.gml.xml.v311.DirectPositionType)2 DirectPositionListType (org.geotoolkit.gml.xml.v321.DirectPositionListType)2 DirectPositionType (org.geotoolkit.gml.xml.v321.DirectPositionType)2 LineStringSegmentType (org.geotoolkit.gml.xml.v321.LineStringSegmentType)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 DocumentComparator (org.apache.sis.test.xml.DocumentComparator)1 AbstractCurveType (org.geotoolkit.gml.xml.v311.AbstractCurveType)1 AbstractGMLType (org.geotoolkit.gml.xml.v311.AbstractGMLType)1 AbstractGeometryType (org.geotoolkit.gml.xml.v311.AbstractGeometryType)1 CurveInterpolationType (org.geotoolkit.gml.xml.v311.CurveInterpolationType)1 CurvePropertyType (org.geotoolkit.gml.xml.v311.CurvePropertyType)1 CurveType (org.geotoolkit.gml.xml.v311.CurveType)1 EnvelopeType (org.geotoolkit.gml.xml.v311.EnvelopeType)1