Search in sources :

Example 11 with SpatialOperatorType

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

the class TestCswFilterDelegate method getMockFilterCapabilitiesForSpatialFallback.

private FilterCapabilities getMockFilterCapabilitiesForSpatialFallback(List<SpatialOperatorNameType> spatialOperatorNameTypes, List<String> geometries) {
    FilterCapabilities mockFilterCapabilities = mock(FilterCapabilities.class);
    ComparisonOperatorsType mockComparisonOps = mock(ComparisonOperatorsType.class);
    when(mockComparisonOps.getComparisonOperator()).thenReturn(getFullComparisonOpsList());
    List<SpatialOperatorType> spatialOperatorList = new ArrayList<>();
    for (SpatialOperatorNameType spatialOperatorNameType : spatialOperatorNameTypes) {
        SpatialOperatorType spatialOperatorType = new SpatialOperatorType();
        spatialOperatorType.setName(spatialOperatorNameType);
        spatialOperatorList.add(spatialOperatorType);
    }
    SpatialOperatorsType mockSpatialOperatorsType = mock(SpatialOperatorsType.class);
    when(mockSpatialOperatorsType.getSpatialOperator()).thenReturn(spatialOperatorList);
    SpatialCapabilitiesType mockSpatialCapabilities = getSpatialCapabilities(geometries);
    when(mockSpatialCapabilities.getSpatialOperators()).thenReturn(mockSpatialOperatorsType);
    ScalarCapabilitiesType mockScalarCapabilities = mock(ScalarCapabilitiesType.class);
    when(mockScalarCapabilities.getComparisonOperators()).thenReturn(mockComparisonOps);
    when(mockFilterCapabilities.getScalarCapabilities()).thenReturn(mockScalarCapabilities);
    when(mockFilterCapabilities.getSpatialCapabilities()).thenReturn(mockSpatialCapabilities);
    when(mockScalarCapabilities.getLogicalOperators()).thenReturn(mock(LogicalOperators.class));
    return mockFilterCapabilities;
}
Also used : FilterCapabilities(net.opengis.filter.v_1_1_0.FilterCapabilities) ComparisonOperatorsType(net.opengis.filter.v_1_1_0.ComparisonOperatorsType) ScalarCapabilitiesType(net.opengis.filter.v_1_1_0.ScalarCapabilitiesType) SpatialOperatorsType(net.opengis.filter.v_1_1_0.SpatialOperatorsType) SpatialOperatorType(net.opengis.filter.v_1_1_0.SpatialOperatorType) ArrayList(java.util.ArrayList) LogicalOperators(net.opengis.filter.v_1_1_0.LogicalOperators) SpatialOperatorNameType(net.opengis.filter.v_1_1_0.SpatialOperatorNameType) SpatialCapabilitiesType(net.opengis.filter.v_1_1_0.SpatialCapabilitiesType)

Example 12 with SpatialOperatorType

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

the class MockWfsServer method getFilterCapabilities.

public static FilterCapabilities getFilterCapabilities() {
    FilterCapabilities capabilities = new FilterCapabilities();
    ConformanceType conformance = new ConformanceType();
    for (CONFORMANCE_CONSTRAINTS constraint : CONFORMANCE_CONSTRAINTS.values()) {
        DomainType domain = new DomainType();
        NoValues noValues = new NoValues();
        domain.setNoValues(noValues);
        ValueType value = new ValueType();
        value.setValue("TRUE");
        domain.setDefaultValue(value);
        domain.setName(constraint.toString());
        conformance.getConstraint().add(domain);
    }
    capabilities.setConformance(conformance);
    ScalarCapabilitiesType scalar = new ScalarCapabilitiesType();
    scalar.setLogicalOperators(new LogicalOperators());
    scalar.setComparisonOperators(new ComparisonOperatorsType());
    for (COMPARISON_OPERATORS compOp : COMPARISON_OPERATORS.values()) {
        ComparisonOperatorType operator = new ComparisonOperatorType();
        operator.setName(compOp.toString());
        scalar.getComparisonOperators().getComparisonOperator().add(operator);
    }
    capabilities.setScalarCapabilities(scalar);
    SpatialCapabilitiesType spatial = new SpatialCapabilitiesType();
    spatial.setSpatialOperators(new SpatialOperatorsType());
    for (SPATIAL_OPERATORS spatialOp : SPATIAL_OPERATORS.values()) {
        SpatialOperatorType operator = new SpatialOperatorType();
        operator.setName(spatialOp.toString());
        spatial.getSpatialOperators().getSpatialOperator().add(operator);
    }
    GeometryOperandsType geometryOperands = new GeometryOperandsType();
    List<QName> qnames = Arrays.asList(Wfs20Constants.POINT, Wfs20Constants.ENVELOPE, Wfs20Constants.POLYGON, Wfs20Constants.LINESTRING);
    for (QName qName : qnames) {
        GeometryOperand operand = new GeometryOperand();
        operand.setName(qName);
        geometryOperands.getGeometryOperand().add(operand);
    }
    spatial.setGeometryOperands(geometryOperands);
    capabilities.setSpatialCapabilities(spatial);
    TemporalCapabilitiesType temporal = new TemporalCapabilitiesType();
    temporal.setTemporalOperators(new TemporalOperatorsType());
    for (TEMPORAL_OPERATORS temporalOp : TEMPORAL_OPERATORS.values()) {
        TemporalOperatorType operator = new TemporalOperatorType();
        operator.setName(temporalOp.toString());
        temporal.getTemporalOperators().getTemporalOperator().add(operator);
    }
    TemporalOperandsType temporalOperands = new TemporalOperandsType();
    List<QName> timeQNames = Arrays.asList(new QName(Wfs20Constants.GML_3_2_NAMESPACE, "TimePeriod"), new QName(Wfs20Constants.GML_3_2_NAMESPACE, "TimeInstant"));
    for (QName qName : timeQNames) {
        TemporalOperand operand = new TemporalOperand();
        operand.setName(qName);
        temporalOperands.getTemporalOperand().add(operand);
    }
    temporal.setTemporalOperands(temporalOperands);
    capabilities.setTemporalCapabilities(temporal);
    return capabilities;
}
Also used : SpatialCapabilitiesType(net.opengis.filter.v_2_0_0.SpatialCapabilitiesType) FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) DomainType(net.opengis.ows.v_1_1_0.DomainType) SpatialOperatorsType(net.opengis.filter.v_2_0_0.SpatialOperatorsType) GeometryOperandsType(net.opengis.filter.v_2_0_0.GeometryOperandsType) TemporalOperatorsType(net.opengis.filter.v_2_0_0.TemporalOperatorsType) NoValues(net.opengis.ows.v_1_1_0.NoValues) ComparisonOperatorType(net.opengis.filter.v_2_0_0.ComparisonOperatorType) TemporalOperand(net.opengis.filter.v_2_0_0.TemporalOperandsType.TemporalOperand) ConformanceType(net.opengis.filter.v_2_0_0.ConformanceType) COMPARISON_OPERATORS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.COMPARISON_OPERATORS) TemporalCapabilitiesType(net.opengis.filter.v_2_0_0.TemporalCapabilitiesType) SPATIAL_OPERATORS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.SPATIAL_OPERATORS) ValueType(net.opengis.ows.v_1_1_0.ValueType) QName(javax.xml.namespace.QName) SpatialOperatorType(net.opengis.filter.v_2_0_0.SpatialOperatorType) TEMPORAL_OPERATORS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.TEMPORAL_OPERATORS) LogicalOperators(net.opengis.filter.v_2_0_0.LogicalOperators) GeometryOperand(net.opengis.filter.v_2_0_0.GeometryOperandsType.GeometryOperand) CONFORMANCE_CONSTRAINTS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.CONFORMANCE_CONSTRAINTS) ComparisonOperatorsType(net.opengis.filter.v_2_0_0.ComparisonOperatorsType) ScalarCapabilitiesType(net.opengis.filter.v_2_0_0.ScalarCapabilitiesType) TemporalOperatorType(net.opengis.filter.v_2_0_0.TemporalOperatorType) TemporalOperandsType(net.opengis.filter.v_2_0_0.TemporalOperandsType)

Example 13 with SpatialOperatorType

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

the class TestWfsFilterDelegate method testIntersectsWithEnvelope.

@Test
public void testIntersectsWithEnvelope() throws SAXException, IOException, JAXBException {
    List<String> gmlProps = new ArrayList<>();
    gmlProps.add(MOCK_GEOM);
    when(mockFeatureMetacardType.getGmlProperties()).thenReturn(gmlProps);
    when(mockFeatureMetacardType.getAttributeDescriptor(MOCK_GEOM)).thenReturn(new FeatureAttributeDescriptor(MOCK_GEOM, MOCK_GEOM, true, false, false, false, BasicTypes.STRING_TYPE));
    SpatialOperatorType operator = new SpatialOperatorType();
    operator.setName(SPATIAL_OPERATORS.Intersects.toString());
    FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
    capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().clear();
    capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().add(operator);
    capabilities.getSpatialCapabilities().getGeometryOperands().getGeometryOperand().clear();
    GeometryOperand geoOperand = new GeometryOperand();
    geoOperand.setName(Wfs20Constants.ENVELOPE);
    capabilities.getSpatialCapabilities().getGeometryOperands().getGeometryOperand().add(geoOperand);
    WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, null, GeospatialUtil.LAT_LON_ORDER);
    FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
    assertTrue(filter.getSpatialOps().getValue() instanceof BinarySpatialOpType);
    assertFalse(filter.isSetLogicOps());
    assertXMLEqual(MockWfsServer.getIntersectsWithEnvelopeXmlFilter(), getXmlFromMarshaller(filter));
}
Also used : GeometryOperand(net.opengis.filter.v_2_0_0.GeometryOperandsType.GeometryOperand) FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) FilterType(net.opengis.filter.v_2_0_0.FilterType) FeatureAttributeDescriptor(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor) SpatialOperatorType(net.opengis.filter.v_2_0_0.SpatialOperatorType) ArrayList(java.util.ArrayList) BinarySpatialOpType(net.opengis.filter.v_2_0_0.BinarySpatialOpType) Test(org.junit.Test)

Example 14 with SpatialOperatorType

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

the class CswFilterDelegate method getGeometryOperands.

private List<QName> getGeometryOperands(SpatialOperatorNameType spatialOperatorName) {
    SpatialOperatorType spatialOperatorType = spatialOps.get(spatialOperatorName);
    List<QName> geometryOperands = new ArrayList<>();
    if (spatialOperatorType != null) {
        GeometryOperandsType geometryOperandsType = spatialOperatorType.getGeometryOperands();
        if (geometryOperandsType != null) {
            geometryOperands = geometryOperandsType.getGeometryOperand();
        }
    }
    return geometryOperands;
}
Also used : QName(javax.xml.namespace.QName) SpatialOperatorType(net.opengis.filter.v_1_1_0.SpatialOperatorType) ArrayList(java.util.ArrayList) GeometryOperandsType(net.opengis.filter.v_1_1_0.GeometryOperandsType)

Example 15 with SpatialOperatorType

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

the class WfsFilterDelegate method setSpatialOps.

public void setSpatialOps(SpatialOperatorsType spatialOperators) {
    spatialOps = new ConcurrentHashMap<SPATIAL_OPERATORS, SpatialOperatorType>(new EnumMap<SPATIAL_OPERATORS, SpatialOperatorType>(SPATIAL_OPERATORS.class));
    for (SpatialOperatorType spatialOp : spatialOperators.getSpatialOperator()) {
        LOGGER.debug("Adding key [spatialOp Name: {}]", spatialOp.getName());
        spatialOps.put(SPATIAL_OPERATORS.valueOf(spatialOp.getName()), spatialOp);
        LOGGER.debug("spatialOps Map: {}", spatialOps.toString());
    }
}
Also used : SPATIAL_OPERATORS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.SPATIAL_OPERATORS) SpatialOperatorType(net.opengis.filter.v_2_0_0.SpatialOperatorType) EnumMap(java.util.EnumMap)

Aggregations

ArrayList (java.util.ArrayList)11 SpatialOperatorType (net.opengis.filter.v_1_1_0.SpatialOperatorType)8 SpatialOperatorType (net.opengis.filter.v_2_0_0.SpatialOperatorType)8 FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)6 FeatureAttributeDescriptor (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor)5 FilterType (net.opengis.filter.v_2_0_0.FilterType)4 QName (javax.xml.namespace.QName)3 FilterCapabilities (net.opengis.filter.v_1_1_0.FilterCapabilities)3 SpatialOperatorNameType (net.opengis.filter.v_1_1_0.SpatialOperatorNameType)3 SpatialOperatorsType (net.opengis.filter.v_1_1_0.SpatialOperatorsType)3 BinarySpatialOpType (net.opengis.filter.v_2_0_0.BinarySpatialOpType)3 GeometryOperand (net.opengis.filter.v_2_0_0.GeometryOperandsType.GeometryOperand)3 EnumMap (java.util.EnumMap)2 ComparisonOperatorsType (net.opengis.filter.v_1_1_0.ComparisonOperatorsType)2 GeometryOperandsType (net.opengis.filter.v_1_1_0.GeometryOperandsType)2 LogicalOperators (net.opengis.filter.v_1_1_0.LogicalOperators)2 ScalarCapabilitiesType (net.opengis.filter.v_1_1_0.ScalarCapabilitiesType)2 SpatialCapabilitiesType (net.opengis.filter.v_1_1_0.SpatialCapabilitiesType)2 SpatialOperatorsType (net.opengis.filter.v_2_0_0.SpatialOperatorsType)2 SPATIAL_OPERATORS (org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.SPATIAL_OPERATORS)2