Search in sources :

Example 31 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class OgcDecoderv100 method parseBBOXFilterType.

/**
 * Parses the spatial filter of a request.
 *
 * @param xbBBOX 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 parseBBOXFilterType(BBOXTypeImpl xbBBOX) throws DecodingException {
    SpatialFilter spatialFilter = new SpatialFilter();
    // FIXME local workaround for SOSHelper check value reference
    String valueRef = "om:featureOfInterest/sams:SF_SpatialSamplingFeature/sams:shape";
    try {
        spatialFilter.setOperator(FilterConstants.SpatialOperator.BBOX);
        XmlCursor geometryCursor = xbBBOX.newCursor();
        if (geometryCursor.toChild(GmlConstants.QN_ENVELOPE)) {
            Object sosGeometry = decodeXmlElement(XmlObject.Factory.parse(geometryCursor.getDomNode()));
            // }
            if (sosGeometry instanceof Geometry) {
                spatialFilter.setGeometry((Geometry) sosGeometry);
                spatialFilter.setValueReference(valueRef);
            }
        } else {
            throw unsupportedSpatialFilterOperand();
        }
        geometryCursor.dispose();
    } catch (XmlException xmle) {
        throw errorParsingSpatialFilter(xmle);
    }
    return spatialFilter;
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) XmlException(org.apache.xmlbeans.XmlException) SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) XmlObject(org.apache.xmlbeans.XmlObject) XmlCursor(org.apache.xmlbeans.XmlCursor)

Example 32 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class FesDecoderv20 method parseBinaryLogicalFilter.

/**
 * parses a single binary logic filter of the requests and returns service
 * binary logic filter
 *
 * @param binaryLogicOpType
 *            XmlObject representing the binary logic filter
 * @return Service representation of binary logic filter
 * @throws DecodingException
 *             if creation of the BinaryLogicFilter failed or filter size is
 *             less than two
 */
private BinaryLogicFilter parseBinaryLogicalFilter(BinaryLogicOpType binaryLogicOpType) throws DecodingException {
    BinaryLogicFilter binaryLogicFilter = null;
    String localName = XmlHelper.getLocalName(binaryLogicOpType);
    if (localName.equals(BinaryLogicOperator.And.name())) {
        binaryLogicFilter = new BinaryLogicFilter(BinaryLogicOperator.And);
    } else if (localName.equals(BinaryLogicOperator.Or.name())) {
        binaryLogicFilter = new BinaryLogicFilter(BinaryLogicOperator.Or);
    } else {
        throw new UnsupportedDecoderXmlInputException(this, binaryLogicOpType);
    }
    Set<Filter<?>> filters = getFilterPredicates(binaryLogicOpType);
    if (filters.size() < 2) {
        throw new DecodingException("The binary logic filter requires minimla two filter predicates!");
    }
    binaryLogicFilter.addFilterPredicates(filters);
    return binaryLogicFilter;
}
Also used : Filter(org.n52.shetland.ogc.filter.Filter) TemporalFilter(org.n52.shetland.ogc.filter.TemporalFilter) SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) BinaryLogicFilter(org.n52.shetland.ogc.filter.BinaryLogicFilter) UnaryLogicFilter(org.n52.shetland.ogc.filter.UnaryLogicFilter) ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) BinaryLogicFilter(org.n52.shetland.ogc.filter.BinaryLogicFilter)

Example 33 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class FesDecoderv20 method parsePropertyIsLikeFilter.

/**
 * Parse XML propertyIsLike element
 *
 * @param comparisonOpsType
 *            XML propertyIsLike element
 * @return SOS comparison filter
 * @throws DecodingException
 *             If an error occurs of the filter is not supported!
 */
private ComparisonFilter parsePropertyIsLikeFilter(PropertyIsLikeType comparisonOpsType) throws DecodingException {
    ComparisonFilter comparisonFilter = new ComparisonFilter();
    comparisonFilter.setOperator(ComparisonOperator.PropertyIsLike);
    comparisonFilter.setEscapeString(comparisonOpsType.getEscapeChar());
    comparisonFilter.setSingleChar(comparisonOpsType.getSingleChar());
    comparisonFilter.setWildCard(comparisonOpsType.getWildCard());
    parseExpressions(comparisonOpsType.getExpressionArray(), comparisonFilter);
    return comparisonFilter;
}
Also used : ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter)

Example 34 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class SosV1GetCapabilitiesResponseEncoder method setSpatialFilterCapabilities.

/**
 * Sets the SpatialFilterCapabilities.
 *
 * !!! Modify method addicted to your implementation !!!
 *
 * @param spatialCapabilities SpatialCapabilities.
 * @param sosFilterCaps       the SOS filter capabilities
 */
protected void setSpatialFilterCapabilities(SpatialCapabilitiesType spatialCapabilities, org.n52.shetland.ogc.filter.FilterCapabilities sosFilterCaps) {
    // set GeometryOperands
    if (!sosFilterCaps.getSpatialOperands().isEmpty()) {
        sosFilterCaps.getSpatialOperands().forEach(spatialCapabilities.addNewGeometryOperands()::addGeometryOperand);
    }
    // set SpatialOperators
    if (!sosFilterCaps.getSpatialOperators().isEmpty()) {
        SpatialOperatorsType spatialOps = spatialCapabilities.addNewSpatialOperators();
        Set<SpatialOperator> keys = sosFilterCaps.getSpatialOperators().keySet();
        keys.forEach(spatialOperator -> {
            SpatialOperatorType operator = spatialOps.addNewSpatialOperator();
            operator.setName(getEnum4SpatialOperator(spatialOperator));
            GeometryOperandsType bboxGeomOps = operator.addNewGeometryOperands();
            sosFilterCaps.getSpatialOperators().get(spatialOperator).forEach(bboxGeomOps::addGeometryOperand);
        });
    }
}
Also used : SpatialOperatorsType(net.opengis.ogc.SpatialOperatorsType) SpatialOperatorType(net.opengis.ogc.SpatialOperatorType) GeometryOperandsType(net.opengis.ogc.GeometryOperandsType) SpatialOperator(org.n52.shetland.ogc.filter.FilterConstants.SpatialOperator)

Example 35 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class FesEncoderv20Test method should_return_correct_schema_location.

@Test
public final void should_return_correct_schema_location() {
    assertThat(fesEncoder.getSchemaLocations().size(), is(1));
    final SchemaLocation schemLoc = fesEncoder.getSchemaLocations().iterator().next();
    assertThat(schemLoc.getNamespace(), is("http://www.opengis.net/fes/2.0"));
    assertThat(schemLoc.getSchemaFileUrl(), is("http://schemas.opengis.net/filter/2.0/filterAll.xsd"));
}
Also used : SchemaLocation(org.n52.shetland.w3c.SchemaLocation) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 SpatialFilter (org.n52.shetland.ogc.filter.SpatialFilter)10 XmlObject (org.apache.xmlbeans.XmlObject)9 ComparisonFilter (org.n52.shetland.ogc.filter.ComparisonFilter)9 XmlException (org.apache.xmlbeans.XmlException)6 DecodingException (org.n52.svalbard.decode.exception.DecodingException)6 URI (java.net.URI)3 Objects (java.util.Objects)3 Set (java.util.Set)3 BinaryTemporalOpType (net.opengis.fes.x20.BinaryTemporalOpType)3 XmlCursor (org.apache.xmlbeans.XmlCursor)3 LocalizedString (org.n52.janmayen.i18n.LocalizedString)3 MultilingualString (org.n52.janmayen.i18n.MultilingualString)3 TimeOperator (org.n52.shetland.ogc.filter.FilterConstants.TimeOperator)3 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)3 OwsDomain (org.n52.shetland.ogc.ows.OwsDomain)3 OwsLanguageString (org.n52.shetland.ogc.ows.OwsLanguageString)3 OwsMetadata (org.n52.shetland.ogc.ows.OwsMetadata)3 Strings (com.google.common.base.Strings)2 Arrays (java.util.Arrays)2