Changes between Initial Version and Version 1 of MapGuideRfc158


Ignore:
Timestamp:
Apr 11, 2017, 8:40:16 AM (7 years ago)
Author:
jng
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MapGuideRfc158

    v1 v1  
     1
     2= !MapGuide RFC 158 - Simplified JSON responses and GeoJSON support =
     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||12 Apr 2017||
     11||Last Modified||12 Apr 2017||
     12||Author||Jackie Ng||
     13||RFC Status||draft||
     14||Implementation Status||In Progress||
     15||Proposed Milestone||3.3||
     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 simplify all JSON responses from the mapagent
     27
     28== Motivation ==
     29
     30All JSON responses from the mapagent are verbatim conversions from their XML counterparts.
     31
     32However this conversion process results in JSON that is quite cumbersome to consume:
     33
     34 * All properties are arrays.
     35 * All properties are string values.
     36 
     37This is due to the conversion process not taking the content model (and its data types/element cardinality) into account, taking the lowest common denominator approach.
     38
     39== Proposed Solution ==
     40
     41The MgJsonConvert class that does the actual XML to JSON conversion will be modified to include a hard-coded list of XML element paths:
     42
     43 * For elements that contain 0 to many elements
     44 * For elements that are not string data types
     45 
     46During the conversion process, we check the computed XML element path of the element we're converting and check if it is in one of these two lists
     47
     48 * If it is in the first list, the element is written as a JSON array
     49 * If it is in the second list, the element will not have its value quoted
     50
     51To retain compatibility with clients using the JSON responses of the older mapagent, using simplified JSON responses is opt-in, by including {{{CLEAN=1}}} as part of your mapagent request parameters.
     52When this is specified, the old XML to JSON conversion behaviour will be used.
     53
     54With the new JSON responses, not only are they more simpler to use (not everything is an array and not everything is a string and the content structure is semantically similar to their XML counterparts), but is also much more compact due to the amount of {{{[}}} and {{{"}}} characters we save by not converting everything to string arrays
     55
     56Fusion will also be updated to take advantage of the new clean JSON responses.
     57
     58== GeoJSON output ==
     59
     60For the {{{SELECTFEATURES}}} mapagent operation, even with the clean JSON response formatting applied, the JSON response is still near-useless for consumption by client applications.
     61
     62For this particular operation, if we want the response in JSON, since it includes spatial data for features it is more practical to return this in GeoJSON format, which is more ubiquitous and more practical for client-application consumption.
     63
     64To enable this, we'll be adding a new MgGeoJsonWriter utility class to the PlatformBase library to enable easy GeoJSON conversion from feature readers
     65
     66{{{
     67class MG_PLATFORMBASE_API MgGeoJsonWriter : public MgGuardDisposable
     68{
     69PUBLISHED_API:
     70    MgGeoJsonWriter();
     71
     72    STRING FeatureToGeoJson(MgFeatureReader* featureReader, MgTransform* transform);
     73
     74    STRING FeatureToGeoJson(MgReader* reader, MgTransform* transform, CREFSTRING idPropertyName, CREFSTRING geomPropName);
     75};
     76}}}
     77
     78The {{{SELECTFEATURES}}} operation with {{{CLEAN=1}}} will use this class to output the response as GeoJSON
     79
     80== Implications ==
     81
     82Any time a new schema or schema revision is introduced, this hard-coded list will have to be updated to know which elements in these new schemas require special processing.
     83
     84== Test Plan ==
     85
     86Test all applicable mapagent operations with CLEAN=1 to verify clean JSON output.
     87
     88== Funding / Resources ==
     89
     90Community