use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPoint in project geotoolkit by Geomatys.
the class JTSGeometryBindingTest method MultiPointMarshalingTest.
/**
* Test multiPoint Marshalling.
*/
@Test
public void MultiPointMarshalingTest() 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);
JTSPoint pt1 = new JTSPoint(p1);
DirectPosition p2 = new GeneralDirectPosition(crs);
p2.setOrdinate(0, 402200);
p2.setOrdinate(1, 3335200);
JTSPoint pt2 = new JTSPoint(p2);
JTSMultiPoint multiPoint = new JTSMultiPoint(crs);
multiPoint.getElements().add(pt1);
multiPoint.getElements().add(pt2);
StringWriter sw = new StringWriter();
m.marshal(factory.createJTSMultiPoint(multiPoint), 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:MultiPoint xmlns:gml=\"http://www.opengis.net/gml\" srsName=\"urn:ogc:def:crs:epsg::27572\" >" + '\n' + " <gml:pointMember>" + '\n' + " <gml:Point srsName=\"urn:ogc:def:crs:epsg::27572\">" + '\n' + " <gml:pos>402000.0 3334850.0</gml:pos>" + '\n' + " </gml:Point>" + '\n' + " </gml:pointMember>" + '\n' + " <gml:pointMember>" + '\n' + " <gml:Point srsName=\"urn:ogc:def:crs:epsg::27572\">" + '\n' + " <gml:pos>402200.0 3335200.0</gml:pos>" + '\n' + " </gml:Point>" + '\n' + " </gml:pointMember>" + '\n' + "</gml:MultiPoint>" + '\n';
assertXmlEquals(expResult, result, "xmlns:*");
}
use of org.geotoolkit.geometry.isoonjts.spatialschema.geometry.primitive.JTSPoint in project geotoolkit by Geomatys.
the class JTSGeometryBindingTest method PointUnMarshalingTest.
/**
* Test point Marshalling.
*/
@Test
public void PointUnMarshalingTest() throws Exception {
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + '\n' + "<gml:Point srsName=\"urn:ogc:def:crs:epsg::4326\" xmlns:gml=\"http://www.opengis.net/gml\">" + '\n' + " <gml:pos>2.1 12.6</gml:pos>" + '\n' + "</gml:Point>" + '\n';
JAXBElement<JTSPoint> result = (JAXBElement) un.unmarshal(new StringReader(xml));
CoordinateReferenceSystem crs = CRS.forCode("urn:ogc:def:crs:epsg::4326");
assertTrue(crs != null);
DirectPosition dp = new GeneralDirectPosition(crs);
dp.setOrdinate(0, 2.1);
dp.setOrdinate(1, 12.6);
JTSPoint expResult = new JTSPoint(dp, crs);
assertEquals(expResult.getDirectPosition(), result.getValue().getDirectPosition());
assertEquals(expResult, result.getValue());
}
Aggregations