Search in sources :

Example 11 with DirectPositionType

use of org.geotoolkit.gml.xml.v321.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();
}
Also used : DirectPositionType(net.opengis.gml.x32.DirectPositionType)

Example 12 with DirectPositionType

use of org.geotoolkit.gml.xml.v321.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;
}
Also used : EnvelopeType(org.geosdi.geoplatform.xml.gml.v311.EnvelopeType) DirectPositionType(org.geosdi.geoplatform.xml.gml.v311.DirectPositionType)

Example 13 with DirectPositionType

use of org.geotoolkit.gml.xml.v321.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;
}
Also used : FilterType(org.geosdi.geoplatform.xml.filter.v110.FilterType) EnvelopeType(org.geosdi.geoplatform.xml.gml.v311.EnvelopeType) BBOXType(org.geosdi.geoplatform.xml.filter.v110.BBOXType) DirectPositionType(org.geosdi.geoplatform.xml.gml.v311.DirectPositionType) ObjectFactory(org.geosdi.geoplatform.xml.gml.v311.ObjectFactory) BBox(org.geosdi.geoplatform.gui.shared.bean.BBox) PropertyNameType(org.geosdi.geoplatform.xml.filter.v110.PropertyNameType)

Example 14 with DirectPositionType

use of org.geotoolkit.gml.xml.v321.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;
}
Also used : EnvelopeType(org.geotoolkit.gml.xml.v311.EnvelopeType) GridEnvelopeType(org.geotoolkit.gml.xml.v311.GridEnvelopeType) DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) GeneralEnvelope(org.apache.sis.geometry.GeneralEnvelope)

Example 15 with DirectPositionType

use of org.geotoolkit.gml.xml.v321.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;
    }
}
Also used : DirectPositionType(org.geotoolkit.gml.xml.v311.DirectPositionType) VerticalCRS(org.opengis.referencing.crs.VerticalCRS) GeodeticObjectBuilder(org.apache.sis.internal.referencing.GeodeticObjectBuilder) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem)

Aggregations

DirectPositionType (org.geotoolkit.gml.xml.v311.DirectPositionType)24 ArrayList (java.util.ArrayList)14 PointType (org.geotoolkit.gml.xml.v311.PointType)14 Test (org.junit.Test)11 StringWriter (java.io.StringWriter)10 DirectPositionType (net.opengis.gml.v_3_1_1.DirectPositionType)10 DirectPositionType (org.geotoolkit.gml.xml.v321.DirectPositionType)10 EnvelopeType (org.geotoolkit.gml.xml.v311.EnvelopeType)9 StringReader (java.io.StringReader)8 JAXBElement (javax.xml.bind.JAXBElement)8 EnvelopeType (net.opengis.gml.v_3_1_1.EnvelopeType)7 Geometry (org.locationtech.jts.geom.Geometry)7 Coordinate (org.locationtech.jts.geom.Coordinate)6 BBOXType (net.opengis.filter.v_1_1_0.BBOXType)5 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)5 DirectPositionType (net.opengis.gml.x32.DirectPositionType)4 FeaturePropertyType (org.geotoolkit.gml.xml.v311.FeaturePropertyType)4 SamplingPointType (org.geotoolkit.sampling.xml.v100.SamplingPointType)4 FilterType (net.opengis.filter.v_1_1_0.FilterType)3 DirectPositionType (net.opengis.gml.v_3_2_1.DirectPositionType)3