use of org.geosdi.geoplatform.xml.gml.v311.LinearRingType 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 org.geosdi.geoplatform.xml.gml.v311.LinearRingType 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"));
}
use of org.geosdi.geoplatform.xml.gml.v311.LinearRingType in project arctic-sea by 52North.
the class GmlEncoderv321 method createPolygonFromJtsGeometry.
/**
* Creates a XML Polygon from a SOS Polygon.
*
* @param jtsPolygon
* SOS Polygon
* @param xbPolType
* XML Polygon
*/
private void createPolygonFromJtsGeometry(Polygon jtsPolygon, PolygonType xbPolType) {
List<?> jtsPolygons = PolygonExtracter.getPolygons(jtsPolygon);
String srsName = getSrsName(jtsPolygon);
for (int i = 0; i < jtsPolygons.size(); i++) {
Polygon pol = (Polygon) jtsPolygons.get(i);
AbstractRingPropertyType xbArpt = xbPolType.addNewExterior();
AbstractRingType xbArt = xbArpt.addNewAbstractRing();
LinearRingType xbLrt = LinearRingType.Factory.newInstance();
// Exterior ring
// LineString ring = pol.getExteriorRing();
Coordinate[] ring = JTSHelper.getExteriorRingCoordinatesFromPolygon(pol);
DirectPositionListType xbPosList = xbLrt.addNewPosList();
xbPosList.setSrsName(srsName);
xbPosList.setStringValue(JTSHelper.getCoordinatesString(ring));
xbArt.set(xbLrt);
// Rename element name for output
XmlCursor cursor = xbArpt.newCursor();
if (cursor.toChild(GmlConstants.QN_ABSTRACT_RING_32)) {
cursor.setName(GmlConstants.QN_LINEAR_RING_32);
}
cursor.dispose();
// Interior ring
int numberOfInteriorRings = pol.getNumInteriorRing();
for (int ringNumber = 0; ringNumber < numberOfInteriorRings; ringNumber++) {
xbArpt = xbPolType.addNewInterior();
xbArt = xbArpt.addNewAbstractRing();
xbLrt = LinearRingType.Factory.newInstance();
xbPosList = xbLrt.addNewPosList();
xbPosList.setSrsName(srsName);
xbPosList.setStringValue(JTSHelper.getCoordinatesString(pol.getInteriorRingN(ringNumber)));
xbArt.set(xbLrt);
// Rename element name for output
cursor = xbArpt.newCursor();
if (cursor.toChild(GmlConstants.QN_ABSTRACT_RING_32)) {
cursor.setName(GmlConstants.QN_LINEAR_RING_32);
}
cursor.dispose();
}
}
}
use of org.geosdi.geoplatform.xml.gml.v311.LinearRingType in project geotoolkit by Geomatys.
the class GeometrytoJTSTest method gmlPolygonToJTSTest3D.
@Test
public void gmlPolygonToJTSTest3D() throws Exception {
GeometryFactory fact = GF;
final Coordinate[] coordinates = new Coordinate[5];
coordinates[0] = new Coordinate(0, 0, 1);
coordinates[1] = new Coordinate(0, 1, 1);
coordinates[2] = new Coordinate(1, 1, 1);
coordinates[3] = new Coordinate(1, 0, 1);
coordinates[4] = new Coordinate(0, 0, 1);
LinearRing linear = GF.createLinearRing(coordinates);
Polygon expected = new Polygon(linear, null, fact);
expected.setSRID(2154);
LinearRingType exterior = new LinearRingType();
List<Double> coords = new ArrayList<>();
coords.add(0.0);
coords.add(0.0);
coords.add(1.0);
coords.add(0.0);
coords.add(1.0);
coords.add(1.0);
coords.add(1.0);
coords.add(1.0);
coords.add(1.0);
coords.add(1.0);
coords.add(0.0);
coords.add(1.0);
coords.add(0.0);
coords.add(0.0);
coords.add(1.0);
exterior.setPosList(new DirectPositionListType(coords));
exterior.setSrsDimension(3);
PolygonType gml = new PolygonType(exterior, null);
final Geometry result = GeometrytoJTS.toJTS((org.geotoolkit.gml.xml.Polygon) gml);
Assert.assertEquals(expected, result);
}
use of org.geosdi.geoplatform.xml.gml.v311.LinearRingType in project tiamat by entur.
the class PolygonConverterTest method convertFromWithHoles.
@Test
public void convertFromWithHoles() throws Exception {
List<Double> values = new ArrayList<>();
values.add(9.8468);
values.add(59.2649);
values.add(9.8456);
values.add(59.2654);
values.add(9.8457);
values.add(59.2655);
values.add(values.get(0));
values.add(values.get(1));
DirectPositionListType positionList = new DirectPositionListType().withValue(values);
LinearRingType linearRing = new LinearRingType().withPosList(positionList);
PolygonType polygonType = new PolygonType().withId("KVE-07").withExterior(new AbstractRingPropertyType().withAbstractRing(openGisObjectFactory.createLinearRing(linearRing))).withInterior(new AbstractRingPropertyType().withAbstractRing(openGisObjectFactory.createLinearRing(linearRing)));
Polygon polygon = polygonConverter.convertFrom(polygonType, new TypeBuilder<Polygon>() {
}.build(), new MappingContext(new HashMap<>()));
assertThat(polygon).isNotNull();
assertThat(polygon.getExteriorRing().getCoordinates()).hasSize(values.size() / 2);
assertThat(polygon.getNumInteriorRing()).isEqualTo(1);
assertCoordinatesMatch(polygon.getExteriorRing(), values, "Exterior ring");
assertInteriorRingsMatch(polygon, Arrays.asList(values));
}
Aggregations