use of net.opengis.gml.x32.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.x32.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.x32.LinearRingType in project arctic-sea by 52North.
the class GmlDecoderv321 method getCoordString4LinearRing.
/**
* method parses the passed linearRing(generated thru XmlBEans) and returns a string containing the coordinate
* values of the passed ring
*
* @param xbLinearRing linearRing(generated thru XmlBEans)
*
* @return Returns a string containing the coordinate values of the passed ring
*
* @throws DecodingException * if parsing the linear Ring failed
*/
private String getCoordString4LinearRing(LinearRingType xbLinearRing) throws DecodingException {
String result = "";
DirectPositionListType xbPosList = xbLinearRing.getPosList();
CoordinatesType xbCoordinates = xbLinearRing.getCoordinates();
DirectPositionType[] xbPosArray = xbLinearRing.getPosArray();
if (xbPosList != null && !(xbPosList.getStringValue().isEmpty())) {
result = getString4PosList(xbPosList);
} else if (xbCoordinates != null && !(xbCoordinates.getStringValue().isEmpty())) {
result = getString4Coordinates(xbCoordinates);
} else if (xbPosArray != null && xbPosArray.length > 0) {
result = getString4PosArray(xbPosArray, true);
} else {
throw new DecodingException("The Polygon must contain the following elements " + "<gml:exterior><gml:LinearRing><gml:posList>, " + "<gml:exterior><gml:LinearRing><gml:coordinates> " + "or <gml:exterior><gml:LinearRing><gml:pos>{<gml:pos>}!");
}
return result;
}
use of net.opengis.gml.x32.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);
}
}
Aggregations