54 | | From the required parameters table above, we can see !GetFeatureInfo requires almost all the parameters required by !GetMap request and plus more, the custom command would also require the same input for Select command and extra parameters (i, j coordinate in pixels of feature in Map CS). [[BR]] |
| 54 | From the required parameters table above, we can see !GetFeatureInfo requires a copy of parameters required by !GetMap request and plus its own parameter. So the custom command would also require the same input for Select command and extra parameters ( QUERY_LAYERS, INFO_FORMAT, FEATURE_COUNT, I and J ). To simplify the implementation and usage of the command, the relevant !GetMap request will be cached in the connection class and this command would pick up it as the part of the !GetMap parameters. This presumes that the command shoud be invoked after the relevant select command. If no cached !GetMap request available, execution of the command would throw an exception.[[BR]] |
| 55 | |
| 56 | Although, it's possible that the command would employ a different bounding box and resolution with those used in the cached !GetMap request, The command also exposes another entries to let user specify the expected bounding box, height and width.[[BR]] |
61 | | <Format>text/html</Format>[[BR]] |
62 | | |
63 | | Currently, the WMS implementation specification doesn’t define a standard format for it. So, the solution is to return a !FdoString* type pointer by this command. If user set the FEATURE_COUNT greater than 1, the information for multiple candidate features will be returned. However, we don’t parse the returned information since no standard regarding the format and client should take the responsibility to parse it. For example the following text is returned from one server to response the !GetFeatureInfo request.[[BR]] |
64 | | |
| 63 | <Format>text/html</Format> [[BR]] |
| 64 | <Format>text/xml</Format> [[BR]] |
| 65 | <Format>image/png</Format> [[BR]] |
| 66 | <Format>video/mpeg</Format> [[BR]] |
| 67 | .......[[BR]] |
| 68 | |
| 69 | Currently, the WMS specification doesn’t define a standard format for each of the subtype. So, the solution is to return a !FdoIoStream* type pointer by this command. Users take the responsibilities to parse the returned data stream. If user set the FEATURE_COUNT greater than 1, the information for multiple candidate features will be returned. [[BR]] For example, if the "text/plain" is specified as the output format and set the FEATURE_COUNT as 2, the string stream below would be obtained.[[BR]] |
106 | | /// FdoString* pointer, which points to the feature information returned |
107 | | /// by the WMS server. |
108 | | /// |
109 | | /// \return |
110 | | /// Returns string contains feature information from the WMS server |
111 | | /// |
112 | | FDO_API virtual FdoString * Execute() = 0; |
| 112 | /// FdoIoStream* pointer. It could be a text, image, video and any |
| 113 | /// binary data stream, ect. The result depends on the specified output |
| 114 | /// format. |
| 115 | /// |
| 116 | /// \return |
| 117 | /// Return a FdoIoStream representing the feature information. |
| 118 | /// |
| 119 | FDO_API virtual FdoIoStream* Execute() = 0; |
| 143 | |
| 144 | /// \brief |
| 145 | /// Set the format of output feature information. The supported values are MIME type |
| 146 | /// strings and should be listed in one or more <Format> elements inside the |
| 147 | /// <Request><FeatureInfo> element of the Capabilities XML. |
| 148 | /// An exception would be thrown if the value isn't in the supported list when |
| 149 | /// executing the command. The default value is the first one specified in the |
| 150 | /// Capabilities document. |
| 151 | /// |
| 152 | /// \para value |
| 153 | /// Input the output feature information format. |
| 154 | /// |
| 155 | FDO_API virtual void SetOutputFormat(FdoString* value) = 0; |
| 156 | |
| 157 | /// \brief |
| 158 | /// Get the specified format for the returning feature information. |
| 159 | /// |
| 160 | /// \return |
| 161 | /// Return the output feature information format. |
| 162 | /// |
| 163 | FDO_API virtual FdoString* GetOutputFormat() = 0; |
| 164 | |
| 165 | /// \brief |
| 166 | /// Set the bounding box that would be used to replace the one in |
| 167 | /// cached GetMap request. If it's not set or the bounding box is |
| 168 | /// empty, directly use the one in cached GetMap request. |
| 169 | /// |
| 170 | /// \param value |
| 171 | /// Input the interest bounding box. |
| 172 | /// |
| 173 | FDO_API virtual void SetBoundingBox(FdoIEnvelope* value) = 0; |
| 174 | |
| 175 | /// \brief |
| 176 | /// Get the bounding box that's specified to replace the one in |
| 177 | /// cached GetMap request. |
| 178 | /// |
| 179 | /// \return |
| 180 | /// Return the specified bounding box for GetMap request. |
| 181 | /// |
| 182 | FDO_API virtual FdoIEnvelope* GetBoundingBox() = 0; |
| 183 | |
| 184 | /// \brief |
| 185 | /// Set the height to replace the one used in the cached GetMap |
| 186 | /// request. Its default value is zero, if the specified value is |
| 187 | /// greater than zero, the replacement would happen. Otherwise, |
| 188 | /// directly use the one in the cached GetMap request. |
| 189 | /// |
| 190 | /// \param value |
| 191 | /// Input the specified image height. |
| 192 | /// |
| 193 | FDO_API virtual void SetHeight(FdoSize value) = 0; |
| 194 | |
| 195 | /// \brief |
| 196 | /// Get the height that's specified to replace the one in cached |
| 197 | /// GetMap request. Its default value is zero. |
| 198 | /// |
| 199 | /// \return |
| 200 | /// Return specified image height. |
| 201 | /// |
| 202 | FDO_API virtual FdoSize GetHeight() = 0; |
| 203 | |
| 204 | /// \brief |
| 205 | /// Set the width to replace the one used in the cached GetMap |
| 206 | /// request. Its default value is zero, if the specified value is |
| 207 | /// greater than zero, the replacement would happen. Otherwise, |
| 208 | /// directly use the one in the cached GetMap request. |
| 209 | /// |
| 210 | /// \param value |
| 211 | /// Input the specified image width. |
| 212 | /// |
| 213 | FDO_API virtual void SetWidth(FdoSize value) = 0; |
| 214 | |
| 215 | /// \brief |
| 216 | /// Get the width that's specified to replace the one in cached |
| 217 | /// GetMap request. Its default value is zero. |
| 218 | /// |
| 219 | /// \return |
| 220 | /// Return specified image width. |
| 221 | /// |
| 222 | FDO_API virtual FdoSize GetWidth() = 0; |
190 | | FdoPtr<FdoWmsIGetFeatureInfo> cmdGFI = static_cast<FdoWmsIGetFeatureInfo*> (connection->CreateCommand(FdoWmsCommandType_!GetFeatureInfo)); |
191 | | FdoPtr<FdoIdentifier> id = FdoIdentifier::Create(L”Park”); |
192 | | cmdGFI->SetFeatureClassName(id); |
| 276 | FdoPtr<FdoIConnection> conn = CreateConnection (); |
| 277 | conn->SetConnectionString (L"FeatureServer=http://www.WMSSERVER.net/wms_service"); |
| 278 | FdoConnectionState_Open == conn->Open (); // Open the connection. |
| 279 | FdoPtr<FdoISelect> cmd = static_cast<FdoISelect *> (conn->CreateCommand (FdoCommandType_Select)); |
| 280 | cmd->SetFeatureClassName (L"Borders_Poly"); |
| 281 | FdoPtr<FdoIdentifierCollection> selProps = cmd->GetPropertyNames (); |
| 282 | FdoPtr<FdoIdentifier> prop = FdoIdentifier::Create (L"FeatId"); |
| 283 | selProps->Add (prop); |
| 284 | FdoPtr<FdoIFeatureReader> featReader = cmd->Execute (); |
| 285 | ...... |
| 286 | }}} |
| 287 | |
| 288 | After viewing the generated WMS map, users could wonder the information at some point of the map. The custom !GetFeatureInfo command could be called as below.[[BR]] |
| 289 | |
| 290 | {{{ |
| 291 | FdoPtr<FdoWmsIGetFeatureInfo> cmdGFI = static_cast<FdoWmsIGetFeatureInfo*> ( conn->CreateCommand(FdoWmsCommandType_!GetFeatureInfo) ); |
| 292 | FdoPtr<FdoIdentifier> id = FdoIdentifier::Create(L"Borders_Poly"); |
| 293 | cmdGFI->SetFeatureClassName(id); |
199 | | Since there are lots of same parameters required as !GetMap request, the Execute function of this custom command will be similar with the select command. The difference is to pass the extra i, j values and fire the !GetFeatureInfo request to WMS server. What’s more, share the same codes between select command and !GetFeatureInfo custom command should be considered seriously.[[BR]] |
200 | | |
201 | | Similar to the !GetMap request, the parameters regarding the !GetMap parts should be obtained from the override configuration. If it’s not customized, the default parameters will be gotten from capabilities documents (returned from !GetCapabilities). One note is that the command should generally be called after the !GetMap request; otherwise, the returned result is probably unexpected if the parameters are wrongly specified. |
| 302 | In the upper case, the cached bounding box and resolution are not changed. However, if the application employs the tile approach to improve the map loading performance, the bounding box and resolution in the cached !GetMap parameters couldn't meet the request. The methods !SetBoundingBox, !SetHeight and !SetWidth need be called to specify the expected ones, and the command would automatically replace the cached parameters before execution.[[BR]] |
| 303 | |
| 304 | Note: If the select command isn't called before executing the !FdoWmsCommandType_!GetFeatureInfo command, an exception would be thrown.[[BR]] |
| 305 | |