use of org.locationtech.jts.geom.Coordinate 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.Coordinate in project arctic-sea by 52North.
the class SweEnvelope method toEnvelope.
public Envelope toEnvelope() throws OwsExceptionReport {
Coordinate min = getLowerCornerAsCoordinate();
Coordinate max = getUpperCornerAsCoordinate();
if (min != null && max != null) {
if (this.northingFirst) {
return new Envelope(min.y, max.y, min.x, max.x);
} else {
return new Envelope(min.x, max.x, min.y, max.y);
}
}
return null;
}
use of org.locationtech.jts.geom.Coordinate in project arctic-sea by 52North.
the class GeoJSONDecoder method decodeCoordinate.
protected Coordinate decodeCoordinate(JsonNode node) throws GeoJSONDecodingException {
if (!node.isArray()) {
throw new GeoJSONDecodingException(EXPECTED_ARRAY);
}
final int dim = node.size();
if (dim < DIM_2D) {
throw new GeoJSONDecodingException("coordinates may have at least 2 dimensions");
}
if (dim > DIM_3D) {
throw new GeoJSONDecodingException("coordinates may have at most 3 dimensions");
}
final Coordinate coordinate = new Coordinate();
for (int i = 0; i < dim; ++i) {
if (node.get(i).isNumber()) {
coordinate.setOrdinate(i, node.get(i).doubleValue());
} else {
throw new GeoJSONDecodingException("coordinate index " + i + " has to be a number");
}
}
return coordinate;
}
use of org.locationtech.jts.geom.Coordinate in project arctic-sea by 52North.
the class JTSHelperTest method factoryFromSridShouldSetSrid.
@Test
public void factoryFromSridShouldSetSrid() {
GeometryFactory factory = getGeometryFactoryForSRID(4326);
assertThat(factory, is(notNullValue()));
Geometry g = factory.createPoint(new Coordinate(1, 2));
assertThat(g, is(notNullValue()));
assertThat(g.getSRID(), is(4326));
}
use of org.locationtech.jts.geom.Coordinate in project arctic-sea by 52North.
the class ReverseOf method matches.
@Override
public boolean matches(Object item) {
if (item == null || item.getClass() != original.getClass()) {
return false;
}
Geometry geom = (Geometry) item;
Coordinate[] orig = original.getCoordinates();
Coordinate[] switched = geom.getCoordinates();
if (orig.length != switched.length) {
return false;
}
for (int i = 0; i < orig.length; ++i) {
if (!isSwitched(orig[i], switched[i])) {
return false;
}
}
return true;
}
Aggregations