use of org.locationtech.jts.geom.Envelope in project h2database by h2database.
the class ValueGeometry method getEnvelopeUnion.
/**
* Get the union.
*
* @param r the other geometry
* @return the union of this geometry envelope and another geometry envelope
*/
public Value getEnvelopeUnion(ValueGeometry r) {
GeometryFactory gf = new GeometryFactory();
Envelope mergedEnvelope = new Envelope(getGeometryNoCopy().getEnvelopeInternal());
mergedEnvelope.expandToInclude(r.getGeometryNoCopy().getEnvelopeInternal());
return get(gf.toGeometry(mergedEnvelope));
}
use of org.locationtech.jts.geom.Envelope in project h2database by h2database.
the class SpatialTreeIndex method getKey.
private SpatialKey getKey(SearchRow row) {
if (row == null) {
return null;
}
Value v = row.getValue(columnIds[0]);
if (v == ValueNull.INSTANCE) {
return null;
}
Geometry g = ((ValueGeometry) v.convertTo(Value.GEOMETRY)).getGeometryNoCopy();
Envelope env = g.getEnvelopeInternal();
return new SpatialKey(row.getKey(), (float) env.getMinX(), (float) env.getMaxX(), (float) env.getMinY(), (float) env.getMaxY());
}
use of org.locationtech.jts.geom.Envelope 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.Envelope in project arctic-sea by 52North.
the class ReferencedEnvelopeTest method testExpandToIncludeEmptyReferencedEnvelope.
@Test
public void testExpandToIncludeEmptyReferencedEnvelope() throws Exception {
originEnvelope.expandToInclude(emptyReferencedEnvelope);
assertThat(originEnvelope.getSrid(), is(4326));
final Envelope envelope = originEnvelope.getEnvelope();
assertThat(envelope.getMinX(), is(0.0));
assertThat(envelope.getMaxX(), is(1.0));
assertThat(envelope.getMinY(), is(0.0));
assertThat(envelope.getMaxY(), is(1.0));
assertThat(envelope.getArea(), is(1.0));
}
use of org.locationtech.jts.geom.Envelope in project arctic-sea by 52North.
the class ReferencedEnvelopeTest method testExpandToIncludeReferencedEnvelopeWithNull.
@Test
public void testExpandToIncludeReferencedEnvelopeWithNull() throws Exception {
final ReferencedEnvelope e = null;
originEnvelope.expandToInclude(e);
assertThat(originEnvelope.isSetSrid(), is(true));
assertThat(originEnvelope.getSrid(), is(srid));
assertThat(originEnvelope.isSetEnvelope(), is(true));
final Envelope envelope = originEnvelope.getEnvelope();
assertThat(envelope.getArea(), is(1.0));
assertThat(envelope.getMinX(), is(0.0));
assertThat(envelope.getMaxX(), is(1.0));
assertThat(envelope.getMinY(), is(0.0));
assertThat(envelope.getMaxY(), is(1.0));
}
Aggregations