Search in sources :

Example 6 with BBOXType

use of org.geotoolkit.ogc.xml.v110.BBOXType in project ddf by codice.

the class WfsFilterDelegate method buildBBoxType.

private JAXBElement<BBOXType> buildBBoxType(String propertyName, String wkt) {
    BBOXType bboxType = new BBOXType();
    bboxType.setPropertyName(createPropertyNameType(propertyName).getValue());
    EnvelopeType envelopeType = gmlObjectFactory.createEnvelopeType();
    Envelope envelope = createEnvelopeFromWkt(wkt);
    List<Double> lowerCornerCoordinates = coordinateStrategy.lowerCorner(envelope);
    List<Double> upperCornerCoordinates = coordinateStrategy.upperCorner(envelope);
    DirectPositionType lowerCorner = new DirectPositionType();
    lowerCorner.setValue(lowerCornerCoordinates);
    envelopeType.setLowerCorner(lowerCorner);
    DirectPositionType upperCorner = new DirectPositionType();
    upperCorner.setValue(upperCornerCoordinates);
    envelopeType.setUpperCorner(upperCorner);
    bboxType.setEnvelope(gmlObjectFactory.createEnvelope(envelopeType));
    return filterObjectFactory.createBBOX(bboxType);
}
Also used : EnvelopeType(net.opengis.gml.v_3_1_1.EnvelopeType) BBOXType(net.opengis.filter.v_1_1_0.BBOXType) DirectPositionType(net.opengis.gml.v_3_1_1.DirectPositionType) Envelope(org.locationtech.jts.geom.Envelope)

Example 7 with BBOXType

use of org.geotoolkit.ogc.xml.v110.BBOXType in project ddf by codice.

the class WfsFilterDelegateTest method testIntersectsAsBoundingBox.

@Test
public void testIntersectsAsBoundingBox() throws SAXException, IOException, JAXBException {
    WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.BBOX.toString());
    FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
    assertNotNull(filter);
    assertTrue(filter.getSpatialOps().getValue() instanceof BBOXType);
    assertFalse(filter.isSetLogicOps());
    assertXMLEqual(MockWfsServer.getBboxXmlFilter(), getXmlFromMarshaller(filter));
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType) BBOXType(net.opengis.filter.v_2_0_0.BBOXType) Test(org.junit.Test)

Example 8 with BBOXType

use of org.geotoolkit.ogc.xml.v110.BBOXType in project ddf by codice.

the class WfsFilterDelegateTest method testDisjointAsNotBBox.

@Test
public void testDisjointAsNotBBox() throws SAXException, IOException, JAXBException {
    WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.BBOX.toString());
    FilterType filter = delegate.disjoint(Metacard.ANY_GEO, POLYGON);
    assertTrue(filter.getLogicOps().getValue() instanceof UnaryLogicOpType);
    UnaryLogicOpType type = (UnaryLogicOpType) filter.getLogicOps().getValue();
    assertTrue(type.getSpatialOps().getValue() instanceof BBOXType);
    assertXMLEqual(MockWfsServer.getNotBboxXmlFilter(), getXmlFromMarshaller(filter));
}
Also used : UnaryLogicOpType(net.opengis.filter.v_2_0_0.UnaryLogicOpType) FilterType(net.opengis.filter.v_2_0_0.FilterType) BBOXType(net.opengis.filter.v_2_0_0.BBOXType) Test(org.junit.Test)

Example 9 with BBOXType

use of org.geotoolkit.ogc.xml.v110.BBOXType in project arctic-sea by 52North.

the class FesDecoderv20 method parseSpatialFilterType.

/**
 * Parses the spatial filter of a request.
 *
 * @param xbSpatialOpsType
 *            XmlBean representing the feature of interest parameter of the
 *            request
 * @return Returns SpatialFilter created from the passed foi request
 *         parameter
 *
 * @throws DecodingException
 *             * if creation of the SpatialFilter failed
 */
private SpatialFilter parseSpatialFilterType(SpatialOpsType xbSpatialOpsType) throws DecodingException {
    SpatialFilter spatialFilter = new SpatialFilter();
    try {
        String localName = XmlHelper.getLocalName(xbSpatialOpsType);
        spatialFilter.setOperator(FilterConstants.SpatialOperator.valueOf(localName));
        if (xbSpatialOpsType instanceof BBOXType) {
            BBOXType xbBBOX = (BBOXType) xbSpatialOpsType;
            if (isValueReferenceExpression(xbBBOX.getExpression())) {
                spatialFilter.setValueReference(parseValueReference(xbBBOX.getExpression()));
            }
            parseGeometry(xbSpatialOpsType, spatialFilter);
        } else if (xbSpatialOpsType instanceof BinarySpatialOpType) {
            BinarySpatialOpType binarySpatialOpType = (BinarySpatialOpType) xbSpatialOpsType;
            if (isValueReferenceExpression(binarySpatialOpType.getExpression())) {
                spatialFilter.setValueReference(parseValueReference(binarySpatialOpType.getExpression()));
            }
            parseGeometry(xbSpatialOpsType, spatialFilter);
        } else if (xbSpatialOpsType instanceof DistanceBufferType) {
            DistanceBufferType distanceBufferType = (DistanceBufferType) xbSpatialOpsType;
            if (isValueReferenceExpression(distanceBufferType.getExpression())) {
                spatialFilter.setValueReference(parseValueReference(distanceBufferType.getExpression()));
            }
            if (distanceBufferType.getDistance() != null) {
                spatialFilter.setDistance(new FesMeasureType(distanceBufferType.getDistance().getDoubleValue(), distanceBufferType.getDistance().getUom()));
            }
            parseGeometry(xbSpatialOpsType, spatialFilter);
        } else {
            throw new DecodingException(Sos2Constants.GetObservationParams.spatialFilter, "The requested spatial filter is not supported by this SOS!");
        }
    } catch (XmlException xmle) {
        throw new DecodingException("Error while parsing spatial filter!", xmle);
    }
    return spatialFilter;
}
Also used : FesMeasureType(org.n52.shetland.ogc.filter.FesMeasureType) BBOXType(net.opengis.fes.x20.BBOXType) XmlException(org.apache.xmlbeans.XmlException) SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) BinarySpatialOpType(net.opengis.fes.x20.BinarySpatialOpType) DecodingException(org.n52.svalbard.decode.exception.DecodingException) DistanceBufferType(net.opengis.fes.x20.DistanceBufferType)

Example 10 with BBOXType

use of org.geotoolkit.ogc.xml.v110.BBOXType in project arctic-sea by 52North.

the class FesEncoderv20 method encodeSpatialFilter.

private XmlObject encodeSpatialFilter(SpatialFilter spatialFilter) throws EncodingException {
    final BBOXDocument bboxDoc = BBOXDocument.Factory.newInstance(getXmlOptions());
    final BBOXType bbox = bboxDoc.addNewBBOX();
    if (spatialFilter.hasValueReference()) {
        bbox.set(encodeReferenceValue(spatialFilter.getValueReference()));
    }
    // TODO check if srid is needed, then add as HelperValue
    bbox.setExpression(encodeExpression(spatialFilter.getGeometry()));
    return bbox;
}
Also used : BBOXType(net.opengis.fes.x20.BBOXType) BBOXDocument(net.opengis.fes.x20.BBOXDocument)

Aggregations

Test (org.junit.Test)8 BBOXType (net.opengis.filter.v_1_1_0.BBOXType)6 EnvelopeType (net.opengis.gml.v_3_1_1.EnvelopeType)6 JAXBElement (javax.xml.bind.JAXBElement)5 BBOXType (net.opengis.filter.v_2_0_0.BBOXType)5 DirectPositionType (net.opengis.gml.v_3_1_1.DirectPositionType)5 FilterType (net.opengis.filter.v_1_1_0.FilterType)4 FilterType (net.opengis.filter.v_2_0_0.FilterType)4 EnvelopeType (org.geotoolkit.gml.xml.v311.EnvelopeType)4 PropertyNameType (org.geotoolkit.ogc.xml.v110.PropertyNameType)4 List (java.util.List)3 BBOXType (net.opengis.fes.x20.BBOXType)3 DirectPositionType (org.geotoolkit.gml.xml.v311.DirectPositionType)3 OverlapsType (org.geotoolkit.ogc.xml.v110.OverlapsType)3 Envelope (org.locationtech.jts.geom.Envelope)3 Expression (org.opengis.filter.Expression)3 ArrayList (java.util.ArrayList)2 UnaryLogicOpType (net.opengis.filter.v_2_0_0.UnaryLogicOpType)2 BBOXType (org.geosdi.geoplatform.xml.filter.v110.BBOXType)2 TimeInstantType (org.geotoolkit.gml.xml.v321.TimeInstantType)2