use of org.locationtech.jts.geom.Geometry in project arctic-sea by 52North.
the class TrajectoryObservation method setValue.
@SuppressWarnings("rawtypes")
@Override
public void setValue(ObservationValue<?> value) {
if (value instanceof StreamingValue || value.getValue() instanceof TLVTValue) {
super.setValue(value);
} else {
Geometry geometry = null;
if (isSetSpatialFilteringProfileParameter()) {
geometry = getSpatialFilteringProfileParameter().getValue().getValue();
} else {
if (getObservationConstellation().getFeatureOfInterest() instanceof AbstractSamplingFeature && ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).isSetGeometry()) {
geometry = ((AbstractSamplingFeature) getObservationConstellation().getFeatureOfInterest()).getGeometry();
}
}
TLVTValue tlvpValue = convertSingleValueToMultiValue((SingleObservationValue<?>) value, geometry);
if (!tlvpValue.isSetUnit() && ((AbstractObservationValue<?>) value).isSetUnit()) {
tlvpValue.setUnit(((AbstractObservationValue<?>) value).getUnit());
}
final MultiObservationValues<List<TimeLocationValueTriple>> multiValue = new MultiObservationValues<List<TimeLocationValueTriple>>();
multiValue.setValue(tlvpValue);
if (!multiValue.isSetObservationID()) {
if (value instanceof AbstractObservationValue && ((AbstractObservationValue) value).isSetObservationID()) {
multiValue.setObservationID(((AbstractObservationValue) value).getObservationID());
} else if (isSetObservationID()) {
multiValue.setObservationID(getObservationID());
}
}
super.setValue(multiValue);
}
}
use of org.locationtech.jts.geom.Geometry in project arctic-sea by 52North.
the class ParameterHolder method addSpatialFilteringProfileParameter.
/**
* Add sampling geometry to observation
*
* @param samplingGeometry The sampling geometry to set
*
* @return this
*/
public ParameterHolder addSpatialFilteringProfileParameter(Geometry samplingGeometry) {
final NamedValue<Geometry> namedValue = new NamedValue<>();
namedValue.setName(new ReferenceType(OmConstants.PARAM_NAME_SAMPLING_GEOMETRY));
namedValue.setValue(new GeometryValue(samplingGeometry));
addParameter(namedValue);
return this;
}
use of org.locationtech.jts.geom.Geometry in project arctic-sea by 52North.
the class OmObservationTest method should_have_SpatialFilteringProfileParameter.
@Test
public final void should_have_SpatialFilteringProfileParameter() throws OwsExceptionReport, DecodingException {
OmObservation omObservation = new OmObservation();
NamedValue<Geometry> namedValue = new NamedValue<>();
namedValue.setName(new ReferenceType(OmConstants.PARAM_NAME_SAMPLING_GEOMETRY));
GeometryFactory fac = new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING), 4326);
namedValue.setValue(new GeometryValue(fac.createPoint(new Coordinate(34.5, 76.4))));
// test no parameter is set
assertFalse(omObservation.isSetParameter());
assertFalse(omObservation.isSetSpatialFilteringProfileParameter());
omObservation.addParameter(namedValue);
// test with set SpatialFilteringProfile parameter
assertTrue(omObservation.isSetParameter());
assertTrue(omObservation.isSetSpatialFilteringProfileParameter());
assertThat(omObservation.getSpatialFilteringProfileParameter(), is(equalTo(namedValue)));
}
use of org.locationtech.jts.geom.Geometry in project arctic-sea by 52North.
the class JTSHelperTest method shouldReverseGeometryCollection.
@Test
public void shouldReverseGeometryCollection() throws OwsExceptionReport {
final GeometryFactory factory = getGeometryFactoryForSRID(4326);
testReverse(factory.createGeometryCollection(new Geometry[] { factory.createMultiPolygon(new Polygon[] { factory.createPolygon(factory.createLinearRing(randomCoordinateRing(13)), new LinearRing[] { factory.createLinearRing(randomCoordinateRing(130)), factory.createLinearRing(randomCoordinateRing(4121)), factory.createLinearRing(randomCoordinateRing(12)) }), factory.createPolygon(factory.createLinearRing(randomCoordinateRing(8)), new LinearRing[] { factory.createLinearRing(randomCoordinateRing(1101)), factory.createLinearRing(randomCoordinateRing(413)), factory.createLinearRing(randomCoordinateRing(123)) }), factory.createPolygon(factory.createLinearRing(randomCoordinateRing(89)), new LinearRing[] { factory.createLinearRing(randomCoordinateRing(112)), factory.createLinearRing(randomCoordinateRing(4)), factory.createLinearRing(randomCoordinateRing(43)) }) }), factory.createMultiLineString(new LineString[] { factory.createLineString(randomCoordinateRing(21)), factory.createLineString(randomCoordinateRing(21)), factory.createLineString(randomCoordinateRing(15)) }), factory.createPolygon(factory.createLinearRing(randomCoordinateRing(10)), new LinearRing[] { factory.createLinearRing(randomCoordinateRing(10)), factory.createLinearRing(randomCoordinateRing(41)), factory.createLinearRing(randomCoordinateRing(13)) }), getGeometryFactoryForSRID(4326).createLineString(randomCoordinates(10)), getGeometryFactoryForSRID(4326).createLineString(randomCoordinates(10)) }));
}
use of org.locationtech.jts.geom.Geometry in project arctic-sea by 52North.
the class JTSHelperTest method testReverse.
protected void testReverse(Geometry geometry) throws OwsExceptionReport {
Geometry reversed = switchCoordinateAxisOrder(geometry);
assertThat(reversed, is(instanceOf(geometry.getClass())));
assertThat(reversed, is(not(sameInstance(geometry))));
assertThat(reversed, is(notNullValue()));
assertThat(reversed, is(ReverseOf.reverseOf(geometry)));
}
Aggregations