1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
6 * Copyright (C) 2006 Refractions Research Inc.
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
13 **********************************************************************/
15 #ifndef GEOS_INDEX_SPATIALINDEX_H
16 #define GEOS_INDEX_SPATIALINDEX_H
18 #include <geos/export.h>
22 // Forward declarations
36 * Abstract class defines basic insertion and query operations supported by
37 * classes implementing spatial index algorithms.
39 * A spatial index typically provides a primary filter for range rectangle queries. A
40 * secondary filter is required to test for exact intersection. Of course, this
41 * secondary filter may consist of other tests besides intersection, such as
42 * testing other kinds of spatial relationships.
44 * Last port: index/SpatialIndex.java rev. 1.11 (JTS-1.7)
47 class GEOS_DLL SpatialIndex
{
50 virtual ~SpatialIndex() {}
53 * Adds a spatial item with an extent specified by the given Envelope
57 * Envelope of the item, ownership left to caller.
58 * TODO: Reference hold by this class ?
61 * Opaque item, ownership left to caller.
62 * Reference hold by this class.
64 virtual void insert(const geom::Envelope
*itemEnv
, void *item
) = 0;
67 * Queries the index for all items whose extents intersect the given search Envelope
69 * Note that some kinds of indexes may also return objects which do not in fact
70 * intersect the query envelope.
72 * @param searchEnv the envelope to query for
73 * @return a list of the items found by the query in a newly allocated vector
75 //virtual std::vector<void*>* query(const geom::Envelope *searchEnv)=0;
76 virtual void query(const geom::Envelope
* searchEnv
, std::vector
<void*>&) = 0;
79 * Queries the index for all items whose extents intersect the given search Envelope
80 * and applies an ItemVisitor to them.
82 * Note that some kinds of indexes may also return objects which do not in fact
83 * intersect the query envelope.
85 * @param searchEnv the envelope to query for
86 * @param visitor a visitor object to apply to the items found
88 virtual void query(const geom::Envelope
*searchEnv
, ItemVisitor
& visitor
) = 0;
91 * Removes a single item from the tree.
93 * @param itemEnv the Envelope of the item to remove
94 * @param item the item to remove
95 * @return <code>true</code> if the item was found
97 virtual bool remove(const geom::Envelope
* itemEnv
, void* item
) = 0;
102 } // namespace geos.index
105 #endif // GEOS_INDEX_SPATIALINDEX_H