1 /*********************************************************************** 2 * Copyright (c) 2013-2024 Commonwealth Computer Research, Inc. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Apache License, Version 2.0 5 * which accompanies this distribution and is available at 6 * http://www.opensource.org/licenses/apache2.0.php. 7 ***********************************************************************/ 8 9 package org.locationtech.geomesa.utils.index 10 11 import org.locationtech.jts.geom.{Envelope, Geometry} 12 13 /** 14 * Trait for indexing and querying spatial data 15 */ 16 trait SpatialIndex[T] { 17 18 /** 19 * Insert a value indexed by a geometry and unique key 20 * 21 * @param geom geometry used for indexing 22 * @param key unique value key 23 * @param value value to store 24 */ 25 def insert(geom: Geometry, key: String, value: T): Unit 26 27 /** 28 * Remove a value based on its indexed geometry and unique key 29 * 30 * @param geom geometry used for indexing 31 * @param key unique value key 32 * @return value, if it exists, or null 33 */ 34 def remove(geom: Geometry, key: String): T 35 36 /** 37 * Retrieves a value by primary key 38 * 39 * @param geom geometry used for indexing 40 * @param key unique value key 41 * @return value, if it exists, or null 42 */ 43 def get(geom: Geometry, key: String): T 44 45 /** 46 * Query based on a bounding box 47 * 48 * @param xmin xmin 49 * @param ymin ymin 50 * @param xmax xmax 51 * @param ymax ymax 52 * @return 53 */ 54 def query(xmin: Double, ymin: Double, xmax: Double, ymax: Double): Iterator[T] 55 56 /** 57 * Query based on a bounding envelope 58 * 59 * @param bbox bbox 60 * @return 61 */ 62 def query(bbox: Envelope): Iterator[T] = query(bbox.getMinX, bbox.getMinY, bbox.getMaxX, bbox.getMaxY) 63 64 /** 65 * Return all items 66 * 67 * @return 68 */ 69 def query(): Iterator[T] 70 71 /** 72 * Number of items in this index 73 * 74 * @return 75 */ 76 def size(): Int 77 78 /** 79 * Remove all items from the index 80 */ 81 def clear(): Unit 82 }
| Line | Stmt Id | Pos | Tree | Symbol | Tests | Code |
|---|---|---|---|---|---|---|
| 62 | 8292 | 1761 - 1773 | Apply | org.locationtech.jts.geom.Envelope.getMinX | bbox.getMinX() | |
| 62 | 8293 | 1775 - 1787 | Apply | org.locationtech.jts.geom.Envelope.getMinY | bbox.getMinY() | |
| 62 | 8294 | 1789 - 1801 | Apply | org.locationtech.jts.geom.Envelope.getMaxX | bbox.getMaxX() | |
| 62 | 8295 | 1803 - 1815 | Apply | org.locationtech.jts.geom.Envelope.getMaxY | bbox.getMaxY() | |
| 62 | 8296 | 1755 - 1816 | Apply | org.locationtech.geomesa.utils.index.SpatialIndex.query | SpatialIndex.this.query(bbox.getMinX(), bbox.getMinY(), bbox.getMaxX(), bbox.getMaxY()) |