Search in sources :

Example 1 with Envelope

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));
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Envelope(org.locationtech.jts.geom.Envelope)

Example 2 with Envelope

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());
}
Also used : ValueGeometry(org.h2.value.ValueGeometry) Geometry(org.locationtech.jts.geom.Geometry) SpatialKey(org.h2.mvstore.rtree.SpatialKey) ValueGeometry(org.h2.value.ValueGeometry) Value(org.h2.value.Value) Envelope(org.locationtech.jts.geom.Envelope)

Example 3 with Envelope

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;
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) Envelope(org.locationtech.jts.geom.Envelope)

Example 4 with Envelope

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));
}
Also used : ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) Envelope(org.locationtech.jts.geom.Envelope) Test(org.junit.Test)

Example 5 with Envelope

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));
}
Also used : ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) Envelope(org.locationtech.jts.geom.Envelope) Test(org.junit.Test)

Aggregations

Envelope (org.locationtech.jts.geom.Envelope)20 ReferencedEnvelope (org.n52.shetland.util.ReferencedEnvelope)13 Test (org.junit.Test)11 Geometry (org.locationtech.jts.geom.Geometry)4 ValueGeometry (org.h2.value.ValueGeometry)3 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)3 XmlObject (org.apache.xmlbeans.XmlObject)2 SpatialKey (org.h2.mvstore.rtree.SpatialKey)2 Value (org.h2.value.Value)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 BigDecimal (java.math.BigDecimal)1 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 BBOXType (net.opengis.fes.x20.BBOXType)1 EnvelopeType (net.opengis.swe.x101.EnvelopeType)1 Coordinate (net.opengis.swe.x101.VectorType.Coordinate)1 VersionedValue (org.h2.mvstore.db.TransactionStore.VersionedValue)1 SimpleResultSet (org.h2.tools.SimpleResultSet)1