Search in sources :

Example 16 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class GetCapabilitiesResponseEncoder method createInsertionCapabilities.

private XmlObject createInsertionCapabilities(SosInsertionCapabilities caps) {
    InsertionCapabilitiesDocument doc = InsertionCapabilitiesDocument.Factory.newInstance(getXmlOptions());
    InsertionCapabilitiesType xbCaps = doc.addNewInsertionCapabilities();
    caps.getFeatureOfInterestTypes().stream().filter(foiType -> !foiType.equals(SosConstants.NOT_DEFINED)).forEachOrdered(foiType -> xbCaps.addFeatureOfInterestType(foiType));
    caps.getObservationTypes().stream().filter(oType -> !oType.equals(SosConstants.NOT_DEFINED)).forEachOrdered(oType -> xbCaps.addObservationType(oType));
    caps.getProcedureDescriptionFormats().stream().filter(pdf -> !pdf.equals(SosConstants.NOT_DEFINED)).forEachOrdered(pdf -> xbCaps.addProcedureDescriptionFormat(pdf));
    caps.getSupportedEncodings().stream().filter(se -> !se.equals(SosConstants.NOT_DEFINED)).forEachOrdered(se -> xbCaps.addSupportedEncoding(se));
    return doc;
}
Also used : Extension(org.n52.shetland.ogc.ows.extension.Extension) SosInsertionCapabilities(org.n52.shetland.ogc.sos.SosInsertionCapabilities) StringBasedExtension(org.n52.shetland.ogc.ows.extension.StringBasedExtension) SosOffering(org.n52.shetland.ogc.sos.SosOffering) GetCapabilitiesResponse(org.n52.shetland.ogc.ows.service.GetCapabilitiesResponse) XmlCursor(org.apache.xmlbeans.XmlCursor) W3CConstants(org.n52.shetland.w3c.W3CConstants) LoggerFactory(org.slf4j.LoggerFactory) SosConstants(org.n52.shetland.ogc.sos.SosConstants) ContentsType(net.opengis.sos.x20.ContentsType) OwsCapabilities(org.n52.shetland.ogc.ows.OwsCapabilities) OwsCapabilitiesExtension(org.n52.shetland.ogc.ows.OwsCapabilitiesExtension) CapabilitiesDocument(net.opengis.sos.x20.CapabilitiesDocument) SosCapabilities(org.n52.shetland.ogc.sos.SosCapabilities) Contents(net.opengis.sos.x20.CapabilitiesType.Contents) XmlObject(org.apache.xmlbeans.XmlObject) CodeType(org.n52.shetland.ogc.gml.CodeType) FeatureRelationshipType(net.opengis.swes.x20.FeatureRelationshipType) Sos2Constants(org.n52.shetland.ogc.sos.Sos2Constants) EncodingException(org.n52.svalbard.encode.exception.EncodingException) Logger(org.slf4j.Logger) SosObservationOfferingExtension(org.n52.shetland.ogc.sos.extension.SosObservationOfferingExtension) Collection(java.util.Collection) Set(java.util.Set) InsertionCapabilitiesDocument(net.opengis.sos.x20.InsertionCapabilitiesDocument) Sets(com.google.common.collect.Sets) ObservationOfferingType(net.opengis.sos.x20.ObservationOfferingType) XmlException(org.apache.xmlbeans.XmlException) CapabilitiesType(net.opengis.sos.x20.CapabilitiesType) GmlConstants(org.n52.shetland.ogc.gml.GmlConstants) InsertionCapabilitiesType(net.opengis.sos.x20.InsertionCapabilitiesType) SchemaLocation(org.n52.shetland.w3c.SchemaLocation) Offering(net.opengis.swes.x20.AbstractContentsType.Offering) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) OwsOperationsMetadata(org.n52.shetland.ogc.ows.OwsOperationsMetadata) SosObservationOffering(org.n52.shetland.ogc.sos.SosObservationOffering) InsertionCapabilitiesType(net.opengis.sos.x20.InsertionCapabilitiesType) InsertionCapabilitiesDocument(net.opengis.sos.x20.InsertionCapabilitiesDocument)

Example 17 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class FesEncoderv20 method setTemporalFilterCapabilities.

/**
 * Sets the TemporalFilterCapabilities.
 *
 * @param temporalCapabilitiesType FES TemporalCapabilities.
 * @param sosFilterCaps            SOS temporal filter information
 *
 * @throws org.n52.svalbard.encode.exception.EncodingException if one of the temporal operators is not supported
 */
private void setTemporalFilterCapabilities(TemporalCapabilitiesType temporalCapabilitiesType, org.n52.shetland.ogc.filter.FilterCapabilities sosFilterCaps) throws EncodingException {
    // set TemporalOperands
    if (sosFilterCaps.getTemporalOperands() != null && !sosFilterCaps.getTemporalOperands().isEmpty()) {
        TemporalOperandsType tempOperands = temporalCapabilitiesType.addNewTemporalOperands();
        sosFilterCaps.getTemporalOperands().forEach(operand -> tempOperands.addNewTemporalOperand().setName(operand));
    }
    // set TemporalOperators
    if (sosFilterCaps.getTemporalOperators() != null && !sosFilterCaps.getTemporalOperators().isEmpty()) {
        TemporalOperatorsType temporalOps = temporalCapabilitiesType.addNewTemporalOperators();
        Set<TimeOperator> keys = sosFilterCaps.getTemporalOperators().keySet();
        for (TimeOperator temporalOperator : keys) {
            TemporalOperatorType operator = temporalOps.addNewTemporalOperator();
            operator.setName(getEnum4TemporalOperator(temporalOperator));
            TemporalOperandsType bboxGeomOps = operator.addNewTemporalOperands();
            sosFilterCaps.getTemporalOperators().get(temporalOperator).forEach(operand -> bboxGeomOps.addNewTemporalOperand().setName(operand));
        }
    }
}
Also used : TimeOperator(org.n52.shetland.ogc.filter.FilterConstants.TimeOperator) TemporalOperatorType(net.opengis.fes.x20.TemporalOperatorType) TemporalOperatorsType(net.opengis.fes.x20.TemporalOperatorsType) TemporalOperandsType(net.opengis.fes.x20.TemporalOperandsType)

Example 18 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class FesEncoderv20 method setConformance.

/**
 * Sets the FES conformance classes in the filter capabilities section.
 *
 * @param conformance XML FES conformence
 * @param sosConformance Service conformance
 *
 * @throws EncodingException If an error occurs
 */
private void setConformance(final ConformanceType conformance, Collection<OwsDomain> sosConformance) throws EncodingException {
    for (OwsDomain owsDomainType : sosConformance) {
        XmlObject encodeObjectToXml = encodeObjectToXml(OWSConstants.NS_OWS, owsDomainType);
        conformance.addNewConstraint().set(encodeObjectToXml);
    }
}
Also used : OwsDomain(org.n52.shetland.ogc.ows.OwsDomain) XmlObject(org.apache.xmlbeans.XmlObject)

Example 19 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class FesEncoderv20Test method should_return_BBoxType_for_spatialFilter.

// @Test
// deactivated until test fails on build server.
public final void should_return_BBoxType_for_spatialFilter() throws EncodingException {
    final SpatialFilter filter = new SpatialFilter();
    filter.setOperator(SpatialOperator.BBOX);
    filter.setGeometry(new GeometryFactory().toGeometry(new Envelope(1, 2, 3, 4)));
    filter.setValueReference("valueReference");
    final XmlObject encode = fesEncoder.encode(filter);
    assertThat(encode, is(instanceOf(BBOXType.class)));
    final BBOXType xbBBox = (BBOXType) encode;
    assertThat(xbBBox.isSetExpression(), is(TRUE));
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) BBOXType(net.opengis.fes.x20.BBOXType) SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) XmlObject(org.apache.xmlbeans.XmlObject) Envelope(org.locationtech.jts.geom.Envelope)

Example 20 with Filter

use of org.n52.shetland.ogc.filter.Filter in project arctic-sea by 52North.

the class JSONDecoder method decodeJsonToObjectList.

protected <T> List<T> decodeJsonToObjectList(JsonNode node, Class<T> type) throws DecodingException {
    Decoder<T, JsonNode> decoder = getDecoder(type);
    if (node.isArray()) {
        CompositeException exceptions = new CompositeException();
        List<T> list = Streams.stream(node).filter(JsonNode::isObject).map(exceptions.wrapFunction(decoder::decode)).filter(Optional::isPresent).map(Optional::get).collect(toList());
        exceptions.throwIfNotEmpty(DecodingException::new);
        return list;
    } else if (node.isObject()) {
        return Collections.singletonList(decoder.decode(node));
    } else {
        return Collections.emptyList();
    }
}
Also used : Optional(java.util.Optional) CompositeException(org.n52.janmayen.exception.CompositeException) JsonNode(com.fasterxml.jackson.databind.JsonNode) DecodingException(org.n52.svalbard.decode.exception.DecodingException)

Aggregations

Test (org.junit.Test)10 SpatialFilter (org.n52.shetland.ogc.filter.SpatialFilter)10 XmlObject (org.apache.xmlbeans.XmlObject)9 ComparisonFilter (org.n52.shetland.ogc.filter.ComparisonFilter)9 XmlException (org.apache.xmlbeans.XmlException)6 DecodingException (org.n52.svalbard.decode.exception.DecodingException)6 URI (java.net.URI)3 Objects (java.util.Objects)3 Set (java.util.Set)3 BinaryTemporalOpType (net.opengis.fes.x20.BinaryTemporalOpType)3 XmlCursor (org.apache.xmlbeans.XmlCursor)3 LocalizedString (org.n52.janmayen.i18n.LocalizedString)3 MultilingualString (org.n52.janmayen.i18n.MultilingualString)3 TimeOperator (org.n52.shetland.ogc.filter.FilterConstants.TimeOperator)3 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)3 OwsDomain (org.n52.shetland.ogc.ows.OwsDomain)3 OwsLanguageString (org.n52.shetland.ogc.ows.OwsLanguageString)3 OwsMetadata (org.n52.shetland.ogc.ows.OwsMetadata)3 Strings (com.google.common.base.Strings)2 Arrays (java.util.Arrays)2