Version 8 (modified by 14 years ago) ( diff ) | ,
---|
FDO RFC 57 - Implement the GetFeatureInfo command for WMS provider
This page contains a request for comments document (RFC) for the FDO Open Source project. More FDO RFCs can be found on the RFCs page.
Status
RFC Template Version | 1.1 |
Submission Date | March 23, 2011 |
Last Modified | Cheney Sun, March 23, 2011 |
Author | Cheney Sun |
RFC Status | proposed |
Implementation Status | completed |
Proposed Milestone | 3.7.0.0 |
Assigned PSC guide(s) | Orest Halustchak, Greg Boone |
Voting History | (vote date) |
+1 | |
+0 | |
-0 | |
-1 |
Overview
The RFC is to implement the GetFeatureInfo command for WMS provider.
Motivation
GetFeatureInfo is an optional operation of WMS server. It is only supported for those Layers for which the attribute queryable="1" (true) has been defined or inherited. The GetFeatureInfo operation is designed to provide clients of a WMS with more information about features in the pictures of maps that were returned by Get Map requests. The canonical use case for GetFeatureInfo is that a user sees the response of a Map request and chooses a point on that map for which to obtain more information.
Here is the table of the parameters of a GetFeatureInfo Request based on the 1.3.0 version:
Request parameter | Mandatory/optional | Description |
VERSION=1.3.0 | M | Request version |
REQUEST=GetFeatureInfo | M | Request name |
map request part | M | Partial copy of the Map request parameters that generated the map for which information is desired. |
QUERY_LAYERS=layer_list | M | Comma-separated list of one or more layers to be queried |
INFO_FORMAT=output_format | M | Return format of feature information (MIME type). |
FEATURE_COUNT=number | O | Number of features about which to return information (default=1). |
I=pixel_column | M | i coordinate in pixels of feature in Map CS |
J=pixel_row | M | j coordinate in pixels of feature in Map CS |
EXCEPTIONS=exception_format | O | The format in which exceptions are to be reported by the WMS (default= XML) |
Basically, the goal is that users must be able to not only connect to WMS services and add features to maps from those services; they should also be able to click on map features to get more information.
As to the 1.1.0 version, the standard employs the x = pixel_column and y = pixel_row to replace I = pixel_column and J = pixel_row.
More details regarding the WMS GetFeatureInfo request can be found in the WMS standards http://www.opengeospatial.org/standards/wms.
Proposed Solution
The shortest WMS GetFeatureInfo implementation path would involve implementing GetFeatureInfo request within the current FDO WMS provider. The design solution would provide a custom command, !FdoWmsCommandType_GetFeatureInfo, for users to retrieve the feature information.
• Input of the GetFeatureInfo request
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.
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.
• Output of the GetFeatureInfo request
The format of responded message from the GetFeatureInfo request is defined by the WMS server. According to the WMS standard, the retrieved feature information is a MIME type. For example, it could be the following format.
<Format>text/plain</Format>
<Format>text/html</Format>
<Format>text/xml</Format>
<Format>image/png</Format>
<Format>video/mpeg</Format>
.......
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.
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.
Layer 'IBA'
Feature 6:
SITEID = 'NU009'
NAME = 'Queen Maud Lowlands'
LINK = 'http://www.bsc-eoc.org/iba/site.jsp?siteID=NU009'
Feature 66:
SITEID = 'NU089'
NAME = 'Middle Back River'
LINK = 'http://www.bsc-eoc.org/iba/site.jsp?siteID=NU089'
However, the following XML formatted message stream will return if issue the command to a MapGuide server and specifying the output format as "text/xml".
<?xml version=”1.0”, encoding=”UTF-18”?> <FeatureInfoCollection> <FeatureInfo layer = “Sample/Layers/Districts”> <Property name=”name” value = “Voting District Three”/> <Property name =”Url” value=””/> <Property name=Key value=3/> <Property name=”Autogenerated_SDF_ID” value=6/> </FeatureInfo> </FeatureInfoCollection>
Similarly, if specifying the output format as "image/png", an image stream would be returned; specifying it as "video/mpeg" would get a video stream. Users have the freedom to choose a way of comsuming those data.
• GetFeatureInfo custom command interface
/// \brief /// The FdoWmsIGetFeatureInfo interface defines the /// FdoWmsIGetFeatureInfo command, which retrieves more information /// about features in the maps. The Execute operation returns a /// FdoIoStream* type pointer pointing to the feature information /// data stream. class FdoWmsIGetFeatureInfo : public FdoICommand { friend class FdoIConnection; public: /// \brief /// Execute the FdoWmsIGetFeatureInfo command and returns a /// FdoIoStream* pointer. It could be a text, image, video and any /// binary data stream, ect. The result depends on the specified output /// format. /// /// \return /// Return a FdoIoStream representing the feature information. /// FDO_API virtual FdoIoStream* Execute() = 0; /// \brief /// Set the feature class name for which feature information /// will be retrieved. This function is mandatory; if not specified or the feature class /// name can’t be found in the schema, execution of the command will throw an /// exception. /// /// \param value /// Input the feature class name. /// /// \return /// Returns nothing /// FDO_API virtual void SetFeatureClassName(FdoIdentifier* values) = 0; /// \brief /// Get the name of the feature class for which feature information /// will be retrieved. /// /// \return /// Input the query feature class name. /// FDO_API virtural FdoIdentifier * GetFeatureClassName() = 0; /// \brief /// Set the format of output feature information. The supported values are MIME type /// strings and should be listed in one or more <Format> elements inside the /// <Request><FeatureInfo> element of the Capabilities XML. /// An exception would be thrown if the value isn't in the supported list when /// executing the command. The default value is the first one specified in the /// Capabilities document. /// /// \para value /// Input the output feature information format. /// FDO_API virtual void SetOutputFormat(FdoString* value) = 0; /// \brief /// Get the specified format for the returning feature information. /// /// \return /// Return the output feature information format. /// FDO_API virtual FdoString* GetOutputFormat() = 0; /// \brief /// Set the bounding box that would be used to replace the one in /// cached GetMap request. If it's not set or the bounding box is /// empty, directly use the one in cached GetMap request. /// /// \param value /// Input the interest bounding box. /// FDO_API virtual void SetBoundingBox(FdoIEnvelope* value) = 0; /// \brief /// Get the bounding box that's specified to replace the one in /// cached GetMap request. /// /// \return /// Return the specified bounding box for GetMap request. /// FDO_API virtual FdoIEnvelope* GetBoundingBox() = 0; /// \brief /// Set the height to replace the one used in the cached GetMap /// request. Its default value is zero, if the specified value is /// greater than zero, the replacement would happen. Otherwise, /// directly use the one in the cached GetMap request. /// /// \param value /// Input the specified image height. /// FDO_API virtual void SetHeight(FdoSize value) = 0; /// \brief /// Get the height that's specified to replace the one in cached /// GetMap request. Its default value is zero. /// /// \return /// Return specified image height. /// FDO_API virtual FdoSize GetHeight() = 0; /// \brief /// Set the width to replace the one used in the cached GetMap /// request. Its default value is zero, if the specified value is /// greater than zero, the replacement would happen. Otherwise, /// directly use the one in the cached GetMap request. /// /// \param value /// Input the specified image width. /// FDO_API virtual void SetWidth(FdoSize value) = 0; /// \brief /// Get the width that's specified to replace the one in cached /// GetMap request. Its default value is zero. /// /// \return /// Return specified image width. /// FDO_API virtual FdoSize GetWidth() = 0; /// \brief /// Set the position (X, Y) which indicates a point of interest on the map that was /// produced by the embedded !GetMap request.The point (X, Y) is a /// point in the (i, j) space defined by the Map CS. /// This function is mandatory; if not specified, /// execution of the command will throw an exception. /// /// \param pos /// Input the point's coordinate value (X, Y) /// /// \return /// Return nothing /// FDO_API virtual void SetPosition(FdoIDirectPosition* pos) = 0; /// \brief /// Get the position (X, Y) which indicates a point of interest on the map that was /// produced by the embedded !GetMap request. The point (X, Y) is a /// point in the (i, j) space defined by the Map CS. /// /// \return /// Return the interesting position. /// FDO_API virtual FdoIDirectPosition* GetPosition() = 0; /// \brief /// Set the number of features about which to return information (default=1). /// /// \param featureCount /// The number of the features to query. /// /// \return /// Returns nothing /// FDO_API virtual void SetFeatureCount(FdoInt32 featureCount = 1) = 0; /// \brief /// Get the number of features about which to return information. /// /// \return /// Returns candidate feature number. /// FDO_API virtual FdoInt32 GetFeatureCount () = 0; };
In this class, both methods GetFeatureClassName and SetFeatureClassName are used to get/set a feature class which would be mapped to WMS layer in order to query the relevant feature information.
• Example
Generally, the FdoWmsSelectCommand will be called before the GetFeatureInfo custom command. The following select command can be called to bring map to the application.
FdoPtr<FdoIConnection> conn = CreateConnection (); conn->SetConnectionString (L"FeatureServer=http://www.WMSSERVER.net/wms_service"); FdoConnectionState_Open == conn->Open (); // Open the connection. FdoPtr<FdoISelect> cmd = static_cast<FdoISelect *> (conn->CreateCommand (FdoCommandType_Select)); cmd->SetFeatureClassName (L"Borders_Poly"); FdoPtr<FdoIdentifierCollection> selProps = cmd->GetPropertyNames (); FdoPtr<FdoIdentifier> prop = FdoIdentifier::Create (L"FeatId"); selProps->Add (prop); FdoPtr<FdoIFeatureReader> featReader = cmd->Execute (); ......
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.
FdoPtr<FdoWmsIGetFeatureInfo> cmdGFI = static_cast<FdoWmsIGetFeatureInfo*> ( conn->CreateCommand(FdoWmsCommandType_!GetFeatureInfo) ); FdoPtr<FdoIdentifier> id = FdoIdentifier::Create(L"Borders_Poly"); cmdGFI->SetFeatureClassName(id); FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance(); FdoPtr<FdoIDirectPosition> pt = gf->CreatePositionXY(-1000, 1000); cmdGFI->SetPosition(pt); cmdGFI->SetOutputFormat(L"text/xml"); FdoPtr<FdoIoStream> stream = cmdGFI->Execute (); ......
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.
Note: If the select command isn't called before executing the !FdoWmsCommandType_GetFeatureInfo command, an exception would be thrown.
Implications
- A new command !FdoWmsCommandType_GetFeatureInfo is added for WMS provider.
Test Plan
Add unit tests into WMS provider to test the new command.
Funding/Resources
Autodesk to provide resources / funding