Search in sources :

Example 16 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.

the class ObservationEncoder method getFieldForValue.

private SweField getFieldForValue(String phenomenon, Value<?> value) throws EncodingException {
    final SweAbstractDataComponent def;
    if (value instanceof BooleanValue) {
        def = new SweBoolean();
    } else if (value instanceof CategoryValue) {
        SweCategory sweCategory = new SweCategory();
        CategoryValue categoryValue = (CategoryValue) value;
        sweCategory.setCodeSpace(categoryValue.getUnit());
        def = sweCategory;
    } else if (value instanceof CountValue) {
        def = new SweCount();
    } else if (value instanceof QuantityValue) {
        SweQuantity sweQuantity = new SweQuantity();
        QuantityValue quantityValue = (QuantityValue) value;
        sweQuantity.setUom(quantityValue.getUnit());
        def = sweQuantity;
    } else if (value instanceof TextValue) {
        def = new SweText();
    } else if (value instanceof NilTemplateValue) {
        def = new SweText();
    } else if (value instanceof BooleanValue) {
        def = new SweBoolean();
    } else if (value instanceof GeometryValue) {
        def = new SweText();
    } else {
        throw new UnsupportedEncoderInputException(this, value);
    }
    def.setDefinition(phenomenon);
    return new SweField(phenomenon, def);
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException) GeometryValue(org.n52.shetland.ogc.om.values.GeometryValue) CountValue(org.n52.shetland.ogc.om.values.CountValue) SweField(org.n52.shetland.ogc.swe.SweField) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) TextValue(org.n52.shetland.ogc.om.values.TextValue) BooleanValue(org.n52.shetland.ogc.om.values.BooleanValue) CategoryValue(org.n52.shetland.ogc.om.values.CategoryValue) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) NilTemplateValue(org.n52.shetland.ogc.om.values.NilTemplateValue)

Example 17 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.

the class AbstractObservationResponseEncoder method encodeResponse.

@Override
protected void encodeResponse(ObjectNode json, T t) throws EncodingException {
    ArrayNode obs = json.putArray(JSONConstants.OBSERVATIONS);
    try {
        ObservationStream observationCollection = t.getObservationCollection();
        encodeObservationStream(observationCollection, obs);
    } catch (OwsExceptionReport ex) {
        throw new EncodingException(ex);
    }
}
Also used : ObservationStream(org.n52.shetland.ogc.om.ObservationStream) EncodingException(org.n52.svalbard.encode.exception.EncodingException) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport)

Example 18 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.

the class FeatureOfInterestEncoder method encodeFeatureCollection.

private JsonNode encodeFeatureCollection(AbstractFeature t) throws EncodingException {
    FeatureCollection featureCollection = (FeatureCollection) t;
    ArrayNode a = nodeFactory().arrayNode();
    for (AbstractFeature af : featureCollection) {
        a.add(encodeObjectToJson(af));
    }
    return a;
}
Also used : FeatureCollection(org.n52.shetland.ogc.om.features.FeatureCollection) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 19 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.

the class AbstractMonitoringFeatureEncoder method setInvolvedIn.

private void setInvolvedIn(AbstractMonitoringFeatureType amft, AbstractMonitoringFeature abstractMonitoringFeature) throws EncodingException {
    if (abstractMonitoringFeature.isSetInvolvedIn()) {
        for (EnvironmentalMonitoringActivity environmentalMonitoringActivity : abstractMonitoringFeature.getInvolvedIn()) {
            if (environmentalMonitoringActivity.isSetSimpleAttrs()) {
                InvolvedIn ii = amft.addNewInvolvedIn();
                ii.setHref(environmentalMonitoringActivity.getSimpleAttrs().getHref());
                if (environmentalMonitoringActivity.getSimpleAttrs().isSetTitle()) {
                    ii.setTitle(environmentalMonitoringActivity.getSimpleAttrs().getTitle());
                }
            } else {
                amft.addNewInvolvedIn().addNewEnvironmentalMonitoringActivity().set(encodeEF(environmentalMonitoringActivity));
            }
        }
    }
}
Also used : EnvironmentalMonitoringActivity(org.n52.shetland.inspire.ef.EnvironmentalMonitoringActivity) InvolvedIn(eu.europa.ec.inspire.schemas.ef.x40.AbstractMonitoringFeatureType.InvolvedIn)

Example 20 with EncodingException

use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.

the class AbstractMonitoringObjectEncoder method setNarrower.

private void setNarrower(AbstractMonitoringObjectType amot, AbstractMonitoringObject abstractMonitoringObject) throws EncodingException {
    if (abstractMonitoringObject.isSetNarrower()) {
        for (Hierarchy narrower : abstractMonitoringObject.getNarrower()) {
            if (narrower.isSetSimpleAttrs()) {
                Narrower n = amot.addNewNarrower();
                n.setHref(narrower.getSimpleAttrs().getHref());
                if (narrower.getSimpleAttrs().isSetTitle()) {
                    n.setTitle(narrower.getSimpleAttrs().getTitle());
                }
            } else {
                amot.addNewNarrower().addNewHierarchy().set(encodeEF(narrower));
            }
        }
    }
}
Also used : Hierarchy(org.n52.shetland.inspire.ef.Hierarchy) Narrower(eu.europa.ec.inspire.schemas.ef.x40.AbstractMonitoringObjectType.Narrower)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)124 Test (org.junit.Test)93 EncodingException (org.n52.svalbard.encode.exception.EncodingException)60 SweField (org.n52.shetland.ogc.swe.SweField)29 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)29 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)22 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)21 XmlException (org.apache.xmlbeans.XmlException)20 DateTime (org.joda.time.DateTime)19 OmObservation (org.n52.shetland.ogc.om.OmObservation)19 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)17 Time (org.n52.shetland.ogc.gml.time.Time)15 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)15 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)13 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)13 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)12 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)12 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)12 SystemType (net.opengis.sensorML.x101.SystemType)11 DataRecordType (net.opengis.swe.x101.DataRecordType)11