use of org.h2.value.ValueGeometry in project ignite by apache.
the class GridH2SpatialIndex method getEnvelope.
/**
* @param row Row.
* @param rowId Row id.
* @return Envelope.
*/
private SpatialKey getEnvelope(SearchRow row, long rowId) {
Value v = row.getValue(columnIds[0]);
Geometry g = ((ValueGeometry) v.convertTo(Value.GEOMETRY)).getGeometry();
Envelope env = g.getEnvelopeInternal();
return new SpatialKey(rowId, (float) env.getMinX(), (float) env.getMaxX(), (float) env.getMinY(), (float) env.getMaxY());
}
use of org.h2.value.ValueGeometry 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.h2.value.ValueGeometry in project h2database by h2database.
the class MVSpatialIndex method getKey.
private SpatialKey getKey(SearchRow row) {
Value v = row.getValue(columnIds[0]);
if (v == ValueNull.INSTANCE) {
return new SpatialKey(row.getKey());
}
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.h2.value.ValueGeometry in project h2database by h2database.
the class TestSpatial method testValueGeometryScript.
/**
* Check ValueGeometry conversion into SQL script
*/
private void testValueGeometryScript() throws SQLException {
ValueGeometry valueGeometry = ValueGeometry.get("POINT(1 1 5)");
try (Connection conn = getConnection(URL)) {
ResultSet rs = conn.createStatement().executeQuery("SELECT " + valueGeometry.getSQL());
assertTrue(rs.next());
Object obj = rs.getObject(1);
ValueGeometry g = ValueGeometry.getFromGeometry(obj);
assertTrue("got: " + g + " exp: " + valueGeometry, valueGeometry.equals(g));
}
}
use of org.h2.value.ValueGeometry in project h2database by h2database.
the class TestSpatial method testHashCode.
private void testHashCode() {
ValueGeometry geomA = ValueGeometry.get("POLYGON ((67 13 6, 67 18 5, 59 18 4, 59 13 6, 67 13 6))");
ValueGeometry geomB = ValueGeometry.get("POLYGON ((67 13 6, 67 18 5, 59 18 4, 59 13 6, 67 13 6))");
ValueGeometry geomC = ValueGeometry.get("POLYGON ((67 13 6, 67 18 5, 59 18 4, 59 13 5, 67 13 6))");
assertEquals(geomA.hashCode(), geomB.hashCode());
assertFalse(geomA.hashCode() == geomC.hashCode());
}
Aggregations