[mapguide-users] querying number of objects in a feature
A H
hizperion at hotmail.com
Mon Aug 1 02:44:05 EDT 2011
i think this is a simple function, but i couldn't find it in the
manual/examples. how do you retrieve number of objects in the feature? i'm
building a page that displays total number of objects in each feature
classes. what i have now:
List<StrItems> result = new List<StrItems>();
Utilities.InitializeWebTier();
string mgSessionId = Utilities.ValidateMgSession("");
MgUserInformation userInfo = new MgUserInformation(mgSessionId);
MgSiteConnection siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo);
MgResourceService resourceService =
siteConnection.CreateService(MgServiceType.ResourceService) as
MgResourceService;
MgFeatureService featureService =
siteConnection.CreateService(MgServiceType.FeatureService) as
MgFeatureService;
MgResourceIdentifier featureSourceId = new
MgResourceIdentifier("Library://World/Data/" + featureSource +
".FeatureSource");
MgFeatureCommandCollection Commands = new
MgFeatureCommandCollection();
MgStringCollection colStringClass =
featureService.GetClasses(featureSourceId, "");
for (int i = 0; i < colStringClass.GetCount(); i++) // iterate
through feature classes
{
MgFeatureQueryOptions newQuery = new MgFeatureQueryOptions();
newQuery.SetFilter("");
MgFeatureReader featureReader =
featureService.SelectFeatures(featureSourceId, colStringClass.GetItem(i),
newQuery);
int featureCount = 0;
while (featureReader.ReadNext())
{
featureCount++;
}
}
return result;
but as you can see, this is slow because it reads through the featureReader.
can't i just get the Count of the featureReader? GetPropertyCount() just
return number of attributes in the feature.
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/querying-number-of-objects-in-a-feature-tp6639982p6639982.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list