[mapguide-users] selectionXML Problem
Greg
gbneff at cid.utah.gov
Thu Jan 13 19:08:15 EST 2011
I am having trouble getting the current selection by using GetSelectionXML(),
passing the selection XML to the server and getting the selection. When a
new item is selected for about 90% of the features, I get the correct Item.
For the other 10%, the item is not found, even though the correct properties
are shown in the properties pane. I am using the basic layout. Below is my
code that takes the XML and gets the item from the Mapguide server. Any
ideas what might be happening?
<%
String sessionId = Request.Form.Get("SID");
String selectionXML = Server.UrlDecode(Request.Form.Get("sel"));
//Response.Write("sessionId: " + sessionId + "<br>selectionXML: " +
selectionXML);
string realPath = Request.ServerVariables["APPL_PHYSICAL_PATH"];
String configPath = realPath + "webconfig.ini";
MapGuideApi.MgInitializeWebTier(configPath);
MgUserInformation userInfo = new MgUserInformation(sessionId);
MgSiteConnection siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo);
if (siteConnection == null)
{
Response.Write("Failed to get site connection.");
return;
}
MgResourceService resService =
(MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);
MgFeatureService featureService =
(MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);
MgMap map = new MgMap();
map.Open(resService, "Cid_Map");
//get LineID information for selected feature (line)
MgSelection selection = new MgSelection(map, selectionXML);
MgLayer layer = (MgLayer)map.GetLayers().GetItem("lines_ss_cid");
string strLayerClassName = layer.GetFeatureClassName();
string strSelection = selection.GenerateFilter(layer,
strLayerClassName);
MgFeatureQueryOptions nameQuery = new MgFeatureQueryOptions();
nameQuery.SetFilter(strSelection);
MgResourceIdentifier resID = new
MgResourceIdentifier("Library://data/sdf/lines_ss_cid.FeatureSource");
MgFeatureReader featureReader = featureService.SelectFeatures(resID,
"lines_ss_cid", nameQuery);
string strLineID = "";
if(featureReader.ReadNext())
{
strLineID = featureReader.GetInt32("LineID").ToString();
}
else
{
//this shouldn't happen
Response.Write("LineID not found in Mapguide datasource.");
}
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/selectionXML-Problem-tp5920249p5920249.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list