Complete Note#1 in the http://wiki.osgeo.org/wiki/GEOS_Provenance_Review to get out...
[geos.git] / include / geos / index / SpatialIndex.h
blob25cc6ca5e6c9f894e71c178e76eab8140a678e02
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>
20 #include <vector>
22 // Forward declarations
23 namespace geos {
24 namespace geom {
25 class Envelope;
27 namespace index {
28 class ItemVisitor;
32 namespace geos {
33 namespace index {
35 /** \brief
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 {
48 public:
50 virtual ~SpatialIndex() {}
52 /** \brief
53 * Adds a spatial item with an extent specified by the given Envelope
54 * to the index
56 * @param itemEnv
57 * Envelope of the item, ownership left to caller.
58 * TODO: Reference hold by this class ?
60 * @param item
61 * Opaque item, ownership left to caller.
62 * Reference hold by this class.
64 virtual void insert(const geom::Envelope *itemEnv, void *item) = 0;
66 /** \brief
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;
78 /** \brief
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;
90 /** \brief
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
103 } // namespace geos
105 #endif // GEOS_INDEX_SPATIALINDEX_H