Interface SpatialIndex

 1  
 2 /*
 3  * Copyright (c) 2016 Vivid Solutions.
 4  *
 5  * All rights reserved. This program and the accompanying materials
 6  * are made available under the terms of the Eclipse Public License 2.0
 7  * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
 8  * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v20.html
 9  * and the Eclipse Distribution License is available at
10  *
11  * http://www.eclipse.org/org/documents/edl-v10.php.
12  */
13 package org.locationtech.jts.index;
14  
15 import java.util.List;
16  
17 import org.locationtech.jts.geom.Envelope;
18  
19 /**
20  * The basic operations supported by classes
21  * implementing spatial index algorithms.
22  * <p>
23  * A spatial index typically provides a primary filter for range rectangle queries.
24  * A secondary filter is required to test for exact intersection.
25  * The secondary filter may consist of other kinds of tests,
26  * such as testing other spatial relationships.
27  *
28  * @version 1.7
29  */
30 public interface SpatialIndex
31 {
32   /**
33    * Adds a spatial item with an extent specified by the given {@link Envelope} to the index
34    */
35   void insert(Envelope itemEnv, Object item);
36  
37   /**
38    * Queries the index for all items whose extents intersect the given search {@link Envelope}
39    * Note that some kinds of indexes may also return objects which do not in fact
40    * intersect the query envelope.
41    *
42    * @param searchEnv the envelope to query for
43    * @return a list of the items found by the query
44    */
45   List query(Envelope searchEnv);
46  
47   /**
48    * Queries the index for all items whose extents intersect the given search {@link Envelope},
49    * and applies an {@link ItemVisitor} to them.
50    * Note that some kinds of indexes may also return objects which do not in fact
51    * intersect the query envelope.
52    *
53    * @param searchEnv the envelope to query for
54    * @param visitor a visitor object to apply to the items found
55    */
56   void query(Envelope searchEnv, ItemVisitor visitor);
57  
58   /**
59    * Removes a single item from the tree.
60    *
61    * @param itemEnv the Envelope of the item to remove
62    * @param item the item to remove
63    * @return <code>true</code> if the item was found
64    */
65   boolean remove(Envelope itemEnv, Object item);
66  
67 }
68