use of org.geotoolkit.gml.xml.v311.CoordinatesType 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.v311.CoordinatesType in project arctic-sea by 52North.
the class GmlDecoderv321 method parsePointType.
private Geometry parsePointType(PointType xbPointType) throws DecodingException {
String geomWKT = null;
int srid = -1;
if (xbPointType.getSrsName() != null) {
srid = CRSHelper.parseSrsName(xbPointType.getSrsName());
}
if (xbPointType.getPos() != null) {
DirectPositionType xbPos = xbPointType.getPos();
if (srid == -1 && xbPos.getSrsName() != null) {
srid = CRSHelper.parseSrsName(xbPos.getSrsName());
}
String directPosition = getString4Pos(xbPos);
geomWKT = "POINT(" + directPosition + ")";
} else if (xbPointType.getCoordinates() != null) {
CoordinatesType xbCoords = xbPointType.getCoordinates();
String directPosition = getString4Coordinates(xbCoords);
geomWKT = "POINT" + directPosition;
} else {
throw new DecodingException("For geometry type 'gml:Point' only element " + "'gml:pos' and 'gml:coordinates' are allowed " + "in the feature of interest parameter!");
}
srid = setDefaultForUnsetSrid(srid);
try {
return JTSHelper.createGeometryFromWKT(geomWKT, srid);
} catch (ParseException ex) {
throw new DecodingException(ex);
}
}
use of org.geotoolkit.gml.xml.v311.CoordinatesType 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 org.geotoolkit.gml.xml.v311.CoordinatesType in project geotoolkit by Geomatys.
the class FilterFactoryImpl method GeometryToGML.
/**
* Transform a JTS geometric object into a GML marshallable object
*/
public Object GeometryToGML(final Object geom) {
Object result = null;
if (geom instanceof Polygon) {
final Polygon p = (Polygon) geom;
final Coordinate[] coord = p.getCoordinates();
// an envelope
if (coord.length == 5) {
final DirectPositionType lowerCorner = new DirectPositionType(coord[0].y, coord[0].x);
final DirectPositionType upperCorner = new DirectPositionType(coord[2].y, coord[2].x);
result = new EnvelopeType(null, lowerCorner, upperCorner, "EPSG:4326");
}
} else if (geom instanceof Point) {
final Point p = (Point) geom;
final Coordinate[] coord = p.getCoordinates();
result = new PointType(null, new DirectPositionType(coord[0].x, coord[0].y, coord[0].z));
((PointType) result).setSrsName("EPSG:4326");
} else if (geom instanceof LineString) {
final LineString ls = (LineString) geom;
final Coordinate[] coord = ls.getCoordinates();
result = new LineStringType(new CoordinatesType(coord[0].x + "," + coord[0].y + " " + coord[1].x + "," + coord[1].y));
((LineStringType) result).setSrsName("EPSG:4326");
} else {
LOGGER.severe("unable to create GML geometry with: " + geom.getClass().getSimpleName());
}
return result;
}
Aggregations