Search in sources :

Example 1 with CoordType

use of org.geotoolkit.gml.xml.v212.CoordType in project ddf by codice.

the class CswQueryFactoryTest method createPolygon.

private JAXBElement<AbstractGeometryType> createPolygon() {
    PolygonType localPolygon = new PolygonType();
    LinearRingType ring = new LinearRingType();
    for (Coordinate coordinate : polygon.getCoordinates()) {
        CoordType coord = new CoordType();
        coord.setX(BigDecimal.valueOf(coordinate.x));
        coord.setY(BigDecimal.valueOf(coordinate.y));
        if (!Double.isNaN(coordinate.z)) {
            coord.setZ(BigDecimal.valueOf(coordinate.z));
        }
        ring.getCoord().add(coord);
    }
    AbstractRingPropertyType abstractRing = new AbstractRingPropertyType();
    abstractRing.setRing(gmlObjectFactory.createLinearRing(ring));
    localPolygon.setExterior(gmlObjectFactory.createExterior(abstractRing));
    JAXBElement<AbstractGeometryType> agt = new JAXBElement<>(new QName("http://www.opengis.net/gml", "Polygon"), AbstractGeometryType.class, null, localPolygon);
    return agt;
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) AbstractGeometryType(net.opengis.gml.v_3_1_1.AbstractGeometryType) LinearRingType(net.opengis.gml.v_3_1_1.LinearRingType) AbstractRingPropertyType(net.opengis.gml.v_3_1_1.AbstractRingPropertyType) QName(javax.xml.namespace.QName) PolygonType(net.opengis.gml.v_3_1_1.PolygonType) JAXBElement(javax.xml.bind.JAXBElement) CoordType(net.opengis.gml.v_3_1_1.CoordType)

Example 2 with CoordType

use of org.geotoolkit.gml.xml.v212.CoordType in project geotoolkit by Geomatys.

the class FilterToOGC100Converter method toBox.

/**
 * Analyze given literal and try to transform it into GML 2 bbox. The
 * conversion is possible only if the given literal contains an
 * {@link Envelope} or a {@link GeographicBoundingBox}.
 *
 * @param input The literal to extract a bbox from.
 * @return Built bbox, never null.
 * @throws IllegalArgumentException If given literal does not contain any
 * usable envelope. Note that an envelope cannot be used if its dimension is
 * more than 2D and no CRS is present to allow us to find horizontal piece.
 */
private static BoxType toBox(final Literal input) throws IllegalArgumentException {
    final Object val = input.getValue();
    if (val == null) {
        throw new IllegalArgumentException("No value in input literal object. Conversion to BoxType impossible");
    }
    final BoxType bType = new BoxType();
    CoordinateReferenceSystem boxCrs = null;
    if (val instanceof Envelope) {
        final Envelope env = (Envelope) val;
        boxCrs = env.getCoordinateReferenceSystem();
        final int xAxis;
        if (env.getDimension() == 2) {
            xAxis = 0;
        } else if (env.getDimension() > 2) {
            if (boxCrs == null) {
                throw new IllegalArgumentException("Cannot find horizontal axis of given envelope");
            }
            final SingleCRS hCrs = CRS.getHorizontalComponent(boxCrs);
            if (hCrs == null) {
                throw new IllegalArgumentException("Cannot find horizontal axis of given envelope");
            }
            xAxis = AxisDirections.indexOfColinear(boxCrs.getCoordinateSystem(), hCrs.getCoordinateSystem());
            boxCrs = hCrs;
        } else
            throw new IllegalArgumentException(String.format("Given envelope has not enough dimension. Cannot build a bbox from it.%nExpected: %d%nBut was: %d", 2, env.getDimension()));
        final int yAxis = xAxis + 1;
        bType.getCoord().add(new CoordType(env.getMinimum(xAxis), env.getMinimum(yAxis)));
        bType.getCoord().add(new CoordType(env.getMaximum(xAxis), env.getMaximum(yAxis)));
    } else if (val instanceof GeographicBoundingBox) {
        final GeographicBoundingBox e = (GeographicBoundingBox) val;
        bType.getCoord().add(new CoordType(e.getWestBoundLongitude(), e.getSouthBoundLatitude()));
        bType.getCoord().add(new CoordType(e.getEastBoundLongitude(), e.getNorthBoundLatitude()));
        boxCrs = CommonCRS.defaultGeographic();
    }
    if (boxCrs != null) {
        String srsName;
        try {
            srsName = IdentifiedObjects.lookupURN(boxCrs, null);
        } catch (FactoryException ex) {
            srsName = IdentifiedObjects.getSimpleNameOrIdentifier(boxCrs);
        }
        if (srsName != null) {
            bType.setSrsName(srsName);
        }
    }
    return bType;
}
Also used : SingleCRS(org.opengis.referencing.crs.SingleCRS) FactoryException(org.opengis.util.FactoryException) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) GeographicBoundingBox(org.opengis.metadata.extent.GeographicBoundingBox) Envelope(org.opengis.geometry.Envelope) BoxType(org.geotoolkit.gml.xml.v212.BoxType) CoordType(org.geotoolkit.gml.xml.v212.CoordType)

Example 3 with CoordType

use of org.geotoolkit.gml.xml.v212.CoordType in project geotoolkit by Geomatys.

the class WfsXMLBindingTest method marshallingTest.

@Test
public void marshallingTest() throws JAXBException {
    WFSCapabilitiesType capa = new WFSCapabilitiesType();
    List<FeatureTypeType> featList = new ArrayList<FeatureTypeType>();
    LatLongBoundingBoxType bbox = new LatLongBoundingBoxType(29.8, -90.1, 30, -89.9);
    FeatureTypeType ft1 = new FeatureTypeType(new QName("http://www.opengis.net/ows-6/utds/0.3", "Building", "utds"), "", "urn:ogc:def:crs:EPSG::4979", Arrays.asList(bbox));
    featList.add(ft1);
    FeatureTypeListType featureList = new FeatureTypeListType(null, featList);
    capa.setFeatureTypeList(featureList);
    StringWriter sw = new StringWriter();
    marshaller.marshal(capa, sw);
    DeleteElementType del = null;
    TransactionType transac = new TransactionType("WFS", "1.1.0", null, AllSomeType.ALL, del);
    PropertyIsLikeType pis = new PropertyIsLikeType("NAME", "Ashton", "*", "?", "\\");
    org.geotoolkit.ogc.xml.v100.ObjectFactory factory = new org.geotoolkit.ogc.xml.v100.ObjectFactory();
    final JAXBElement<? extends ComparisonOpsType> jbPis = factory.createPropertyIsLike(pis);
    FilterType filter = new FilterType(null, jbPis, null, null);
    CoordType dp = new CoordType(21400.0, 2001368.0);
    PointType pt = new PointType(dp);
    pt.setSrsName("urn:ogc:def:crs:epsg:7.4:27582");
    PropertyType property = new PropertyType("the_geom", pt);
    UpdateElementType update = new UpdateElementType(Arrays.asList(property), filter, new QName("http://www.opengis.net/gml", "NamedPlaces"));
    transac.getInsertOrUpdateOrDelete().add(update);
// marshaller.marshal(transac, System.out);
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) FilterType(org.geotoolkit.ogc.xml.v100.FilterType) StringWriter(java.io.StringWriter) PointType(org.geotoolkit.gml.xml.v212.PointType) PropertyIsLikeType(org.geotoolkit.ogc.xml.v100.PropertyIsLikeType) CoordType(org.geotoolkit.gml.xml.v212.CoordType)

Aggregations

QName (javax.xml.namespace.QName)2 CoordType (org.geotoolkit.gml.xml.v212.CoordType)2 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 JAXBElement (javax.xml.bind.JAXBElement)1 AbstractGeometryType (net.opengis.gml.v_3_1_1.AbstractGeometryType)1 AbstractRingPropertyType (net.opengis.gml.v_3_1_1.AbstractRingPropertyType)1 CoordType (net.opengis.gml.v_3_1_1.CoordType)1 LinearRingType (net.opengis.gml.v_3_1_1.LinearRingType)1 PolygonType (net.opengis.gml.v_3_1_1.PolygonType)1 BoxType (org.geotoolkit.gml.xml.v212.BoxType)1 PointType (org.geotoolkit.gml.xml.v212.PointType)1 FilterType (org.geotoolkit.ogc.xml.v100.FilterType)1 PropertyIsLikeType (org.geotoolkit.ogc.xml.v100.PropertyIsLikeType)1 Coordinate (org.locationtech.jts.geom.Coordinate)1 Envelope (org.opengis.geometry.Envelope)1 GeographicBoundingBox (org.opengis.metadata.extent.GeographicBoundingBox)1 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)1 SingleCRS (org.opengis.referencing.crs.SingleCRS)1 FactoryException (org.opengis.util.FactoryException)1