Search in sources :

Example 6 with TimeLocationValueTriple

use of org.n52.shetland.ogc.om.TimeLocationValueTriple in project arctic-sea by 52North.

the class TrajectoryObservationTypeEncoderTest method getCountObservation.

private OmObservation getCountObservation() throws EncodingException, ParseException, DecodingException, XmlException, IOException {
    MultiObservationValues<List<TimeLocationValueTriple>> multiObservationValues = new MultiObservationValues<List<TimeLocationValueTriple>>();
    TLVTValue tlvtValue = new TLVTValue();
    tlvtValue.addValue(getTimeLocationValueTriple(new CountValue(15)));
    tlvtValue.addValue(getTimeLocationValueTriple(new CountValue(16)));
    tlvtValue.addValue(getTimeLocationValueTriple(new CountValue(17)));
    tlvtValue.addValue(getTimeLocationValueTriple(new CountValue(18)));
    multiObservationValues.setValue(tlvtValue);
    OmObservation observation = createObservation();
    observation.setValue(multiObservationValues);
    return observation;
}
Also used : CountValue(org.n52.shetland.ogc.om.values.CountValue) OmObservation(org.n52.shetland.ogc.om.OmObservation) List(java.util.List) TLVTValue(org.n52.shetland.ogc.om.values.TLVTValue) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues) TimeLocationValueTriple(org.n52.shetland.ogc.om.TimeLocationValueTriple)

Example 7 with TimeLocationValueTriple

use of org.n52.shetland.ogc.om.TimeLocationValueTriple in project arctic-sea by 52North.

the class TrajectoryObservation method mergeValues.

protected boolean mergeValues(ObservationValue<?> observationValue) {
    if (observationValue.getValue() instanceof TLVTValue) {
        TLVTValue tlvtValue = (TLVTValue) observationValue.getValue();
        List<TimeLocationValueTriple> valuesToMerge = tlvtValue.getValue();
        // List<TimeLocationValueTriple> valuesToMerge =
        // (List<TimeLocationValueTriple>)((TLVTValue)observationValue.getValue()).getValue();
        ((TLVTValue) getValue().getValue()).addValues(valuesToMerge);
        checkForFeature(valuesToMerge);
        return true;
    } else {
        return super.mergeValues(observationValue);
    }
}
Also used : TLVTValue(org.n52.shetland.ogc.om.values.TLVTValue) TimeLocationValueTriple(org.n52.shetland.ogc.om.TimeLocationValueTriple)

Example 8 with TimeLocationValueTriple

use of org.n52.shetland.ogc.om.TimeLocationValueTriple in project arctic-sea by 52North.

the class TrajectoryObservation method checkForFeature.

/**
 * Create geometry for featureOfInterest from
 * {@link TimeLocationValueTriple}s
 *
 * @param values
 *            The {@link TimeLocationValueTriple}s to check for
 *            featureOfInterest
 */
private void checkForFeature(List<TimeLocationValueTriple> values) {
    AbstractFeature featureOfInterest = getObservationConstellation().getFeatureOfInterest();
    if (featureOfInterest instanceof AbstractSamplingFeature) {
        AbstractSamplingFeature sf = (AbstractSamplingFeature) featureOfInterest;
        Coordinate[] coords = getCoordinates(values);
        int srid = 0;
        if (sf.isSetGeometry()) {
            srid = sf.getGeometry().getSRID();
            coords = (Coordinate[]) ArrayUtils.addAll(sf.getGeometry().getCoordinates(), coords);
        } else {
            TimeLocationValueTriple next = values.iterator().next();
            if (next.isSetLocation()) {
                srid = next.getLocation().getSRID();
            }
        }
        try {
            if (coords.length == 1) {
                Point point = new GeometryFactory().createPoint(coords[0]);
                point.setSRID(srid);
                sf.setGeometry(point);
            } else if (coords.length > 1) {
                LineString lineString = new GeometryFactory().createLineString(coords);
                lineString.setSRID(srid);
                sf.setGeometry(lineString);
            }
        } catch (InvalidSridException e) {
        // TODO
        }
    }
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) Coordinate(org.locationtech.jts.geom.Coordinate) LineString(org.locationtech.jts.geom.LineString) InvalidSridException(org.n52.shetland.ogc.om.features.samplingFeatures.InvalidSridException) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) Point(org.locationtech.jts.geom.Point) Point(org.locationtech.jts.geom.Point) TimeLocationValueTriple(org.n52.shetland.ogc.om.TimeLocationValueTriple)

Example 9 with TimeLocationValueTriple

use of org.n52.shetland.ogc.om.TimeLocationValueTriple in project arctic-sea by 52North.

the class AbstractTimeLocationValueTripleTypeEncoder method createMeasurementTimeLocationValueTripleType.

/**
 * Create a {@link MeasurementTimeLocationValueTripleType} from
 * {@link TimeLocationValueTriple}
 *
 * @param timeLocationValueTriple
 *            The {@link TimeLocationValueTriple} to encode
 * @return The encoded {@link TimeLocationValueTriple}
 * @throws EncodingException
 *             If an error occurs
 */
private TimeValuePairType createMeasurementTimeLocationValueTripleType(TimeLocationValueTriple timeLocationValueTriple) throws EncodingException {
    MeasurementTimeLocationValueTripleType mtlvtt = MeasurementTimeLocationValueTripleType.Factory.newInstance();
    mtlvtt.addNewTime().setStringValue(getTimeString(timeLocationValueTriple.getTime()));
    mtlvtt.addNewLocation().addNewPoint().set(encodeGML(timeLocationValueTriple.getLocation()));
    String value = null;
    if (timeLocationValueTriple.getValue() instanceof QuantityValue) {
        QuantityValue quantityValue = (QuantityValue) timeLocationValueTriple.getValue();
        if (quantityValue.isSetValue()) {
            value = quantityValue.getValue().toPlainString();
        }
    } else if (timeLocationValueTriple.getValue() instanceof CountValue) {
        CountValue countValue = (CountValue) timeLocationValueTriple.getValue();
        if (countValue.getValue() != null) {
            value = Integer.toString(countValue.getValue().intValue());
        }
    }
    if (value != null && !value.isEmpty()) {
        mtlvtt.addNewValue().setStringValue(value);
    } else {
        mtlvtt.addNewValue().setNil();
        mtlvtt.addNewMetadata().addNewTVPMeasurementMetadata().addNewNilReason().setNilReason(MISSING);
    }
    return mtlvtt;
}
Also used : CountValue(org.n52.shetland.ogc.om.values.CountValue) MeasurementTimeLocationValueTripleType(eu.europa.ec.inspire.schemas.omso.x30.MeasurementTimeLocationValueTripleType) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue)

Example 10 with TimeLocationValueTriple

use of org.n52.shetland.ogc.om.TimeLocationValueTriple in project arctic-sea by 52North.

the class AbstractTimeLocationValueTripleTypeEncoder method createCategoricalTimeLocationValueTripleType.

/**
 * Create a {@link CategoricalTimeLocationValueTripleType} from
 * {@link TimeLocationValueTriple}
 *
 * @param timeLocationValueTriple
 *            The {@link TimeLocationValueTriple} to encode
 * @return The encoded {@link TimeLocationValueTriple}
 * @throws EncodingException
 *             If an error occurs
 */
private TimeValuePairType createCategoricalTimeLocationValueTripleType(TimeLocationValueTriple timeLocationValueTriple) throws EncodingException {
    CategoricalTimeLocationValueTripleType ctlvtt = CategoricalTimeLocationValueTripleType.Factory.newInstance();
    ctlvtt.addNewTime().setStringValue(getTimeString(timeLocationValueTriple.getTime()));
    ctlvtt.addNewLocation().addNewPoint().set(encodeGML(timeLocationValueTriple.getLocation()));
    if (timeLocationValueTriple.getValue() instanceof CategoryValue) {
        CategoryValue categoryValue = (CategoryValue) timeLocationValueTriple.getValue();
        if (categoryValue.isSetValue()) {
            ctlvtt.addNewValue().addNewCategory().set(encodeSweCommon(convertToSweCategory(categoryValue)));
        } else {
            ctlvtt.addNewValue().setNil();
            ctlvtt.addNewMetadata().addNewTVPMetadata().addNewNilReason().setNilReason(MISSING);
        }
    }
    return ctlvtt;
}
Also used : CategoricalTimeLocationValueTripleType(eu.europa.ec.inspire.schemas.omso.x30.CategoricalTimeLocationValueTripleType) CategoryValue(org.n52.shetland.ogc.om.values.CategoryValue)

Aggregations

TimeLocationValueTriple (org.n52.shetland.ogc.om.TimeLocationValueTriple)9 TLVTValue (org.n52.shetland.ogc.om.values.TLVTValue)8 List (java.util.List)6 MultiObservationValues (org.n52.shetland.ogc.om.MultiObservationValues)6 OmObservation (org.n52.shetland.ogc.om.OmObservation)3 TVPDefaultMetadataPropertyType (net.opengis.waterml.x20.TVPDefaultMetadataPropertyType)2 SingleObservationValue (org.n52.shetland.ogc.om.SingleObservationValue)2 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)2 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)2 CountValue (org.n52.shetland.ogc.om.values.CountValue)2 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)2 CategoricalTimeLocationValueTripleType (eu.europa.ec.inspire.schemas.omso.x30.CategoricalTimeLocationValueTripleType)1 MeasurementTimeLocationValueTripleType (eu.europa.ec.inspire.schemas.omso.x30.MeasurementTimeLocationValueTripleType)1 CategoricalTimeseriesDocument (net.opengis.waterml.x20.CategoricalTimeseriesDocument)1 CategoricalTimeseriesType (net.opengis.waterml.x20.CategoricalTimeseriesType)1 DefaultCategoricalTVPMetadataType (net.opengis.waterml.x20.DefaultCategoricalTVPMetadataType)1 DefaultTVPCategoricalMetadataDocument (net.opengis.waterml.x20.DefaultTVPCategoricalMetadataDocument)1 DefaultTVPMeasurementMetadataDocument (net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument)1 MeasurementTimeseriesDocument (net.opengis.waterml.x20.MeasurementTimeseriesDocument)1 MeasurementTimeseriesType (net.opengis.waterml.x20.MeasurementTimeseriesType)1