Search in sources :

Example 1 with PointValuePair

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

the class MultiPointObservation method setValue.

@Override
public void setValue(ObservationValue<?> value) {
    if (value.getValue() instanceof MultiPointCoverage) {
        super.setValue(value);
    } else {
        MultiPointCoverage multiPointCoverage = new MultiPointCoverage(getObservationID());
        multiPointCoverage.setUnit(((AbstractObservationValue<?>) value).getUnit());
        multiPointCoverage.addValue(new PointValuePair(getPoint(), value.getValue()));
        super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), multiPointCoverage));
    }
}
Also used : MultiPointCoverage(org.n52.shetland.ogc.om.values.MultiPointCoverage) PointValuePair(org.n52.shetland.ogc.om.PointValuePair)

Example 2 with PointValuePair

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

the class MultiPointObservation method getEnvelope.

/**
 * Get the envelope from {@link PointValuePair}s {@link List}
 *
 * @param pointValuePairs
 *            The {@link PointValuePair}s to get the envelope from
 * @return The envelope of the {@link PointValuePair}s
 */
private Geometry getEnvelope(List<PointValuePair> pointValuePairs) {
    Envelope envelope = new Envelope();
    GeometryFactory factory = null;
    int srid = 4326;
    if (CollectionHelper.isNotEmpty(pointValuePairs)) {
        for (PointValuePair pointValuePair : pointValuePairs) {
            if (factory == null && pointValuePair.getPoint() != null) {
                factory = pointValuePair.getPoint().getFactory();
            }
            if (pointValuePair.getPoint().getSRID() > 0) {
                srid = pointValuePair.getPoint().getSRID();
            }
            envelope.expandToInclude(pointValuePair.getPoint().getEnvelopeInternal());
        }
    } else {
        if (isSetSpatialFilteringProfileParameter()) {
            Geometry geometry = getSpatialFilteringProfileParameter().getValue().getValue();
            if (geometry != null) {
                if (factory == null) {
                    factory = geometry.getFactory();
                }
                if (geometry.getSRID() > 0) {
                    srid = geometry.getSRID();
                }
                envelope.expandToInclude(geometry.getEnvelopeInternal());
            }
        } else {
            if (getObservationConstellation().getFeatureOfInterest() instanceof AbstractSamplingFeature && ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).isSetGeometry()) {
                Geometry geometry = ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).getGeometry();
                if (geometry != null) {
                    if (factory == null) {
                        factory = geometry.getFactory();
                    }
                    if (geometry.getSRID() > 0) {
                        srid = geometry.getSRID();
                    }
                    envelope.expandToInclude(geometry.getEnvelopeInternal());
                }
            }
        }
    }
    if (factory == null) {
        factory = JTSHelper.getGeometryFactoryForSRID(srid);
    }
    Geometry geometry = factory.toGeometry(envelope);
    geometry.setSRID(srid);
    return geometry;
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) Envelope(org.locationtech.jts.geom.Envelope) Point(org.locationtech.jts.geom.Point) PointValuePair(org.n52.shetland.ogc.om.PointValuePair)

Example 3 with PointValuePair

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

the class PointObservation method setValue.

@Override
public void setValue(ObservationValue<?> value) {
    if (value instanceof StreamingValue<?>) {
        super.setValue(value);
    } else if (value.getValue() instanceof CvDiscretePointCoverage) {
        super.setValue(value);
    } else {
        CvDiscretePointCoverage cvDiscretePointCoverage = new CvDiscretePointCoverage(getObservationID());
        cvDiscretePointCoverage.setRangeType(new ReferenceType(getObservationConstellation().getObservablePropertyIdentifier()));
        cvDiscretePointCoverage.setUnit(((AbstractObservationValue<?>) value).getUnit());
        Geometry geometry = null;
        String domainExtent = "";
        if (isSetSpatialFilteringProfileParameter() && getSpatialFilteringProfileParameter().getValue() instanceof GeometryValue) {
            GeometryValue geometryValue = (GeometryValue) getSpatialFilteringProfileParameter().getValue();
            geometry = getSpatialFilteringProfileParameter().getValue().getValue();
            domainExtent = geometryValue.getGmlId();
        } else if (checkForFeatureGeometry(this)) {
            geometry = getGeometryFromFeature(this);
            domainExtent = getObservationConstellation().getFeatureOfInterest().getGmlId();
        }
        if (geometry != null) {
            cvDiscretePointCoverage.setDomainExtent("#" + geometry.getGeometryType() + "_" + domainExtent);
            Point point = null;
            if (geometry instanceof Point) {
                point = (Point) geometry;
            } else {
                point = geometry.getCentroid();
            }
            cvDiscretePointCoverage.setValue(new PointValuePair(point, value.getValue()));
        }
        super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), cvDiscretePointCoverage));
    }
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) CvDiscretePointCoverage(org.n52.shetland.ogc.om.values.CvDiscretePointCoverage) AbstractObservationValue(org.n52.shetland.ogc.om.AbstractObservationValue) GeometryValue(org.n52.shetland.ogc.om.values.GeometryValue) SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) StreamingValue(org.n52.shetland.ogc.om.StreamingValue) Point(org.locationtech.jts.geom.Point) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) PointValuePair(org.n52.shetland.ogc.om.PointValuePair)

Example 4 with PointValuePair

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

the class MultiPointCoverage method getExtent.

/**
 * Get the extent of all {@link Point}s
 *
 * @return The extent as {@link Polygon}
 */
public Polygon getExtent() {
    if (isSetValue()) {
        int srid = -1;
        List<Coordinate> coordinates = Lists.newLinkedList();
        for (PointValuePair pointValuePair : getValue()) {
            Point point = pointValuePair.getPoint();
            coordinates.add(point.getCoordinate());
            if (point.getSRID() != srid) {
                srid = point.getSRID();
            }
        }
        GeometryFactory geometryFactory;
        if (srid > 0) {
            geometryFactory = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING), srid);
        } else {
            geometryFactory = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING));
        }
        return geometryFactory.createPolygon(coordinates.toArray(new Coordinate[coordinates.size()]));
    }
    return null;
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Coordinate(org.locationtech.jts.geom.Coordinate) PrecisionModel(org.locationtech.jts.geom.PrecisionModel) Point(org.locationtech.jts.geom.Point) Point(org.locationtech.jts.geom.Point) PointValuePair(org.n52.shetland.ogc.om.PointValuePair)

Aggregations

PointValuePair (org.n52.shetland.ogc.om.PointValuePair)4 Point (org.locationtech.jts.geom.Point)3 Geometry (org.locationtech.jts.geom.Geometry)2 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)2 Coordinate (org.locationtech.jts.geom.Coordinate)1 Envelope (org.locationtech.jts.geom.Envelope)1 PrecisionModel (org.locationtech.jts.geom.PrecisionModel)1 ReferenceType (org.n52.shetland.ogc.gml.ReferenceType)1 AbstractObservationValue (org.n52.shetland.ogc.om.AbstractObservationValue)1 SingleObservationValue (org.n52.shetland.ogc.om.SingleObservationValue)1 StreamingValue (org.n52.shetland.ogc.om.StreamingValue)1 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)1 CvDiscretePointCoverage (org.n52.shetland.ogc.om.values.CvDiscretePointCoverage)1 GeometryValue (org.n52.shetland.ogc.om.values.GeometryValue)1 MultiPointCoverage (org.n52.shetland.ogc.om.values.MultiPointCoverage)1