Select to view content in your preferred language

Query / Buffer / Return results

3297
13
01-20-2011 08:41 AM
JayKappy
Frequent Contributor
In my app I have a search textblock that is returning a record from the search criteria...in my example its the unique "PID" (parcel identification).  I then push the results to a results window.

What I am looking to do now is run the search list above BUT also return the results from a couple other layers in my app.  The problem is that they are not ideitifyed by the same unique id and most of them are much larger polygons representing polling precints, school boundaries etc.

I assume that I should be able to do some sort of spatial query based on the found feature searched on and then spatially query to locate the polygon that it lies within.  Then take those fields values and return them to another results window....Does that make sense...

Just looking for some ideas on how to take this one on....THanks
0 Kudos
13 Replies
JayKappy
Frequent Contributor
Awesome...got that to work...the spatial part anyways...

I have the buffer working out of the box from the ESRI examples...but as you know the example relys on a user click in the map....I am tryign to convert this to the same as teh spatial query. I want the query to use the geometry from the Parcel found in the query not the user click.

How do I tie in the Buffer query to do the same as the Spatial Query???

Thanks again for your guidance and thoughts....well and patience....

I added the buffer Handler here:
        Dim queryTask As New QueryTask("http://gis.logis.org/arcgis/rest/services/MG_Test_WGS84/MapServer/8")
        AddHandler queryTask.ExecuteCompleted, AddressOf QueryTaskFindPID_ExecuteCompletedSearch
        AddHandler queryTask.ExecuteCompleted, AddressOf QueryTask_ExecuteCompletedSpatialQuery
        AddHandler queryTask.ExecuteCompleted, AddressOf QueryTask_ExecuteCompletedBuffer2        
AddHandler queryTask.Failed, AddressOf QueryTaskFindPID_FailedSearch


This code is what draws the buffer graphic from which to set the search boundary to select features. I assume that I have to mess with this line to set it to the Initial query result?

clickGraphic.Geometry = e.MapPoint

I tried clickGraphic.Geometry = graphic.Geometry and it didnt like it....I can see how the e.MapPoint is not even in the parameters so thats not going to work...so I think that I need to get the Gemoetry of the Parcel found in the inital query here....just cant figure that one out....think Ihave all the rest that I need to pull this off....

    Private Sub QueryTask_ExecuteCompletedBuffer2(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.Tasks.QueryEventArgs)
        ' BUFFER
        _geometryService = New GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer")
        AddHandler _geometryService.BufferCompleted, AddressOf GeometryService_BufferCompleted
        AddHandler _geometryService.Failed, AddressOf GeometryService_Failed

        _queryTask = New QueryTask("http://gis.logis.org/arcgis/rest/services/MG_Test_WGS84/MapServer/1")
        AddHandler _queryTask.ExecuteCompleted, AddressOf QueryTask_ExecuteCompletedBuffer
        AddHandler _queryTask.Failed, AddressOf QueryTask_Failed

        _pointAndBufferGraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayerBuffer"), GraphicsLayer)
        _resultsGraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayerBufferResults"), GraphicsLayer)


        Dim clickGraphic As New Graphic()
        clickGraphic.Symbol = TryCast(LayoutRoot.Resources("DefaultMarkerSymbol2"), ESRI.ArcGIS.Client.Symbols.Symbol)
        clickGraphic.Geometry = e.MapPoint       
 ' Input spatial reference for buffer operation defined by first feature of input geometry array
        clickGraphic.Geometry.SpatialReference = MyMap.SpatialReference

        _pointAndBufferGraphicsLayer.ClearGraphics()
        _resultsGraphicsLayer.ClearGraphics()

        clickGraphic.SetZIndex(2)
        _pointAndBufferGraphicsLayer.Graphics.Add(clickGraphic)

        ' If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
        Dim bufferParams As New ESRI.ArcGIS.Client.Tasks.BufferParameters() With
            {
                .BufferSpatialReference = New SpatialReference(4326),
                .OutSpatialReference = MyMap.SpatialReference,
                .Unit = LinearUnit.Meter
            }
        bufferParams.Distances.Add(4000)
        bufferParams.Features.Add(clickGraphic)

        _geometryService.BufferAsync(bufferParams)
End Sub
0 Kudos
JayKappy
Frequent Contributor
I tried this and am closer....BUT the buffer was the entire map extent....all my features were selected but for soem reason teh 4000 meter buffer was ignored...

    Private Sub QueryTask_ExecuteCompletedBuffer1(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.Tasks.QueryEventArgs)
        'Private Sub QueryTask_ExecuteCompletedBuffer2(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.Tasks.GraphicsEventArgs)

        _geometryService = New GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer")
        AddHandler _geometryService.BufferCompleted, AddressOf GeometryService_BufferCompleted2
        AddHandler _geometryService.Failed, AddressOf GeometryService_Failed2

        _queryTask = New QueryTask("http://gis.logis.org/arcgis/rest/services/MG_Test_WGS84/MapServer/1")
        AddHandler _queryTask.ExecuteCompleted, AddressOf QueryTask_ExecuteCompletedBuffer2
        AddHandler _queryTask.Failed, AddressOf QueryTask_Failed2

        _pointAndBufferGraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayerBuffer"), GraphicsLayer)
        _resultsGraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayerBufferResults"), GraphicsLayer)

        Dim featureSet As FeatureSet = args.FeatureSet

        If featureSet Is Nothing OrElse featureSet.Features.Count < 1 Then
            MessageBox.Show("No features retured from query")
            Return
        End If

        If featureSet IsNot Nothing AndAlso featureSet.Features.Count > 0 Then
            For Each feature As Graphic In featureSet.Features

                Dim clickGraphic As New Graphic()
                clickGraphic.Symbol = TryCast(LayoutRoot.Resources("DefaultMarkerSymbol2"), ESRI.ArcGIS.Client.Symbols.Symbol)
                clickGraphic.Geometry = feature.Geometry
                ' Input spatial reference for buffer operation defined by first feature of input geometry array
                clickGraphic.Geometry.SpatialReference = MyMap.SpatialReference

                _pointAndBufferGraphicsLayer.ClearGraphics()
                _resultsGraphicsLayer.ClearGraphics()

                clickGraphic.SetZIndex(2)
                _pointAndBufferGraphicsLayer.Graphics.Add(clickGraphic)

                ' If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
                Dim bufferParams As New ESRI.ArcGIS.Client.Tasks.BufferParameters() With
                    {
                        .BufferSpatialReference = New SpatialReference(4326),
                        .OutSpatialReference = MyMap.SpatialReference,
                        .Unit = LinearUnit.Meter
                    }
                bufferParams.Distances.Add(4000)
                bufferParams.Features.Add(clickGraphic)

                _geometryService.BufferAsync(bufferParams)


            Next feature
        End If
End Sub
0 Kudos
JayKappy
Frequent Contributor
I modifed the above entry to this and got the saem results....EVERYTHING being included in the buffer...I think I am really close but cant see to get a handle on how to capture the geopmetry of the Parcel done in the first query

        _pointAndBufferGraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayerBuffer"), GraphicsLayer)
        _resultsGraphicsLayer = TryCast(MyMap.Layers("MyGraphicsLayerBufferResults"), GraphicsLayer)

        '====================================
        Dim featureSet As FeatureSet = args.FeatureSet
        If featureSet Is Nothing OrElse featureSet.Features.Count < 1 Then
            MessageBox.Show("No features retured from query")
            Return
        End If

        If featureSet IsNot Nothing AndAlso featureSet.Features.Count > 0 Then
            For Each feature As Graphic In featureSet.Features

                Dim selectedFeature As Graphic = featureSet.Features(0)
                Dim clickGraphic As New Graphic()
                clickGraphic.Symbol = TryCast(LayoutRoot.Resources("DefaultMarkerSymbol2"), ESRI.ArcGIS.Client.Symbols.Symbol)
                'clickGraphic.Geometry = feature.Geometry
                clickGraphic.Geometry = selectedFeature.Geometry
0 Kudos
JayKappy
Frequent Contributor
I now went in and changed the Buffer Distance parameter...
I had to decrease the value down to where it is not making sense...ALTOUGH it is now within my city and makeing the correct selections based on the buffer, and not the whoel world.....obviuosly soemthing to do with the spatial reference or something else....

This is not 0.05 meters (where the example was 100 meters) as the buffer graphic that gets created is about 1.5 miles Radius / 3 mile diameter...

These are the first three Map Services I have in my app

ArcGISDynamicMapServiceLayer  SpatialReference(4326).....
ArcGISDynamicMapServiceLayer  Spatial Reference: 102100 (3857)
FeatureLayer:                          Spatial Reference: 4269

All my layers are in this:
Full Extent:

XMin: 457057.270826343
YMin: 197381.565205937
XMax: 498385.319567721
YMax: 234726.316205273
Spatial Reference: PROJCS["HENNEPIN COUNTY",GEOGCS["GCS_User_Defined",DATUM["D_User_Defined",SPHEROID["User_Defined_Spheroid",6378418.941,298.2572242549207]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",100000.0],PARAMETER["Central_Meridian",-93.38333333333334],PARAMETER["Standard_Parallel_1",44.88333333333333],PARAMETER["Standard_Parallel_2",45.13333333333333],PARAMETER["Latitude_Of_Origin",44.79111111111111],UNIT["Foot_US",0.304800609601219]]

Units: esriFeet

I removed the 2nd and 3rd listed above leaving only the 4326 Spatial Reference and my layers, plus the Graphic Layers...and I still get a wierd value of 0.05 being about 1.5 mile radius

Anyone know how I can clear this up or at least figure out how to calculate a know buffer distance that makes sense?  I would like to allow the user to enter a unit in feet or meters if need be....but have to figure out what is happening with the value and why 0.05 is needed...

Thanks
            ' If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            Dim bufferParams As New ESRI.ArcGIS.Client.Tasks.BufferParameters() With
                {
                    .BufferSpatialReference = New SpatialReference(4326),
                    .OutSpatialReference = MyMap.SpatialReference,
                    .Unit = LinearUnit.Meter
                }
            bufferParams.Distances.Add(0.05)
            bufferParams.Features.Add(clickGraphic)

            _geometryService.BufferAsync(bufferParams)
0 Kudos