| 1 | = !MapGuide RFC 44 - Specific Geometry Types in Property Definition = |
| 2 | |
| 3 | This page contains a change request (RFC) for the !MapGuide Open Source project. |
| 4 | More !MapGuide RFCs can be found on the [wiki:MapGuideRfcs RFCs] page. |
| 5 | |
| 6 | |
| 7 | == Status == |
| 8 | |
| 9 | ||RFC Template Version||(1.0)|| |
| 10 | ||Submission Date||2007dec20|| |
| 11 | ||Last Modified||Gavin Cramer [[Timestamp]]|| |
| 12 | ||Author||Gavin Cramer|| |
| 13 | ||RFC Status||draft|| |
| 14 | ||Implementation Status||pending|| |
| 15 | ||Proposed Milestone||TBD|| |
| 16 | ||Assigned PSC guide(s)||(when determined)|| |
| 17 | ||'''Voting History'''||(vote date)|| |
| 18 | ||+1|| || |
| 19 | ||+0|| || |
| 20 | ||-0|| || |
| 21 | ||-1|| || |
| 22 | |
| 23 | == Overview == |
| 24 | |
| 25 | The geometric property definition only describes geometry types grouped by their shape’s dimensionality. In order to successfully persist data to some providers with more specific restrictions (e.g. SHP), the undiluted list of geometric types is required. This has already been done in the FDO API. This RFC proposes to offer the same via MapGuide API. |
| 26 | |
| 27 | == Motivation == |
| 28 | |
| 29 | The current API describes the allowed geometry types via MgGeometricPropertyDefinition::GetGeometryTypes, which returns a bit-mask value composed of values from the MgFeatureGeometricType enumeration. The allowed values pertain to the shape dimensionality (Point, Curve, Surface or Solid), rather than to specific geometry types as described by MgGeometryType (Point, LineString, CurveString, Polygon, etc.). Some FDO Providers restrict the type of geometry in a geometric property to a specific. SHP is a good example of this. The provider may advertise that the geometry can be a Curve, which implies LineString, MultiLineString, CurveString, and MultiCurveString. However, the provider might only allow LineString in this case. If an attempt is made to insert a MultiLineString geometry, an exception is thrown that it cannot be written. A more fine grained specification of allowed geometry types will avoid these situations because the caller can check specific types beforehand. |
| 30 | FDO supports the needed check via the FdoGeometricPropertyDefinition::GetSpecificGeometryTypes method, and its counterpart, SetSpecificGeometryTypes. These more specific method were never added to the corresponding GIS Platform class, MgGeometricPropertyDefinition. This RFC proposes to add the same methods to the Platform. |
| 31 | |
| 32 | == Proposed Solution == |
| 33 | |
| 34 | Add the following class to contain the accessor’s results (in lieu of the FDO method’s use of an output parameter): |
| 35 | {{{ |
| 36 | #define MAX_GEOMETRY_TYPE_SIZE 12 |
| 37 | |
| 38 | class MG_PLATFORMBASE_API MgGeometryTypeInfo : public MgSerializable |
| 39 | { |
| 40 | PUBLISHED_API: |
| 41 | MgGeometryType GetType(INT32 index); |
| 42 | INT32 GetCount(); |
| 43 | |
| 44 | INTERNAL_API: |
| 45 | virtual INT32 GetClassId(); |
| 46 | virtual void Serialize(MgStream* stream); |
| 47 | virtual void Deserialize(MgStream* stream); |
| 48 | virtual void ToXml(string &str); |
| 49 | virtual void SetTypes(MgGeometryType * types, INT32 count); |
| 50 | |
| 51 | protected: |
| 52 | virtual void Dispose(); |
| 53 | |
| 54 | private: |
| 55 | MgGeometryType m_types[MAX_GEOMETRY_TYPE_SIZE]; |
| 56 | INT32 m_count; |
| 57 | |
| 58 | CLASS_ID: |
| 59 | static const INT32 m_cls_id = PlatformBase_FeatureService_GeometryTypeInfo; |
| 60 | }; |
| 61 | }}} |
| 62 | Add the following methods to the PUBLISHED_API section of MgGeometricPropertyDefinition. Descriptions are adapted from the FDO API version for brevity. |
| 63 | {{{ |
| 64 | /// \brief |
| 65 | /// Gets the specific geometry types that can be stored in this geometric |
| 66 | /// property. The returned value is a list of geometry types that are |
| 67 | /// supported. The caller does NOT own the array of types and should not free its memory. |
| 68 | /// |
| 69 | /// \return |
| 70 | /// Returns a list of geometry types that are supported. |
| 71 | /// |
| 72 | MgGeometryTypeInfo * GetSpecificGeometryTypes(); |
| 73 | |
| 74 | /// \brief |
| 75 | /// Sets the specific set of geometry types that can be stored in this |
| 76 | /// geometric property. The provided value is a list of geometry types |
| 77 | /// that are supported. |
| 78 | /// |
| 79 | /// \param typeInfo |
| 80 | /// The specific set of geometry types that can be stored in this |
| 81 | /// geometric property. |
| 82 | /// |
| 83 | /// \return |
| 84 | /// Returns nothing. |
| 85 | /// |
| 86 | void SetSpecificGeometryTypes(MgGeometryTypeInfo * typeInfo); |
| 87 | }}} |
| 88 | Defaults will be applied as appropriate when the older SetGeometryTypes method is used. The MgFeatureGeometricType --> MgGeometryType mappings are: |
| 89 | * Point --> Point and MultiPoint |
| 90 | * Curve --> LineString, MultiLineString, CurveString, MultiCurveString |
| 91 | * Surface --> Polygon, MultiPolygon, CurvePolygon, MultiCurvePolygon |
| 92 | * Solid --> (none) |
| 93 | * All --> All types above, plus MultiGeometry. |
| 94 | |
| 95 | |
| 96 | == Implications == |
| 97 | |
| 98 | This is strictly an API change. |
| 99 | |
| 100 | == Test Plan == |
| 101 | |
| 102 | • Add unit tests which test the new API methods. |
| 103 | |
| 104 | == Funding/Resources == |
| 105 | |
| 106 | Autodesk to supply the resources to make the required changes. |