Search in sources :

Example 26 with Filter

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

the class FesEncoderv20 method encodeTemporalFilterDuring.

private XmlObject encodeTemporalFilterDuring(TemporalFilter temporalFilter) throws EncodingException {
    final DuringDocument duringDoc = DuringDocument.Factory.newInstance(getXmlOptions());
    final BinaryTemporalOpType during = duringDoc.addNewDuring();
    if (temporalFilter.getTime() instanceof TimePeriod) {
        during.set(encodeObjectToXml(GmlConstants.NS_GML_32, temporalFilter.getTime(), EncodingContext.of(XmlBeansEncodingFlags.DOCUMENT)));
    } else {
        throw new EncodingException("The temporal filter value is not a TimePeriod!");
    }
    checkAndAddValueReference(during, temporalFilter);
    return duringDoc;
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) DuringDocument(net.opengis.fes.x20.DuringDocument) BinaryTemporalOpType(net.opengis.fes.x20.BinaryTemporalOpType)

Example 27 with Filter

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

the class ODataFesParserTest method testFeatureOfInterestShapeGeoIntersectsPolygon.

@Test
public void testFeatureOfInterestShapeGeoIntersectsPolygon() throws Exception {
    Filter<?> filter = parser.decode(String.format("geo.intersects(featureOfInterest/shape,'SRID=%s;%s')", polygon.getSRID(), wktGeometry));
    assertThat(filter, is(instanceOf(SpatialFilter.class)));
    SpatialFilter sf = (SpatialFilter) filter;
    errors.checkThat(sf.getSrid(), is(4326));
    errors.checkThat(sf.getGeometry().isEnvelope(), is(false));
    errors.checkThat(sf.getGeometry().isGeometry(), is(true));
    errors.checkThat(sf.getGeometry().getGeometry().get(), is(instanceOf(Polygon.class)));
    errors.checkThat(sf.getValueReference(), is("om:featureOfInterest/*/sams:shape"));
}
Also used : SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) Test(org.junit.Test)

Example 28 with Filter

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

the class ODataFesParserTest method testSamplingGeometryGeoIntersectsPolygon.

@Test
public void testSamplingGeometryGeoIntersectsPolygon() throws Exception {
    Filter<?> filter = parser.decode(String.format("geo.intersects(samplingGeometry,'SRID=%s;%s')", polygon.getSRID(), wktGeometry));
    assertThat(filter, is(instanceOf(SpatialFilter.class)));
    SpatialFilter sf = (SpatialFilter) filter;
    errors.checkThat(sf.getSrid(), is(4326));
    errors.checkThat(sf.getGeometry().isEnvelope(), is(false));
    errors.checkThat(sf.getGeometry().isGeometry(), is(true));
    errors.checkThat(sf.getGeometry().getGeometry().get(), is(instanceOf(Polygon.class)));
    errors.checkThat(sf.getValueReference(), is("http://www.opengis.net/req/omxml/2.0/data/samplingGeometry"));
}
Also used : SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) Test(org.junit.Test)

Example 29 with Filter

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

the class ODataFesParserTest method testContains.

@Test
public void testContains() throws DecodingException {
    Filter<?> filter = parser.decode("contains(textValue,'as%df')");
    assertThat(filter, is(instanceOf(ComparisonFilter.class)));
    ComparisonFilter cf = (ComparisonFilter) filter;
    errors.checkThat(cf.getOperator(), is(ComparisonOperator.PropertyIsLike));
    errors.checkThat(cf.getValue(), is("%as%df%"));
    errors.checkThat(cf.getValueReference(), is("om:result"));
}
Also used : ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) Test(org.junit.Test)

Example 30 with Filter

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

the class ODataFesParserTest method testConjunction.

@Test
@SuppressWarnings("unchecked")
public void testConjunction() throws Exception {
    Filter<?> filter = parser.decode("countValue lt 10 and textValue eq 'thetext'");
    assertThat(filter, is(instanceOf(BinaryLogicFilter.class)));
    BinaryLogicFilter blf = (BinaryLogicFilter) filter;
    errors.checkThat(blf.getOperator(), is(BinaryLogicOperator.And));
    Set<Filter<?>> filterPredicates = blf.getFilterPredicates();
    errors.checkThat(filterPredicates, Matchers.containsInAnyOrder(Matchers.instanceOf(ComparisonFilter.class), Matchers.instanceOf(ComparisonFilter.class)));
}
Also used : SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) BinaryLogicFilter(org.n52.shetland.ogc.filter.BinaryLogicFilter) ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) Filter(org.n52.shetland.ogc.filter.Filter) BinaryLogicFilter(org.n52.shetland.ogc.filter.BinaryLogicFilter) 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