Search in sources :

Example 26 with DistanceBufferType

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

the class WfsFilterDelegateTest method testPointLonLatOrder.

@Test
public void testPointLonLatOrder() {
    final WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.DWITHIN.getValue(), new LonLatCoordinateStrategy());
    final FilterType filter = delegate.dwithin(Metacard.ANY_GEO, POINT, DISTANCE);
    assertThat(filter.getSpatialOps().getValue(), is(instanceOf(DistanceBufferType.class)));
    final DistanceBufferType distanceBufferType = (DistanceBufferType) filter.getSpatialOps().getValue();
    assertThat(distanceBufferType.getGeometry().getValue(), is(instanceOf(PointType.class)));
    final PointType pointType = (PointType) distanceBufferType.getGeometry().getValue();
    assertThat(pointType.getCoordinates().getValue(), is("30.0,-10.0"));
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType) PointType(net.opengis.gml.v_3_1_1.PointType) DistanceBufferType(net.opengis.filter.v_1_1_0.DistanceBufferType) Test(org.junit.Test)

Example 27 with DistanceBufferType

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

the class WfsSourceTest method testQueryLatLonCoordinateOrder.

@Test
public void testQueryLatLonCoordinateOrder() throws Exception {
    mapSchemaToFeatures(ONE_GML_PROPERTY_SCHEMA, ONE_FEATURE);
    setUpMocks(Collections.singletonList("DWithin"), SRS_NAME, ONE_FEATURE, ONE_FEATURE);
    source.setPollInterval(1);
    final Map<String, Object> configuration = ImmutableMap.<String, Object>builder().put("wfsUrl", "http://localhost/wfs").put("coordinateOrder", LAT_LON_ORDER).put("forceSpatialFilter", "NO_FILTER").put("allowRedirects", false).put("disableCnCheck", false).put("pollInterval", 1).put("disableSorting", false).put("supportsStartIndex", false).put("forceAllGeometryOperands", false).build();
    source.refresh(configuration);
    final Filter withinFilter = builder.attribute(Metacard.ANY_GEO).is().withinBuffer().wkt(POINT_WKT, 10.0);
    final Query withinQuery = new QueryImpl(withinFilter);
    final ArgumentCaptor<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
    source.query(new QueryRequestImpl(withinQuery));
    verify(mockWfs, times(2)).getFeature(captor.capture());
    ExtendedGetFeatureType getFeatureType = captor.getAllValues().get(1);
    assertThat(getFeatureType.getQuery(), hasSize(1));
    final QueryType query = getFeatureType.getQuery().get(0);
    assertThat(query.getFilter().getSpatialOps().getValue(), is(instanceOf(DistanceBufferType.class)));
    final DistanceBufferType distanceBufferType = (DistanceBufferType) query.getFilter().getSpatialOps().getValue();
    assertThat(distanceBufferType.getGeometry().getValue(), is(instanceOf(PointType.class)));
    final PointType pointType = (PointType) distanceBufferType.getGeometry().getValue();
    assertThat(pointType.getCoordinates().getValue(), is("-10.0,30.0"));
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) Query(ddf.catalog.operation.Query) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) PointType(net.opengis.gml.v_3_1_1.PointType) DistanceBufferType(net.opengis.filter.v_1_1_0.DistanceBufferType) QueryType(net.opengis.wfs.v_1_1_0.QueryType) Test(org.junit.Test)

Example 28 with DistanceBufferType

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

the class WfsFilterDelegateTest method testLogicalAndOrSpatial.

private void testLogicalAndOrSpatial(String methName, String compOpName) throws Exception {
    String mockProperty = "myPropertyName";
    String mockType = "myType";
    WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
    FilterType spatialFilter1 = delegate.dwithin(Metacard.ANY_GEO, "POINT (30 10)", 1000);
    FilterType spatialFilter2 = delegate.dwithin(Metacard.ANY_GEO, "POINT (50 10)", 1500);
    List<FilterType> filtersToCombine = new ArrayList<>();
    filtersToCombine.add(spatialFilter1);
    filtersToCombine.add(spatialFilter2);
    // Perform Test
    Method method = WfsFilterDelegate.class.getMethod(methName, List.class);
    FilterType filter = (FilterType) method.invoke(delegate, filtersToCombine);
    // Verify
    assertThat(filter.getLogicOps().getName().toString(), is(compOpName));
    BinaryLogicOpType logicOpType = (BinaryLogicOpType) filter.getLogicOps().getValue();
    DistanceBufferType spatialOpsType1 = (DistanceBufferType) logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(0).getValue();
    assertThat(spatialOpsType1.getDistance().getValue(), is(1000d));
    DistanceBufferType spatialOpsType2 = (DistanceBufferType) logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(1).getValue();
    assertThat(spatialOpsType2.getDistance().getValue(), is(1500d));
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType) BinaryLogicOpType(net.opengis.filter.v_2_0_0.BinaryLogicOpType) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) DistanceBufferType(net.opengis.filter.v_2_0_0.DistanceBufferType)

Example 29 with DistanceBufferType

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

the class WfsFilterDelegateTest method testDWithinFilterPoint.

@Test
public void testDWithinFilterPoint() throws SAXException, IOException, JAXBException {
    WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.D_WITHIN.toString());
    FilterType filter = delegate.dwithin(Metacard.ANY_GEO, POINT, DISTANCE);
    assertFalse(filter.isSetLogicOps());
    assertTrue(filter.isSetSpatialOps());
    assertTrue(filter.getSpatialOps().getValue() instanceof DistanceBufferType);
    assertXMLEqual(MockWfsServer.getDWithinPointXmlFilter(), 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 30 with DistanceBufferType

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

the class WfsFilterDelegateTest 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)

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