use of net.opengis.gml.v_3_1_1.PolygonType in project ddf by codice.
the class Wfs20JTStoGML321Converter method convertToPolygonType.
public static PolygonType convertToPolygonType(Polygon polygon, String srsName) {
PolygonType polygonType = GML320_OBJECT_FACTORY.createPolygonType();
// exterior
LineString lineString = polygon.getExteriorRing();
LinearRing linearRing = lineString.getFactory().createLinearRing(lineString.getCoordinateSequence());
RingType ringType = convertToRingType(linearRing, srsName);
JAXBElement<RingType> ringTypeJAXBElement = GML320_OBJECT_FACTORY.createRing(ringType);
AbstractRingPropertyType abstractRingPropertyType = GML320_OBJECT_FACTORY.createAbstractRingPropertyType();
abstractRingPropertyType.setAbstractRing(ringTypeJAXBElement);
polygonType.setExterior(abstractRingPropertyType);
// interiors
for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
LineString interiorRingN = polygon.getInteriorRingN(i);
LinearRing linearRing1 = interiorRingN.getFactory().createLinearRing(interiorRingN.getCoordinateSequence());
RingType ringType1 = convertToRingType(linearRing1, srsName);
JAXBElement<RingType> ringTypeJAXBElement1 = GML320_OBJECT_FACTORY.createRing(ringType1);
AbstractRingPropertyType abstractRingPropertyType1 = GML320_OBJECT_FACTORY.createAbstractRingPropertyType();
abstractRingPropertyType1.setAbstractRing(ringTypeJAXBElement1);
polygonType.getInterior().add(abstractRingPropertyType1);
}
polygonType.setSrsName(srsName);
return polygonType;
}
use of net.opengis.gml.v_3_1_1.PolygonType in project ddf by codice.
the class Wfs20JTStoGML321Converter method createGeometryPropertyType.
private static GeometryPropertyType createGeometryPropertyType(Geometry geometry, String srsName) {
final GeometryPropertyType geometryPropertyType = GML320_OBJECT_FACTORY.createGeometryPropertyType();
if (geometry instanceof Point) {
PointType pointType = convertToPointType((Point) geometry, srsName);
geometryPropertyType.setAbstractGeometry(convertPointTypeToJAXB(pointType));
} else if (geometry instanceof LineString) {
LineStringType lineStringType = convertToLineStringType((LineString) geometry, srsName);
geometryPropertyType.setAbstractGeometry(convertLineStringTypeToJAXB(lineStringType));
} else if (geometry instanceof Polygon) {
PolygonType polygonType = convertToPolygonType((Polygon) geometry, srsName);
geometryPropertyType.setAbstractGeometry(convertPolygonTypeToJAXB(polygonType));
} else if (geometry instanceof MultiPoint) {
MultiPointType multiPointType = convertToMultiPointType((MultiPoint) geometry, srsName);
geometryPropertyType.setAbstractGeometry(convertMultiPointTypeToJAXB(multiPointType));
} else if (geometry instanceof MultiLineString) {
MultiCurveType multiCurveType = convertToMultiLineStringType((MultiLineString) geometry, srsName);
geometryPropertyType.setAbstractGeometry(convertMultiCurveTypeToJAXB(multiCurveType));
} else if (geometry instanceof MultiPolygon) {
MultiSurfaceType multiSurfaceType = convertToMultiSurfaceType((MultiPolygon) geometry, srsName);
geometryPropertyType.setAbstractGeometry(convertMultiSurfaceTypeToJAXB(multiSurfaceType));
} else if (geometry instanceof GeometryCollection) {
MultiGeometryType multiGeometryType = convertToMultiGeometryType((GeometryCollection) geometry, srsName);
geometryPropertyType.setAbstractGeometry(convertMultiGeometryTypeToJAXB(multiGeometryType));
} else {
throw new IllegalArgumentException();
}
return geometryPropertyType;
}
use of net.opengis.gml.v_3_1_1.PolygonType in project ddf by codice.
the class WfsFilterDelegateTest method testMultiPolygonSupportsOnlyPolygonIsEnvelopePolygon.
@Test
public void testMultiPolygonSupportsOnlyPolygonIsEnvelopePolygon() {
final WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.INTERSECTS.getValue(), new LonLatCoordinateStrategy());
delegate.setSupportedGeometryOperands(singletonList(Wfs11Constants.POLYGON));
final FilterType filter = delegate.intersects(Metacard.ANY_GEO, MULTIPOLYGON);
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("5.0,5.0 5.0,40.0 45.0,40.0 45.0,5.0 5.0,5.0"));
}
use of net.opengis.gml.v_3_1_1.PolygonType in project ddf by codice.
the class WfsFilterDelegateTest method testPolygonLonLatOrder.
@Test
public void testPolygonLonLatOrder() {
final WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.INTERSECTS.getValue(), new LonLatCoordinateStrategy());
final FilterType filter = delegate.intersects(Metacard.ANY_GEO, 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("40.0,-10.0 40.0,30.0 10.0,30.0 10.0,-10.0 40.0,-10.0"));
}
use of net.opengis.gml.v_3_1_1.PolygonType in project ddf by codice.
the class WfsFilterDelegateTest method testPolygonLatLonOrder.
@Test
public void testPolygonLatLonOrder() {
final WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.INTERSECTS.getValue(), new LatLonCoordinateStrategy());
final FilterType filter = delegate.intersects(Metacard.ANY_GEO, 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("-10.0,40.0 30.0,40.0 30.0,10.0 -10.0,10.0 -10.0,40.0"));
}
Aggregations