use of org.geotoolkit.gml.xml.v311.DirectPositionType in project arctic-sea by 52North.
the class GmlDecoderv321 method getString4PosArray.
/**
* parses XmlBeans DirectPosition[] to a String with coordinates for WKT.
*
* @param xbPosArray XmlBeans generated DirectPosition[].
*
* @return Returns String with coordinates for WKT.
*/
private String getString4PosArray(DirectPositionType[] xbPosArray, boolean polygon) {
StringBuilder coordinateString = new StringBuilder();
coordinateString.append("(");
for (DirectPositionType directPositionType : xbPosArray) {
coordinateString.append(directPositionType.getStringValue());
coordinateString.append(", ");
}
if (polygon && !xbPosArray[0].getStringValue().equalsIgnoreCase(xbPosArray[xbPosArray.length - 1].getStringValue())) {
coordinateString.append(xbPosArray[0].getStringValue());
} else {
coordinateString.delete(coordinateString.length() - 2, coordinateString.length());
}
coordinateString.append(")");
return coordinateString.toString();
}
use of org.geotoolkit.gml.xml.v311.DirectPositionType in project geo-platform by geosdi.
the class WFSGetFeatureRequestV110 method createEnvelope.
/**
* @param bbox
* @return {@link EnvelopeType}
*/
private EnvelopeType createEnvelope(BBox bbox) {
EnvelopeType envelope = new EnvelopeType();
DirectPositionType lower = new DirectPositionType();
lower.setValue(asList(bbox.getMinX(), bbox.getMinY()));
envelope.setLowerCorner(lower);
DirectPositionType upper = new DirectPositionType();
upper.setValue(asList(bbox.getMaxX(), bbox.getMaxY()));
envelope.setUpperCorner(upper);
return envelope;
}
use of org.geotoolkit.gml.xml.v311.DirectPositionType in project geo-platform by geosdi.
the class QueryRestrictionsBuilderTest method createFilterType.
/**
* @return {@link FilterType}
*/
private FilterType createFilterType() {
FilterType filter = new FilterType();
BBox bbox = new BBox(14.131237640976908, 36.56356461583572, 15.821758881211283, 37.143760728459014);
BBOXType bBoxType = new BBOXType();
PropertyNameType propertyNameType = new PropertyNameType();
propertyNameType.setContent(Arrays.asList("the_geom"));
bBoxType.setPropertyName(propertyNameType);
EnvelopeType envelope = new EnvelopeType();
DirectPositionType lower = new DirectPositionType();
lower.setValue(asList(bbox.getMinX(), bbox.getMinY()));
envelope.setLowerCorner(lower);
DirectPositionType upper = new DirectPositionType();
upper.setValue(asList(bbox.getMaxX(), bbox.getMaxY()));
envelope.setUpperCorner(upper);
envelope.setSrsName("EPSG:4326");
bBoxType.setEnvelope(new ObjectFactory().createEnvelope(envelope));
filter.setSpatialOps(new org.geosdi.geoplatform.xml.filter.v110.ObjectFactory().createBBOX(bBoxType));
return filter;
}
use of org.geotoolkit.gml.xml.v311.DirectPositionType in project geotoolkit by Geomatys.
the class GetCoverageType method getEnvelope.
/**
* {@inheritDoc}
*/
@Override
public Envelope getEnvelope() throws FactoryException {
if (domainSubset == null || domainSubset.getSpatialSubSet() == null || domainSubset.getSpatialSubSet().getEnvelope() == null) {
return null;
}
final EnvelopeType env = domainSubset.getSpatialSubSet().getEnvelope();
final List<DirectPositionType> positions = env.getPos();
if (positions == null || positions.isEmpty()) {
return null;
}
final DirectPositionType lows = positions.get(0);
final DirectPositionType highs = positions.get(1);
final CoordinateReferenceSystem crs = getCRS();
final GeneralEnvelope objEnv = new GeneralEnvelope(crs);
objEnv.setRange(0, lows.getValue().get(0), highs.getValue().get(0));
objEnv.setRange(1, lows.getValue().get(1), highs.getValue().get(1));
// If the CRS has a vertical part, then the envelope to return should be a 3D one.
if (CRS.getVerticalComponent(crs, true) != null) {
objEnv.setRange(2, lows.getValue().get(2), highs.getValue().get(2));
}
return objEnv;
}
use of org.geotoolkit.gml.xml.v311.DirectPositionType in project geotoolkit by Geomatys.
the class GetCoverageType method getResponseCRS.
/**
* {@inheritDoc}
*/
@Override
public CoordinateReferenceSystem getResponseCRS() throws FactoryException {
if (output == null || output.getCrs() == null || output.getCrs().getValue() == null) {
return null;
}
final CoordinateReferenceSystem objCrs = CRS.forCode(output.getCrs().getValue());
final List<DirectPositionType> positions = domainSubset.getSpatialSubSet().getEnvelope().getPos();
/*
* If the bounding box contains at least 3 dimensions and the CRS specified is just
* a 2D one, then we have to add a VerticalCRS to the one gotten by the crs decoding step.
* Otherwise the CRS decoded is already fine, and we just return it.
*/
if (positions.get(0).getDimension() > 2 && objCrs.getCoordinateSystem().getDimension() < 3) {
final VerticalCRS verticalCRS = CommonCRS.Vertical.ELLIPSOIDAL.crs();
return new GeodeticObjectBuilder().addName(objCrs.getName().getCode() + " (3D)").createCompoundCRS(objCrs, verticalCRS);
} else {
return objCrs;
}
}
Aggregations