Search in sources :

Example 1 with SpatialOperatorsType

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

the class WfsSource method updateSupportedSpatialOperators.

private void updateSupportedSpatialOperators(SpatialOperatorsType spatialOperatorsType) {
    if (spatialOperatorsType == null) {
        return;
    }
    supportedSpatialOperators = spatialOperatorsType;
    if (NO_FORCED_SPATIAL_FILTER.equals(forceSpatialFilter)) {
        return;
    }
    SpatialOperatorsType forcedSpatialOpType = new SpatialOperatorsType();
    SpatialOperatorType sot = new SpatialOperatorType();
    sot.setName(forceSpatialFilter);
    forcedSpatialOpType.getSpatialOperator().add(sot);
    for (WfsFilterDelegate delegate : featureTypeFilters.values()) {
        delegate.setSpatialOps(forcedSpatialOpType);
    }
}
Also used : SpatialOperatorsType(net.opengis.filter.v_2_0_0.SpatialOperatorsType) SpatialOperatorType(net.opengis.filter.v_2_0_0.SpatialOperatorType)

Example 2 with SpatialOperatorsType

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

the class AbstractCswSource method readGetRecordsOperation.

/**
     * Parses the getRecords {@link Operation} to understand the capabilities of the org.codice.ddf.spatial.ogc.csw.catalog.common.Csw Server. A
     * sample GetRecords Operation may look like this:
     * <p>
     * <pre>
     *   <ows:Operation name="GetRecords">
     *     <ows:DCP>
     *       <ows:HTTP>
     *         <ows:Get  xlink:href="http://www.cubewerx.com/cwcsw.cgi?" />
     *         <ows:Post xlink:href="http://www.cubewerx.com/cwcsw.cgi" />
     *       </ows:HTTP>
     *     </ows:DCP>
     *     <ows:Parameter name="TypeName">
     *       <ows:Value>csw:Record</ows:Value>
     *     </ows:Parameter>
     *     <ows:Parameter name="outputFormat">
     *       <ows:Value>application/xml</ows:Value>
     *       <ows:Value>text/html</ows:Value>
     *       <ows:Value>text/plain</ows:Value>
     *     </ows:Parameter>
     *     <ows:Parameter name="outputSchema">
     *       <ows:Value>http://www.opengis.net/cat/csw/2.0.2</ows:Value>
     *     </ows:Parameter>
     *     <ows:Parameter name="resultType">
     *       <ows:Value>hits</ows:Value>
     *       <ows:Value>results</ows:Value>
     *       <ows:Value>validate</ows:Value>
     *     </ows:Parameter>
     *     <ows:Parameter name="ElementSetName">
     *       <ows:Value>brief</ows:Value>
     *       <ows:Value>summary</ows:Value>
     *       <ows:Value>full</ows:Value>
     *     </ows:Parameter>
     *     <ows:Parameter name="CONSTRAINTLANGUAGE">
     *       <ows:Value>Filter</ows:Value>
     *     </ows:Parameter>
     *   </ows:Operation>
     * </pre>
     *
     * @param capabilitiesType The capabilities the org.codice.ddf.spatial.ogc.csw.catalog.common.Csw Server supports
     */
private void readGetRecordsOperation(CapabilitiesType capabilitiesType) {
    OperationsMetadata operationsMetadata = capabilitiesType.getOperationsMetadata();
    if (null == operationsMetadata) {
        LOGGER.info("{}: CSW Source contains no operations", cswSourceConfiguration.getId());
        return;
    }
    description = capabilitiesType.getServiceIdentification().getAbstract();
    Operation getRecordsOp = getOperation(operationsMetadata, CswConstants.GET_RECORDS);
    if (null == getRecordsOp) {
        LOGGER.info("{}: CSW Source contains no getRecords Operation", cswSourceConfiguration.getId());
        return;
    }
    this.supportedOutputSchemas = getParameter(getRecordsOp, CswConstants.OUTPUT_SCHEMA_PARAMETER);
    DomainType constraintLanguage = getParameter(getRecordsOp, CswConstants.CONSTRAINT_LANGUAGE_PARAMETER);
    if (null != constraintLanguage) {
        DomainType outputFormatValues = getParameter(getRecordsOp, CswConstants.OUTPUT_FORMAT_PARAMETER);
        DomainType resultTypesValues = getParameter(getRecordsOp, CswConstants.RESULT_TYPE_PARAMETER);
        readSetDetailLevels(getParameter(getRecordsOp, CswConstants.ELEMENT_SET_NAME_PARAMETER));
        List<String> constraints = new ArrayList<>();
        for (String s : constraintLanguage.getValue()) {
            constraints.add(s.toLowerCase());
        }
        if (constraints.contains(CswConstants.CONSTRAINT_LANGUAGE_CQL.toLowerCase()) && !constraints.contains(CswConstants.CONSTRAINT_LANGUAGE_FILTER.toLowerCase())) {
            isConstraintCql = true;
        } else {
            isConstraintCql = false;
        }
        setFilterDelegate(getRecordsOp, capabilitiesType.getFilterCapabilities(), outputFormatValues, resultTypesValues, cswSourceConfiguration);
        spatialCapabilities = capabilitiesType.getFilterCapabilities().getSpatialCapabilities();
        if (!NO_FORCE_SPATIAL_FILTER.equals(forceSpatialFilter)) {
            SpatialOperatorType sot = new SpatialOperatorType();
            SpatialOperatorNameType sont = SpatialOperatorNameType.fromValue(forceSpatialFilter);
            sot.setName(sont);
            sot.setGeometryOperands(cswFilterDelegate.getGeoOpsForSpatialOp(sont));
            SpatialOperatorsType spatialOperators = new SpatialOperatorsType();
            spatialOperators.setSpatialOperator(Arrays.asList(sot));
            cswFilterDelegate.setSpatialOps(spatialOperators);
        }
    }
}
Also used : OperationsMetadata(net.opengis.ows.v_1_0_0.OperationsMetadata) DomainType(net.opengis.ows.v_1_0_0.DomainType) SpatialOperatorsType(net.opengis.filter.v_1_1_0.SpatialOperatorsType) SpatialOperatorType(net.opengis.filter.v_1_1_0.SpatialOperatorType) ArrayList(java.util.ArrayList) Operation(net.opengis.ows.v_1_0_0.Operation) SpatialOperatorNameType(net.opengis.filter.v_1_1_0.SpatialOperatorNameType)

Example 3 with SpatialOperatorsType

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

the class CswFilterDelegate method setSpatialOps.

public void setSpatialOps(SpatialOperatorsType spatialOperators) {
    spatialOps = new ConcurrentHashMap<>(new EnumMap<>(SpatialOperatorNameType.class));
    for (SpatialOperatorType spatialOp : spatialOperators.getSpatialOperator()) {
        LOGGER.debug("Adding key [spatialOp Name: {}]", spatialOp.getName());
        spatialOps.put(spatialOp.getName(), spatialOp);
        LOGGER.debug("spatialOps Map: {}", spatialOps.toString());
    }
}
Also used : SpatialOperatorType(net.opengis.filter.v_1_1_0.SpatialOperatorType) EnumMap(java.util.EnumMap)

Example 4 with SpatialOperatorsType

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

the class CswEndpoint method buildFilterCapabilities.

/**
     * Creates the Filter_Capabilities section of the GetCapabilities response. These are defined
     * statically by the DDF FilterAdapter implementation TODO: If the implementation changes,
     * update this method to reflect the changes.
     *
     * @return The constructed FilterCapabilities object
     */
private FilterCapabilities buildFilterCapabilities() {
    // Create the FilterCapabilites - These are defined statically by the
    // DDF FilterAdapter implementation
    FilterCapabilities filterCapabilities = new FilterCapabilities();
    ScalarCapabilitiesType scalarCapabilities = new ScalarCapabilitiesType();
    ComparisonOperatorsType cot = new ComparisonOperatorsType();
    cot.setComparisonOperator(COMPARISON_OPERATORS);
    scalarCapabilities.setLogicalOperators(new LogicalOperators());
    scalarCapabilities.setComparisonOperators(cot);
    filterCapabilities.setScalarCapabilities(scalarCapabilities);
    SpatialOperatorsType spatialOpsType = new SpatialOperatorsType();
    ArrayList<SpatialOperatorType> spatialOpTypes = new ArrayList<>();
    for (SpatialOperatorNameType sont : SPATIAL_OPERATORS) {
        SpatialOperatorType sot = new SpatialOperatorType();
        sot.setName(sont);
        spatialOpTypes.add(sot);
    }
    GeometryOperandsType geometryOperands = new GeometryOperandsType();
    List<QName> geoOperandsList = geometryOperands.getGeometryOperand();
    geoOperandsList.add(new QName(CswConstants.GML_SCHEMA, CswConstants.GML_POINT, CswConstants.GML_NAMESPACE_PREFIX));
    geoOperandsList.add(new QName(CswConstants.GML_SCHEMA, CswConstants.GML_LINESTRING, CswConstants.GML_NAMESPACE_PREFIX));
    geoOperandsList.add(new QName(CswConstants.GML_SCHEMA, CswConstants.GML_POLYGON, CswConstants.GML_NAMESPACE_PREFIX));
    spatialOpsType.setSpatialOperator(spatialOpTypes);
    SpatialCapabilitiesType spatialCaps = new SpatialCapabilitiesType();
    spatialCaps.setSpatialOperators(spatialOpsType);
    spatialCaps.setGeometryOperands(geometryOperands);
    filterCapabilities.setSpatialCapabilities(spatialCaps);
    IdCapabilitiesType idCapabilities = new IdCapabilitiesType();
    idCapabilities.getEIDOrFID().add(new EID());
    filterCapabilities.setIdCapabilities(idCapabilities);
    return filterCapabilities;
}
Also used : EID(net.opengis.filter.v_1_1_0.EID) QName(javax.xml.namespace.QName) SpatialOperatorType(net.opengis.filter.v_1_1_0.SpatialOperatorType) LogicalOperators(net.opengis.filter.v_1_1_0.LogicalOperators) ArrayList(java.util.ArrayList) SpatialOperatorNameType(net.opengis.filter.v_1_1_0.SpatialOperatorNameType) SpatialCapabilitiesType(net.opengis.filter.v_1_1_0.SpatialCapabilitiesType) FilterCapabilities(net.opengis.filter.v_1_1_0.FilterCapabilities) IdCapabilitiesType(net.opengis.filter.v_1_1_0.IdCapabilitiesType) 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) GeometryOperandsType(net.opengis.filter.v_1_1_0.GeometryOperandsType)

Example 5 with SpatialOperatorsType

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

the class TestWfsSource method setUp.

public void setUp(final String schema, final List<Object> supportedGeos, final String srsName, final Integer numFeatures, final Integer numResults) throws WfsException, SecurityServiceException {
    mockFactory = mock(SecureCxfClientFactory.class);
    when(mockFactory.getClient()).thenReturn(mockWfs);
    // GetCapabilities Response
    when(mockWfs.getCapabilities(any(GetCapabilitiesRequest.class))).thenReturn(mockCapabilites);
    mockCapabilites.setFilterCapabilities(new FilterCapabilities());
    mockCapabilites.getFilterCapabilities().setSpatialCapabilities(new SpatialCapabilitiesType());
    mockCapabilites.getFilterCapabilities().getSpatialCapabilities().setSpatialOperators(new SpatialOperatorsType());
    if (null != supportedGeos && !supportedGeos.isEmpty()) {
        mockCapabilites.getFilterCapabilities().getSpatialCapabilities().getSpatialOperators().getBBOXOrEqualsOrDisjoint().addAll(supportedGeos);
    }
    // DescribeFeatureType Response
    XmlSchema xmlSchema = null;
    if (null != schema) {
        XmlSchemaCollection schemaCollection = new XmlSchemaCollection();
        wfsUriResolver.setGmlNamespace(Wfs10Constants.GML_NAMESPACE);
        wfsUriResolver.setWfsNamespace(Wfs10Constants.WFS_NAMESPACE);
        schemaCollection.setSchemaResolver(wfsUriResolver);
        xmlSchema = schemaCollection.read(new StreamSource(new ByteArrayInputStream(schema.getBytes())));
    }
    when(mockWfs.describeFeatureType(any(DescribeFeatureTypeRequest.class))).thenReturn(xmlSchema);
    sampleFeatures = new ArrayList<>();
    mockCapabilites.setFeatureTypeList(new FeatureTypeListType());
    if (numFeatures != null) {
        for (int ii = 0; ii < numFeatures; ii++) {
            FeatureTypeType feature = new FeatureTypeType();
            QName qName;
            if (ii == 0) {
                qName = new QName("SampleFeature" + ii);
            } else {
                qName = new QName("http://example.com", "SampleFeature" + ii, "Prefix" + ii);
            }
            sampleFeatures.add(qName);
            feature.setName(qName);
            // feature.setName(SAMPLE_FEATURE[ii]);
            if (null != srsName) {
                feature.setSRS(srsName);
            }
            mockCapabilites.getFeatureTypeList().getFeatureType().add(feature);
        }
    }
    // GetFeature Response
    when(mockWfs.getFeature(any(GetFeatureType.class))).thenReturn(mockFeatureCollection);
    when(mockFeatureCollection.getFeatureMembers()).thenAnswer(new Answer<List<Metacard>>() {

        @Override
        public List<Metacard> answer(InvocationOnMock invocation) {
            // Create as many metacards as there are features
            Integer resultsToReturn = numResults;
            if (resultsToReturn == null && numFeatures != null) {
                resultsToReturn = numFeatures;
            }
            List<Metacard> metacards = new ArrayList<Metacard>(resultsToReturn);
            for (int i = 0; i < resultsToReturn; i++) {
                MetacardImpl mc = new MetacardImpl();
                mc.setId("ID_" + String.valueOf(i + 1));
                metacards.add(mc);
            }
            return metacards;
        }
    });
    when(mockAvailabilityTask.isAvailable()).thenReturn(true);
    source = new WfsSource(new GeotoolsFilterAdapterImpl(), mockContext, mockAvailabilityTask, mockFactory, encryptionService);
}
Also used : SecureCxfClientFactory(org.codice.ddf.cxf.SecureCxfClientFactory) SpatialCapabilitiesType(ogc.schema.opengis.filter_capabilities.v_1_0_0.SpatialCapabilitiesType) FilterCapabilities(ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities) SpatialOperatorsType(ogc.schema.opengis.filter_capabilities.v_1_0_0.SpatialOperatorsType) List(java.util.List) ArrayList(java.util.ArrayList) GetFeatureType(ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType) GetCapabilitiesRequest(org.codice.ddf.spatial.ogc.wfs.v1_0_0.catalog.common.GetCapabilitiesRequest) FeatureTypeType(ogc.schema.opengis.wfs_capabilities.v_1_0_0.FeatureTypeType) FeatureTypeListType(ogc.schema.opengis.wfs_capabilities.v_1_0_0.FeatureTypeListType) QName(javax.xml.namespace.QName) StreamSource(javax.xml.transform.stream.StreamSource) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) BigInteger(java.math.BigInteger) Metacard(ddf.catalog.data.Metacard) XmlSchema(org.apache.ws.commons.schema.XmlSchema) ByteArrayInputStream(java.io.ByteArrayInputStream) InvocationOnMock(org.mockito.invocation.InvocationOnMock) DescribeFeatureTypeRequest(org.codice.ddf.spatial.ogc.wfs.v1_0_0.catalog.common.DescribeFeatureTypeRequest) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)

Aggregations

SpatialOperatorsType (net.opengis.filter.v_1_1_0.SpatialOperatorsType)5 ArrayList (java.util.ArrayList)4 ComparisonOperatorsType (net.opengis.filter.v_1_1_0.ComparisonOperatorsType)4 FilterCapabilities (net.opengis.filter.v_1_1_0.FilterCapabilities)4 LogicalOperators (net.opengis.filter.v_1_1_0.LogicalOperators)4 ScalarCapabilitiesType (net.opengis.filter.v_1_1_0.ScalarCapabilitiesType)4 SpatialCapabilitiesType (net.opengis.filter.v_1_1_0.SpatialCapabilitiesType)4 SpatialOperatorType (net.opengis.filter.v_1_1_0.SpatialOperatorType)4 QName (javax.xml.namespace.QName)3 SpatialOperatorNameType (net.opengis.filter.v_1_1_0.SpatialOperatorNameType)3 SpatialOperatorType (net.opengis.filter.v_2_0_0.SpatialOperatorType)2 SpatialOperatorsType (net.opengis.filter.v_2_0_0.SpatialOperatorsType)2 Metacard (ddf.catalog.data.Metacard)1 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 GeotoolsFilterAdapterImpl (ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 BigInteger (java.math.BigInteger)1 EnumMap (java.util.EnumMap)1 List (java.util.List)1 StreamSource (javax.xml.transform.stream.StreamSource)1