Search in sources :

Example 6 with JTSRing

use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing in project geotoolkit by Geomatys.

the class JTSGeometryBindingTest method PolyHedralSurfaceMarshalingTest.

/**
 * Test PolyHedral surface Marshalling.
 */
@Test
public void PolyHedralSurfaceMarshalingTest() throws Exception {
    CoordinateReferenceSystem crs = CRS.forCode("urn:ogc:def:crs:epsg::27572");
    assertTrue(crs != null);
    JTSPolyhedralSurface polyHedralSurface = new JTSPolyhedralSurface(crs);
    /*
         * FIRST POLYGON
         */
    // EXTERIOR
    JTSRing exterior1 = new JTSRing(crs);
    JTSCurve c1 = new JTSCurve(crs);
    JTSLineString c1l1 = new JTSLineString();
    DirectPosition c1l1p1 = new GeneralDirectPosition(crs);
    c1l1p1.setOrdinate(0, 401500);
    c1l1p1.setOrdinate(1, 3334500);
    DirectPosition c1l1p2 = new GeneralDirectPosition(crs);
    c1l1p2.setOrdinate(0, 401700);
    c1l1p2.setOrdinate(1, 3334850);
    DirectPosition c1l1p3 = new GeneralDirectPosition(crs);
    c1l1p3.setOrdinate(0, 402200);
    c1l1p3.setOrdinate(1, 3335200);
    c1l1.getControlPoints().add(c1l1p1);
    c1l1.getControlPoints().add(c1l1p2);
    c1l1.getControlPoints().add(c1l1p3);
    c1.getSegments().add(c1l1);
    JTSLineString c1l2 = new JTSLineString();
    DirectPosition c1l2p1 = new GeneralDirectPosition(crs);
    c1l2p1.setOrdinate(0, 402320);
    c1l2p1.setOrdinate(1, 3334850);
    DirectPosition c1l2p2 = new GeneralDirectPosition(crs);
    c1l2p2.setOrdinate(0, 402200);
    c1l2p2.setOrdinate(1, 3335200);
    c1l2.getControlPoints().add(c1l2p1);
    c1l2.getControlPoints().add(c1l2p2);
    c1.getSegments().add(c1l2);
    exterior1.getElements().add(c1);
    // INTERIOR
    Ring[] interiors1 = new Ring[1];
    JTSRing interior1 = new JTSRing(crs);
    JTSCurve c2 = new JTSCurve(crs);
    JTSLineString c2l1 = new JTSLineString();
    DirectPosition c2l1p1 = new GeneralDirectPosition(crs);
    c2l1p1.setOrdinate(0, 401500);
    c2l1p1.setOrdinate(1, 3334500);
    DirectPosition c2l1p2 = new GeneralDirectPosition(crs);
    c2l1p2.setOrdinate(0, 401700);
    c2l1p2.setOrdinate(1, 3334850);
    DirectPosition c2l1p3 = new GeneralDirectPosition(crs);
    c2l1p3.setOrdinate(0, 402200);
    c2l1p3.setOrdinate(1, 3335200);
    c2l1.getControlPoints().add(c2l1p1);
    c2l1.getControlPoints().add(c2l1p2);
    c2l1.getControlPoints().add(c2l1p3);
    c2.getSegments().add(c2l1);
    interior1.getElements().add(c2);
    interiors1[0] = interior1;
    JTSSurfaceBoundary bound1 = new JTSSurfaceBoundary(crs, exterior1, interiors1);
    JTSPolygon p1 = new JTSPolygon(bound1);
    /*
         * SECOND POLYGON
         */
    // EXTERIOR
    JTSRing exterior2 = new JTSRing(crs);
    JTSCurve c3 = new JTSCurve(crs);
    JTSLineString c3l1 = new JTSLineString();
    DirectPosition c3l1p1 = new GeneralDirectPosition(crs);
    c3l1p1.setOrdinate(0, 401500);
    c3l1p1.setOrdinate(1, 3334500);
    DirectPosition c3l1p2 = new GeneralDirectPosition(crs);
    c3l1p2.setOrdinate(0, 401700);
    c3l1p2.setOrdinate(1, 3334850);
    DirectPosition c3l1p3 = new GeneralDirectPosition(crs);
    c3l1p3.setOrdinate(0, 402200);
    c3l1p3.setOrdinate(1, 3335200);
    c3l1.getControlPoints().add(c3l1p1);
    c3l1.getControlPoints().add(c3l1p2);
    c3l1.getControlPoints().add(c3l1p3);
    c3.getSegments().add(c3l1);
    exterior2.getElements().add(c3);
    // INTERIOR
    JTSRing interior2 = new JTSRing(crs);
    JTSCurve c4 = new JTSCurve(crs);
    JTSLineString c4l1 = new JTSLineString();
    DirectPosition c4l1p1 = new GeneralDirectPosition(crs);
    c4l1p1.setOrdinate(0, 401500);
    c4l1p1.setOrdinate(1, 3334500);
    DirectPosition c4l1p2 = new GeneralDirectPosition(crs);
    c4l1p2.setOrdinate(0, 401700);
    c4l1p2.setOrdinate(1, 3334850);
    DirectPosition c4l1p3 = new GeneralDirectPosition(crs);
    c4l1p3.setOrdinate(0, 402200);
    c4l1p3.setOrdinate(1, 3335200);
    c4l1.getControlPoints().add(c4l1p1);
    c4l1.getControlPoints().add(c4l1p2);
    c4l1.getControlPoints().add(c4l1p3);
    c4.getSegments().add(c4l1);
    interior2.getElements().add(c4);
    Ring[] interiors2 = new Ring[1];
    interiors2[0] = interior2;
    JTSSurfaceBoundary bound2 = new JTSSurfaceBoundary(crs, exterior2, interiors2);
    JTSPolygon p2 = new JTSPolygon(bound2);
    polyHedralSurface.getPatches().add(p1);
    polyHedralSurface.getPatches().add(p2);
    StringWriter sw = new StringWriter();
    m.marshal(factory.createJTSPolyhedralSurface(polyHedralSurface), sw);
    String result = sw.toString();
    result = result.replaceAll("(?i)epsg\\:\\d+\\.\\d+\\.?\\d*\\:", "epsg::");
    String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<gml:PolyhedralSurface xmlns:gml=\"http://www.opengis.net/gml\" srsName=\"urn:ogc:def:crs:epsg::27572\" >" + '\n' + "  <gml:polygonPatches>" + '\n' + "    <gml:PolygonPatch>" + '\n' + "      <gml:exterior>" + '\n' + "        <gml:LinearRing>" + '\n' + "          <gml:posList>401500.0 3334500.0 401700.0 3334850.0 402200.0 3335200.0 402320.0 3334850.0 402200.0 3335200.0</gml:posList>" + '\n' + "        </gml:LinearRing>" + '\n' + "      </gml:exterior>" + '\n' + "      <gml:interior>" + '\n' + "        <gml:LinearRing>" + '\n' + "          <gml:posList>401500.0 3334500.0 401700.0 3334850.0 402200.0 3335200.0</gml:posList>" + '\n' + "        </gml:LinearRing>" + '\n' + "      </gml:interior>" + '\n' + "    </gml:PolygonPatch>" + '\n' + "    <gml:PolygonPatch>" + '\n' + "      <gml:exterior>" + '\n' + "        <gml:LinearRing>" + '\n' + "          <gml:posList>401500.0 3334500.0 401700.0 3334850.0 402200.0 3335200.0</gml:posList>" + '\n' + "        </gml:LinearRing>" + '\n' + "      </gml:exterior>" + '\n' + "      <gml:interior>" + '\n' + "        <gml:LinearRing>" + '\n' + "          <gml:posList>401500.0 3334500.0 401700.0 3334850.0 402200.0 3335200.0</gml:posList>" + '\n' + "        </gml:LinearRing>" + '\n' + "      </gml:interior>" + '\n' + "    </gml:PolygonPatch>" + '\n' + "  </gml:polygonPatches>" + '\n' + "</gml:PolyhedralSurface>" + '\n';
    assertXmlEquals(expResult, result, "xmlns:*");
}
Also used : GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) DirectPosition(org.opengis.geometry.DirectPosition) JTSPolyhedralSurface(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPolyhedralSurface) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) JTSRing(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing) JTSSurfaceBoundary(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSSurfaceBoundary) JTSPolygon(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSPolygon) JTSLineString(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString) JTSCurve(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve) JTSLineString(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString) StringWriter(java.io.StringWriter) JTSRing(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing) Ring(org.opengis.geometry.primitive.Ring) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem)

Example 7 with JTSRing

use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing in project geotoolkit by Geomatys.

the class PolyhedralSurfaceType method getIsoPolyHedralSurface.

public JTSPolyhedralSurface getIsoPolyHedralSurface() {
    JTSPolyhedralSurface result = new JTSPolyhedralSurface(coordinateReferenceSystem);
    for (JTSSurfaceBoundary s : patchList.getPatches()) {
        s.setCoordinateReferenceSystem(coordinateReferenceSystem);
        ((JTSRing) s.getExterior()).setCoordinateReferenceSystem(coordinateReferenceSystem);
        for (Primitive p : s.getExterior().getElements()) {
            if (p instanceof JTSCurve) {
                JTSCurve curve = (JTSCurve) p;
                curve.setCoordinateReferenceSystem(coordinateReferenceSystem);
                for (CurveSegment cv : curve.getSegments()) {
                    if (cv instanceof JTSLineString) {
                        JTSLineString line = (JTSLineString) cv;
                        PointArray pa = line.getControlPoints();
                        List<Position> newPositions = new ArrayList<Position>();
                        for (Position pos : pa) {
                            if (pos instanceof GeneralDirectPosition) {
                                ((GeneralDirectPosition) pos).setCoordinateReferenceSystem(coordinateReferenceSystem);
                                newPositions.add(pos);
                            }
                        }
                        line.getControlPoints().clear();
                        line.getControlPoints().addAll(newPositions);
                    }
                }
            }
        }
        if (s.getInteriors() != null) {
            for (Ring ring : s.getInteriors()) {
                ((JTSRing) ring).setCoordinateReferenceSystem(coordinateReferenceSystem);
                for (Primitive p : ring.getElements()) {
                    if (p instanceof JTSCurve) {
                        JTSCurve curve = (JTSCurve) p;
                        curve.setCoordinateReferenceSystem(coordinateReferenceSystem);
                        for (CurveSegment cv : curve.getSegments()) {
                            if (cv instanceof JTSLineString) {
                                JTSLineString line = (JTSLineString) cv;
                                PointArray pa = line.getControlPoints();
                                List<Position> newPositions = new ArrayList<Position>();
                                for (Position pos : pa) {
                                    if (pos instanceof GeneralDirectPosition) {
                                        ((GeneralDirectPosition) pos).setCoordinateReferenceSystem(coordinateReferenceSystem);
                                        newPositions.add(pos);
                                    }
                                }
                                line.getControlPoints().clear();
                                line.getControlPoints().addAll(newPositions);
                            }
                        }
                    }
                }
            }
        }
        result.getPatches().add(new JTSPolygon(s));
    }
    return result;
}
Also used : JTSPolyhedralSurface(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPolyhedralSurface) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) JTSRing(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing) Position(org.opengis.geometry.coordinate.Position) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) JTSSurfaceBoundary(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSSurfaceBoundary) JTSPolygon(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSPolygon) ArrayList(java.util.ArrayList) JTSCurve(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve) PointArray(org.opengis.geometry.coordinate.PointArray) JTSLineString(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString) Primitive(org.opengis.geometry.primitive.Primitive) CurveSegment(org.opengis.geometry.primitive.CurveSegment) JTSRing(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing) Ring(org.opengis.geometry.primitive.Ring)

Example 8 with JTSRing

use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing in project geotoolkit by Geomatys.

the class LinearRingPosListType method getJTSRing.

public JTSRing getJTSRing() {
    final List<Double> values;
    if (posList != null) {
        values = posList.getValue();
    } else if (coordinates != null) {
        values = coordinates.getValues();
    } else {
        values = new ArrayList<Double>();
    }
    final JTSLineString line = new JTSLineString();
    for (int i = 0; i < values.size() - 1; i = i + 2) {
        double x = values.get(i);
        double y = values.get(i + 1);
        final DirectPosition pos = new GeneralDirectPosition(x, y);
        line.getControlPoints().add(pos);
    }
    JTSCurve curve = new JTSCurve();
    curve.getSegments().add(line);
    JTSRing ring = new JTSRing();
    ring.getElements().add(curve);
    return ring;
}
Also used : GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) DirectPosition(org.opengis.geometry.DirectPosition) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) JTSRing(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing) ArrayList(java.util.ArrayList) JTSCurve(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve) JTSLineString(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString)

Example 9 with JTSRing

use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing in project geotoolkit by Geomatys.

the class JTSGeometryBindingTest method PolygonUnmarshalingTest.

/**
 * Test Ring Unmarshalling.
 */
@Test
public void PolygonUnmarshalingTest() throws Exception {
    CoordinateReferenceSystem crs = CRS.forCode("urn:ogc:def:crs:epsg::27572");
    assertTrue(crs != null);
    // EXTERIOR
    JTSRing exterior1 = new JTSRing(crs);
    JTSCurve c1 = new JTSCurve(crs);
    JTSLineString c1l1 = new JTSLineString(crs);
    DirectPosition c1l1p1 = new GeneralDirectPosition(crs);
    c1l1p1.setOrdinate(0, 401500);
    c1l1p1.setOrdinate(1, 3334500);
    DirectPosition c1l1p2 = new GeneralDirectPosition(crs);
    c1l1p2.setOrdinate(0, 401700);
    c1l1p2.setOrdinate(1, 3334850);
    DirectPosition c1l1p3 = new GeneralDirectPosition(crs);
    c1l1p3.setOrdinate(0, 402200);
    c1l1p3.setOrdinate(1, 3335200);
    c1l1.getControlPoints().add(c1l1p1);
    c1l1.getControlPoints().add(c1l1p2);
    c1l1.getControlPoints().add(c1l1p3);
    DirectPosition c1l2p1 = new GeneralDirectPosition(crs);
    c1l2p1.setOrdinate(0, 402320);
    c1l2p1.setOrdinate(1, 3334850);
    DirectPosition c1l2p2 = new GeneralDirectPosition(crs);
    c1l2p2.setOrdinate(0, 402200);
    c1l2p2.setOrdinate(1, 3335200);
    c1l1.getControlPoints().add(c1l2p1);
    c1l1.getControlPoints().add(c1l2p2);
    c1.getSegments().add(c1l1);
    exterior1.getElements().add(c1);
    // INTERIOR
    Ring[] interiors1 = new Ring[1];
    JTSRing interior1 = new JTSRing(crs);
    JTSCurve c2 = new JTSCurve(crs);
    JTSLineString c2l1 = new JTSLineString(crs);
    DirectPosition c2l1p1 = new GeneralDirectPosition(crs);
    c2l1p1.setOrdinate(0, 401500);
    c2l1p1.setOrdinate(1, 3334500);
    DirectPosition c2l1p2 = new GeneralDirectPosition(crs);
    c2l1p2.setOrdinate(0, 401700);
    c2l1p2.setOrdinate(1, 3334850);
    DirectPosition c2l1p3 = new GeneralDirectPosition(crs);
    c2l1p3.setOrdinate(0, 402200);
    c2l1p3.setOrdinate(1, 3335200);
    c2l1.getControlPoints().add(c2l1p1);
    c2l1.getControlPoints().add(c2l1p2);
    c2l1.getControlPoints().add(c2l1p3);
    c2.getSegments().add(c2l1);
    interior1.getElements().add(c2);
    interiors1[0] = interior1;
    JTSSurfaceBoundary bound1 = new JTSSurfaceBoundary(crs, exterior1, interiors1);
    JTSPolygon expResult = new JTSPolygon(bound1);
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<gml:Polygon srsName=\"urn:ogc:def:crs:epsg::27572\" xmlns:gml=\"http://www.opengis.net/gml\">" + '\n' + "  <gml:exterior>" + '\n' + "    <gml:LinearRing>" + '\n' + "      <gml:posList>401500.0 3334500.0 401700.0 3334850.0 402200.0 3335200.0 402320.0 3334850.0 402200.0 3335200.0</gml:posList>" + '\n' + "    </gml:LinearRing>" + '\n' + "  </gml:exterior>" + '\n' + "  <gml:interior>" + '\n' + "    <gml:LinearRing>" + '\n' + "      <gml:posList>401500.0 3334500.0 401700.0 3334850.0 402200.0 3335200.0</gml:posList>" + '\n' + "    </gml:LinearRing>" + '\n' + "  </gml:interior>" + '\n' + "</gml:Polygon>" + '\n';
    PolygonType temp = (PolygonType) ((JAXBElement) un.unmarshal(new StringReader(xml))).getValue();
    JTSPolygon result = temp.getJTSPolygon();
    assertEquals(expResult, result);
    xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<gml:Polygon srsName=\"urn:ogc:def:crs:epsg::27572\" xmlns:gml=\"http://www.opengis.net/gml\">" + '\n' + "  <gml:outerBoundaryIs>" + '\n' + "    <gml:LinearRing>" + '\n' + "      <gml:posList>401500.0 3334500.0 401700.0 3334850.0 402200.0 3335200.0 402320.0 3334850.0 402200.0 3335200.0</gml:posList>" + '\n' + "    </gml:LinearRing>" + '\n' + "  </gml:outerBoundaryIs>" + '\n' + "  <gml:innerBoundaryIs>" + '\n' + "    <gml:LinearRing>" + '\n' + "      <gml:posList>401500.0 3334500.0 401700.0 3334850.0 402200.0 3335200.0</gml:posList>" + '\n' + "    </gml:LinearRing>" + '\n' + "  </gml:innerBoundaryIs>" + '\n' + "</gml:Polygon>" + '\n';
    temp = (PolygonType) ((JAXBElement) un.unmarshal(new StringReader(xml))).getValue();
    result = temp.getJTSPolygon();
    assertEquals(expResult, result);
}
Also used : GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) DirectPosition(org.opengis.geometry.DirectPosition) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) JTSRing(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing) JTSSurfaceBoundary(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSSurfaceBoundary) JTSPolygon(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSPolygon) PolygonType(org.geotoolkit.internal.jaxb.PolygonType) JTSLineString(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString) JAXBElement(javax.xml.bind.JAXBElement) JTSCurve(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve) JTSLineString(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString) JTSRing(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing) Ring(org.opengis.geometry.primitive.Ring) StringReader(java.io.StringReader) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem)

Example 10 with JTSRing

use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing in project geotoolkit by Geomatys.

the class JTSGeometryBindingTest method PolygonMarshalingTest.

/**
 * Test Ring Unmarshalling.
 */
@Test
public void PolygonMarshalingTest() throws Exception {
    CoordinateReferenceSystem crs = CRS.forCode("urn:ogc:def:crs:epsg::27572");
    assertTrue(crs != null);
    // EXTERIOR
    JTSRing exterior1 = new JTSRing(crs);
    JTSCurve c1 = new JTSCurve(crs);
    JTSLineString c1l1 = new JTSLineString();
    DirectPosition c1l1p1 = new GeneralDirectPosition(crs);
    c1l1p1.setOrdinate(0, 401500);
    c1l1p1.setOrdinate(1, 3334500);
    DirectPosition c1l1p2 = new GeneralDirectPosition(crs);
    c1l1p2.setOrdinate(0, 401700);
    c1l1p2.setOrdinate(1, 3334850);
    DirectPosition c1l1p3 = new GeneralDirectPosition(crs);
    c1l1p3.setOrdinate(0, 402200);
    c1l1p3.setOrdinate(1, 3335200);
    DirectPosition c1l2p1 = new GeneralDirectPosition(crs);
    c1l2p1.setOrdinate(0, 402320);
    c1l2p1.setOrdinate(1, 3334850);
    DirectPosition c1l2p2 = new GeneralDirectPosition(crs);
    c1l2p2.setOrdinate(0, 402200);
    c1l2p2.setOrdinate(1, 3335200);
    c1l1.getControlPoints().add(c1l1p1);
    c1l1.getControlPoints().add(c1l1p2);
    c1l1.getControlPoints().add(c1l1p3);
    c1l1.getControlPoints().add(c1l2p1);
    c1l1.getControlPoints().add(c1l2p2);
    c1.getSegments().add(c1l1);
    exterior1.getElements().add(c1);
    // INTERIOR
    Ring[] interiors1 = new Ring[1];
    JTSRing interior1 = new JTSRing(crs);
    JTSCurve c2 = new JTSCurve(crs);
    JTSLineString c2l1 = new JTSLineString();
    DirectPosition c2l1p1 = new GeneralDirectPosition(crs);
    c2l1p1.setOrdinate(0, 401500);
    c2l1p1.setOrdinate(1, 3334500);
    DirectPosition c2l1p2 = new GeneralDirectPosition(crs);
    c2l1p2.setOrdinate(0, 401700);
    c2l1p2.setOrdinate(1, 3334850);
    DirectPosition c2l1p3 = new GeneralDirectPosition(crs);
    c2l1p3.setOrdinate(0, 402200);
    c2l1p3.setOrdinate(1, 3335200);
    c2l1.getControlPoints().add(c2l1p1);
    c2l1.getControlPoints().add(c2l1p2);
    c2l1.getControlPoints().add(c2l1p3);
    c2.getSegments().add(c2l1);
    interior1.getElements().add(c2);
    interiors1[0] = interior1;
    JTSSurfaceBoundary bound1 = new JTSSurfaceBoundary(crs, exterior1, interiors1);
    JTSPolygon polygon = new JTSPolygon(bound1);
    StringWriter sw = new StringWriter();
    m.marshal(factory.createJTSPolygon(polygon), sw);
    String result = sw.toString();
    result = result.replaceAll("(?i)epsg\\:\\d+\\.\\d+\\.?\\d*\\:", "epsg::");
    String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<gml:Polygon xmlns:gml=\"http://www.opengis.net/gml\" srsName=\"urn:ogc:def:crs:epsg::27572\" >" + '\n' + "  <gml:exterior>" + '\n' + "    <gml:LinearRing>" + '\n' + "      <gml:posList>401500.0 3334500.0 401700.0 3334850.0 402200.0 3335200.0 402320.0 3334850.0 402200.0 3335200.0</gml:posList>" + '\n' + "    </gml:LinearRing>" + '\n' + "  </gml:exterior>" + '\n' + "  <gml:interior>" + '\n' + "    <gml:LinearRing>" + '\n' + "      <gml:posList>401500.0 3334500.0 401700.0 3334850.0 402200.0 3335200.0</gml:posList>" + '\n' + "    </gml:LinearRing>" + '\n' + "  </gml:interior>" + '\n' + "</gml:Polygon>" + '\n';
    assertXmlEquals(expResult, result, "xmlns:*");
}
Also used : GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) DirectPosition(org.opengis.geometry.DirectPosition) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) StringWriter(java.io.StringWriter) JTSRing(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing) JTSRing(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing) Ring(org.opengis.geometry.primitive.Ring) JTSSurfaceBoundary(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSSurfaceBoundary) JTSPolygon(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSPolygon) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) JTSLineString(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString) JTSCurve(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve) JTSLineString(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString)

Aggregations

GeneralDirectPosition (org.apache.sis.geometry.GeneralDirectPosition)14 JTSLineString (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSLineString)14 JTSCurve (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve)14 JTSRing (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSRing)14 JTSPolygon (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.geometry.JTSPolygon)11 DirectPosition (org.opengis.geometry.DirectPosition)11 Ring (org.opengis.geometry.primitive.Ring)11 JTSSurfaceBoundary (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSSurfaceBoundary)10 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)10 StringReader (java.io.StringReader)5 StringWriter (java.io.StringWriter)5 JTSPolyhedralSurface (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPolyhedralSurface)5 ArrayList (java.util.ArrayList)3 PointArray (org.opengis.geometry.coordinate.PointArray)3 Position (org.opengis.geometry.coordinate.Position)3 CurveSegment (org.opengis.geometry.primitive.CurveSegment)3 Primitive (org.opengis.geometry.primitive.Primitive)3 JAXBElement (javax.xml.bind.JAXBElement)2 JTSMultiPolygon (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.aggregate.JTSMultiPolygon)2 JTSMultiPrimitive (org.geotoolkit.geometry.isoonjts.spatialschema.geometry.aggregate.JTSMultiPrimitive)2