Search in sources :

Example 16 with JTSCurve

use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve 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 17 with JTSCurve

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

the class JTSGeometryBindingTest method CurveMarshalingTest.

/**
 * Test curve Marshalling.
 */
@Test
public void CurveMarshalingTest() throws Exception {
    CoordinateReferenceSystem crs = CRS.forCode("urn:ogc:def:crs:epsg::27572");
    assertTrue(crs != null);
    JTSCurve curve = new JTSCurve(crs);
    JTSLineString line1 = new JTSLineString();
    DirectPosition p1 = new GeneralDirectPosition(crs);
    p1.setOrdinate(0, 401500);
    p1.setOrdinate(1, 3334500);
    DirectPosition p2 = new GeneralDirectPosition(crs);
    p2.setOrdinate(0, 401700);
    p2.setOrdinate(1, 3334850);
    DirectPosition p3 = new GeneralDirectPosition(crs);
    p3.setOrdinate(0, 402200);
    p3.setOrdinate(1, 3335200);
    line1.getControlPoints().add(p1);
    line1.getControlPoints().add(p2);
    line1.getControlPoints().add(p3);
    curve.getSegments().add(line1);
    JTSLineString line2 = new JTSLineString();
    DirectPosition p21 = new GeneralDirectPosition(crs);
    p21.setOrdinate(0, 402320);
    p21.setOrdinate(1, 3334850);
    DirectPosition p22 = new GeneralDirectPosition(crs);
    p22.setOrdinate(0, 402200);
    p22.setOrdinate(1, 3335200);
    line2.getControlPoints().add(p21);
    line2.getControlPoints().add(p22);
    curve.getSegments().add(line2);
    StringWriter sw = new StringWriter();
    m.marshal(factory.createJTSCurve(curve), 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:Curve xmlns:gml=\"http://www.opengis.net/gml\" srsName=\"urn:ogc:def:crs:epsg::27572\" >" + '\n' + "  <gml:segments>" + '\n' + "    <gml:LineStringSegment interpolation=\"linear\">" + '\n' + "      <gml:pos>401500.0 3334500.0</gml:pos>" + '\n' + "      <gml:pos>401700.0 3334850.0</gml:pos>" + '\n' + "      <gml:pos>402200.0 3335200.0</gml:pos>" + '\n' + "    </gml:LineStringSegment>" + '\n' + "    <gml:LineStringSegment interpolation=\"linear\">" + '\n' + "      <gml:pos>402320.0 3334850.0</gml:pos>" + '\n' + "      <gml:pos>402200.0 3335200.0</gml:pos>" + '\n' + "    </gml:LineStringSegment>" + '\n' + "  </gml:segments>" + '\n' + "</gml:Curve>" + '\n';
    assertXmlEquals(expResult, result, "xmlns:*");
    pool.recycle(m);
}
Also used : GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) DirectPosition(org.opengis.geometry.DirectPosition) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) StringWriter(java.io.StringWriter) 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)

Example 18 with JTSCurve

use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSCurve 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)

Example 19 with JTSCurve

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

the class JTSGeometryBindingTest method RingUnmarshalingTest.

/**
 * Test Ring Unmarshalling.
 */
@Test
public void RingUnmarshalingTest() throws Exception {
    CoordinateReferenceSystem crs = CRS.forCode("urn:ogc:def:crs:epsg::27572");
    assertTrue(crs != null);
    JTSRing expResult = 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);
    c1.getSegments().add(c1l1);
    JTSLineString c1l2 = new JTSLineString(crs);
    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);
    expResult.getElements().add(c1);
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<gml:Ring srsName=\"urn:ogc:def:crs:epsg::27572\" xmlns:gml=\"http://www.opengis.net/gml\">" + '\n' + "  <gml:curveMember>" + '\n' + "    <gml:Curve srsName=\"urn:ogc:def:crs:epsg::27572\">" + '\n' + "      <gml:segments>" + '\n' + "        <gml:LineStringSegment interpolation=\"linear\">" + '\n' + "          <gml:pos>401500.0 3334500.0</gml:pos>" + '\n' + "          <gml:pos>401700.0 3334850.0</gml:pos>" + '\n' + "          <gml:pos>402200.0 3335200.0</gml:pos>" + '\n' + "        </gml:LineStringSegment>" + '\n' + "        <gml:LineStringSegment interpolation=\"linear\">" + '\n' + "          <gml:pos>402320.0 3334850.0</gml:pos>" + '\n' + "          <gml:pos>402200.0 3335200.0</gml:pos>" + '\n' + "        </gml:LineStringSegment>" + '\n' + "      </gml:segments>" + '\n' + "    </gml:Curve>" + '\n' + "  </gml:curveMember>" + '\n' + "</gml:Ring>" + '\n';
    JTSRing result = (JTSRing) un.unmarshal(new StringReader(xml));
    assertEquals(expResult.getElements().iterator().next(), result.getElements().iterator().next());
    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) StringReader(java.io.StringReader) 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)

Example 20 with JTSCurve

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

the class JTSGeometryBindingTest method MultiPrimitiveMarshalingTest.

/**
 * Test Composite curve Marshalling.
 */
@Test
public void MultiPrimitiveMarshalingTest() throws Exception {
    CoordinateReferenceSystem crs = CRS.forCode("urn:ogc:def:crs:epsg::27572");
    assertTrue(crs != null);
    DirectPosition p1 = new GeneralDirectPosition(crs);
    p1.setOrdinate(0, 402000);
    p1.setOrdinate(1, 3334850);
    DirectPosition p2 = new GeneralDirectPosition(crs);
    p2.setOrdinate(0, 402200);
    p2.setOrdinate(1, 3335200);
    JTSLineString l1 = new JTSLineString();
    l1.getControlPoints().add(p1);
    l1.getControlPoints().add(p2);
    JTSCurve c2 = new JTSCurve(crs);
    c2.getSegments().add(l1);
    JTSCurve c1 = new JTSCurve(crs);
    JTSLineString l2 = new JTSLineString();
    DirectPosition p21 = new GeneralDirectPosition(crs);
    p21.setOrdinate(0, 401500);
    p21.setOrdinate(1, 3334500);
    DirectPosition p22 = new GeneralDirectPosition(crs);
    p22.setOrdinate(0, 401700);
    p22.setOrdinate(1, 3334850);
    DirectPosition p23 = new GeneralDirectPosition(crs);
    p23.setOrdinate(0, 402200);
    p23.setOrdinate(1, 3335200);
    l2.getControlPoints().add(p21);
    l2.getControlPoints().add(p22);
    l2.getControlPoints().add(p23);
    c1.getSegments().add(l2);
    JTSLineString l3 = new JTSLineString();
    DirectPosition p31 = new GeneralDirectPosition(crs);
    p31.setOrdinate(0, 402320);
    p31.setOrdinate(1, 3334850);
    DirectPosition p32 = new GeneralDirectPosition(crs);
    p32.setOrdinate(0, 402200);
    p32.setOrdinate(1, 3335200);
    l3.getControlPoints().add(p31);
    l3.getControlPoints().add(p32);
    c1.getSegments().add(l3);
    JTSMultiPrimitive multip = new JTSMultiPrimitive();
    multip.getElements().add(c1);
    multip.getElements().add(c2);
    StringWriter sw = new StringWriter();
    m.marshal(factory.createJTSMultiGeometry(multip), 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:MultiGeometry xmlns:gml=\"http://www.opengis.net/gml\" >" + '\n' + "  <gml:geometryMember>" + '\n' + "    <gml:Curve srsName=\"urn:ogc:def:crs:epsg::27572\">" + '\n' + "      <gml:segments>" + '\n' + "        <gml:LineStringSegment interpolation=\"linear\">" + '\n' + "          <gml:pos>401500.0 3334500.0</gml:pos>" + '\n' + "          <gml:pos>401700.0 3334850.0</gml:pos>" + '\n' + "          <gml:pos>402200.0 3335200.0</gml:pos>" + '\n' + "        </gml:LineStringSegment>" + '\n' + "        <gml:LineStringSegment interpolation=\"linear\">" + '\n' + "          <gml:pos>402320.0 3334850.0</gml:pos>" + '\n' + "          <gml:pos>402200.0 3335200.0</gml:pos>" + '\n' + "        </gml:LineStringSegment>" + '\n' + "      </gml:segments>" + '\n' + "    </gml:Curve>" + '\n' + "  </gml:geometryMember>" + '\n' + "  <gml:geometryMember>" + '\n' + "    <gml:Curve srsName=\"urn:ogc:def:crs:epsg::27572\">" + '\n' + "      <gml:segments>" + '\n' + "        <gml:LineStringSegment interpolation=\"linear\">" + '\n' + "          <gml:pos>402000.0 3334850.0</gml:pos>" + '\n' + "          <gml:pos>402200.0 3335200.0</gml:pos>" + '\n' + "        </gml:LineStringSegment>" + '\n' + "      </gml:segments>" + '\n' + "    </gml:Curve>" + '\n' + "  </gml:geometryMember>" + '\n' + "</gml:MultiGeometry>" + '\n';
    assertXmlEquals(expResult, result, "xmlns:*");
    crs = CRS.forCode("urn:ogc:def:crs:epsg::27593");
    assertTrue(crs != null);
    /*
         * FIRST POLYGON
         */
    // EXTERIOR
    JTSRing exterior1 = new JTSRing(crs);
    JTSCurve cu1 = new JTSCurve(crs);
    JTSLineString c1l1 = new JTSLineString();
    DirectPosition dp1 = new GeneralDirectPosition(crs);
    dp1.setOrdinate(0, 656216.1977884835);
    dp1.setOrdinate(1, 38574.31079256255);
    DirectPosition dp2 = new GeneralDirectPosition(crs);
    dp2.setOrdinate(0, 656209.434300029);
    dp2.setOrdinate(1, 38569.570186997764);
    c1l1.getControlPoints().add(dp1);
    c1l1.getControlPoints().add(dp2);
    cu1.getSegments().add(c1l1);
    exterior1.getElements().add(cu1);
    // INTERIOR
    Ring[] interiors1 = new Ring[0];
    JTSSurfaceBoundary bound1 = new JTSSurfaceBoundary(crs, exterior1, interiors1);
    JTSPolygon poly1 = new JTSPolygon(bound1);
    JTSPolyhedralSurface PS = new JTSPolyhedralSurface(crs);
    PS.getPatches().add(poly1);
    multip = new JTSMultiPrimitive();
    multip.getElements().add(PS);
    sw = new StringWriter();
    m.marshal(factory.createJTSMultiGeometry(multip), sw);
    result = sw.toString();
    result = result.replaceAll("(?i)epsg\\:\\d+\\.\\d+\\.?\\d*\\:", "epsg::");
    expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<gml:MultiGeometry xmlns:gml=\"http://www.opengis.net/gml\" >" + '\n' + "  <gml:geometryMember>" + '\n' + "    <gml:PolyhedralSurface srsName=\"urn:ogc:def:crs:epsg::27593\">" + '\n' + "      <gml:polygonPatches>" + '\n' + "        <gml:PolygonPatch>" + '\n' + "          <gml:exterior>" + '\n' + "            <gml:LinearRing>" + '\n' + "              <gml:posList>656216.1977884835 38574.31079256255 656209.434300029 38569.570186997764</gml:posList>" + '\n' + "            </gml:LinearRing>" + '\n' + "          </gml:exterior>" + '\n' + "        </gml:PolygonPatch>" + '\n' + "      </gml:polygonPatches>" + '\n' + "    </gml:PolyhedralSurface>" + '\n' + "  </gml:geometryMember>" + '\n' + "</gml:MultiGeometry>" + '\n';
    assertXmlEquals(expResult, result, "xmlns:*");
    crs = CRS.forCode("urn:ogc:def:crs:epsg::4326");
    // EXTERIOR
    exterior1 = new JTSRing(crs);
    cu1 = new JTSCurve(crs);
    c1l1 = new JTSLineString();
    dp1 = new GeneralDirectPosition(crs);
    dp1.setOrdinate(0, -1.0);
    dp1.setOrdinate(1, 0.0);
    dp2 = new GeneralDirectPosition(crs);
    dp2.setOrdinate(0, 0.0);
    dp2.setOrdinate(1, 1.0);
    GeneralDirectPosition dp3 = new GeneralDirectPosition(crs);
    dp3.setOrdinate(0, 1.0);
    dp3.setOrdinate(1, 0.0);
    GeneralDirectPosition dp4 = new GeneralDirectPosition(crs);
    dp4.setOrdinate(0, 0.0);
    dp4.setOrdinate(1, -1.0);
    GeneralDirectPosition dp5 = new GeneralDirectPosition(crs);
    dp5.setOrdinate(0, -1.0);
    dp5.setOrdinate(1, 0.0);
    c1l1.getControlPoints().add(dp1);
    c1l1.getControlPoints().add(dp2);
    c1l1.getControlPoints().add(dp3);
    c1l1.getControlPoints().add(dp4);
    c1l1.getControlPoints().add(dp5);
    cu1.getSegments().add(c1l1);
    exterior1.getElements().add(cu1);
    // INTERIOR
    interiors1 = new Ring[0];
    bound1 = new JTSSurfaceBoundary(crs, exterior1, interiors1);
    poly1 = new JTSPolygon(bound1);
    multip = new JTSMultiPrimitive();
    multip.getElements().add(poly1);
    sw = new StringWriter();
    m.marshal(factory.createJTSMultiGeometry(multip), sw);
    result = sw.toString();
    result = result.replaceAll("(?i)epsg\\:\\d+\\.\\d+\\.?\\d*\\:", "epsg::");
    expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<gml:MultiGeometry xmlns:gml=\"http://www.opengis.net/gml\" >" + '\n' + "  <gml:geometryMember>" + '\n' + "    <gml:Polygon srsName=\"urn:ogc:def:crs:epsg::4326\">" + '\n' + "      <gml:exterior>" + '\n' + "        <gml:LinearRing>" + '\n' + "          <gml:posList>-1.0 0.0 0.0 1.0 1.0 0.0 0.0 -1.0 -1.0 0.0</gml:posList>" + '\n' + "        </gml:LinearRing>" + '\n' + "      </gml:exterior>" + '\n' + "    </gml:Polygon>" + '\n' + "  </gml:geometryMember>" + '\n' + "</gml:MultiGeometry>" + '\n';
    assertXmlEquals(expResult, result, "xmlns:*");
}
Also used : GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) DirectPosition(org.opengis.geometry.DirectPosition) GeneralDirectPosition(org.apache.sis.geometry.GeneralDirectPosition) JTSPolyhedralSurface(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPolyhedralSurface) 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) JTSMultiPrimitive(org.geotoolkit.geometry.isoonjts.spatialschema.geometry.aggregate.JTSMultiPrimitive) 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)

Aggregations

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