Select to view content in your preferred language

Spatial query of multiple services

978
7
12-01-2010 06:59 AM
ShannonMartel
Emerging Contributor
I am trying to create to tool where you can use find to locate a parcel, then use a spatial query to find data in other services (like zoning, floodplain, school district).  I can get it to work finding the parcel and spatial query of one service with a query and querytask.  I can't figure out how to do more.  I can post my code if that would help.  I started with the code posted by Robert Scheitlin at the link below.


Thanks!

http://forums.arcgis.com/threads/6812-I-need-an-example-of-how-to-use-a-spatial-relationship-in-a-qu...
Tags (2)
0 Kudos
7 Replies
ShannonMartel
Emerging Contributor
Does anyone have any ideas?  I am still stuck!

Thank you in advance for any help!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Shannon,

   I don't know of any other way to do this than to do the spatial query on each layer that you want to search for one at a time. The FindTask that can search multiple layers at once only accepts a sting and not a spatial component.
0 Kudos
JeffPerkins
Occasional Contributor
A different approach, but if you can, create a sql view that represents those layers based on an unique id and query that.  

Here's a example of a view.   http://gis.glo.state.tx.us/test/services/bw/Stations/MapServer/0  . 

This is in sql 2003.  I have a live sql table and point feature class.  The view is created from the two. 

This is how I've been dealing with this issue since the ArcIMS days. 
  Good luck..
0 Kudos
ShannonMartel
Emerging Contributor
Could I run multiple queryTasks in the FindEvent?  I have in the findCompleteHandler(event.FindEvent) there is on "queryTask.execute(query)"  Could I do at queryTask2.execute(query) queryTask3.execute(query) and then put all the results in a datagrid?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Shannon,

   It sounds like you don't need the find task at all.

The sequence would be:
1. use QueryTask to search for particular parcel.
2. use results (parcel Polygon) as geometry for input of next query using same querytask just different url and outfields
3. When query 2 returns use same queryTask again (with new url to School Districts) and same geometry from query 2.
4. Repeat the same for all additional layers that need to be queried.
0 Kudos
ShannonMartel
Emerging Contributor
Robert,

I am a little confused how to how to use the same querytask.  Where do you set the different url for the querytask?  Do you by chance have a simple example or know where I could find one.

Thank you again for all your help.

Here is my code:

private function doQuery():void
   {
    // clear the graphics layer
    myGraphicsLayer.clear();
    
    queryTask.execute(query, new AsyncResponder(onResult, onFault));
    function onResult(featureSet:FeatureSet, token:Object = null):void
    {
     
     if (featureSet.features.length == 0)
     {
      Alert.show("No Parcel Found.");
     }
     else
     {
      var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features);
      if (graphicsExtent)
      {
       map.extent = graphicsExtent;
      }
     }
    }
    function onFault(info:Object, token:Object = null):void
    {
     Alert.show(info.toString());
    }
   }

<esri:QueryTask id="queryTask"
      url="http://gis2.stallingsnc.org:8084/Stallings/rest/services/Flex2/ParcelsAgain/MapServer/0"
      useAMF="false"/>
  
  <esri:Query id="query"
     where="ACCTNO like '%{fText.text}%'"
     outSpatialReference="{map.spatialReference}"
     returnGeometry="true"
     text="{fText.text}">
   <esri:outFields>
    <fx:String>ACCTNO</fx:String>
    <fx:String>Owner1</fx:String>
   </esri:outFields>
  </esri:Query>
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Shannon,

   Sorry no example of this put together right now but to reuse the same queryTask all you would have to do is in the onResults portion of your code change the:
queryTask.url = "someother url";
queryTask.execute(query2, new AsyncResponder(onResult2, onFault));


Notice the query2 and onResult2 that way you can send a different where clause and respond to results differently.
0 Kudos