use of net.opengis.gml.x32.PolygonType in project ddf by codice.
the class WfsFilterDelegate method createPolygon.
private JAXBElement<PolygonType> createPolygon(String wkt) {
PolygonType polygon = new PolygonType();
LinearRingType linearRing = new LinearRingType();
Coordinate[] coordinates = getCoordinatesFromWkt(wkt);
if (coordinates != null && coordinates.length > 0) {
StringBuffer coordString = new StringBuffer();
for (Coordinate coordinate : coordinates) {
coordString.append(coordinate.x).append(",").append(coordinate.y).append(" ");
}
CoordinatesType coordinatesType = new CoordinatesType();
coordinatesType.setValue(coordString.toString());
coordinatesType.setDecimal(".");
coordinatesType.setCs(",");
coordinatesType.setTs(" ");
linearRing.setCoordinates(coordinatesType);
LinearRingMemberType member = new LinearRingMemberType();
member.setGeometry(gmlObjectFactory.createLinearRing(linearRing));
polygon.setOuterBoundaryIs(member);
polygon.setSrsName(srsName);
return gmlObjectFactory.createPolygon(polygon);
} else {
throw new IllegalArgumentException("Unable to parse Polygon coordinates from WKT String");
}
}
use of net.opengis.gml.x32.PolygonType 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();
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);
}
// Interior ring
int numberOfInteriorRings = pol.getNumInteriorRing();
for (int ringNumber = 0; ringNumber < numberOfInteriorRings; ringNumber++) {
xbArpt = xbPolType.addNewInterior();
xbArt = xbArpt.addNewAbstractRing();
xbLrt = LinearRingType.Factory.newInstance();
ring = pol.getInteriorRingN(ringNumber);
xbPosList = xbLrt.addNewPosList();
xbPosList.setSrsName(srsName);
xbPosList.setStringValue(JTSHelper.getCoordinatesString(ring));
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);
}
}
}
}
use of net.opengis.gml.x32.PolygonType in project arctic-sea by 52North.
the class GmlEncoderv321 method createPosition.
private XmlObject createPosition(Geometry geom, EncodingContext ctx) throws EncodingException {
String foiId = ctx.<String>get(XmlBeansEncodingFlags.GMLID).orElse(null);
if (geom instanceof Point) {
PointType xbPoint = PointType.Factory.newInstance(getXmlOptions());
xbPoint.setId(getGmlID(geom, foiId));
createPointFromJtsGeometry((Point) geom, xbPoint);
if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
PointDocument xbPointDoc = PointDocument.Factory.newInstance(getXmlOptions());
xbPointDoc.setPoint(xbPoint);
return xbPointDoc;
} else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
geometryPropertyType.setAbstractGeometry(xbPoint);
geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_POINT_32, PointType.type);
return geometryPropertyType;
}
return xbPoint;
} else if (geom instanceof LineString) {
LineStringType xbLineString = LineStringType.Factory.newInstance(getXmlOptions());
xbLineString.setId(getGmlID(geom, foiId));
createLineStringFromJtsGeometry((LineString) geom, xbLineString);
if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
LineStringDocument xbLineStringDoc = LineStringDocument.Factory.newInstance(getXmlOptions());
xbLineStringDoc.setLineString(xbLineString);
return xbLineStringDoc;
} else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
geometryPropertyType.setAbstractGeometry(xbLineString);
geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_LINESTRING_32, LineStringType.type);
return geometryPropertyType;
}
return xbLineString;
} else if (geom instanceof MultiLineString) {
MultiCurveType xbMultiCurve = MultiCurveType.Factory.newInstance(getXmlOptions());
xbMultiCurve.setId(getGmlID(geom, foiId));
xbMultiCurve.setSrsName(getSrsName(geom));
for (int i = 0; i < geom.getNumGeometries(); ++i) {
Geometry lineString = geom.getGeometryN(i);
LineStringType xbLineString = LineStringType.Factory.newInstance(getXmlOptions());
xbLineString.setId(getGmlID(geom, foiId));
xbLineString.addNewPosList().setStringValue(JTSHelper.getCoordinatesString(lineString));
CurvePropertyType xbCurveMember = xbMultiCurve.addNewCurveMember();
xbCurveMember.addNewAbstractCurve().set(xbLineString);
XmlHelper.substituteElement(xbCurveMember.getAbstractCurve(), xbLineString);
}
if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
MultiCurveDocument xbMultiCurveDoc = MultiCurveDocument.Factory.newInstance(getXmlOptions());
xbMultiCurveDoc.setMultiCurve(xbMultiCurve);
return xbMultiCurveDoc;
} else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
GeometryPropertyType xbGeometryProperty = GeometryPropertyType.Factory.newInstance(getXmlOptions());
xbGeometryProperty.addNewAbstractGeometry().set(xbMultiCurve);
XmlHelper.substituteElement(xbGeometryProperty.getAbstractGeometry(), xbMultiCurve);
return xbGeometryProperty;
} else {
return xbMultiCurve;
}
} else if (geom instanceof Polygon) {
PolygonType xbPolygon = PolygonType.Factory.newInstance(getXmlOptions());
xbPolygon.setId(getGmlID(geom, foiId));
createPolygonFromJtsGeometry((Polygon) geom, xbPolygon);
if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
PolygonDocument xbPolygonDoc = PolygonDocument.Factory.newInstance(getXmlOptions());
xbPolygonDoc.setPolygon(xbPolygon);
return xbPolygonDoc;
} else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
geometryPropertyType.setAbstractGeometry(xbPolygon);
geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_POLYGON_32, PolygonType.type);
return geometryPropertyType;
}
return xbPolygon;
} else if (geom instanceof MultiPoint) {
MultiPointType xbMultiPoint = MultiPointType.Factory.newInstance(getXmlOptions());
String id = getGmlID(geom, foiId);
xbMultiPoint.setId(id);
createMultiPointFromJtsGeometry((MultiPoint) geom, xbMultiPoint, id);
if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
MultiPointDocument xbMultiPointDoc = MultiPointDocument.Factory.newInstance(getXmlOptions());
xbMultiPointDoc.setMultiPoint(xbMultiPoint);
return xbMultiPointDoc;
} else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
geometryPropertyType.setAbstractGeometry(xbMultiPoint);
geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_MULTI_POINT_32, PolygonType.type);
return geometryPropertyType;
}
return xbMultiPoint;
} else {
throw new UnsupportedEncoderInputException(this, geom);
}
}
use of net.opengis.gml.x32.PolygonType 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 net.opengis.gml.x32.PolygonType in project ddf by codice.
the class Wfs20JTStoGML321Converter method convertToMultiSurfaceType.
/**
* Converts a @link com.vividsolutions.jts.geom.MultiPolygon to a @link net.opengis.gml.v_3_2_1.MultiSurfaceType
* Note: MultiPolygon maps to gml MultiSurfaceType
*
* @param multiPolygon
* @return MultiSurfaceType
*/
public static MultiSurfaceType convertToMultiSurfaceType(MultiPolygon multiPolygon, String srsName) {
MultiSurfaceType multiSurfaceType = GML320_OBJECT_FACTORY.createMultiSurfaceType();
for (int i = 0; i < multiPolygon.getNumGeometries(); i++) {
Polygon poly = (Polygon) multiPolygon.getGeometryN(i);
PolygonType polygonType = convertToPolygonType(poly, srsName);
JAXBElement<PolygonType> polygonTypeJAXBElement = GML320_OBJECT_FACTORY.createPolygon(polygonType);
SurfacePropertyType surfacePropertyType = GML320_OBJECT_FACTORY.createSurfacePropertyType();
surfacePropertyType.setAbstractSurface(polygonTypeJAXBElement);
multiSurfaceType.getSurfaceMember().add(surfacePropertyType);
}
multiSurfaceType.setSrsName(srsName);
return multiSurfaceType;
}
Aggregations