Changes between Version 17 and Version 18 of FDORfc48


Ignore:
Timestamp:
Jul 29, 2010, 10:12:02 PM (14 years ago)
Author:
leaf
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FDORfc48

    v17 v18  
    3131== Overview ==
    3232
    33 Currently there are two inconsistencies in dealing with polygon vertex order. The first consistency is the vertex order rule in a polygon loop.
     33Currently there are two inconsistencies in dealing with polygon vertex order. The first inconsistency is the vertex order rule in a polygon loop.
    3434
    3535    * For most systems where there is a specific rule for the order of vertices in a polygon boundary, the rule is that exterior loops follow a counterclockwise order whereas inner loops follow a clockwise order. This is the rule that OGC has defined and applies to 2D polygons.
    3636    * The exception to this rule is the SHP file format specification. SHP follows a clockwise rule; however the SHP format was defined before OGC existed.
    3737
    38 The second consistency is the vertex order strictness when inserting or updating a polygon.
     38The second inconsistency is the vertex order strictness when inserting or updating a polygon.
    3939
    4040    * SQL Server 2008 Spatial has two data types that support geometry. They are Geometry and Geography. Both of these support polygons but the Geography type has a constraint that the vertex order around loops must be counterclockwise for outer loops and clockwise for inner loops. Polygons that fail this test will be rejected. The FDO SQL Server Spatial provider does not attempt to fix these polygons.
     
    183183Autodesk to provide resources / funding.
    184184
     185== Addendum, Sept. 08, 2009 ==
     186
     187This 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///
     194enum 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///
     210enum 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///
     223class FdoSpatialUtility
     224{
     225public:
     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
     254Method 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{{{
     257static 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
     302static 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
     348If 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.