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
Solved! Go to Solution.
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
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
Thanks Shobana. I didn't realize that the iterator itself held the features, good to know how that works.
Regards,
-Paul