Select features using For Each Loop
I have a For-Each loop that loops over all items in an iList and applys a query and add the result to a featureset (featureset4), in each cycle in the loop, the query returns a feature and add it to featureset4 but it removes with keeping the features in featureset4, and after finishing the loop the resultant featurest4 only contains the last queried feature alone.
My target is to populate the feature set with all the features queried through the loop. Is there anyway to handle this?
Any help is highly appreciated
Hani
_img_ alt="User-added image" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=906600000004Imv&feoid=Body&refid=0EM600000004YGC"_/_img_
0
-
Hi Hani,
The Query Task activity will return a new FeatureSet object every time it runs in this loop. It will not merge together if there are already features in the featureset.
To resolve this, you could do two different things:
1. Change your WHERE clause to request all parcels at once, then do not loop the Query Task. To do this, you would use a loop or similar function call to create a string like this:
PARCELNUMBER IN ('abc', 'def', 'ghi', ... 'xyz')
2. Use a second FeatureSet variable to store your results. In your loop, you would add a variable called featureSetComplete. Then, using an If activity to test if featureSetComplete is Nothing, branch to activities that assign featureSetComplete the value of featureSet3 if it's nothing, otherwise use an Add Range To Collection activity to add the Features attribute of featureSet3 to the Features attribute of featureSetComplete.
Note: you can only add to the Features attribute of a FeatureSet if the Graphic objects you're going to add match up with the geometry type and fields of the FeatureSet. So, if you know you are getting these features all from the same place you will be fine. If your Features actually come from different layers, you may not get your expected results.
Regards,
-Malcolm0 -
Many Thanks for the wonderful suggestion Malcolm!
I went with the second one qand it worked fine!0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
2 Kommentare