185 | | == Addendum, July 30, 2010 == |
186 | | |
187 | | This RFC provides some utility methods to check polygon vertex order and fix polygon vertex order errors. However, what action should be taken when copying a polygon from one feature source to another feature source isn't addressed in this RFC. The answer for this question depends on users' preference. The following enums and methods will be introduced to address it. |
188 | | |
189 | | {{{ |
190 | | /// \brief |
191 | | /// FdoFixPolygonVertexOrderAction is an enumeration of the action taken |
192 | | /// when fixing polygon vertex order. |
193 | | /// |
194 | | enum FdoFixPolygonVertexOrderAction |
195 | | { |
196 | | /// No processing. |
197 | | FdoFixPolygonVertexOrderAction_None = 0, |
198 | | |
199 | | /// Reverse polygon vertex. |
200 | | FdoFixPolygonVertexOrderAction_Reverse = 1, |
201 | | |
202 | | /// Check polygon vertex order and fix it if necessary. |
203 | | FdoFixPolygonVertexOrderAction_CheckAndFix = 2 |
204 | | }; |
205 | | |
206 | | /// \brief |
207 | | /// FdoFixPolygonVertexOrderPreference represents the preference |
208 | | /// when fixing polygon vertex order. |
209 | | /// |
210 | | enum FdoFixPolygonVertexOrderPreference |
211 | | { |
212 | | /// Prefer performance. It guarantees that polygons in the target have the correct |
213 | | /// vertex order if the target is enforced. |
214 | | FdoFixPolygonVertexOrderPreference_Performance = 0, |
215 | | |
216 | | /// Prefer correctness. It guarantees that polygons in the target have |
217 | | /// the correct vertex order if the vertex order rule of the target isn't none. |
218 | | FdoFixPolygonVertexOrderPreference_Correctness = 1 |
219 | | }; |
220 | | |
221 | | |
222 | | /// \brief |
223 | | /// Spatial utility class |
224 | | /// |
225 | | class FdoSpatialUtility |
226 | | { |
227 | | public: |
228 | | /// \brief |
229 | | /// Given the vertex order and strictness rule of the source and the target, |
230 | | /// get what action should be taken to fix polygon. |
231 | | /// |
232 | | /// \param sourceVertexOrderRule |
233 | | /// Input the vertex order rule of the source. |
234 | | /// \param sourceStrictnessRule |
235 | | /// Input the vertex order strictness rule of the source. |
236 | | /// \param targetVertexOrderRule |
237 | | /// Input the vertex order rule of the target. |
238 | | /// \param targetStrictnessRule |
239 | | /// Input the vertex order strictness rule of the target. |
240 | | /// \param preference |
241 | | /// Input the preference when fixing polygon vertex order. |
242 | | /// |
243 | | /// \return |
244 | | /// Returns the action taken to fixing polygon vertex order. |
245 | | /// |
246 | | FDO_SPATIAL_API static FdoFixPolygonVertexOrderAction GetFixPolygonVertexOrderAction( |
247 | | FdoPolygonVertexOrderRule sourceVertexOrderRule, |
248 | | FdoBoolean sourceStrictnessRule, |
249 | | FdoPolygonVertexOrderRule targetVertexOrderRule, |
250 | | FdoBoolean targetStrictnessRule, |
251 | | FdoFixPolygonVertexOrderPreference preference); |
252 | | }; |
253 | | }}} |
254 | | |
255 | | Method !GetFixPolygonVertexOrderAction is used to get what action should be taken when copying a polygon from one feature source to another feature source. The following two tables are defined in this method. |
256 | | |
257 | | {{{ |
258 | | static FdoFixPolygonVertexOrderAction table1[36] = { |
259 | | // From Order From Strict To Order To Strict NonSense |
260 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Enforced CCW Enforced |
261 | | FdoFixPolygonVertexOrderAction_None, // CCW Enforced CCW Not enforced |
262 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Enforced CW Enforced |
263 | | FdoFixPolygonVertexOrderAction_Reverse, // CCW Enforced CW Not enforced |
264 | | FdoFixPolygonVertexOrderAction_None, // CCW Enforced None Enforced True |
265 | | FdoFixPolygonVertexOrderAction_None, // CCW Enforced None Not enforced |
266 | | |
267 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Not enforced CCW Enforce |
268 | | FdoFixPolygonVertexOrderAction_None, // CCW Not enforced CCW Not enforced |
269 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Not enforced CW Enforced |
270 | | FdoFixPolygonVertexOrderAction_Reverse, // CCW Not enforced CW Not enforced |
271 | | FdoFixPolygonVertexOrderAction_None, // CCW Not enforced None Enforced True |
272 | | FdoFixPolygonVertexOrderAction_None, // CCW Not enforced None Not enforced |
273 | | |
274 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Enforced CCW Enforced |
275 | | FdoFixPolygonVertexOrderAction_Reverse, // CW Enforced CCW Not enforced |
276 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Enforced CW Enforced |
277 | | FdoFixPolygonVertexOrderAction_None, // CW Enforced CW Not enforced |
278 | | FdoFixPolygonVertexOrderAction_None, // CW Enforced None Enforced True |
279 | | FdoFixPolygonVertexOrderAction_None, // CW Enforced None Not enforced |
280 | | |
281 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Not enforced CCW Enforced |
282 | | FdoFixPolygonVertexOrderAction_Reverse, // CW Not enforced CCW Not enforced |
283 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Not enforced CW Enforced |
284 | | FdoFixPolygonVertexOrderAction_None, // CW Not enforced CW Not enforced |
285 | | FdoFixPolygonVertexOrderAction_None, // CW Not enforced None Enforced True |
286 | | FdoFixPolygonVertexOrderAction_None, // CW Not enforced None Not enforced |
287 | | |
288 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Enforced CCW Enforced True |
289 | | FdoFixPolygonVertexOrderAction_None, // None Enforced CCW Not enforced True |
290 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Enforced CW Enforced True |
291 | | FdoFixPolygonVertexOrderAction_None, // None Enforced CW Not enforced True |
292 | | FdoFixPolygonVertexOrderAction_None, // None Enforced None Enforced True |
293 | | FdoFixPolygonVertexOrderAction_None, // None Enforced None Not enforced True |
294 | | |
295 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Not enforced CCW Enforced |
296 | | FdoFixPolygonVertexOrderAction_None, // None Not enforced CCW Not enforced |
297 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Not enforced CW Enforced |
298 | | FdoFixPolygonVertexOrderAction_None, // None Not enforced CW Not enforced |
299 | | FdoFixPolygonVertexOrderAction_None, // None Not enforced None Enforced True |
300 | | FdoFixPolygonVertexOrderAction_None // None Not enforced None Not enforced |
301 | | }; |
302 | | |
303 | | static FdoFixPolygonVertexOrderAction table2[36] = { |
304 | | // From Order From Strict To Order To Strict NonSense |
305 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Enforced CCW Enforced |
306 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Enforced CCW Not enforced |
307 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Enforced CW Enforced |
308 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Enforced CW Not enforced |
309 | | FdoFixPolygonVertexOrderAction_None, // CCW Enforced None Enforced True |
310 | | FdoFixPolygonVertexOrderAction_None, // CCW Enforced None Not enforced |
311 | | |
312 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Not enforced CCW Enforced |
313 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Not enforced CCW Not enforced |
314 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Not enforced CW Enforced |
315 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Not enforced CW Not enforced |
316 | | FdoFixPolygonVertexOrderAction_None, // CCW Not enforced None Enforced True |
317 | | FdoFixPolygonVertexOrderAction_None, // CCW Not enforced None Not enforced |
318 | | |
319 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Enforced CCW Enforced |
320 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Enforced CCW Not enforced |
321 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Enforced CW Enforced |
322 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Enforced CW Not enforced |
323 | | FdoFixPolygonVertexOrderAction_None, // CW Enforced None Enforced True |
324 | | FdoFixPolygonVertexOrderAction_None, // CW Enforced None Not enforced |
325 | | |
326 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Not enforced CCW Enforced |
327 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Not enforced CCW Not enforced |
328 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Not enforced CW Enforced |
329 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Not enforced CW Not enforced |
330 | | FdoFixPolygonVertexOrderAction_None, // CW Not enforced None Enforced True |
331 | | FdoFixPolygonVertexOrderAction_None, // CW Not enforced None Not enforced |
332 | | |
333 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Enforced CCW Enforced True |
334 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Enforced CCW Not enforced True |
335 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Enforced CW Enforced True |
336 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Enforced CW Not enforced True |
337 | | FdoFixPolygonVertexOrderAction_None, // None Enforced None Enforced True |
338 | | FdoFixPolygonVertexOrderAction_None, // None Enforced None Not enforced True |
339 | | |
340 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Not enforced CCW Enforced |
341 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Not enforced CCW Not enforced |
342 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Not enforced CW Enforced |
343 | | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Not enforced CW Not enforced |
344 | | FdoFixPolygonVertexOrderAction_None, // None Not enforced None Enforced True |
345 | | FdoFixPolygonVertexOrderAction_None // None Not enforced None Not enforced |
346 | | }; |
347 | | }}} |
348 | | |
349 | | If users perfer performance to correctness, method !GetFixPolygonVertexOrderAction will use table1. It guarantees that polygons in the target will have the correct vertex order if the target is enforced. If users perfer correctness to performance, method !GetFixPolygonVertexOrderAction will use table2. It guarantees that polygons in the target will have the correct vertex order if the vertex order rule of the target isn't none. |
350 | | |
351 | | Considering performance, an additional parameter '!FdoBoolean checkInteriorRings' will be added for method FdoSpatialUtility::!ReversePolygonVertexOrder(...). If users know the input polygon is a valid polygon, they can pass false for parameter checkInteriorRings to reverse its vertex order. Otherwise, pass true. Method !FdoSpatialUtility::!ReversePolygonVertexOrder(...) will check whether interior rings have the different vertex order with exterior ring and guarantee the returned polygon is a valid polygon after reversing the vertex order of the input polygon. |
352 | | |
353 | | |
354 | | {{{ |
355 | | class FdoSpatialUtility |
356 | | { |
357 | | public: |
358 | | /// \brief |
359 | | /// Reverse the vertex order of the input polygon. |
360 | | /// |
361 | | /// \param geometry |
362 | | /// Input the polygon geometry to be reversed. It can be a polygon, multipolygon, |
363 | | /// curvepolygon, or multicurvepolygon. |
364 | | /// \param checkInteriorRings |
365 | | /// true - Check whether interior rings have the different vertex order with |
366 | | /// exterior ring and guarantee the returned polygon is a valid polygon |
367 | | /// after reversing the vertex order of the input polygon. |
368 | | /// false - Reverse the vertex order of interior rings and exterior ring directly |
369 | | /// no matter interior rings have the different vertex order with exterior ring. |
370 | | /// |
371 | | /// \return |
372 | | /// Returns the modified polygon. |
373 | | /// |
374 | | FDO_SPATIAL_API static FdoIGeometry* ReversePolygonVertexOrder ( |
375 | | FdoIGeometry * geometry, |
376 | | FdoBoolean checkInteriorRings = false ); |
377 | | } |
378 | | }}} |