Select to view content in your preferred language

How to use a 'FeatureResult' from a queryFeatures on a GeodatabaseFeatureTable?

3308
2
Jump to solution
07-22-2015 09:29 PM
by Anonymous User
Not applicable

How do you use a 'FeatureResult' returned from a queryFeatures on a GeodatabaseFeatureTable?

e.g.

myFeaturetable.queryFeatures(query)

followed by, in the feature table:

onQueryFeaturesStatusChanged: {

console.log("count of features returned", queryFeaturesResult.featureCount)

}

I can successfully get this to return a feature count, however,  how do I access the features? The documentation says a 'FeatureResult' is "A set of features and their metadata." I expected it to have a list (i.e. a set!) of features, but there is no such property. How do you go about using the results?

I couldn't figure it out, so instead switched to using 'myFeatureTable.queryIds(query)' and used the resulting list of Id's to look up the features - which works fine, but I'm curious as to what the purpose of the queryFeatures is and how it can be used.

Cheers,

-Paul

0 Kudos
1 Solution

Accepted Solutions
ShobanaSuresh
Esri Contributor

Hi Paul,

You can use FeatureResult::iterator to iterate through the features in FeatureResult.

onQueryFeaturesStatusChanged: {

  if (queryFeaturesStatus === Enums.QueryFeaturesStatusCompleted) {

       var iterator = queryFeaturesResult.iterator;

       while (iterator.hasNext()) {

            var feature = iterator.next();

            //Do something with the feature

      }

}

Thanks

Shobana

View solution in original post

2 Replies
ShobanaSuresh
Esri Contributor

Hi Paul,

You can use FeatureResult::iterator to iterate through the features in FeatureResult.

onQueryFeaturesStatusChanged: {

  if (queryFeaturesStatus === Enums.QueryFeaturesStatusCompleted) {

       var iterator = queryFeaturesResult.iterator;

       while (iterator.hasNext()) {

            var feature = iterator.next();

            //Do something with the feature

      }

}

Thanks

Shobana

by Anonymous User
Not applicable

Thanks Shobana. I didn't realize that the iterator itself held the features, good to know how that works.

Regards,

-Paul

0 Kudos