Search in sources :

Example 16 with DistanceBufferType

use of net.opengis.filter.v_1_1_0.DistanceBufferType in project ddf by codice.

the class CswQueryFactoryTest method ogcSpatialRelativeQuery.

/**
     * Runs a binary Spatial OGC Query, verifying that the right filter class is generated based on OGC Filter
     *
     * @param spatialOps BinarySpatialOps query
     * @throws UnsupportedQueryException
     * @throws SourceUnavailableException
     * @throws FederationException
     * @throws CswException
     */
private <N extends DistanceBufferOperator> void ogcSpatialRelativeQuery(Class<N> clz, JAXBElement<DistanceBufferType> spatialOps) throws UnsupportedQueryException, SourceUnavailableException, FederationException, CswException {
    GetRecordsType grr = createDefaultPostRecordsRequest();
    QueryType query = new QueryType();
    List<QName> typeNames = new ArrayList<>();
    typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
    query.setTypeNames(typeNames);
    QueryConstraintType constraint = new QueryConstraintType();
    FilterType filter = new FilterType();
    filter.setSpatialOps(spatialOps);
    constraint.setFilter(filter);
    query.setConstraint(constraint);
    JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
    grr.setAbstractQuery(jaxbQuery);
    QueryImpl frameworkQuery = (QueryImpl) queryFactory.getQuery(grr).getQuery();
    assertThat(frameworkQuery.getFilter(), instanceOf(clz));
    @SuppressWarnings("unchecked") N spatial = (N) frameworkQuery.getFilter();
    assertThat(((LiteralExpressionImpl) spatial.getExpression2()).getValue(), is(polygon));
    assertThat(((AttributeExpressionImpl) spatial.getExpression1()).getPropertyName(), is(SPATIAL_TEST_ATTRIBUTE));
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType) QueryImpl(ddf.catalog.operation.impl.QueryImpl) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) JAXBElement(javax.xml.bind.JAXBElement) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType) QueryConstraintType(net.opengis.cat.csw.v_2_0_2.QueryConstraintType)

Aggregations

DistanceBufferType (net.opengis.filter.v_2_0_0.DistanceBufferType)9 FilterType (net.opengis.filter.v_2_0_0.FilterType)9 Test (org.junit.Test)9 DistanceBufferType (net.opengis.filter.v_1_1_0.DistanceBufferType)6 ArrayList (java.util.ArrayList)4 DistanceType (net.opengis.filter.v_1_1_0.DistanceType)3 PropertyNameType (net.opengis.filter.v_1_1_0.PropertyNameType)3 BinaryLogicOpType (net.opengis.filter.v_2_0_0.BinaryLogicOpType)3 UnaryLogicOpType (net.opengis.filter.v_2_0_0.UnaryLogicOpType)3 Geometry (com.vividsolutions.jts.geom.Geometry)2 Method (java.lang.reflect.Method)2 QueryImpl (ddf.catalog.operation.impl.QueryImpl)1 JAXBElement (javax.xml.bind.JAXBElement)1 QName (javax.xml.namespace.QName)1 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)1 QueryConstraintType (net.opengis.cat.csw.v_2_0_2.QueryConstraintType)1 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)1 FilterType (net.opengis.filter.v_1_1_0.FilterType)1 BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)1 PropertyIsLikeType (net.opengis.filter.v_2_0_0.PropertyIsLikeType)1