Changes between Version 19 and Version 20 of rfc61_support_for_measured_geometries


Ignore:
Timestamp:
Jan 28, 2016, 11:17:21 PM (8 years ago)
Author:
Ari Jolma
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • rfc61_support_for_measured_geometries

    v19 v20  
    2323=== Common API ===
    2424
    25 New OGRwkbGeometryType values are needed - that is a rather complex system due to history. SFSQL 1.2 and ISO SQL/MM Part 3 will be used, i.e., 2D type + 2000 for M and  2D type + 3000 for ZM. (Also types such as Tin and !PolyhedralSurface types can be added for completeness, even if unimplemented currently)
     25New OGRwkbGeometryType values are needed. SFSQL 1.2 and ISO SQL/MM Part 3 will be used, i.e., 2D type + 2000 for M and  2D type + 3000 for ZM. (Also types such as Tin and !PolyhedralSurface types can be added for completeness, even if unimplemented currently)
     26
     27On a more general note, there could be a path to using a clean set of values and have legacy support as an exception. I'm proposing to define aliases for legacy *25D values to have a uniform set of values. Are there any problems with that?
     28
     29Abstract types are defined and not part of the enum.
    2630
    2731{{{
     
    6771...
    6872
    69 // define new abstract types (why? what's the difference to the enum values? - they do not need to be handled in switches)
     73// define new abstract types (why? what's the difference to the enum values? - at least they do not need to be handled in switches)
    7074#define wkbCurveZ           ((OGRwkbGeometryType)1013)      /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
    7175#define wkbSurfaceZ         ((OGRwkbGeometryType)1014)      /**< ISO SQL/MM Part 3. GDAL &gt;= 2.1 */
     
    8690}}}
    8791
    88 Currently hacks such as nCoordDimension == -2 are used to denote empty geometries. This implies many changes to drivers etc. which get or set nCoordinateDimension.
    89 
    90 !IsEmpty = !(flags & OGR_G_NOT_EMPTY), Is3D = flags & OGR_G_3D, !IsMeasured = flags & OGR_G_MEASURED.
    91 
    92 The !IsEmpty method is needed only in the base class but the emptiness needs to be managed in all classes through the flags.
    93 
    94 Keep (with original semantics, i.e., coordinate dimension is 2 or 3), but deprecate. In documentation it says that this may return zero for empty points while in ogrpoint.cpp it says that negative nCoordDimension values are used for empty points and getCoordinateDimension of point returns absolute value of nCoordDimension - thus not zero.
    95 {{{
    96 getCoordinateDimension();
    97 setCoordinateDimension();
    98 }}}
     92Currently a hack to set nCoordDimension negative is used to denote an empty point. This implies many changes to drivers etc. which get or set nCoordinateDimension.
     93
     94The tests are
     95
     96{{{
     97!IsEmpty = !(flags & OGR_G_NOT_EMPTY)
     98Is3D = flags & OGR_G_3D
     99!IsMeasured = flags & OGR_G_MEASURED
     100}}}
     101
     102The setters and getters are implemented with |= and &=.
     103
     104The !IsEmpty method is needed only in the base class but the emptiness needs to be managed in all classes. It needs to be decided but when any of these flags is set, the corresponding data becomes invalid and may be discarded.
     105
     106Keep the following methods with original semantics, i.e., coordinate dimension is 2 or 3, but deprecate. There is some discrepancy in documentation. Their documentation says that they may return zero for empty points while in ogrpoint.cpp it says that negative nCoordDimension values are used for empty points and the getCoordinateDimension method of point returns absolute value of nCoordDimension - thus not zero.
     107{{{
     108int getCoordinateDimension();
     109void setCoordinateDimension(int nDimension);
     110void flattenTo2D()
     111}}}
     112
     113It is proposed to possibly add a new method to replace getCoordinateDimension. set3D and setMeasured would replace setCoordinateDimension and flattenTo2D. See below.
    99114
    100115class OGRGeometry:
    101116{{{
    102117//Possibly add methods (SF Common Architecture):
    103 int Dimension(); // -1 for empty geometries, 0 for points, 1 for curves, 2 for surfaces, max of components for collections
     118int Dimension(); // -1 for empty geometries (to denote undefined), 0 for points, 1 for curves, 2 for surfaces, max of components for collections
     119char *GeometryType(); // calls OGRToOGCGeomType (which needs to be enhanced)
     120
     121//Add methods (SF Common Architecture) see above for implementation:
    104122int CoordinateDimension(); // 2 if not 3D and not measured, 3 if 3D or measured, 4 if 3D and measured
    105 int SpatialDimension(); // ??
    106 char *GeometryType(); // calls OGRToOGCGeomType (which needs to be enhanced)
    107 
    108 //Add methods (SF Common Architecture):
    109123OGRBoolean Is3D();
    110124OGRBoolean IsMeasured();
    111125
    112 //Add methods (non-standard, may cause internal changes, e.g., allocate memory for Z or M values):
     126//Add methods (non-standard, may cause internal changes, e.g., allocate memory for Z or M values; note the use of one method instead of second unset* method):
    113127virtual void set3D(OGRBoolean bIs3D);
    114128virtual void setMeasured(OGRBoolean bIsMeasured);
     
    121135int !CoordinateDimension() should have the new semantics. The method name  in simple features documents actually is without prefix get.
    122136
    123 Whether set3D and setMeasured should affect the children geometries in a collection is an issue. Currently doc for setCoordinateDimension says "Setting
    124 the dimension of a geometry collection will not necessarily affect the children geometries.", which is not very clear.
    125 [ Note from E. Rouault --> the comment was wrong and has been fixed in r33184. I strongly believe that set3D and setMeasured should affect all sub-geometries, otherwise inconsistant WKB / WKT can be produced, leading to issues such as #6332 ]
     137Whether set3D and setMeasured should affect the children geometries in a collection is an issue. Currently doc for setCoordinateDimension says "Setting the dimension of a geometry collection will affect the children geometries.", thus we have already committed to maintaining dimensions of children in collections. It is proposed that set3D and setMeasured either add or strip Z or M values to or from the geometry (including possible children).
    126138
    127139Add property double m to class OGRPoint. Add constructor, getters, and setters for it.
    128140
    129 Add property double *padfM to class OGRSimpleCurve. Add constructor, getters, and setters for it. The getters and setters can take advantage of the flags to determine whether Z or M is to be set in some of them. For backwards compatibility Z is preferred.
     141Add property double *padfM to class OGRSimpleCurve. Add constructor, getters, and setters for it. The getters and setters can take advantage of the flags to determine whether Z or M is to be set in some of them - this is needed for prototypes like set(double, double, double). For backwards compatibility Z is preferred.
    130142
    131143Override methods set3D and setMeasured in those classes where setCoordinateDimension is overridden.
     
    189201}}}
    190202
     203=== GEOS, filters, and other issues ===
     204
     205When a geometry with measures is sent to GEOS or used as a filter the M coordinate is ignored.
     206
     207LocateAlong and LocateBetween are the only standard methods, which use M but there could be others, which for example get the extent of M. Such are not intended to be added now but they can be added later.
    191208
    192209== SWIG bindings (Python / Java / C# / Perl) changes ==
     
    198215Drivers that are probably affected by the C++ changes are at least (these use the !CoordinateDimension API) pg, mssqlspatial, sqlite, db2, mysql, gml, pgdump, geojson, libkml, gpkg, wasp, gpx, filegdb, vfk, bna, dxf.
    199216
     217The now deprecated !CoordinateDimension API is proposed to be replaced with calls to *3D and *Measured.
     218
     219Once the support for M coordinates is in place the driver will advertise the support.
     220
     221Within the work of this RFC the support is built into shape and pg. Support for other drivers are left for further work.
    200222
    201223== Utilities ==