Select to view content in your preferred language

Selection of points inside polygons - Not showing all the features in the data grid

525
2
Jump to solution
07-19-2012 05:45 AM
ionarawilson1
Deactivated User
I am still having that problem with not being able to get all the features from the query. I have two queries, one to select counties and the other to select companies inside the counties selected. If I select two counties I see the two counties and the points selected inside but the datagrid shows the records of the county that has less companies. Let's say I select a county with 1 company and one with 5 companies. When I select those counties, for a split of a second I see 4 companies on the datagrid and then it changes to 1 company. It is like the data is getting in separate featuresets. Why is this happening? I have been trying to figure this out since yesterday but to no avail. Do you guys have any ideas why this is happening? Thank you!

            //This is the query using the point tool to select the counties        [Bindable] private var queryTaskcounty:QueryTask = new QueryTask();    [Bindable] private var querycounty:Query = new Query();            //this is the query using the point tool to select the companies inside the counties selected        [Bindable] private var queryTaskcompanyincounty:QueryTask = new QueryTask();    [Bindable] private var querycompanyincounty:Query = new Query();                private function runQueryTaskcounty(geometry:Geometry):void    {     queryTaskcounty.url = "http://tfs-24279/ArcGIS/rest/services/ForestProducts/county_forest_products/MapServer/0";     queryTaskcounty.showBusyCursor = true;     queryTaskcounty.useAMF = false;          querycounty.geometry = geometry;      //geometry from the drawToolbar     querycounty.returnGeometry = true;    //set to true because we want to place points on the map     querycounty.spatialRelationship = "esriSpatialRelIntersects";     querycounty.outSpatialReference = myMap.spatialReference;     querycounty.outFields = ['*'];         //run the query task     queryTaskcounty.execute(querycounty, new AsyncResponder(onResult, onFault));          function onResult(featureSet:FeatureSet, token:Object = null):void     {            myGraphicslayer.clear()      myGraphicslayer.visible = true;      for each(var graphic : Graphic in featureSet.features)      {       graphic.symbol = fillSymbolmultipoint;        myGraphicslayer.add(graphic);              //Now run this query       //Of course this url needs to be to the layer that has your companies       queryTaskcompanyincounty.url = "http://tfs-24279/ArcGIS/rest/services/ForestProducts/dynamic_layer_forest_products/MapServer/0";       queryTaskcompanyincounty.showBusyCursor = true;       queryTaskcompanyincounty.useAMF = false;             querycompanyincounty.geometry = graphic.geometry;      //geometry from the first query       querycompanyincounty.returnGeometry = true;    //set to true because we want to place points on the map       querycompanyincounty.spatialRelationship = "esriSpatialRelIntersects";       querycompanyincounty.outSpatialReference = myMap.spatialReference;       querycompanyincounty.outFields = ['*'];           //run the query task       queryTaskcompanyincounty.execute(querycompanyincounty, new AsyncResponder(onResultcompanyincounty, onFault));                  }                           }          function onResultcompanyincounty(featureSet:FeatureSet, token:Object = null):void     {                  //myGraphicslayer.clear()      myGraphicslayer.visible = true;      resizableDraggableTitleWindowcompanyincounty.visible = true;      querydgcompanyincounty.visible = true;      //querydgcompanyincounty.dataProvider = queryTaskcompanyincounty.executeLastResult.attributes      // to deselect the zooming tools when the graphic layers appear      tbb.selectedIndex = -1      var countyName:String = new String;      var tempArray:Array = new Array();       var featuresInSelect:int = 0             for each(var graphic:Graphic in featureSet.features){       graphic.symbol = resultsSymbol;              myGraphicsLayer.add(graphic);                      var Companyv:String = graphic.attributes['Company'];       countyName = graphic.attributes['County'];                                       featuresInSelect++;       //set up array so that this data can be sent to the datagrid       tempArray.push(        {         Name:countyName,         Company:Companyv                 }       );                                  }                                                       //populate the datagrid,       querydgcompanyincounty.dataProvider = tempArray;            if (myGraphicsLayer.numGraphics  == 0) {       info.text = "There are no  records";      }      if (myGraphicsLayer.numGraphics > 1) {       info.text = " There are" + myGraphicsLayer.numGraphics  + " matching records";      }      if (myGraphicsLayer.numGraphics == 1) {       info.text = " There is" + myGraphicsLayer.numGraphics  + " matching record";      }             }                    function onFault(info:Object, token:Object = null):void     {      Alert.show(info.toString(), "Query Problem");     }    }     
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ionarawilson1
Deactivated User
I found a solution for this but I am still interested in knowing how to merge featuresets when this happens if anybody has any ideas. My solution was to create a fetuareset from the graphic layer since it is giving me all the graphics, and then set the data provider for the datagrid as the attributes for that new featureset. Here is the code

    
    
    function onResultcompanyincounty(featureSet:FeatureSet, token:Object = null):void
    {
     
     
     //myGraphicslayer.clear()
     myGraphicslayercounty.visible = true;
     resizableDraggableTitleWindowcompanyincounty.visible = true;
     querydgcompanyincounty.visible = true;
     //querydgcompanyincounty.dataProvider = queryTaskcompanyincounty.executeLastResult.attributes
     // to deselect the zooming tools when the graphic layers appear
     tbb.selectedIndex = -1
     
     //Alert.show(featureSet.features.length.toString())
     for each(var graphic : Graphic in featureSet.features){
      graphic.symbol = resultsSymbol; 
      myGraphicsLayer.add(graphic);
     
      // added these 3 next lines to make all the records appear in the datagrid, I had to use the graphics as source as the featureset just shows part of the results
      //Because all the first county selected will immediattely get a point, then the second one and so forth, like there are two queries, the first and second queries
      //occur concurrently for the county selected.
      var featureset:FeatureSet;
      featureset = new FeatureSet(ArrayCollection(myGraphicsLayer.graphicProvider).toArray());
      querydgcompanyincounty.dataProvider = featureset.attributes;       graphic.addEventListener(MouseEvent.MOUSE_OVER, onMouseOvercompanyincounty);
      graphic.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutcompanyincounty);
      
     }
     
     if (myGraphicsLayer.numGraphics  == 0) {
      info.text = "There are no  records";
     }
     if (myGraphicsLayer.numGraphics > 1) {
      info.text = " There are" + myGraphicsLayer.numGraphics  + " matching records";
     }
     if (myGraphicsLayer.numGraphics == 1) {
      info.text = " There is" + myGraphicsLayer.numGraphics  + " matching record";
     }  
     
    }
    
    
    
    function onFault(info:Object, token:Object = null):void
    {
     Alert.show(info.toString(), "Query Problem");
    }
   }

View solution in original post

0 Kudos
2 Replies
ionarawilson1
Deactivated User
I still haven't found a solution but I think I know why this is happening. After the query for county runs, for each graphic it runs the second query for the companies, so it runs first for one graphic and then for the other(s).

So it creates two feature sets. I created an alert and the alert show the count of features for the first featureset and the second feature set.


But I need them together for the results to show on the datagrid. Does anybody know a way of changing the expression

querydgcompanyincounty.dataProvider = queryTaskcompanyincounty.executeLastResult.attributes


So the datagrid provider has the attributes of both results and not only the last?
or a way to combine the two feature sets together and then add it to the datagrid? Or another way of having the second query only after both counties have been queried?

Thanks!



 function onResultcompanyincounty(featureSet:FeatureSet, token:Object = null):void
    {
     
      
      

     
     //myGraphicslayer.clear()
     myGraphicslayer.visible = true;
     resizableDraggableTitleWindowcompanyincounty.visible = true;
     querydgcompanyincounty.visible = true;
     querydgcompanyincounty.dataProvider = queryTaskcompanyincounty.executeLastResult.attributes
     // to deselect the zooming tools when the graphic layers appear
     tbb.selectedIndex = -1
   
     Alert.show(featureSet.features.length.toString())
     for each(var graphic : Graphic in featureSet.features){
      graphic.symbol = resultsSymbol; 
      myGraphicsLayer.add(graphic);
      
     
     }
     
     if (myGraphicsLayer.numGraphics  == 0) {
      info.text = "There are no  records";
     }
     if (myGraphicsLayer.numGraphics > 1) {
      info.text = " There are" + myGraphicsLayer.numGraphics  + " matching records";
     }
     if (myGraphicsLayer.numGraphics == 1) {
      info.text = " There is" + myGraphicsLayer.numGraphics  + " matching record";
     }  
     
    }
    
    
    
    function onFault(info:Object, token:Object = null):void
    {
     Alert.show(info.toString(), "Query Problem");
    }
   }

0 Kudos
ionarawilson1
Deactivated User
I found a solution for this but I am still interested in knowing how to merge featuresets when this happens if anybody has any ideas. My solution was to create a fetuareset from the graphic layer since it is giving me all the graphics, and then set the data provider for the datagrid as the attributes for that new featureset. Here is the code

    
    
    function onResultcompanyincounty(featureSet:FeatureSet, token:Object = null):void
    {
     
     
     //myGraphicslayer.clear()
     myGraphicslayercounty.visible = true;
     resizableDraggableTitleWindowcompanyincounty.visible = true;
     querydgcompanyincounty.visible = true;
     //querydgcompanyincounty.dataProvider = queryTaskcompanyincounty.executeLastResult.attributes
     // to deselect the zooming tools when the graphic layers appear
     tbb.selectedIndex = -1
     
     //Alert.show(featureSet.features.length.toString())
     for each(var graphic : Graphic in featureSet.features){
      graphic.symbol = resultsSymbol; 
      myGraphicsLayer.add(graphic);
     
      // added these 3 next lines to make all the records appear in the datagrid, I had to use the graphics as source as the featureset just shows part of the results
      //Because all the first county selected will immediattely get a point, then the second one and so forth, like there are two queries, the first and second queries
      //occur concurrently for the county selected.
      var featureset:FeatureSet;
      featureset = new FeatureSet(ArrayCollection(myGraphicsLayer.graphicProvider).toArray());
      querydgcompanyincounty.dataProvider = featureset.attributes;       graphic.addEventListener(MouseEvent.MOUSE_OVER, onMouseOvercompanyincounty);
      graphic.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutcompanyincounty);
      
     }
     
     if (myGraphicsLayer.numGraphics  == 0) {
      info.text = "There are no  records";
     }
     if (myGraphicsLayer.numGraphics > 1) {
      info.text = " There are" + myGraphicsLayer.numGraphics  + " matching records";
     }
     if (myGraphicsLayer.numGraphics == 1) {
      info.text = " There is" + myGraphicsLayer.numGraphics  + " matching record";
     }  
     
    }
    
    
    
    function onFault(info:Object, token:Object = null):void
    {
     Alert.show(info.toString(), "Query Problem");
    }
   }

0 Kudos