Coverage Report

Created: 2025-11-12 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/geos/include/geos/index/SpatialIndex.h
Line
Count
Source
1
/**********************************************************************
2
 *
3
 * GEOS - Geometry Engine Open Source
4
 * http://geos.osgeo.org
5
 *
6
 * Copyright (C) 2006 Refractions Research Inc.
7
 *
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.
12
 *
13
 **********************************************************************/
14
15
#pragma once
16
17
#include <geos/export.h>
18
19
#include <vector>
20
21
// Forward declarations
22
namespace geos {
23
namespace geom {
24
class Envelope;
25
}
26
namespace index {
27
class ItemVisitor;
28
}
29
}
30
31
namespace geos {
32
namespace index {
33
34
/** \brief
35
 * Abstract class defines basic insertion and query operations supported by
36
 * classes implementing spatial index algorithms.
37
 *
38
 * A spatial index typically provides a primary filter for range rectangle queries. A
39
 * secondary filter is required to test for exact intersection. Of course, this
40
 * secondary filter may consist of other tests besides intersection, such as
41
 * testing other kinds of spatial relationships.
42
 *
43
 * Last port: index/SpatialIndex.java rev. 1.11 (JTS-1.7)
44
 *
45
 */
46
class GEOS_DLL SpatialIndex {
47
public:
48
49
    virtual
50
350k
    ~SpatialIndex() {}
51
52
    /** \brief
53
     * Adds a spatial item with an extent specified by the given Envelope
54
     * to the index
55
     *
56
     * @param itemEnv
57
     *    Envelope of the item, ownership left to caller.
58
     *    TODO: Reference hold by this class ?
59
     *
60
     * @param item
61
     *    Opaque item, ownership left to caller.
62
     *    Reference hold by this class.
63
     */
64
    virtual void insert(const geom::Envelope* itemEnv, void* item) = 0;
65
66
    /** \brief
67
     * Queries the index for all items whose extents intersect the given search Envelope
68
     *
69
     * Note that some kinds of indexes may also return objects which do not in fact
70
     * intersect the query envelope.
71
     *
72
     * @param searchEnv the envelope to query for
73
     */
74
    //virtual std::vector<void*>* query(const geom::Envelope *searchEnv)=0;
75
    virtual void query(const geom::Envelope* searchEnv, std::vector<void*>&) = 0;
76
77
    /** \brief
78
     * Queries the index for all items whose extents intersect the given search Envelope
79
     * and applies an ItemVisitor to them.
80
     *
81
     * Note that some kinds of indexes may also return objects which do not in fact
82
     * intersect the query envelope.
83
     *
84
     * @param searchEnv the envelope to query for
85
     * @param visitor a visitor object to apply to the items found
86
     */
87
    virtual void query(const geom::Envelope* searchEnv, ItemVisitor& visitor) = 0;
88
89
    /** \brief
90
     * Removes a single item from the tree.
91
     *
92
     * @param itemEnv the Envelope of the item to remove
93
     * @param item the item to remove
94
     * @return <code>true</code> if the item was found
95
     */
96
    virtual bool remove(const geom::Envelope* itemEnv, void* item) = 0;
97
98
};
99
100
101
} // namespace geos.index
102
} // namespace geos
103