Search in sources :

Example 1 with DistanceBufferType

use of net.opengis.fes.x20.DistanceBufferType in project ddf by codice.

the class TestWfsFilterDelegate method testBeyondFilter.

@Test
public void testBeyondFilter() throws JAXBException, SAXException, IOException {
    WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.Beyond.toString());
    FilterType filter = delegate.beyond(Metacard.ANY_GEO, POLYGON, DISTANCE);
    assertTrue(filter.isSetSpatialOps());
    assertTrue(filter.getSpatialOps().getValue() instanceof DistanceBufferType);
    assertXMLEqual(MockWfsServer.getBeyondXmlFilter(), getXmlFromMarshaller(filter));
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType) DistanceBufferType(net.opengis.filter.v_2_0_0.DistanceBufferType) Test(org.junit.Test)

Example 2 with DistanceBufferType

use of net.opengis.fes.x20.DistanceBufferType in project ddf by codice.

the class TestWfsFilterDelegate method testLogicalNotOfSpatial.

@Test
public void testLogicalNotOfSpatial() throws Exception {
    String mockProperty = "myPropertyName";
    String mockType = "myType";
    WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
    FilterType spatialFilter1 = delegate.dwithin(Metacard.ANY_GEO, "POINT (30 10)", Double.valueOf(1000));
    //Perform Test
    FilterType filter = delegate.not(spatialFilter1);
    //Verify
    assertThat(filter.getLogicOps().getName().toString(), is(LOGICAL_NOT_NAME));
    UnaryLogicOpType logicOpType = (UnaryLogicOpType) filter.getLogicOps().getValue();
    DistanceBufferType spatialOpsType1 = (DistanceBufferType) logicOpType.getSpatialOps().getValue();
    assertThat(Double.toString(spatialOpsType1.getDistance().getValue()), is(Double.valueOf(1000).toString()));
}
Also used : UnaryLogicOpType(net.opengis.filter.v_2_0_0.UnaryLogicOpType) FilterType(net.opengis.filter.v_2_0_0.FilterType) DistanceBufferType(net.opengis.filter.v_2_0_0.DistanceBufferType) Test(org.junit.Test)

Example 3 with DistanceBufferType

use of net.opengis.fes.x20.DistanceBufferType in project ddf by codice.

the class TestWfsFilterDelegate method testDWithinFilterPolygon.

@Test
public void testDWithinFilterPolygon() throws SAXException, IOException, JAXBException {
    WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.DWithin.toString());
    FilterType filter = delegate.dwithin(Metacard.ANY_GEO, POLYGON, DISTANCE);
    assertFalse(filter.isSetLogicOps());
    assertTrue(filter.isSetSpatialOps());
    assertTrue(filter.getSpatialOps().getValue() instanceof DistanceBufferType);
    assertXMLEqual(MockWfsServer.getDWithinXmlFilter(), getXmlFromMarshaller(filter));
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType) DistanceBufferType(net.opengis.filter.v_2_0_0.DistanceBufferType) Test(org.junit.Test)

Example 4 with DistanceBufferType

use of net.opengis.fes.x20.DistanceBufferType in project web-feature-service by 3dcitydb.

the class SpatialFilterBuilder method buildSpatialOperator.

public Predicate buildSpatialOperator(JAXBElement<?> spatialOpsElement, FeatureType featureType, NamespaceFilter namespaceFilter, String handle) throws WFSException {
    if (!spatialOpsElement.getName().getNamespaceURI().equals(Constants.FES_NAMESPACE_URI))
        throw new WFSException(WFSExceptionCode.OPTION_NOT_SUPPORTED, "Only spatial operators associated with the namespace " + Constants.FES_NAMESPACE_URI + " are supported.", handle);
    // check whether the operator is advertised
    if (!wfsConfig.getFilterCapabilities().getSpatialCapabilities().containsSpatialOperator(SpatialOperatorName.fromValue(spatialOpsElement.getName().getLocalPart())))
        throw new WFSException(WFSExceptionCode.OPTION_NOT_SUPPORTED, "The spatial operator '" + spatialOpsElement.getName() + "' is not advertised.", handle);
    Object operator = spatialOpsElement.getValue();
    Predicate predicate = null;
    if (operator instanceof BBOXType)
        predicate = buildBBOXOperator((BBOXType) operator, spatialOpsElement.getName(), featureType, namespaceFilter, handle);
    else if (operator instanceof BinarySpatialOpType)
        predicate = buildBinaryOperator((BinarySpatialOpType) operator, spatialOpsElement.getName(), featureType, namespaceFilter, handle);
    else if (operator instanceof DistanceBufferType)
        predicate = buildDistanceOperator((DistanceBufferType) operator, spatialOpsElement.getName(), featureType, namespaceFilter, handle);
    return predicate;
}
Also used : WFSException(vcs.citydb.wfs.exception.WFSException) BBOXType(net.opengis.fes._2.BBOXType) BinarySpatialOpType(net.opengis.fes._2.BinarySpatialOpType) GeometryObject(org.citydb.config.geometry.GeometryObject) DistanceBufferType(net.opengis.fes._2.DistanceBufferType) Predicate(org.citydb.core.query.filter.selection.Predicate)

Example 5 with DistanceBufferType

use of net.opengis.fes.x20.DistanceBufferType 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)

Aggregations

Test (org.junit.Test)21 DistanceBufferType (net.opengis.filter.v_2_0_0.DistanceBufferType)18 FilterType (net.opengis.filter.v_2_0_0.FilterType)18 DistanceBufferType (net.opengis.filter.v_1_1_0.DistanceBufferType)11 ArrayList (java.util.ArrayList)6 BinaryLogicOpType (net.opengis.filter.v_2_0_0.BinaryLogicOpType)6 UnaryLogicOpType (net.opengis.filter.v_2_0_0.UnaryLogicOpType)6 Method (java.lang.reflect.Method)4 PointType (net.opengis.gml.v_3_1_1.PointType)4 DistanceType (net.opengis.filter.v_1_1_0.DistanceType)3 FilterType (net.opengis.filter.v_1_1_0.FilterType)3 PropertyNameType (net.opengis.filter.v_1_1_0.PropertyNameType)3 Query (ddf.catalog.operation.Query)2 QueryImpl (ddf.catalog.operation.impl.QueryImpl)2 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)2 BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)2 PropertyIsLikeType (net.opengis.filter.v_2_0_0.PropertyIsLikeType)2 QueryType (net.opengis.wfs.v_1_1_0.QueryType)2 DateTime (org.joda.time.DateTime)2 Geometry (org.locationtech.jts.geom.Geometry)2