| 1 | = !MapGuide RFC 157 - Support creating MgMap instances with initial display parameters = |
| 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 | == Status == |
| 7 | |
| 8 | ||RFC Template Version||(1.0)|| |
| 9 | ||Submission Date||9 Feb 2017|| |
| 10 | ||Last Modified||9 Feb 2017|| |
| 11 | ||Author||Jackie Ng|| |
| 12 | ||RFC Status||draft|| |
| 13 | ||Implementation Status||discussion|| |
| 14 | ||Proposed Milestone||3.3|| |
| 15 | ||Assigned PSC guide(s)||(when determined)|| |
| 16 | ||'''Voting History'''||(vote date)|| |
| 17 | ||+1|||| |
| 18 | ||+0|||| |
| 19 | ||-0|||| |
| 20 | ||-1|||| |
| 21 | ||no vote|| || |
| 22 | |
| 23 | == Overview == |
| 24 | |
| 25 | This RFC proposes to add a new overload of MgMap.Create() that allows for initial display parameters (width/height/dpi/center/scale) |
| 26 | |
| 27 | to be set, allowing them to be used for certain MgRenderingService operations without a session id. |
| 28 | |
| 29 | == Motivation == |
| 30 | |
| 31 | A key roadblock of MapGuide scalability is the current use of session repositories. Using session repositories imposes an upper limit when vertically scaling up MapGuide. Each MapGuide session adds memory and administrative burden on the MapGuide Server. A truly scalable solution would be to completely do away with the notion of session repositories and support stateless rendering of map selection and querying. A stateless map viewer would then be responsible for the management of map selections and view state, leaving the MapGuide Server solely responsible for rendering and querying of feature data. |
| 32 | |
| 33 | However, the current building blocks to enable the above scenario simply do not exist in the MapGuide Web API in its current form. |
| 34 | |
| 35 | There are a certain set of APIs in the MgRenderingService that can accept an MgMap object. However, these APIs implicitly assume the MgMap object is to be opened from an existing session repository. |
| 36 | |
| 37 | It is currently not possible to create an MgMap using MgMap.Create() and immediately use this MgMap in any of the following operations: |
| 38 | |
| 39 | * QueryFeatureProperties |
| 40 | * QueryFeatures |
| 41 | * RenderDynamicOverlay |
| 42 | * RenderMapLegend |
| 43 | |
| 44 | These operations require a MgMap instance that was opened from an existing session repository via a mapname/session pair, thus a MapGuide session must always be involved when using any of these operations. |
| 45 | |
| 46 | It is not possible to use the above APIs in a "stateless" manner without needing to create or use a MapGuide session ID/repository. |
| 47 | |
| 48 | The reason these operations don't work in a "stateless" context is because such operations expect the MgMap's display properties to be already set: |
| 49 | |
| 50 | * Display Width |
| 51 | * Display Height |
| 52 | * DPI |
| 53 | * View Center |
| 54 | * View Scale |
| 55 | |
| 56 | However, these properties are immutable and can only be modified through the mapagent-only GETDYNAMICMAPOVERLAYIMAGE API via: |
| 57 | |
| 58 | * SETDISPLAYWIDTH |
| 59 | * SETDISPLAYHEIGHT |
| 60 | * SETDISPLAYDPI |
| 61 | * SETVIEWCENTERX |
| 62 | * SETVIEWCENTERY |
| 63 | * SETVIEWSCALE |
| 64 | |
| 65 | This API also requires a SESSION/MAPNAME pair meaning once again you have to have created and saved a MgMap and MgSelection into a session repository. |
| 66 | |
| 67 | The immutability of these display parameters hinders our ability to use certain MgRenderingService operations in a "stateless" manner without a MapGuide session id. Without the ability to use these MgRenderingService operations in a stateless manner, we do not have the required pieces to build a stateless map viewer. |
| 68 | |
| 69 | == Proposed Solution == |
| 70 | |
| 71 | To remove these limitations, we will introduce an overload of MgMap.Create() that allows these display parameters to be set as part of map creation. |
| 72 | |
| 73 | {{{ |
| 74 | |
| 75 | class MG_MAPGUIDE_API MgMap : public MgSerializable |
| 76 | { |
| 77 | PUBLISHED_API: |
| 78 | ////////////////////////////////////////////////////////////////// |
| 79 | /// \brief |
| 80 | /// Initializes a new MgMap object given a map definition or tile set |
| 81 | /// definition and a name for the map with initial display parameters set. |
| 82 | /// This method is used for MapGuide Viewers or for offline map production. |
| 83 | /// |
| 84 | /// \remarks |
| 85 | /// If creating a MgMap object from a tile set definition, only "Default" is the |
| 86 | /// acceptable tile provider. Any other provider will cause this method to |
| 87 | /// throw a MgUnsupportedTileProviderException |
| 88 | /// |
| 89 | /// <!-- Syntax in .Net, Java, and PHP --> |
| 90 | /// \htmlinclude DotNetSyntaxTop.html |
| 91 | /// void Create(MgResourceIdentifier mapDefinition, string mapName, int displayWidth, int displayHeight, double x, double y, double scale, int dpi); |
| 92 | /// \htmlinclude SyntaxBottom.html |
| 93 | /// \htmlinclude JavaSyntaxTop.html |
| 94 | /// void Create(MgResourceIdentifier mapDefinition, String mapName, int displayWidth, int displayHeight, double x, double y, double scale, int dpi); |
| 95 | /// \htmlinclude SyntaxBottom.html |
| 96 | /// \htmlinclude PHPSyntaxTop.html |
| 97 | /// void Create(MgResourceIdentifier mapDefinition, string mapName, int displayWidth, int displayHeight, double x, double y, double scale, int dpi); |
| 98 | /// \htmlinclude SyntaxBottom.html |
| 99 | /// |
| 100 | /// \param resource |
| 101 | /// An MgResourceIdentifier that specifies the |
| 102 | /// location of the map definition in a resource |
| 103 | /// repository. |
| 104 | /// \param mapName |
| 105 | /// A string that specifies the name of the map. |
| 106 | /// \param displayWidth |
| 107 | /// The display width to initially set for the map |
| 108 | /// \param displayHeight |
| 109 | /// The display height to initially set for the map |
| 110 | /// \param x |
| 111 | /// The view center X coordinate to initially set for the map |
| 112 | /// \param y |
| 113 | /// The view center Y coordinate to initially set for the map |
| 114 | /// \param scale |
| 115 | /// The view scale to initially set for the map |
| 116 | /// \param dpi |
| 117 | /// The display DPI to initially set for the map |
| 118 | /// |
| 119 | /// \return |
| 120 | /// Returns nothing. |
| 121 | /// |
| 122 | /// <!-- Example (PHP) --> |
| 123 | /// \htmlinclude PHPExampleTop.html |
| 124 | /// \code |
| 125 | /// // Assuming the site connection has already been intialized |
| 126 | /// $resourceID = new MgResourceIdentifier('Library://Calgary/Maps/Calgary.MapDefinition'); |
| 127 | /// $map = new MgMap($site); |
| 128 | /// // Initializes the map to be centered on the Calgary CBD at 1:5000 scale with a DPI of 96 |
| 129 | /// $map->Create($resourceID, 'Calgary', 640, 480, -114.054565, 51.068369, 5000.0, 96); |
| 130 | /// \endcode |
| 131 | /// \htmlinclude ExampleBottom.html |
| 132 | /// |
| 133 | virtual void Create(MgResourceIdentifier* resource, CREFSTRING mapName, INT32 displayWidth, INT32 displayheight, double x, double y, double scale, INT32 dpi); |
| 134 | }; |
| 135 | |
| 136 | }}} |
| 137 | |
| 138 | Any MgMap instance created by this new API can immediately be used for any MgRenderingService API that accepts an MgMap without requiring it be loaded from an existing session repository. |
| 139 | |
| 140 | == Implications == |
| 141 | |
| 142 | This is a new API addition. Existing forms of MgMap::Create() work as before. |
| 143 | |
| 144 | == Test Plan == |
| 145 | |
| 146 | Create MgMap instances using the new overload API and verify they can be used immediately with the following MgRenderingService |
| 147 | |
| 148 | operations without errors: |
| 149 | |
| 150 | * QueryFeatureProperties |
| 151 | * QueryFeatures |
| 152 | * RenderDynamicOverlay |
| 153 | * RenderMapLegend |
| 154 | |
| 155 | == Funding / Resources == |
| 156 | |
| 157 | Community |