Changes between Initial Version and Version 1 of MapGuideRfc126


Ignore:
Timestamp:
Aug 8, 2012, 7:45:59 AM (12 years ago)
Author:
jng
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MapGuideRfc126

    v1 v1  
     1
     2= !MapGuide RFC 126 - Viewer selection optimization =
     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
     8== Status ==
     9
     10||RFC Template Version||(1.0)||
     11||Submission Date||||
     12||Last Modified||||
     13||Author||Jackie Ng||
     14||RFC Status||draft||
     15||Implementation Status||||
     16||Proposed Milestone||2.5||
     17||Assigned PSC guide(s)||(when determined)||
     18||'''Voting History'''||(vote date)||
     19||+1||||
     20||+0||||
     21||-0||||
     22||-1||||
     23||no vote|| ||
     24
     25== Overview ==
     26
     27This RFC proposes to add a new version of QUERYMAPFEATURES in the mapagent that is designed to eliminate the need for additional round-tripping during selection operations.
     28
     29== Motivation ==
     30
     31The current suite of client viewer applications all suffer from inefficent selections due to excessive roundtripping.
     32
     33For example, the AJAX viewer will fire the following requests for a selection.
     34
     35[EXAMPLE]
     36
     37For Fusion, the round-tripping is even worse:
     38
     39[EXAMPLE]
     40
     41So what is the root problem for such excessive round-tripping? The answer is simply that QUERYMAPFEATURES does not fulfill the requirements that our current lineup of client-side viewers are demanding, so we have to make additional requests to other APIs or web extensions glue to work-around the shortcomings of this API. Some examples:
     42
     43 1) Select and give me back attributes of all features? Not possible. QUERYMAPFEATURES can only return attributes for one. That's why the AJAX viewer has to then make an additional call to getselectedfeatures.[php/jsp/aspx] and why Fusion has to make at least 4 extra requests (!!!) through various PHP glue (!!!!!) to get the required attribute information. We have a QueryFeatureProperties API that supposedly does this, but there is no way to tap into this API via the mapagent. We need a mapagent API that can do the query and selection persistence, but be able to give us the attributes of all selected features instead of one.
     44
     45[Benefit: no additional requests for extra attribute data]
     46
     47 2) QUERYMAPFEATURES also modifies the server-side selection, so it requires a follow-up GETDYNAMICMAPOVERLAYIMAGE request to update the selection image. If we can utilise data URIs to return the actual selection image back inline (as base64 encoded content) as part of the response, this eliminates the extra request for the selection image. Not all browsers support data URIs (a certain browser from Microsoft for example), so we can workaround that by letting the client specify if they want the inline selection image (browsers that support data URIs will say "yes" and those that can't will say "no"). The current state of data URI support can be found [http://en.wikipedia.org/wiki/Data_URI_scheme#Web_browser_support here]
     48
     49[Benefit: no additional requests for browsers that support data URIs. Those that don't will fall back to existing behaviour of doing the additional GETDYNAMICMAPOVERLAYIMAGE request.]
     50
     51 3) QUERYMAPFEATURES for tooltip requests doesn't need attribute information, so don't include this information.
     52
     53[Benefit: Less data through the wire]
     54
     55== Proposed Solution ==
     56
     57This RFC introduces a new, enhanced version of QUERYMAPFEATURES that can satisify all of the above requirements, being a one-stop shop of all our viewer selection and tooltip needs. The key features of this API over the previous QUERYMAPFEATURES API is that:
     58
     59 a) the client can specify what bits of information they want. So for the above cases:
     60
     61    1) and 2) wants attribute information, with an inline selection image if they say it is possible
     62    3) Only wants tooltip and hyperlink information
     63
     64 b) If requested, it returns attributes of all selected features instead of one. It turns out, that we already have an existing API in MgRenderingService that gets us half-way there ({{{QueryFeatureProperties}}}). The problem with the current implementation of {{{QueryFeatureProperties}}} is that it only records the layer name for each feature (as a special hard-coded property: {{{_MgLayerName}}}) and does not include other useful information such as the feature's bounding box (needed by the "Zoom to current feature" function of the AJAX viewer property pane). So we will offer a new internal API to MgRenderingService:
     65
     66{{{
     67class MG_MAPGUIDE_API MgRenderingService : public MgService
     68{
     69INTERNAL_API:
     70    /////////////////////////////////////////////////////////////////
     71    /// \brief
     72    /// The QueryFeatureProperties operation identifies those features that
     73    /// meet the specified spatial selection criteria. This operation
     74    /// is used to implement WMS feature info and returns property values
     75    /// for all features which match the spatial query
     76    ///
     77    /// \param map
     78    /// Input
     79    /// map object containing current state of map.
     80    /// \param layerNames
     81    /// Input
     82    /// Active layer names for which to query features
     83    /// \param filterGeometry
     84    /// Input
     85    /// geometry object specifying the selection area
     86    /// \param selectionVariant
     87    /// Input
     88    /// selection criterion - integer value corresponding to one of
     89    /// the MgFeatureSpatialOperations values
     90    /// \param featureFilter
     91    /// Input
     92    /// an XML selection string containing the required feature IDs
     93    /// \param maxFeatures
     94    /// Input
     95    /// the maximum number of features to return
     96    /// \param layerAttributeFilter
     97    /// Input
     98    /// bitmask values - 1=Visible, 2=Selectable, 4=HasTooltips
     99    ///
     100    /// \return
     101    /// An MgSelection instance identifying the features that meet the
     102    /// selection criteria. Returns null if no features are identified.
     103    ///
     104    virtual MgBatchPropertyCollection* QueryFeatureProperties(
     105        MgMap* map,
     106        MgStringCollection* layerNames,
     107        MgGeometry* filterGeometry,
     108        INT32 selectionVariant,
     109        CREFSTRING featureFilter,
     110        INT32 maxFeatures,
     111        INT32 layerAttributeFilter,
     112        bool bIncludeFeatureBBOX) = 0;
     113};
     114}}}
     115
     116The existing public implementation of QueryFeatureProperties will be re-routed into this internal API with {{{bIncludeFeatureBBOX = false}}} to preserve existing response behaviour (for WFS, which uses this API). When {{{bIncludeFeatureBBOX = true}}}, a new {{{_MgFeatureBoundingBox}}} special property is included with each {{{MgPropertyCollection}}} of the {{{MgBatchPropertyCollection}}} that is returned.
     117
     118To support computation of each feature's bounding box, the existing {{{FeaturePropRenderer}}} needs to be modified as such:
     119
     120 * The constructor includes a boolean parameter {{{bIncludeFeatureBBOX}}}
     121 * Overriding the following methods of Renderer, to get and the bounding boxes of each stylized geometry. The {{{FeaturePropRenderer}}} does not actually stylize features per-se, but these methods still get passed the raw geometry that we're interested in for each iteration of the stylization loop.
     122    * {{{ProcessMarker}}}
     123    * {{{ProcessPolyline}}}
     124    * {{{ProcessPolygon}}}
     125 * The bounding box computation only happens if {{{bIncludeFeatureBBOX = true}}}
     126
     127A new overload of QueryMapFeatures method will be added to MgHtmlController
     128
     129{{{
     130class MG_MAPGUIDE_API MgHtmlController : public MgController
     131{
     132INTERNAL_API:
     133    //////////////////////////////////////////////////////////////////
     134    /// \brief
     135    /// Processes a QueryMapFeatures request from the Viewer
     136    ///
     137    /// \param mapName
     138    /// Name of the map
     139    /// \param layer
     140    /// Layer for which to provide feature descriptions
     141    /// \param selectionGeometry
     142    /// Geometry defining which features to select
     143    /// \param selectionVariant
     144    /// Specifies how features are selected
     145    /// \param maxFeatures
     146    /// Max number of feature descriptions to return
     147    /// \param persist
     148    /// Indicates if the returned selection set should be persisted in the session repository
     149    ///
     150    /// \return
     151    /// A byte reader containing the feature info
     152    ///
     153    MgByteReader* QueryMapFeatures(
     154        CREFSTRING mapName,
     155        MgStringCollection* layerNames,
     156        MgGeometry* selectionGeometry,
     157        INT32 selectionVariant,
     158        CREFSTRING featureFilter,
     159        INT32 maxFeatures,
     160        bool persist,
     161        INT32 layerAttributeFilter,
     162        INT32 requestData,
     163        CREFSTRING selectionColor,
     164        CREFSTRING selectionFormat);
     165};
     166}}}
     167
     168This method will be invoked by v2.5.0 of the QUERYMAPFEATURES operation. v2.5.0 of QUERYMAPFEATURES includes the following extra parameters:
     169
     170||Name||Description||Required||
     171||REQUESTDATA||A bitmask indicating the type of information to be returned to the client||Yes||
     172||SELECTIONCOLOR||The color of the inline selection image||Yes||
     173||SELECTIONFORMAT||The format of the inline selection image||No||
     174
     175This new overload behaves mostly like the original QueryMapFeatures (clearing MgMap changes before API invocation and saving selection if {{{persist = true}}}) with the following differences.
     176
     177The requestData parameter is a bitmask indicating the information the client viewer requires.
     178
     179 Attributes = 1
     180 InlineSelection = 2
     181 Tooltip = 4
     182 Hyperlink = 8
     183
     184Thus based on the value of {{{requestData}}}, we do the following:
     185
     186 * If {{{Tooltip}}} flag set or {{{Hyperlink}}} flag set: Call existing {{{MgRenderingService::QueryMapFeatures}}} and store the result
     187 * If {{{Attributes}}} flag set: Call new internal {{{MgRenderingService::QueryFeatureProperties}}} and store the result
     188 * If {{{InlineSelection}}} flag set: Call {{{MgRenderingService::RenderDynamicOverlay}}} for selection only and convert the response to a base64 string
     189
     190Depending on the requestData masked value, we will have a {{{MgFeatureInformation}}} (containing the tooltip, hyperlink and selection set), a {{{MgBatchPropertyCollection}}} containing the selected feature attributes and a {{{STRING}}} (containing the base64 selection image). Then we construct the appropriate XML response based on what pieces of data we have.
     191
     192Here's a rectangular selection query would look like this:
     193
     194{{{
     195TBD
     196}}}
     197
     198Or if the browser supports data URIs
     199
     200{{{
     201TBD
     202}}}
     203
     204And produces a response like this (without inline selection):
     205
     206{{{
     207TBD
     208}}}
     209
     210And a response like this (with inline selection):
     211
     212{{{
     213TBD
     214}}}
     215
     216A tooltip/hyperlink query, would look like this:
     217
     218{{{
     219TBD
     220}}}
     221
     222and produces a response like this:
     223
     224{{{
     225TBD
     226}}}
     227
     228Inline selection images are rendered out as inline base64 string, avoiding an additional GETDYNAMICMAPOVERLAYIMAGE request. This exploits the new Data URI feature supported by most modern browsers, the AJAX and Fusion viewers can do the capability checks client-side to determine whether to request an inline selection. Attributes of all features are grouped by their respective layer name.
     229
     230The inline image does not have the mime-type prepended to the string. It is the responsibility of the calling viewer to prepend the appropriate mime type to the base64 string in order to constitute a valid data URI. The reason for this omission is that data URIs are a browser-centric feature and would involve extra client-side processing for non-browser clients to strip out this mime type (as they probably wouldn't support or recognise data URIs)
     231
     232As a result of this implementation, we are effectively batching up a series of operations server-side that previously would've been done with individual HTTP requests. Doing all this work in one shot eliminates the need for these additional requests.
     233
     234On the viewer front, although we can't make a true "one size fits all" model that can accommodate both viewers, we can at least provide enough information in the response for client viewers to reshape and re-project into their desired form.
     235
     236The AJAX viewer will need some slight modifications to deal with the new QUERYMAPFEATURES response as the structure differs from what is returned by getselectedfeatures.[php/jsp/aspx], but the content is the same. Selected features can be grouped by layer name and each individual selected feature has a bounding box for the "Zoom to current feature" function to work. If data URIs are supported, the viewer needs to simply check the content of the {{{InlineSelectionImage}}} property in the response. If it is not empty, it can be assigned straight into the {{{<img>}}} element that holds the selection image, otherwise we proceeed as normal and send off a GETDYNAMICMAPOVERLAYIMAGE request for that image. With the implementation of this RFC, getselectedfeatures.[php/jsp/ajax] will no longer be required and can be removed.
     237
     238For Fusion, it gets a bit more complicated as it makes various calls to assorted PHP scripts (SaveSelection.php, GetSelectionProperties.php, etc). This asynchronous call chain of PHP scripts needs to be refactored so that it only needs to send the new QUERYMAPFEATURES request and process its response as it does all the things that these PHP scripts were previously needed for. In addition, it's client-side selection structure is radically different from that of the AJAX viewer. Given the very early stage of this RFC, discussion with Fusion developers is needed to determine if the sample responses proposed here is enough to replicate the existing client-side selection model and this RFC will be updated accordingly based on developer feedback.
     239
     240== Implications ==
     241
     242This RFC is a mapagent API addition. No existing APIs are affected. No additions are made to the MapGuide Web Extension API.
     243
     244The AJAX and Fusion viewers will be updated to take advantage of this new version of QUERYMAPFEATURES
     245
     246== Test Plan ==
     247
     248Test AJAX and Fusion viewers with sample selections and verify the selection set data matches the previous implementation.
     249
     250Verify that the invocations of QueryFeatureProperties from WFS does not include our newly introduced special property.
     251
     252== Funding / Resources ==
     253
     254Community