Changes between Initial Version and Version 1 of MapGuideRfc153


Ignore:
Timestamp:
11/18/15 07:05:22 (9 years ago)
Author:
jng
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MapGuideRfc153

    v1 v1  
     1
     2= !MapGuide RFC 153 - Geometry simplification APIs =
     3
     4This page contains a change request (RFC) for the !MapGuide Open Source project.
     5More !MapGuide RFCs can be found on the [wiki:MapGuideRfcs RFCs] page.
     6
     7== Status ==
     8
     9||RFC Template Version||(1.0)||
     10||Submission Date||19 Nov 2015||
     11||Last Modified||19 Nov 2015||
     12||Author||Jackie Ng||
     13||RFC Status||draft||
     14||Implementation Status||sandbox experimental||
     15||Proposed Milestone||3.1||
     16||Assigned PSC guide(s)||(when determined)||
     17||'''Voting History'''||(vote date)||
     18||+1||||
     19||+0||||
     20||-0||||
     21||-1||||
     22||no vote|| ||
     23
     24== Overview ==
     25
     26This RFC proposes to add geometry simplfication APIs to MapGuide
     27
     28== Motivation ==
     29
     30MapGuide's geometry APIs are wrappers around equivalent APIs in GEOS
     31
     32One set of APIs in GEOS that is not exposed in MapGuide's geometry APIs is geometry simplification
     33
     34There is value in having such functionality available in the MapGuide API (eg. A MapGuide application that wants to return geometry data to clients at reduced fidelity)
     35
     36== Proposed Solution ==
     37
     38We'll add a new MgGeometrySimplifier class
     39
     40{{{
     41/// \defgroup MgAgfReaderWriter MgAgfReaderWriter
     42/// \ingroup Geometry_Module_classes
     43/// \{
     44
     45////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     46/// \brief
     47/// The MgGeometrySimplifier class provides the ability to simplify MgGeometry instances.
     48///
     49/// <!-- Example (PHP) -->
     50/// \htmlinclude PHPExampleTop.html
     51/// \code
     52/// $wktRw = new MgWktReaderWriter();
     53/// $geom = $wktRw->Read("LINESTRING (0 5, 1 5, 2 5, 5 5)");
     54/// $simp = new MgGeometrySimplifier();
     55/// $simplified = $simp->Simplify($geom, 10.0, MgGeometrySimplificationAlgorithmType::DouglasPeucker);
     56/// \endcode
     57/// \htmlinclude ExampleBottom.html
     58///
     59/// <!-- Example (C#) -->
     60/// \htmlinclude CSharpExampleTop.html
     61/// \code
     62/// using OSGeo.MapGuide;
     63/// ...
     64/// MgWktReaderWriter wktRw = new MgWktReaderWriter();
     65/// MgGeometry geom = wktRw.Read("LINESTRING (0 5, 1 5, 2 5, 5 5)");
     66/// MgGeometrySimplifier simp = new MgGeometrySimplifier();
     67/// MgGeometry simplified = simp.Simplify(geom, 10.0, MgGeometrySimplificationAlgorithmType.DouglasPeucker);
     68/// \endcode
     69/// \htmlinclude ExampleBottom.html
     70///
     71/// <!-- Example (Java) -->
     72/// \htmlinclude JavaExampleTop.html
     73/// \code
     74/// import org.osgeo.mapguide;
     75/// ...
     76/// MgWktReaderWriter wktRw = new MgWktReaderWriter();
     77/// MgGeometry geom = wktRw.Read("LINESTRING (0 5, 1 5, 2 5, 5 5)");
     78/// MgGeometrySimplifier simp = new MgGeometrySimplifier();
     79/// MgGeometry simplified = simp.Simplify(geom, 10.0, MgGeometrySimplificationAlgorithmType.DouglasPeucker);
     80/// \endcode
     81/// \htmlinclude ExampleBottom.html
     82///
     83class MG_GEOMETRY_API MgGeometrySimplifier : public MgGuardDisposable
     84{
     85    DECLARE_CLASSNAME(MgGeometrySimplifier)
     86
     87PUBLISHED_API:
     88    ///////////////////////////////////////////////////////////////////////////
     89    /// \brief
     90    /// Creates an MgGeometrySimplifier object
     91    ///
     92    /// <!-- Syntax in .Net, Java, and PHP -->
     93    /// \htmlinclude DotNetSyntaxTop.html
     94    /// MgGeometrySimplifier();
     95    /// \htmlinclude SyntaxBottom.html
     96    /// \htmlinclude JavaSyntaxTop.html
     97    /// MgGeometrySimplifier();
     98    /// \htmlinclude SyntaxBottom.html
     99    /// \htmlinclude PHPSyntaxTop.html
     100    /// MgGeometrySimplifier();
     101    /// \htmlinclude SyntaxBottom.html
     102    ///
     103    MgGeometrySimplifier();
     104
     105    ///////////////////////////////////////////////////////////////////////////
     106    /// \brief
     107    /// Simplifies the given geometry using the specified algorithm and tolerance
     108    ///
     109    /// <!-- Syntax in .Net, Java, and PHP -->
     110    /// \htmlinclude DotNetSyntaxTop.html
     111    /// virtual MgGeometry Simplify(MgGeometry geom, double tolerance, int algorithm);
     112    /// \htmlinclude SyntaxBottom.html
     113    /// \htmlinclude JavaSyntaxTop.html
     114    /// virtual MgGeometry Simplify(MgGeometry geom, double tolerance, int algorithm);
     115    /// \htmlinclude SyntaxBottom.html
     116    /// \htmlinclude PHPSyntaxTop.html
     117    /// virtual MgGeometry Simplify(MgGeometry geom, double tolerance, int algorithm);
     118    /// \htmlinclude SyntaxBottom.html
     119    ///
     120    /// \param geom (MgGeometry)
     121    /// The geometry instance to be simplified
     122    ///
     123    /// \param tolerance (double)
     124    /// The tolerance factor to simplify by
     125    ///
     126    /// \param algorithm (int)
     127    /// The simplification algorithm to use. Use any value from MgGeometrySimplificationAlgorithmType
     128    ///
     129    /// \return
     130    /// A simplified MgGeometry instance or null if simpification results in an empty geometry
     131    ///
     132    MgGeometry* Simplify(MgGeometry* geom, double tolerance, INT32 algorithm);
     133
     134INTERNAL_API:
     135
     136    //////////////////////////////////////////////////////////////////
     137    /// \brief
     138    /// Get the unique identifier for the class
     139    ///
     140    /// \return
     141    /// Class Identifider.
     142    ///
     143    virtual INT32 GetClassId();
     144
     145protected:
     146
     147    //////////////////////////////////////////////
     148    /// \brief
     149    /// Dispose this object.
     150    ///
     151    virtual void Dispose();
     152
     153CLASS_ID:
     154    static const INT32 m_cls_id = Geometry_GeometrySimplifier;
     155};
     156/// \}
     157}}}
     158
     159The {{{algorithm}}} parameter can be any value of {{{MgGeometrySimplificationAlgorithmType}}}
     160
     161{{{
     162////////////////////////////////////////////////////////////
     163/// \brief
     164/// MgGeometrySimplificationAlgorithmType defines constants indicating
     165/// the various simplification algorithms available for simplifying
     166/// geometry instances
     167///
     168class MgGeometrySimplificationAlgorithmType
     169{
     170PUBLISHED_API:
     171    /////////////////////////////////////////////////////////////////
     172    /// \brief
     173    /// Specifies that the Douglas-Peucker algorithm be used for simplification.
     174    ///
     175    static const INT32 DouglasPeucker = 0;
     176
     177    ///////////////////////////////////////////////////////
     178    /// \brief
     179    /// Specifies that the Topology Preserving algorithm be used for simplification
     180    ///
     181    static const INT32 TopologyPreserving = 1;
     182};
     183}}}
     184
     185Implementation-wise, depending on the choice of algorithm the MgGeometry is converted to its GEOS counterpart (like every other MapGuide geometry API) and forwarded to the matching GEOS simplifier ({{{geos::simplify::DouglasPeuckerSimplifier}}} or {{{geos::simplify::TopologyPreservingSimplifier}}})
     186
     187The simplified result is then converted back to its MgGeometry form.
     188
     189== Implications ==
     190
     191This is a new API addition
     192
     193== Test Plan ==
     194
     195Exercise the MgGeometrySimplifier against the same set of sample geometries as the geos simplifier tests.
     196
     197== Funding / Resources ==
     198
     199Community