use of net.opengis.gml._3.LinearRingType 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 net.opengis.gml._3.LinearRingType in project arctic-sea by 52North.
the class GmlDecoderv321 method parsePolygonType.
private Geometry parsePolygonType(PolygonType xbPolygonType) throws DecodingException {
int srid = -1;
if (xbPolygonType.getSrsName() != null) {
srid = CRSHelper.parseSrsName(xbPolygonType.getSrsName());
}
String exteriorCoordString = null;
StringBuilder geomWKT = new StringBuilder();
StringBuilder interiorCoordString = new StringBuilder();
AbstractRingPropertyType xbExterior = xbPolygonType.getExterior();
if (xbExterior != null) {
AbstractRingType xbExteriorRing = xbExterior.getAbstractRing();
if (xbExteriorRing instanceof LinearRingType) {
LinearRingType xbLinearRing = (LinearRingType) xbExteriorRing;
exteriorCoordString = getCoordString4LinearRing(xbLinearRing);
} else {
throw new DecodingException("The Polygon must contain the following elements <gml:exterior><gml:LinearRing><gml:posList>!");
}
}
AbstractRingPropertyType[] xbInterior = xbPolygonType.getInteriorArray();
if (xbInterior != null && xbInterior.length != 0) {
for (AbstractRingPropertyType xbInteriorRing : xbInterior) {
if (xbInteriorRing.getAbstractRing() instanceof LinearRingType) {
interiorCoordString.append(", ").append(getCoordString4LinearRing((LinearRingType) xbInteriorRing.getAbstractRing()));
}
}
}
geomWKT.append("POLYGON(");
geomWKT.append(exteriorCoordString);
geomWKT.append(interiorCoordString);
geomWKT.append(")");
srid = setDefaultForUnsetSrid(srid);
try {
return JTSHelper.createGeometryFromWKT(geomWKT.toString(), srid);
} catch (ParseException ex) {
throw new DecodingException(ex);
}
}
use of net.opengis.gml._3.LinearRingType in project geo-platform by geosdi.
the class GMLLinearRingGeoJsonParserTest method linearRingGeoJsonParserTest.
@Test
public void linearRingGeoJsonParserTest() throws Exception {
LinearRingType linearRingType = jaxbContextBuilder.unmarshal(new File(dirFiles.concat("LinearRing.xml")), LinearRingType.class);
logger.info("#######################LINEAR_RING_AS_GEOJSON : \n{}\n", mapper.writeValueAsString(linearRingParser.parseGeometryAsGeoJson(linearRingType)));
}
use of net.opengis.gml._3.LinearRingType in project geotoolkit by Geomatys.
the class GeometrytoJTSTest method gmlPolygonToJTSTest2D.
@Test
public void gmlPolygonToJTSTest2D() throws Exception {
GeometryFactory fact = GF;
final Coordinate[] coordinates = new Coordinate[5];
coordinates[0] = new Coordinate(0, 0);
coordinates[1] = new Coordinate(0, 1);
coordinates[2] = new Coordinate(1, 1);
coordinates[3] = new Coordinate(1, 0);
coordinates[4] = new Coordinate(0, 0);
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(0.0);
coords.add(1.0);
coords.add(1.0);
coords.add(1.0);
coords.add(1.0);
coords.add(0.0);
coords.add(0.0);
coords.add(0.0);
exterior.setPosList(new DirectPositionListType(coords));
PolygonType gml = new PolygonType(exterior, null);
final Geometry result = GeometrytoJTS.toJTS((org.geotoolkit.gml.xml.Polygon) gml);
Assert.assertEquals(expected, result);
}
use of net.opengis.gml._3.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());
}
Aggregations