Search in sources :

Example 1 with SpatialOperatorNameType

use of net.opengis.filter.v_1_1_0.SpatialOperatorNameType 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 2 with SpatialOperatorNameType

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

the class CswFilterDelegateTest method getXmlProperty.

private String getXmlProperty(CswFilterDelegate localCswFilterDelegate, String propName, SpatialOperatorNameType spatialOp, String wkt) throws JAXBException {
    FilterType filterType = null;
    switch(spatialOp) {
        case CONTAINS:
            filterType = localCswFilterDelegate.contains(propName, wkt);
            break;
        case CROSSES:
            filterType = localCswFilterDelegate.crosses(propName, wkt);
            break;
        case D_WITHIN:
            filterType = localCswFilterDelegate.dwithin(propName, polygonWkt, SAMPLE_DISTANCE);
            break;
        case DISJOINT:
            filterType = localCswFilterDelegate.disjoint(propName, wkt);
            break;
        case INTERSECTS:
            filterType = localCswFilterDelegate.intersects(propName, wkt);
            break;
        case OVERLAPS:
            filterType = localCswFilterDelegate.overlaps(propName, wkt);
            break;
        case TOUCHES:
            filterType = localCswFilterDelegate.touches(propName, polygonWkt);
            break;
        case WITHIN:
            filterType = localCswFilterDelegate.within(propName, wkt);
            break;
        default:
            break;
    }
    marshaller.marshal(getFilterTypeJaxbElement(filterType), writer);
    String xml = writer.toString();
    LOGGER.debug("\nXml: {}", xml);
    return xml;
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType)

Example 3 with SpatialOperatorNameType

use of net.opengis.filter.v_1_1_0.SpatialOperatorNameType 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);
        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 4 with SpatialOperatorNameType

use of net.opengis.filter.v_1_1_0.SpatialOperatorNameType 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 5 with SpatialOperatorNameType

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

the class TestCswFilterDelegate method getXmlProperty.

private String getXmlProperty(CswFilterDelegate localCswFilterDelegate, String propName, SpatialOperatorNameType spatialOp, String wkt) throws JAXBException {
    FilterType filterType = null;
    switch(spatialOp) {
        case CONTAINS:
            filterType = localCswFilterDelegate.contains(propName, wkt);
            break;
        case CROSSES:
            filterType = localCswFilterDelegate.crosses(propName, wkt);
            break;
        case D_WITHIN:
            filterType = localCswFilterDelegate.dwithin(propName, polygonWkt, SAMPLE_DISTANCE);
            break;
        case DISJOINT:
            filterType = localCswFilterDelegate.disjoint(propName, wkt);
            break;
        case INTERSECTS:
            filterType = localCswFilterDelegate.intersects(propName, wkt);
            break;
        case OVERLAPS:
            filterType = localCswFilterDelegate.overlaps(propName, wkt);
            break;
        case TOUCHES:
            filterType = localCswFilterDelegate.touches(propName, polygonWkt);
            break;
        case WITHIN:
            filterType = localCswFilterDelegate.within(propName, wkt);
            break;
        default:
            break;
    }
    marshaller.marshal(getFilterTypeJaxbElement(filterType), writer);
    String xml = writer.toString();
    LOGGER.debug("\nXml: {}", xml);
    return xml;
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType)

Aggregations

ArrayList (java.util.ArrayList)5 SpatialOperatorType (net.opengis.filter.v_1_1_0.SpatialOperatorType)5 SpatialOperatorNameType (net.opengis.filter.v_1_1_0.SpatialOperatorNameType)4 SpatialOperatorsType (net.opengis.filter.v_1_1_0.SpatialOperatorsType)4 ComparisonOperatorsType (net.opengis.filter.v_1_1_0.ComparisonOperatorsType)3 FilterCapabilities (net.opengis.filter.v_1_1_0.FilterCapabilities)3 LogicalOperators (net.opengis.filter.v_1_1_0.LogicalOperators)3 ScalarCapabilitiesType (net.opengis.filter.v_1_1_0.ScalarCapabilitiesType)3 SpatialCapabilitiesType (net.opengis.filter.v_1_1_0.SpatialCapabilitiesType)3 QName (javax.xml.namespace.QName)2 FilterType (net.opengis.filter.v_1_1_0.FilterType)2 GeometryOperandsType (net.opengis.filter.v_1_1_0.GeometryOperandsType)2 EID (net.opengis.filter.v_1_1_0.EID)1 IdCapabilitiesType (net.opengis.filter.v_1_1_0.IdCapabilitiesType)1 DomainType (net.opengis.ows.v_1_0_0.DomainType)1 Operation (net.opengis.ows.v_1_0_0.Operation)1 OperationsMetadata (net.opengis.ows.v_1_0_0.OperationsMetadata)1