0

I'm trying to execute recursive queries and each one depend on the previous result. I'm looking for a method to use a filter field in the query execution based on the previous query result. Is this possible in arcgis flex api? If yes then what method is used in Flex?

here is My DoQuery function:

            private function doQuery(geom:Geometry):void
            {
                try
                {
                    var query:Query = new Query();
                    query.spatialRelationship = Query.SPATIAL_REL_INTERSECTS;
                    query.geometry = geom;
                    query.returnGeometry = true;
                    query.outFields = ['HUC_14'];
                    queryTask.execute(query, new AsyncResponder(onResult, onFault));
                    var GlobalFeaturesArray:Array = new Array();
                    var count:Number = 0;
                    function onResult(featureSet:FeatureSet, token:Object = null):void
                    {

                        if (featureSet.features.length > 0)
                        {

                            count = featureSet.features.length;
                            GlobalFeaturesArray = GlobalFeaturesArray.concat(featureSet.features);
                            var attributes:ArrayCollection = new ArrayCollection(featureSet.attributes);
                            var Collection:Array = new Array();
//In this if clause, I'm trying to append all HUC_14 values from the query to Collection Array in order to run next query.
                            if (count > 0){
                                var i:Number;
                                for (i=0 ; i < count; i++){
                                    Collection.concat(featureSet.features[i].attributes["HUC_14"]);
                                }
                            }


                            while (count > 0 )
                            {
                                var query2:Query = new Query();
                                query2.outFields = ['HUC_14'];
                                Alert.show(Collection.toString(), 'Alert Box', mx.controls.Alert.OK);
                                query2.where = "HU_14_DS in (" + Collection.toString() + ')';
                                queryTask.execute(query2, new AsyncResponder(onResult2, onFault2));
                                function onResult2(featureSet2:FeatureSet, token2:Object = null):void
                                {
                                    count = featureSet2.features.length;
                                    Collection.concat(featureSet2.attributes['HUC_14']);
                                    GlobalFeaturesArray = GlobalFeaturesArray.concat(featureSet2.features);
                                }

                                function onFault2(info2:Object, token2:Object = null):void
                                {
                                    Alert.show(info2.toString(), "Query2 Problem");
                                }

                            }


                            for each (var myGraphic:Graphic in GlobalFeaturesArray)
                            {
                                myGraphicsLayer.add(myGraphic);
                            }
                        }
                        else
                        {
                            Alert.show("No parcels were found", "Try something else");
                        }
                    }
                    function onFault(info:Object, token:Object = null):void
                    {
                        Alert.show(info.faultString + "\n\n" + info.faultDetail, "queryTask fault " + info.faultCode);
                    }
                }
                catch (error:Error)
                {
                    Alert.show(error.toString(), "myGeometryService_simplifyCompleteHandler error");
                }
            }
  • Do both queries use the same Query Task, or do they query different services? – evv_gis Oct 31 '14 at 19:54
  • yes both queries use the same Query Task – fkili mohamed Nov 3 '14 at 13:10
  • I have an idea what you want, but if you can provide an example, then I can make sure my answer will help you. – evv_gis Nov 3 '14 at 14:44
  • you want a code example? – fkili mohamed Nov 3 '14 at 15:03
  • Currently I'm progressing in the code, but I'm still stuck trying to retrieve an Attribute value List as an Array from the Query featureSet result. – fkili mohamed Nov 3 '14 at 15:07
0

Instead of using concat (which creates a new Array), use push.

Collection.push(featureSet.features[i].attributes["HUC_14"]);

Collection.push(featureSet2.attributes['HUC_14']);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.