Search in sources :

Example 11 with FeatureAttributeDescriptor

use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.

the class WfsFilterDelegate method buildBeforeFilterType.

private FilterType buildBeforeFilterType(String propertyName, String date) {
    TemporalOperand timeInstantTemporalOperand = new TemporalOperand();
    timeInstantTemporalOperand.setName(new QName(Wfs20Constants.GML_3_2_NAMESPACE, Wfs20Constants.TIME_INSTANT));
    if (!isTemporalOperandSupported(timeInstantTemporalOperand)) {
        throw new UnsupportedOperationException("Temporal Operand [" + timeInstantTemporalOperand.getName() + "] is not supported.");
    }
    if (!isValidInputParameters(propertyName, date)) {
        throw new IllegalArgumentException(MISSING_PARAMETERS_MSG);
    }
    if (!isPropertyTemporalType(propertyName)) {
        throw new IllegalArgumentException("Property [" + propertyName + "] is not of type " + timeInstantTemporalOperand.getName() + ".");
    }
    FilterType filter = filterObjectFactory.createFilterType();
    if (featureMetacardType.getProperties().contains(propertyName)) {
        FeatureAttributeDescriptor featureAttributeDescriptor = (FeatureAttributeDescriptor) featureMetacardType.getAttributeDescriptor(propertyName);
        if (featureAttributeDescriptor.isIndexed()) {
            filter.setTemporalOps(createBefore(featureAttributeDescriptor.getPropertyName(), featureMetacardType.getName(), date));
        } else {
            throw new IllegalArgumentException(String.format(PROPERTY_NOT_QUERYABLE, propertyName));
        }
    } else {
        return null;
    }
    return filter;
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType) QName(javax.xml.namespace.QName) FeatureAttributeDescriptor(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor) TemporalOperand(net.opengis.filter.v_2_0_0.TemporalOperandsType.TemporalOperand)

Example 12 with FeatureAttributeDescriptor

use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.

the class WfsFilterDelegate method buildDuringFilterType.

private FilterType buildDuringFilterType(String propertyName, String startDate, String endDate) {
    if (!isTemporalOpSupported(TEMPORAL_OPERATORS.During)) {
        throw new UnsupportedOperationException("Temporal Operator [" + TEMPORAL_OPERATORS.During + "] is not supported.");
    }
    TemporalOperand timePeriodTemporalOperand = new TemporalOperand();
    timePeriodTemporalOperand.setName(new QName(Wfs20Constants.GML_3_2_NAMESPACE, Wfs20Constants.TIME_PERIOD));
    if (!isTemporalOperandSupported(timePeriodTemporalOperand)) {
        throw new UnsupportedOperationException("Temporal Operand [" + timePeriodTemporalOperand.getName() + "] is not supported.");
    }
    if (!isValidInputParameters(propertyName, startDate, endDate)) {
        throw new IllegalArgumentException(MISSING_PARAMETERS_MSG);
    }
    if (!isPropertyTemporalType(propertyName)) {
        throw new IllegalArgumentException("Property [" + propertyName + "] is not of type " + timePeriodTemporalOperand.getName() + ".");
    }
    FilterType filter = filterObjectFactory.createFilterType();
    if (featureMetacardType.getProperties().contains(propertyName)) {
        FeatureAttributeDescriptor featureAttributeDescriptor = (FeatureAttributeDescriptor) featureMetacardType.getAttributeDescriptor(propertyName);
        if (featureAttributeDescriptor.isIndexed()) {
            filter.setTemporalOps(createDuring(featureAttributeDescriptor.getPropertyName(), featureMetacardType.getName(), startDate, endDate));
        } else {
            throw new IllegalArgumentException(String.format(PROPERTY_NOT_QUERYABLE, propertyName));
        }
    } else {
        return null;
    }
    return filter;
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType) QName(javax.xml.namespace.QName) FeatureAttributeDescriptor(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor) TemporalOperand(net.opengis.filter.v_2_0_0.TemporalOperandsType.TemporalOperand)

Example 13 with FeatureAttributeDescriptor

use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.

the class TestWfsFilterDelegate method mockFeatureMetacardCreateDelegate.

private WfsFilterDelegate mockFeatureMetacardCreateDelegate(String mockProperty, String mockType) {
    List<String> mockProperties = new ArrayList<>(1);
    mockProperties.add(mockProperty);
    when(mockFeatureMetacardType.getProperties()).thenReturn(mockProperties);
    when(mockFeatureMetacardType.getGmlProperties()).thenReturn(mockProperties);
    when(mockFeatureMetacardType.getTextualProperties()).thenReturn(mockProperties);
    when(mockFeatureMetacardType.getTemporalProperties()).thenReturn(mockProperties);
    when(mockFeatureMetacardType.getName()).thenReturn(mockType);
    FeatureAttributeDescriptor mockFeatureAttributeDescriptor = mock(FeatureAttributeDescriptor.class);
    when(mockFeatureAttributeDescriptor.isIndexed()).thenReturn(true);
    when(mockFeatureAttributeDescriptor.getPropertyName()).thenReturn(mockProperty);
    when(mockFeatureMetacardType.getAttributeDescriptor(mockProperty)).thenReturn(mockFeatureAttributeDescriptor);
    return new WfsFilterDelegate(mockFeatureMetacardType, MockWfsServer.getFilterCapabilities(), GeospatialUtil.EPSG_4326_URN, null, GeospatialUtil.LAT_LON_ORDER);
}
Also used : FeatureAttributeDescriptor(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor) ArrayList(java.util.ArrayList)

Example 14 with FeatureAttributeDescriptor

use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor 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 15 with FeatureAttributeDescriptor

use of org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor in project ddf by codice.

the class TestWfsFilterDelegate method testSingleGmlPropertyBlacklisted.

@Test(expected = IllegalArgumentException.class)
public void testSingleGmlPropertyBlacklisted() {
    WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.Contains.toString());
    when(mockFeatureMetacardType.getAttributeDescriptor(MOCK_GEOM)).thenReturn(new FeatureAttributeDescriptor(MOCK_GEOM, MOCK_GEOM, false, false, false, false, BasicTypes.STRING_TYPE));
    delegate.contains(MOCK_GEOM, POLYGON);
}
Also used : FeatureAttributeDescriptor(org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor) Test(org.junit.Test)

Aggregations

FeatureAttributeDescriptor (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor)17 ArrayList (java.util.ArrayList)13 FilterType (net.opengis.filter.v_2_0_0.FilterType)9 FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)6 SpatialOperatorType (net.opengis.filter.v_2_0_0.SpatialOperatorType)5 LineString (com.vividsolutions.jts.geom.LineString)4 QName (javax.xml.namespace.QName)4 Test (org.junit.Test)4 BinarySpatialOpType (net.opengis.filter.v_2_0_0.BinarySpatialOpType)3 TemporalOperand (net.opengis.filter.v_2_0_0.TemporalOperandsType.TemporalOperand)3 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)2 GeometryOperand (net.opengis.filter.v_2_0_0.GeometryOperandsType.GeometryOperand)2 FilterType (ogc.schema.opengis.filter.v_1_0_0.FilterType)2 MetacardMapper (org.codice.ddf.spatial.ogc.wfs.catalog.mapper.MetacardMapper)2 Function (com.google.common.base.Function)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Date (java.util.Date)1 ComparisonOperatorType (net.opengis.filter.v_2_0_0.ComparisonOperatorType)1 ComparisonOperatorsType (net.opengis.filter.v_2_0_0.ComparisonOperatorsType)1