use of org.geotoolkit.gml.xml.v321.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");
}
}
use of org.geotoolkit.gml.xml.v321.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 org.geotoolkit.gml.xml.v321.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 org.geotoolkit.gml.xml.v321.LinearRingType in project tiamat by entur.
the class TopographicPlaceImportTest method publicationDeliveryWithTopographicPlaceAndPolygon.
@Test
public void publicationDeliveryWithTopographicPlaceAndPolygon() 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(9.8443);
values.add(59.2663);
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)));
MultilingualString nameDescriptor = new MultilingualString().withValue("Vestfold").withLang("nb");
TopographicPlace topographicPlace = new TopographicPlace().withId("KVE:TopographicPlace:07").withName(nameDescriptor).withVersion("1").withDescriptor(new TopographicPlaceDescriptor_VersionedChildStructure().withName(nameDescriptor)).withTopographicPlaceType(TopographicPlaceTypeEnumeration.COUNTY).withCountryRef(new CountryRef().withValue("NO")).withPolygon(polygonType);
PublicationDeliveryStructure publicationDelivery = publicationDeliveryTestHelper.createPublicationDeliveryTopographicPlace(topographicPlace);
PublicationDeliveryStructure response = publicationDeliveryTestHelper.postAndReturnPublicationDelivery(publicationDelivery);
List<TopographicPlace> result = publicationDeliveryTestHelper.extractTopographicPlace(response);
assertThat(result).as("Expecting topographic place in return").hasSize(1);
TopographicPlace actualTopographicPlace = result.get(0);
assertThat(actualTopographicPlace.getPolygon()).as("polygon must not be null").isNotNull();
List<Double> actualExteriorValues = polygonConverter.extractValues(topographicPlace.getPolygon().getExterior());
assertThat(actualExteriorValues).isEqualTo(values);
assertThat(actualTopographicPlace.getId()).isEqualTo(topographicPlace.getId());
}
use of org.geotoolkit.gml.xml.v321.LinearRingType in project tiamat by entur.
the class PolygonConverterTest method convertFrom.
@Test
public void convertFrom() 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)));
Polygon polygon = polygonConverter.convertFrom(polygonType, new TypeBuilder<Polygon>() {
}.build(), new MappingContext(new HashMap<>()));
assertThat(polygon).isExactlyInstanceOf(Polygon.class).isNotNull();
assertThat(polygon.getExteriorRing().getCoordinates()).hasSize(values.size() / 2);
assertCoordinatesMatch(polygon.getExteriorRing(), values, "Exterior ring");
}
Aggregations