| 185 | == Addendum, Sept. 08, 2009 == |
| 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 high performance |
| 213 | FdoFixPolygonVertexOrderPreference_HighPerformance = 0, |
| 214 | |
| 215 | /// Prefer correctness |
| 216 | FdoFixPolygonVertexOrderPreference_Correctness = 1 |
| 217 | }; |
| 218 | |
| 219 | |
| 220 | /// \brief |
| 221 | /// Spatial utility class |
| 222 | /// |
| 223 | class FdoSpatialUtility |
| 224 | { |
| 225 | public: |
| 226 | /// \brief |
| 227 | /// Given the vertex order and strictness rule of the source and the target, |
| 228 | /// get what action should be taken to fix polygon. |
| 229 | /// |
| 230 | /// \param sourceVertexOrderRule |
| 231 | /// The vertex order rule of the source. |
| 232 | /// \param sourceStrictnessRule |
| 233 | /// The vertex order strictness rule of the source. |
| 234 | /// \param targetVertexOrderRule |
| 235 | /// The vertex order rule of the target. |
| 236 | /// \param targetStrictnessRule |
| 237 | /// The vertex order strictness rule of the target. |
| 238 | /// \param highPerformance |
| 239 | /// True - Prefer performance to correctness. It will guarantee the polygon i |
| 240 | /// False - Prefer correctness to performance. |
| 241 | /// |
| 242 | /// \return |
| 243 | /// Returns the action taken to fixing polygon vertex order. |
| 244 | /// |
| 245 | FDO_SPATIAL_API static FdoBulkCopyFixPolygonVertexOrderAction GetFixPolygonVertexOrderAction( |
| 246 | FdoPolygonVertexOrderRule sourceVertexOrderRule, |
| 247 | FdoBoolean sourceStrictnessRule, |
| 248 | FdoPolygonVertexOrderRule targetVertexOrderRule, |
| 249 | FdoBoolean targetStrictnessRule, |
| 250 | highPerformance); |
| 251 | }; |
| 252 | }}} |
| 253 | |
| 254 | 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. |
| 255 | |
| 256 | {{{ |
| 257 | static FdoBulkCopyFixPolygonVertexOrderAction table1[36] = { |
| 258 | // From Order From Strict To Order To Strict NonSense |
| 259 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Enforced CCW Enforced |
| 260 | FdoFixPolygonVertexOrderAction_None, // CCW Enforced CCW Not enforced |
| 261 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Enforced CW Enforced |
| 262 | FdoFixPolygonVertexOrderAction_Reverse, // CCW Enforced CW Not enforced |
| 263 | FdoFixPolygonVertexOrderAction_None, // CCW Enforced None Enforced True |
| 264 | FdoFixPolygonVertexOrderAction_None, // CCW Enforced None Not enforced |
| 265 | |
| 266 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Not enforced CCW Enforce |
| 267 | FdoFixPolygonVertexOrderAction_None, // CCW Not enforced CCW Not enforced |
| 268 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Not enforced CW Enforced |
| 269 | FdoFixPolygonVertexOrderAction_Reverse, // CCW Not enforced CW Not enforced |
| 270 | FdoFixPolygonVertexOrderAction_None, // CCW Not enforced None Enforced True |
| 271 | FdoFixPolygonVertexOrderAction_None, // CCW Not enforced None Not enforced |
| 272 | |
| 273 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Enforced CCW Enforced |
| 274 | FdoFixPolygonVertexOrderAction_Reverse, // CW Enforced CCW Not enforced |
| 275 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Enforced CW Enforced |
| 276 | FdoFixPolygonVertexOrderAction_None, // CW Enforced CW Not enforced |
| 277 | FdoFixPolygonVertexOrderAction_None, // CW Enforced None Enforced True |
| 278 | FdoFixPolygonVertexOrderAction_None, // CW Enforced None Not enforced |
| 279 | |
| 280 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Not enforced CCW Enforced |
| 281 | FdoFixPolygonVertexOrderAction_Reverse, // CW Not enforced CCW Not enforced |
| 282 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Not enforced CW Enforced |
| 283 | FdoFixPolygonVertexOrderAction_None, // CW Not enforced CW Not enforced |
| 284 | FdoFixPolygonVertexOrderAction_None, // CW Not enforced None Enforced True |
| 285 | FdoFixPolygonVertexOrderAction_None, // CW Not enforced None Not enforced |
| 286 | |
| 287 | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Enforced CCW Enforced True |
| 288 | FdoFixPolygonVertexOrderAction_None, // None Enforced CCW Not enforced True |
| 289 | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Enforced CW Enforced True |
| 290 | FdoFixPolygonVertexOrderAction_None, // None Enforced CW Not enforced True |
| 291 | FdoFixPolygonVertexOrderAction_None, // None Enforced None Enforced True |
| 292 | FdoFixPolygonVertexOrderAction_None, // None Enforced None Not enforced True |
| 293 | |
| 294 | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Not enforced CCW Enforced |
| 295 | FdoFixPolygonVertexOrderAction_None, // None Not enforced CCW Not enforced |
| 296 | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Not enforced CW Enforced |
| 297 | FdoFixPolygonVertexOrderAction_None, // None Not enforced CW Not enforced |
| 298 | FdoFixPolygonVertexOrderAction_None, // None Not enforced None Enforced True |
| 299 | FdoFixPolygonVertexOrderAction_None // None Not enforced None Not enforced |
| 300 | }; |
| 301 | |
| 302 | static FdoBulkCopyFixPolygonVertexOrderAction table2[36] = { |
| 303 | // From Order From Strict To Order To Strict NonSense |
| 304 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Enforced CCW Enforced |
| 305 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Enforced CCW Not enforced |
| 306 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Enforced CW Enforced |
| 307 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Enforced CW Not enforced |
| 308 | FdoFixPolygonVertexOrderAction_None, // CCW Enforced None Enforced True |
| 309 | FdoFixPolygonVertexOrderAction_None, // CCW Enforced None Not enforced |
| 310 | |
| 311 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Not enforced CCW Enforced |
| 312 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Not enforced CCW Not enforced |
| 313 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Not enforced CW Enforced |
| 314 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CCW Not enforced CW Not enforced |
| 315 | FdoFixPolygonVertexOrderAction_None, // CCW Not enforced None Enforced True |
| 316 | FdoFixPolygonVertexOrderAction_None, // CCW Not enforced None Not enforced |
| 317 | |
| 318 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Enforced CCW Enforced |
| 319 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Enforced CCW Not enforced |
| 320 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Enforced CW Enforced |
| 321 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Enforced CW Not enforced |
| 322 | FdoFixPolygonVertexOrderAction_None, // CW Enforced None Enforced True |
| 323 | FdoFixPolygonVertexOrderAction_None, // CW Enforced None Not enforced |
| 324 | |
| 325 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Not enforced CCW Enforced |
| 326 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Not enforced CCW Not enforced |
| 327 | FdoFixPolygonVertexOrderAction_CheckAndFix, // CW Not enforced CW Enforced |
| 328 | FdoFixPolygonVertexOrderAction__CheckAndFix, // CW Not enforced CW Not enforced |
| 329 | FdoFixPolygonVertexOrderAction_None, // CW Not enforced None Enforced True |
| 330 | FdoFixPolygonVertexOrderAction_None, // CW Not enforced None Not enforced |
| 331 | |
| 332 | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Enforced CCW Enforced True |
| 333 | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Enforced CCW Not enforced True |
| 334 | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Enforced CW Enforced True |
| 335 | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Enforced CW Not enforced True |
| 336 | FdoFixPolygonVertexOrderAction_None, // None Enforced None Enforced True |
| 337 | FdoFixPolygonVertexOrderAction_None, // None Enforced None Not enforced True |
| 338 | |
| 339 | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Not enforced CCW Enforced |
| 340 | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Not enforced CCW Not enforced |
| 341 | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Not enforced CW Enforced |
| 342 | FdoFixPolygonVertexOrderAction_CheckAndFix, // None Not enforced CW Not enforced |
| 343 | FdoFixPolygonVertexOrderAction_None, // None Not enforced None Enforced True |
| 344 | FdoFixPolygonVertexOrderAction_None // None Not enforced None Not enforced |
| 345 | }; |
| 346 | }}} |
| 347 | |
| 348 | 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. |