Search in sources :

Example 6 with SweQuantity

use of org.n52.shetland.ogc.swe.simpleType.SweQuantity in project arctic-sea by 52North.

the class SweCommonEncoderv101 method createFieldForSimpleDataRecord.

private AnyScalarPropertyType createFieldForSimpleDataRecord(SweField sweField) throws EncodingException {
    SweAbstractDataComponent sosElement = sweField.getElement();
    AnyScalarPropertyType xbField = AnyScalarPropertyType.Factory.newInstance(getXmlOptions());
    if (sweField.isSetName()) {
        xbField.setName(sweField.getName().getValue());
    }
    AbstractDataComponentType xbDCD;
    if (sosElement instanceof SweBoolean) {
        xbDCD = xbField.addNewBoolean();
        xbDCD.set(createSimpleType((SweBoolean) sosElement));
    } else if (sosElement instanceof SweCategory) {
        xbDCD = xbField.addNewCategory();
        xbDCD.set(createSimpleType((SweCategory) sosElement));
    } else if (sosElement instanceof SweCount) {
        xbDCD = xbField.addNewCount();
        xbDCD.set(createSimpleType((SweCount) sosElement));
    } else if (sosElement instanceof SweQuantity) {
        xbDCD = xbField.addNewQuantity();
        xbDCD.set(createSimpleType((SweQuantity) sosElement));
    } else if (sosElement instanceof SweText) {
        xbDCD = xbField.addNewText();
        xbDCD.set(createSimpleType((SweText) sosElement));
    } else if (sosElement instanceof SweTime) {
        xbDCD = xbField.addNewTime();
        xbDCD.set(createSimpleType((SweTime) sosElement));
    } else {
        throw new EncodingException("The element type '%s' of the received %s is not supported by this encoder '%s'.", new Object[] { sosElement != null ? sosElement.getClass().getName() : null, sweField.getClass().getName(), getClass().getName() });
    }
    return xbField;
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) AbstractDataComponentType(net.opengis.swe.x101.AbstractDataComponentType) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) EncodingException(org.n52.svalbard.encode.exception.EncodingException) NotYetSupportedEncodingException(org.n52.svalbard.encode.exception.NotYetSupportedEncodingException) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) XmlObject(org.apache.xmlbeans.XmlObject) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean)

Example 7 with SweQuantity

use of org.n52.shetland.ogc.swe.simpleType.SweQuantity in project arctic-sea by 52North.

the class SweCommonEncoderv101 method createCoordinate.

/**
 * Adds values to SWE coordinates
 *
 * @param coordinate
 *            SOS internal representation
 *
 * @return the coordinate
 */
private Coordinate createCoordinate(SweCoordinate<?> coordinate) {
    Coordinate xbCoordinate = Coordinate.Factory.newInstance(getXmlOptions());
    xbCoordinate.setName(coordinate.getName());
    xbCoordinate.setQuantity(createQuantity((SweQuantity) coordinate.getValue()));
    return xbCoordinate;
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SweCoordinate(org.n52.shetland.ogc.swe.SweCoordinate) Coordinate(net.opengis.swe.x101.VectorType.Coordinate)

Example 8 with SweQuantity

use of org.n52.shetland.ogc.swe.simpleType.SweQuantity in project arctic-sea by 52North.

the class SweCommonEncoderv101 method encode.

@Override
public XmlObject encode(Object element, EncodingContext context) throws EncodingException {
    XmlObject encodedObject = null;
    if (element instanceof SweAbstractSimpleType) {
        encodedObject = createSimpleType((SweAbstractSimpleType<?>) element, context);
    // }
    // if (element instanceof SweBoolean) {
    // encodedObject = createBoolean((SweBoolean) element);
    // } else if (element instanceof SweCategory) {
    // encodedObject = createCategory((SweCategory) element);
    // } else if (element instanceof SweCount) {
    // encodedObject = createCount((SweCount) element);
    // } else if (element instanceof SweObservableProperty) {
    // encodedObject = createObservableProperty((SweObservableProperty)
    // element);
    // } else if (element instanceof SweQuantity) {
    // encodedObject = createQuantity((SweQuantity) element);
    // } else if (element instanceof SweQuantityRange) {
    // encodedObject = createQuantityRange((SweQuantityRange) element);
    // } else if (element instanceof SweText) {
    // encodedObject = createText((SweText) element);
    // } else if (element instanceof SweTime) {
    // encodedObject = createTime((SweTime) element);
    // } else if (element instanceof SweTimeRange) {
    // encodedObject = createTimeRange((SweTimeRange) element);
    } else if (element instanceof SweCoordinate) {
        encodedObject = createCoordinate((SweCoordinate<?>) element);
    } else if (element instanceof SweDataArray) {
        encodedObject = createDataArray((SweDataArray) element);
    } else if (element instanceof SweDataRecord) {
        DataRecordType drt = createDataRecord((SweDataRecord) element);
        if (context.has(XmlBeansEncodingFlags.DOCUMENT)) {
            DataRecordDocument drd = DataRecordDocument.Factory.newInstance(getXmlOptions());
            drd.setDataRecord(drt);
            encodedObject = drd;
        } else {
            encodedObject = drt;
        }
    } else if (element instanceof SweEnvelope) {
        encodedObject = createEnvelope((SweEnvelope) element);
    } else if (element instanceof SweSimpleDataRecord) {
        encodedObject = createSimpleDataRecord((SweSimpleDataRecord) element);
    } else if (element instanceof TimePeriod) {
        encodedObject = createTimeGeometricPrimitivePropertyType((TimePeriod) element);
    } else {
        throw new UnsupportedEncoderInputException(this, element);
    }
    XmlHelper.validateDocument(encodedObject, EncodingException::new);
    return encodedObject;
}
Also used : DataRecordType(net.opengis.swe.x101.DataRecordType) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) SweAbstractSimpleType(org.n52.shetland.ogc.swe.simpleType.SweAbstractSimpleType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) EncodingException(org.n52.svalbard.encode.exception.EncodingException) NotYetSupportedEncodingException(org.n52.svalbard.encode.exception.NotYetSupportedEncodingException) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) XmlObject(org.apache.xmlbeans.XmlObject) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) DataRecordDocument(net.opengis.swe.x101.DataRecordDocument) SweCoordinate(org.n52.shetland.ogc.swe.SweCoordinate) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Example 9 with SweQuantity

use of org.n52.shetland.ogc.swe.simpleType.SweQuantity in project arctic-sea by 52North.

the class SweCommonEncoderv20 method createQuality.

private QualityPropertyType[] createQuality(final Collection<SweQuality> quality) throws EncodingException {
    if (!quality.isEmpty()) {
        final ArrayList<QualityPropertyType> xbQualities = Lists.newArrayListWithCapacity(quality.size());
        for (final SweQuality sweQuality : quality) {
            final QualityPropertyType xbQuality = QualityPropertyType.Factory.newInstance();
            if (sweQuality instanceof SweText) {
                xbQuality.addNewText().set(((SweText) sweQuality).accept(new SweDataComponentVisitorImpl()));
            } else if (sweQuality instanceof SweCategory) {
                xbQuality.addNewCategory().set(((SweCategory) sweQuality).accept(new SweDataComponentVisitorImpl()));
            } else if (sweQuality instanceof SweQuantity) {
                xbQuality.addNewQuantity().set(((SweQuantity) sweQuality).accept(new SweDataComponentVisitorImpl()));
            } else if (sweQuality instanceof SweQuantityRange) {
                xbQuality.addNewQuantityRange().set(((SweQuantityRange) sweQuality).accept(new SweDataComponentVisitorImpl()));
            }
            xbQualities.add(xbQuality);
        }
        return xbQualities.toArray(new QualityPropertyType[xbQualities.size()]);
    }
    final QualityPropertyType[] result = { QualityPropertyType.Factory.newInstance() };
    return result;
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SweQuality(org.n52.shetland.ogc.swe.simpleType.SweQuality) QualityPropertyType(net.opengis.swe.x20.QualityPropertyType) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory)

Example 10 with SweQuantity

use of org.n52.shetland.ogc.swe.simpleType.SweQuantity in project arctic-sea by 52North.

the class WmlTDREncoderv20 method createDataRecord.

private XmlObject createDataRecord(SweQuantity quantity, String observationId) throws EncodingException {
    SweField field = new SweField("observed_value", quantity);
    SweDataRecord dataRecord = new SweDataRecord();
    dataRecord.setIdentifier(DATA_RECORD_ID_PREFIX + observationId);
    dataRecord.addField(field);
    return encodeObjectToXml(SweConstants.NS_SWE_20, dataRecord, EncodingContext.of(XmlBeansEncodingFlags.FOR_OBSERVATION));
}
Also used : SweField(org.n52.shetland.ogc.swe.SweField) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord)

Aggregations

SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)22 Test (org.junit.Test)11 XmlObject (org.apache.xmlbeans.XmlObject)9 SweField (org.n52.shetland.ogc.swe.SweField)9 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)9 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)9 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)8 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)8 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)7 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)5 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)5 NotYetSupportedEncodingException (org.n52.svalbard.encode.exception.NotYetSupportedEncodingException)5 SweQuantityRange (org.n52.shetland.ogc.swe.simpleType.SweQuantityRange)4 EncodingException (org.n52.svalbard.encode.exception.EncodingException)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 BigDecimal (java.math.BigDecimal)3 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)3 DataComponentPropertyType (net.opengis.swe.x101.DataComponentPropertyType)3 DataRecordType (net.opengis.swe.x101.DataRecordType)3 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)3