use of net.opengis.gml._3.LinearRingType 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 net.opengis.gml._3.LinearRingType 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);
}
use of net.opengis.gml._3.LinearRingType in project ddf by codice.
the class CswJTSToGML311LinearRingConverter method doCreateGeometryType.
/**
* @see {@code JTSToGML311LinearRingConverter#doCreateGeometryType}
*/
@Override
protected LinearRingType doCreateGeometryType(LinearRing linearRing) {
final LinearRingType resultLinearRing;
if (usePosList) {
resultLinearRing = getObjectFactory().createLinearRingType();
List<Double> posDoubleList = new ArrayList<Double>();
for (Coordinate coordinate : linearRing.getCoordinates()) {
posDoubleList.add(coordinate.x);
posDoubleList.add(coordinate.y);
}
DirectPositionListType directPosListType = new DirectPositionListType();
directPosListType.setValue(posDoubleList);
resultLinearRing.setPosList(directPosListType);
} else {
resultLinearRing = super.doCreateGeometryType(linearRing);
}
return resultLinearRing;
}
use of net.opengis.gml._3.LinearRingType in project ddf by codice.
the class WfsFilterDelegateTest method testMultiPolygonLonLatOrder.
@Test
public void testMultiPolygonLonLatOrder() {
final WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.INTERSECTS.getValue(), new LonLatCoordinateStrategy());
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(MultiPolygonType.class)));
final MultiPolygonType multiPolygonType = (MultiPolygonType) binarySpatialOpType.getGeometry().getValue();
assertThat(multiPolygonType.getPolygonMember().size(), is(2));
final LinearRingType firstLinearRing = (LinearRingType) multiPolygonType.getPolygonMember().get(0).getPolygon().getExterior().getValue().getRing().getValue();
assertThat(firstLinearRing.getCoordinates().getValue(), is("30.0,20.0 10.0,40.0 45.0,40.0 30.0,20.0"));
}
use of net.opengis.gml._3.LinearRingType 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");
}
}
Aggregations