use of org.geotoolkit.gml.xml.v321.PolygonType in project geo-platform by geosdi.
the class GMLPolygonParserTest method b_polygonJTSParserTest.
@Test
public void b_polygonJTSParserTest() throws Exception {
PolygonType polygonType = GPJAXBContextBuilder.newInstance().unmarshal(new File(of(new File(".").getCanonicalPath(), "src", "test", "resources", "Polygon_3.xml").collect(joining(File.separator))), PolygonType.class);
logger.info("##########################POLYGON_STRING_JTS : {}\n", polygonParser.parseGeometry(polygonType));
}
use of org.geotoolkit.gml.xml.v321.PolygonType in project geo-platform by geosdi.
the class GMLPolygonParserTest method c_polygonJTSParserTest.
@Test
public void c_polygonJTSParserTest() throws Exception {
PolygonType polygonType = GPJAXBContextBuilder.newInstance().unmarshal(new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<gml:Polygon xmlns:gml=\"http://www.opengis.net/gml\" srsName=\"SDO:\">\n" + " <gml:exterior>\n" + " <gml:LinearRing>\n" + " <gml:posList srsDimension=\"2\">5.0 1.0 8.0 1.0 8.0 6.0 5.0 7.0 5.0 1.0</gml:posList>\n" + " </gml:LinearRing>\n" + " </gml:exterior>\n" + "</gml:Polygon>"), PolygonType.class);
logger.info("##########################POLYGON_STRING_JTS : {}\n", polygonParser.parseGeometry(polygonType));
}
use of org.geotoolkit.gml.xml.v321.PolygonType in project ddf by codice.
the class WfsFilterDelegateTest method testMultiPolygonWithSinglePolygonSupportsOnlyPolygon.
@Test
public void testMultiPolygonWithSinglePolygonSupportsOnlyPolygon() {
final String MULTIPOLYGON_SINGLE_POLYGON = "MULTIPOLYGON (((30 20, 10 40, 45 40, 30 20)))";
final WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.INTERSECTS.getValue(), new LatLonCoordinateStrategy());
delegate.setSupportedGeometryOperands(singletonList(Wfs11Constants.POLYGON));
final FilterType filter = delegate.intersects(Metacard.ANY_GEO, MULTIPOLYGON_SINGLE_POLYGON);
assertThat(filter.getSpatialOps().getValue(), is(instanceOf(BinarySpatialOpType.class)));
final BinarySpatialOpType binarySpatialOpType = (BinarySpatialOpType) filter.getSpatialOps().getValue();
assertThat(binarySpatialOpType.getGeometry().getValue(), is(instanceOf(PolygonType.class)));
final PolygonType polygonType = (PolygonType) binarySpatialOpType.getGeometry().getValue();
assertThat(polygonType.getExterior().getValue().getRing().getValue(), is(instanceOf(LinearRingType.class)));
final LinearRingType linearRingType = (LinearRingType) polygonType.getExterior().getValue().getRing().getValue();
assertThat(linearRingType.getCoordinates().getValue(), is("20.0,30.0 40.0,10.0 40.0,45.0 20.0,30.0"));
}
use of org.geotoolkit.gml.xml.v321.PolygonType in project ddf by codice.
the class WfsFilterDelegate method createPolygon.
private PolygonType createPolygon(Coordinate[] coordinates) {
if (coordinates != null && coordinates.length > 0) {
PolygonType polygon = new PolygonType();
LinearRingType linearRing = new LinearRingType();
String coordinateString = coordinateStrategy.toString(coordinates);
CoordinatesType coordinatesType = new CoordinatesType();
coordinatesType.setValue(coordinateString);
coordinatesType.setDecimal(".");
coordinatesType.setCs(",");
coordinatesType.setTs(" ");
linearRing.setCoordinates(coordinatesType);
AbstractRingPropertyType abstractRingPropertyType = gmlObjectFactory.createAbstractRingPropertyType();
abstractRingPropertyType.setRing(gmlObjectFactory.createLinearRing(linearRing));
polygon.setExterior(gmlObjectFactory.createExterior(abstractRingPropertyType));
return polygon;
} else {
throw new IllegalArgumentException("Unable to parse Polygon coordinates from WKT String");
}
}
use of org.geotoolkit.gml.xml.v321.PolygonType in project ddf by codice.
the class Wfs20JTStoGML321Converter method convertToMultiSurfaceType.
/**
* Converts a @link org.locationtech.jts.geom.MultiPolygon to a @link
* net.opengis.gml.v_3_2_1.MultiSurfaceType Note: MultiPolygon maps to gml MultiSurfaceType
*
* @param multiPolygon
* @return MultiSurfaceType
*/
public static MultiSurfaceType convertToMultiSurfaceType(MultiPolygon multiPolygon, String srsName) {
MultiSurfaceType multiSurfaceType = GML320_OBJECT_FACTORY.createMultiSurfaceType();
for (int i = 0; i < multiPolygon.getNumGeometries(); i++) {
Polygon poly = (Polygon) multiPolygon.getGeometryN(i);
PolygonType polygonType = convertToPolygonType(poly, srsName);
JAXBElement<PolygonType> polygonTypeJAXBElement = GML320_OBJECT_FACTORY.createPolygon(polygonType);
SurfacePropertyType surfacePropertyType = GML320_OBJECT_FACTORY.createSurfacePropertyType();
surfacePropertyType.setAbstractSurface(polygonTypeJAXBElement);
multiSurfaceType.getSurfaceMember().add(surfacePropertyType);
}
multiSurfaceType.setSrsName(srsName);
return multiSurfaceType;
}
Aggregations