Identify Task and Polygon GeometryType

2610
2
02-07-2012 07:07 AM
BenTreptow
New Contributor II
I'm trying to create an identify tool that will return all of the features that intersect the geometry of a particular parcel. For example, a user clicks (or draws a rectangle on) a parcel and then can get information on utilities, contours, zoning, etc. that cross that and only that property. I'm using the geometry of the selected parcel(s) (GeometryType.Polygon) as the input geoemtry for my IdentifyParameters. The first problem is that adjacent parcels are also selected in addition to the parcel(s) that are actually selected. It's almost like it's overiding the Polygon geometry of each parcel and using an envelope instead. I can get around this by specifying a LayerDefinition in the IdentifyParameters that only uses the Parcel ID number of the selected parcel(s). This kind of leads into the other problem... I need to submit the geometry of the selected parcel(s) to the IdentifyTask and since it's a Polygon, the URL can exceed the maximum URL length (2083 chars, I think) pretty easily. Put this together with my LayerDefinition and the URL quickly becomes too long. Especially considering I want to use a Rectangle to select one or many parcels to Identify on at once.

Is there a better, more effective way to do this?

            StringBuilder definitionString = new StringBuilder("PID in ("); //PID = Unique Parcel ID #

            pidList.ForEach(pid => { definitionString.Append("'" + pid + "',"); });

            if (definitionString.ToString().EndsWith(","))
                definitionString.Remove(definitionString.Length - 1, 1);

            if (!definitionString.ToString().EndsWith(")"))
                definitionString.Append(")"); 

            LayerDefinition layerDefinition = new LayerDefinition();
            layerDefinition.Definition = definitionString.ToString();
            layerDefinition.LayerID = 2;

            List<LayerDefinition> layerDefinitions = new List<LayerDefinition>();
            layerDefinitions.Add(layerDefinition);

            IdentifyParameters identifyParams = new IdentifyParameters();
            identifyParams.Geometry = geometry; //geometry = Parcel (polygon) geometry returned in from another method.
            identifyParams.MapExtent = Target.Extent; //-10405823.111712,5607318.33490769,-10405351.611712,5607522.08490769
            identifyParams.Width = (int)Target.ActualWidth; //1886
            identifyParams.Height = (int)Target.ActualHeight; //815
            identifyParams.LayerOption = LayerOption.all;
            identifyParams.LayerDefinitions = layerDefinitions; //ex: PID in ('2811722310044', '2811722310043')
            identifyParams.Tolerance = 0;

            IdentifyTask identifyTask = new IdentifyTask(IdentifyService.Url);
            identifyTask.ExecuteCompleted += new EventHandler<IdentifyEventArgs>(identifyTask_ExecuteCompleted);
            identifyTask.Failed += new EventHandler<TaskFailedEventArgs>(identifyTask_Failed);
            identifyTask.ExecuteAsync(identifyParams);
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
The first problem is that adjacent parcels are also selected in addition to the parcel(s) that are actually selected.

An object overlapping the geometry even for one pixel is returned (else nothing would be returned when the geometry is a point). We may imagine a mechanism accepting negative tolerance but I don't think this is working (not tested though).
Anyway you found out a workaround (you may also filter the result to keep only the right parcel).

I need to submit the geometry of the selected parcel(s) to the IdentifyTask and since it's a Polygon, the URL can exceed the maximum URL length (2083 chars, I think) pretty easily.

This is supposed to work with latest ArcGIS SL versions by using automatically HTTP POST instead of GET.
Which error do you get?
Which version of the API are you using?
0 Kudos
BenTreptow
New Contributor II
I was using v2.3, but I installed v2.4. I ran it through Fiddler and it looks like it's doing a POST now instead of a GET from the SL API. Either way though, when I specify a polygon geometry that has enough rings/vertices to exceed 2083 characters in the URL it is going to bomb out right? If I plug the parameters into the REST API and do a GET (using a geometry with a lot vertices), it'll redirect to a page that says "HTTP Error 414. The request URL is too long." If I do a POST, it doesn't redirect and it doesn't error out, but it says "No results found." My Silverlight app doesn't return an error at all. It just continues to work without bringing back any identify results. I think we might be onto somthing with the POST thing, but I can't figure out why it's not returning anything.
0 Kudos