[mapguide-users] Another way to list selection
yof85
loref85 at yahoo.com.ar
Wed Mar 13 11:30:38 PDT 2013
Hello
I used listselection.aspx
(http://trac.osgeo.org/mapguide/browser/trunk/MgDev/Doc/samples/dotnetsamples/working_with_feature_data/listselection.aspx)
as a base to get selected data from my map points
I changed it a bit adding the output style of search.aspx (I mean, getting
the xml of the point in order to use the CellClicked javascript function to
zoom into a certain result)
My problem is I have points with 68 properties and takes forever listing the
features (the end user expects to select 500-2000 features at a time)
This is part of my code:
do
{
Response.Write("
");
for (int k = 0; k < colCount; k++)
{
String prop = (String)propNames[k];
int propType = featureReader.GetPropertyType(prop);
if (!featureReader.IsNull(prop))
{
switch (propType)
{
case MgPropertyType.Boolean:
val = featureReader.GetBoolean(prop) ? "True" : "False";
break;
case MgPropertyType.Single:
val = featureReader.GetSingle(prop).ToString();
break;
case MgPropertyType.Double:
val = featureReader.GetDouble(prop).ToString();
break;
case MgPropertyType.Int16:
val = featureReader.GetInt16(prop).ToString();
break;
case MgPropertyType.Int32:
val = featureReader.GetInt32(prop).ToString();
break;
case MgPropertyType.Int64:
val = featureReader.GetInt64(prop).ToString();
break;
case MgPropertyType.String:
val = featureReader.GetString(prop);
break;
case MgPropertyType.DateTime:
val = featureReader.GetDateTime(prop).ToString();
break;
}
}
// Generate XML to selection this feature
//
MgSelection sel = new MgSelection(map);
MgPropertyCollection idProps = new MgPropertyCollection();
foreach (string id in propNames)
{
idPropType = featureReader.GetPropertyType(id);
Boolean isNull = featureReader.IsNull(id);
switch (idPropType)
{
case MgPropertyType.Int32:
idProps.Add(new MgInt32Property(id, isNull ? -1 :
featureReader.GetInt32(id)));
break;
case MgPropertyType.String:
idProps.Add(new MgStringProperty(id, isNull ? "null" :
featureReader.GetString(id)));
break;
case MgPropertyType.Int64:
idProps.Add(new MgInt64Property(id, isNull ? -1 :
featureReader.GetInt64(id)));
break;
case MgPropertyType.Double:
idProps.Add(new MgDoubleProperty(id, isNull ? 0.0 :
featureReader.GetDouble(id)));
break;
case MgPropertyType.Single:
idProps.Add(new MgSingleProperty(id, isNull ? 0.0F :
featureReader.GetSingle(id)));
break;
case MgPropertyType.DateTime:
idProps.Add(new MgDateTimeProperty(id, isNull ? null :
featureReader.GetDateTime(id)));
break;
default:
break;
}
}
sel.AddFeatureIds(layer, layerClassName, idProps);
String selText = EscapeForHtml(sel.ToXml());
Response.Write(String.Format(" {5}\n", (row % 2) == 0 ? "Search" :
"Search2", row, i, row, selText, val));
}
Response.Write("");
if (++row == 1000)
break;
} while (featureReader.ReadNext());
Is there a way to avoid the foreach inside the for? (that foreach is in
order to get the xml of the feature:
<?xml version="1.0" encoding="UTF-8"?><FeatureSet
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="FeatureSet-1.0.0.xsd"> <Layer
id="7393d7b4-8be3-11e2-8002-08002700bc54"> <Class
id="KingOra:MAPS~LAYER1~GEOLOC"> <ID>bwYAAAAAAAA=</ID> </Class>
</Layer></FeatureSet>
)
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Another-way-to-list-selection-tp5040201.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list