Search in sources :

Example 1 with SpatialKey

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

Example 2 with SpatialKey

use of org.gridgain.internal.h2.mvstore.rtree.SpatialKey in project h2database by h2database.

the class MVSpatialIndex method remove.

@Override
public void remove(Session session, Row row) {
    SpatialKey key = getKey(row);
    if (key.isNull()) {
        return;
    }
    TransactionMap<SpatialKey, Value> map = getMap(session);
    try {
        Value old = map.remove(key);
        if (old == null) {
            old = map.remove(key);
            throw DbException.get(ErrorCode.ROW_NOT_FOUND_WHEN_DELETING_1, getSQL() + ": " + row.getKey());
        }
    } catch (IllegalStateException e) {
        throw mvTable.convertException(e);
    }
}
Also used : SpatialKey(org.h2.mvstore.rtree.SpatialKey) Value(org.h2.value.Value) VersionedValue(org.h2.mvstore.db.TransactionStore.VersionedValue)

Example 3 with SpatialKey

use of org.gridgain.internal.h2.mvstore.rtree.SpatialKey in project h2database by h2database.

the class MVSpatialIndex method findByGeometry.

@Override
public Cursor findByGeometry(TableFilter filter, SearchRow first, SearchRow last, SearchRow intersection) {
    Session session = filter.getSession();
    if (intersection == null) {
        return find(session, first, last);
    }
    Iterator<SpatialKey> cursor = spatialMap.findIntersectingKeys(getKey(intersection));
    TransactionMap<SpatialKey, Value> map = getMap(session);
    Iterator<SpatialKey> it = map.wrapIterator(cursor, false);
    return new MVStoreCursor(session, it);
}
Also used : SpatialKey(org.h2.mvstore.rtree.SpatialKey) Value(org.h2.value.Value) VersionedValue(org.h2.mvstore.db.TransactionStore.VersionedValue) Session(org.h2.engine.Session)

Example 4 with SpatialKey

use of org.gridgain.internal.h2.mvstore.rtree.SpatialKey in project h2database by h2database.

the class ValueDataType method write.

@Override
public void write(WriteBuffer buff, Object obj) {
    if (obj instanceof SpatialKey) {
        buff.put((byte) SPATIAL_KEY_2D);
        getSpatialDataType().write(buff, obj);
        return;
    }
    Value x = (Value) obj;
    writeValue(buff, x);
}
Also used : SpatialKey(org.h2.mvstore.rtree.SpatialKey) Value(org.h2.value.Value)

Example 5 with SpatialKey

use of org.gridgain.internal.h2.mvstore.rtree.SpatialKey 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)

Aggregations

SpatialKey (org.gridgain.internal.h2.mvstore.rtree.SpatialKey)20 MVRTreeMap (org.gridgain.internal.h2.mvstore.rtree.MVRTreeMap)9 MVStore (org.gridgain.internal.h2.mvstore.MVStore)8 Value (org.gridgain.internal.h2.value.Value)8 SpatialKey (org.h2.mvstore.rtree.SpatialKey)7 Value (org.h2.value.Value)7 Random (java.util.Random)6 VersionedValue (org.gridgain.internal.h2.value.VersionedValue)5 VersionedValue (org.h2.mvstore.db.TransactionStore.VersionedValue)4 ValueGeometry (org.gridgain.internal.h2.value.ValueGeometry)3 ArrayList (java.util.ArrayList)2 Page (org.gridgain.internal.h2.mvstore.Page)2 ValueGeometry (org.h2.value.ValueGeometry)2 Envelope (org.locationtech.jts.geom.Envelope)2 Geometry (org.locationtech.jts.geom.Geometry)2 Envelope (com.vividsolutions.jts.geom.Envelope)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 Graphics2D (java.awt.Graphics2D)1 BufferedImage (java.awt.image.BufferedImage)1 File (java.io.File)1