use of org.locationtech.jts.geom.GeometryFactory in project arctic-sea by 52North.
the class ProfileValue method getGeometry.
public Geometry getGeometry() {
if (isSetGeometry()) {
TreeMap<Time, Coordinate> map = new TreeMap<>();
int srid = -1;
for (ProfileLevel level : getValue()) {
if (level.isSetPhenomenonTime() && level.isSetLocation()) {
if (srid < 0) {
srid = level.getLocation().getSRID();
}
map.put(level.getPhenomenonTime(), level.getLocation().getCoordinate());
}
}
if (!map.isEmpty()) {
if (new HashSet<>(map.values()).size() == 1) {
return getValue().iterator().next().getLocation();
} else {
return new GeometryFactory(new PrecisionModel(), srid).createLineString(map.values().toArray(new Coordinate[1]));
}
}
}
return null;
}
use of org.locationtech.jts.geom.GeometryFactory 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.GeometryFactory in project arctic-sea by 52North.
the class JTSHelperTest method shouldReverseMultiPoint.
@Test
public void shouldReverseMultiPoint() throws OwsExceptionReport {
final GeometryFactory factory = getGeometryFactoryForSRID(4326);
testReverse(factory.createMultiPointFromCoords(randomCoordinates(20)));
}
use of org.locationtech.jts.geom.GeometryFactory 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.GeometryFactory in project arctic-sea by 52North.
the class JTSHelperTest method shouldReversePolygon.
@Test
public void shouldReversePolygon() throws OwsExceptionReport {
final GeometryFactory factory = getGeometryFactoryForSRID(4326);
testReverse(factory.createPolygon(factory.createLinearRing(randomCoordinateRing(10)), new LinearRing[] { factory.createLinearRing(randomCoordinateRing(10)), factory.createLinearRing(randomCoordinateRing(41)), factory.createLinearRing(randomCoordinateRing(13)) }));
}
Aggregations