use of org.geosdi.geoplatform.xml.gml.v311.PolygonType in project geo-platform by geosdi.
the class GMLPolygonGeoJsonParserTest method a_polygonGeoJsonParserTest.
@Test
public void a_polygonGeoJsonParserTest() throws Exception {
PolygonType polygonType = jaxbContextBuilder.unmarshal(new File(dirFiles.concat("Polygon.xml")), PolygonType.class);
Polygon polygon = polygonParser.parseGeometryAsGeoJson(polygonType);
List<List<LngLatAlt>> interiorRings = polygon.getInteriorRings();
assertNotNull(interiorRings);
Assert.assertTrue(interiorRings.size() == 2);
logger.info("#######################POLYGON_AS_GEOJSON : \n{}\n", mapper.writeValueAsString(polygon));
}
use of org.geosdi.geoplatform.xml.gml.v311.PolygonType in project geo-platform by geosdi.
the class GMLPolygonGeoJsonParserTest method b_polygonGeoJsonParserTest.
@Test
public void b_polygonGeoJsonParserTest() throws Exception {
PolygonType polygonType = jaxbContextBuilder.unmarshal(new File(dirFiles.concat("Polygon_1.xml")), PolygonType.class);
Polygon polygon = polygonParser.parseGeometryAsGeoJson(polygonType);
Assert.assertTrue(polygon.getInteriorRings().size() == 0);
logger.info("#######################POLYGON1_AS_GEOJSON : \n{}\n", mapper.writeValueAsString(polygon));
}
use of org.geosdi.geoplatform.xml.gml.v311.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 org.geosdi.geoplatform.xml.gml.v311.PolygonType in project tiamat by entur.
the class PolygonConverter method convertFrom.
@Override
public Polygon convertFrom(PolygonType polygonType, Type<Polygon> type, MappingContext mappingContext) {
Optional<List<Double>> optionalExteriorValues = Optional.ofNullable(polygonType).map(PolygonType::getExterior).map(this::extractValues);
Optional<List<List<Double>>> interiorValues = Optional.ofNullable(polygonType).map(PolygonType::getInterior).map(list -> list.stream().map(this::extractValues).collect(Collectors.toList())).filter(list -> !list.isEmpty());
if (optionalExteriorValues.isPresent()) {
List<Double> exteriorValues = optionalExteriorValues.get();
CoordinateSequence exteriorCoordinateSequence = doubleValuesToCoordinateSequence.convert(exteriorValues);
LinearRing exteriorLinearRing = new LinearRing(exteriorCoordinateSequence, geometryFactory);
LinearRing[] interiorHoles = null;
if (interiorValues.isPresent()) {
interiorHoles = interiorValues.get().stream().map(doubleValuesToCoordinateSequence::convert).map(coordinateSequence -> new LinearRing(coordinateSequence, geometryFactory)).toArray(size -> new LinearRing[size]);
}
return new Polygon(exteriorLinearRing, interiorHoles, geometryFactory);
}
logger.warn("Cannot convert polygon from PolygonType. Cannot find exterior values: {}", polygonType);
return null;
}
use of org.geosdi.geoplatform.xml.gml.v311.PolygonType 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());
}
Aggregations