45 | | /// \ingroup (enums) |
46 | | /// \brief |
47 | | /// FdoSpatialIndexMode is an enumeration of the types of the Spatial Index |
48 | | enum FdoSpatialIndexMode |
49 | | { |
50 | | /// Mode #1 - Regular Spatial Index: one entry in the SI for the entire geometry |
51 | | FdoSpatialIndex_ByGeometriesBoundingBox = 0, |
52 | | |
53 | | /// Mode #2 - The geometries are broken into segments and each segment has an entry in the SI. |
54 | | /// The segment index is contiguous over parts and subparts. |
55 | | FdoSpatialIndex_BySegmentsMultipleFeatures = 1, |
56 | | |
57 | | /// Mode #3 - Just one geometry is allowed. The geometry is broken into segments |
58 | | /// and each segment has an entry in the SI. The part and subpart are encoded to allow |
59 | | /// for sorting and fast processing. |
60 | | FdoSpatialIndex_BySegmentsSingleFeature = 2 |
61 | | }; |
62 | | |
63 | | /// \brief |
64 | | /// Spatial Index class. |
65 | | class FdoSpatialIndex : public FdoIDisposable |
66 | | { |
67 | | friend class FdoSpatialIndexIterator; |
68 | | |
69 | | public: |
79 | | FDO_SPATIAL_API static FdoSpatialIndex* Create(FdoSpatialIndexMode mode = FdoSpatialIndex_ByGeometriesBoundingBox); |
80 | | |
81 | | /// \brief |
82 | | /// Retrieves the Spatial index mode set at creation time |
83 | | /// |
84 | | /// \return |
85 | | /// Returns the Spatial index mode set at creation |
86 | | /// |
87 | | FDO_SPATIAL_API FdoSpatialIndexMode GetMode(); |
88 | | |
89 | | /// \brief |
90 | | /// Inserts a feature into the spatial index given a bounding box |
91 | | /// |
92 | | /// \remarks |
93 | | /// Applies only for Mode #1. The objectId is not encoded. |
94 | | /// |
95 | | /// \param objectId |
96 | | /// Input The object identifier |
97 | | /// \param ext |
98 | | /// Input A bounding box |
| 53 | /// \param g1 |
| 54 | /// Input Left hand Geometry to Evaluate |
| 55 | /// \param si1 |
| 56 | /// Input The spatial index associated with g1. A valid spatial index is not NULL |
| 57 | /// and of type BySegmentsSingleFeature or BySegmentsMultipleFeatures (just one |
| 58 | /// feature). If an invalid spatial index is provided, then this method will silently |
| 59 | /// delegate to Evaluate(g1, op, g2, tolXY). |
| 60 | /// \param op |
| 61 | /// Input The spatial operation to apply to the left and right hand geometries |
| 62 | /// \param g2 |
| 63 | /// Input Right hand Geometry to Evaluate |
| 64 | /// \param toleranceXY |
| 65 | /// Input XY tolerance to evaluate the spatial condition |
| 66 | /// Default tolerance used is 1e-10. Valid range is >0 |
| 67 | /// If an invalid value is provided, the default then will be used |
101 | | /// Returns Nothing |
102 | | /// |
103 | | FDO_SPATIAL_API void InsertObject(FdoInt64 objectId, FdoIEnvelope *ext); |
104 | | |
105 | | /// \brief |
106 | | /// Inserts a feature into the spatial index given a geometry |
107 | | /// |
108 | | /// \remarks |
109 | | /// Applies for Mode #2 and #3. The objectId is encoded as follows: |
110 | | /// Mode #2: |
111 | | /// 32 bits (0-31) - 1-based object identifier |
112 | | /// 32 bits (32-63) - 1-based segment # (contiguous) |
113 | | /// |
114 | | /// Mode #3: |
115 | | /// 0 bits - object identifier (will be ignored) |
116 | | /// 16 bits (0-15) - part # (for multi-features) max. 65534 |
117 | | /// 16 bits (16-31) - subpart # (e.g. polygons with interior rings) max 65534 |
118 | | /// 32 bits (32-63) - 1-based segment # |
119 | | /// |
120 | | /// In Mode #3 a exception will be thrown in case the encoding fails. In this case |
121 | | /// Mode #2 can be used instead. |
122 | | /// |
123 | | /// \param objectId |
124 | | /// Input The object identifier |
125 | | /// \param fgfArray |
126 | | /// Input A geometry in FGF format |
127 | | /// |
128 | | /// \return |
129 | | /// Returns Nothing |
130 | | /// |
131 | | FDO_SPATIAL_API void InsertObject(FdoInt32 objectId, FdoByteArray* fgfArray); |
132 | | |
133 | | /// \brief |
134 | | /// Erases an entry in the spatial index given the id and a bounding box |
135 | | /// |
136 | | /// \remarks |
137 | | /// In Mode #2 removes all the entries related to the feature identifier. |
138 | | /// In Mode #3 the spatial index will be emptied. |
139 | | /// |
140 | | /// \param objectId |
141 | | /// Input The object identifier. |
142 | | /// \param ext |
143 | | /// Input The bounding box of the feature. It may be NULL in which case |
144 | | /// the spatial index total extents will be used. |
145 | | /// |
146 | | /// \return |
147 | | /// Returns Nothing |
148 | | /// |
149 | | FDO_SPATIAL_API void EraseObject(FdoInt64 objectId, FdoIEnvelope *ext); |
150 | | |
151 | | /// \brief |
152 | | /// Returns the extent of the spatial index |
153 | | /// |
154 | | /// \return |
155 | | /// Returns The extents of the spatial index |
156 | | /// |
157 | | FDO_SPATIAL_API FdoIEnvelope* GetTotalExtent(); |
158 | | |
159 | | /// \brief |
160 | | /// Decodes a marker returned by the Spatial index iterator. |
161 | | /// Applies only for Mode #2, BySegmentsMultipleFeatures. |
162 | | /// |
163 | | /// \param marker |
164 | | /// Input A marker returned by the Spatial index iterator |
165 | | /// \param objectId |
166 | | /// Output The object identifier |
167 | | /// \param iVertex |
168 | | /// Output The index of the segment in the original geometry, 1-based |
169 | | /// |
170 | | /// \return |
171 | | /// Returns Nothing |
172 | | /// |
173 | | FDO_SPATIAL_API void DecodeMarker(FdoInt64 marker, FdoInt32 &objectId, FdoInt32 &iSegment); |
174 | | |
175 | | /// \brief |
176 | | /// Decodes a marker returned by the Spatial index iterator. |
177 | | /// Applies only for Mode #3, BySegmentsSingleFeature. |
178 | | /// |
179 | | /// \param marker |
180 | | /// Input A marker returned by the Spatial index iterator |
181 | | /// \param iPart |
182 | | /// Output The index of the part in a multi-geometry, e.g. a polygon # in a multi-polygon |
183 | | /// \param iSubPart |
184 | | /// Output The index of the subpart in a geometry, e.g. a ring # in a polygon |
185 | | /// \param iVertex |
186 | | /// Output The index of the segment in the sub-part, 1-based |
187 | | /// |
188 | | /// \return |
189 | | /// Returns Nothing |
190 | | /// |
191 | | FDO_SPATIAL_API void DecodeMarker(FdoInt64 marker, FdoInt32 &iPart, FdoInt32 &iSubPart, FdoInt32 &iSegment); |
192 | | |
193 | | /// \cond DOXYGEN-IGNORE |
194 | | virtual void Dispose(); |
195 | | /// \endcond |
196 | | |
197 | | protected: |
198 | | // Constructor |
199 | | FdoSpatialIndex(FdoSpatialIndexMode mode = FdoSpatialIndex_ByGeometriesBoundingBox); |
200 | | |
201 | | virtual ~FdoSpatialIndex(); |
202 | | }; |
203 | | |
204 | | /// \brief |
205 | | /// Spatial Index Iterator class |
206 | | class FdoSpatialIndexIterator |
207 | | { |
208 | | public: |
209 | | /// \brief |
210 | | /// Creates a Spatial Index Iterator instance |
211 | | /// |
212 | | /// \param si |
213 | | /// Input A Spatial Index instance |
214 | | /// \param minx |
215 | | /// Input The minimim X of the bounding box representing the search area |
216 | | /// \param miny |
217 | | /// Input The minimim Y of the bounding box representing the search area |
218 | | /// \param maxx |
219 | | /// Input The maximum X of the bounding box representing the search area |
220 | | /// \param maxy |
221 | | /// Input The maximum Y of the bounding box representing the search area |
222 | | /// |
223 | | /// \return |
224 | | /// Returns A Spatial Index Iterator instance |
225 | | /// |
226 | | FDO_SPATIAL_API FdoSpatialIndexIterator(FdoSpatialIndex* si, double minx, double miny, double maxx, double maxy); |
227 | | |
228 | | /// \brief |
229 | | /// Iterator over the features selected in the the search area |
230 | | /// |
231 | | /// \return |
232 | | /// Returns an encoded marker. Zero (0) return value stands for the end of fetch |
233 | | /// |
234 | | FDO_SPATIAL_API FdoInt64 GetNextObject(); |
235 | | |
236 | | FDO_SPATIAL_API ~FdoSpatialIndexIterator(); |
237 | | }; |
| 70 | /// Returns the evaluation of spatial operation. |
| 71 | FDO_SPATIAL_API static bool Evaluate(FdoIGeometry* g1, FdoSpatialIndex* si1, FdoSpatialOperations op, FdoIGeometry* g2, double toleranceXY); |