use of net.opengis.gml.v_3_2_1.PolygonType in project ddf by codice.
the class WfsFilterDelegate method createPolygon.
private JAXBElement<PolygonType> createPolygon(String wkt) {
PolygonType polygon = new PolygonType();
LinearRingType linearRing = new LinearRingType();
Coordinate[] coordinates = getCoordinatesFromWkt(wkt);
if (coordinates != null && coordinates.length > 0) {
StringBuffer coordString = new StringBuffer();
for (Coordinate coordinate : coordinates) {
coordString.append(coordinate.x).append(",").append(coordinate.y).append(" ");
}
CoordinatesType coordinatesType = new CoordinatesType();
coordinatesType.setValue(coordString.toString());
coordinatesType.setDecimal(".");
coordinatesType.setCs(",");
coordinatesType.setTs(" ");
linearRing.setCoordinates(coordinatesType);
LinearRingMemberType member = new LinearRingMemberType();
member.setGeometry(gmlObjectFactory.createLinearRing(linearRing));
polygon.setOuterBoundaryIs(member);
polygon.setSrsName(srsName);
return gmlObjectFactory.createPolygon(polygon);
} else {
throw new IllegalArgumentException("Unable to parse Polygon coordinates from WKT String");
}
}
use of net.opengis.gml.v_3_2_1.PolygonType in project ddf by codice.
the class Wfs20JTStoGML321Converter method convertToMultiSurfaceType.
/**
* Converts a @link com.vividsolutions.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;
}
use of net.opengis.gml.v_3_2_1.PolygonType in project ddf by codice.
the class TestWfs10JTStoGML200Converter method testGMLToPolygonType.
@Test
public void testGMLToPolygonType() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
Polygon polygon = (Polygon) getGeometryFromWkt(POLYGON);
assertThat(polygon == null, is(Boolean.FALSE));
String polygonGML = Wfs10JTStoGML200Converter.convertGeometryToGML(polygon);
PolygonType polygonType = (PolygonType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(polygonGML, Wfs10Constants.POLYGON);
assertThat(null != polygonType, is(Boolean.TRUE));
assertThat(polygonType.isSetInnerBoundaryIs(), is(Boolean.FALSE));
assertThat(polygonType.isSetOuterBoundaryIs(), is(Boolean.TRUE));
LinearRingMemberType linearRingMemberType = polygonType.getOuterBoundaryIs();
JAXBElement<? extends AbstractGeometryType> geometry = linearRingMemberType.getGeometry();
LinearRingType linearRingType = (LinearRingType) geometry.getValue();
String coordinates = linearRingType.getCoordinates().getValue().replaceAll("\n", "").trim();
assertThat(POLYGON_COORDS.equals(coordinates), is(Boolean.TRUE));
}
use of net.opengis.gml.v_3_2_1.PolygonType in project ddf by codice.
the class WfsFilterDelegate method createPolygon.
private JAXBElement<PolygonType> createPolygon(Geometry geometry) {
PolygonType polygonType = gml320ObjectFactory.createPolygonType();
polygonType.setSrsName(GeospatialUtil.EPSG_4326_URN);
LinearRingType ring = gml320ObjectFactory.createLinearRingType();
ring.setCoordinates(createCoordinates(geometry));
AbstractRingPropertyType abstractRing = gml320ObjectFactory.createAbstractRingPropertyType();
abstractRing.setAbstractRing(gml320ObjectFactory.createLinearRing(ring));
polygonType.setExterior(abstractRing);
return gml320ObjectFactory.createPolygon(polygonType);
}
Aggregations