eSearch widget - combine graphical search, apply buffer, and intersect results

1906
12
Jump to solution
05-13-2014 02:32 PM
MarkHuffman
New Contributor III
My customer wants to be able to select a road segment, apply the buffer, and select the intersecting parcels - all with one click. I have put "applyBuffer();" at the end of queryFeaturesGraphical's onResult function, and placed "intersectResults("esriSpatialRelIntersects");" just before the catch in bufferCompleteHandler. The result is that the intersecting parcels are selected, then all parcels connectd to those parcels are selected then all parcels connected to those are select, and on and on. Any help is appreciated.

Mark
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Mark,

   Honestly I did not spend the time to run through these changes in the code that you made (your customer not mine). But now I see that the intersectResults is going to call the queryFeaturesGraphical again (as it should). But then you are going to have the applyBuffer at the end and loop through that whole thing again. So you have to limit the applyBuffer to one time through.

So that being said. You need to add a private var to count the number of times thru.

private var xThru:int = 0;
Preferably outside the queryFeaturesGraphical function, and then where you currently have the applyBuffer call change it to this:

                        if(xThru == 0){                             applyBuffer();                             xThru++;                         }


Then you need to clear that private var when you are ready to do the whole operation again (or else you will only be able to do it one time and that's it). So I added this to the clear function:

xThru = 0;

View solution in original post

0 Kudos
12 Replies
RobertScheitlin__GISP
MVP Emeritus
Mark,

   At the end of the bufferCompleteHandler there are these lines that are causing your loop scenario:

                            if(isGraphicalBufferOp){
                                queryFeaturesGraphical(resultEvent, "esriSpatialRelIntersects", configSearchGraphical[(cboLayerGraphical.selectedIndex < 0)?0:cboLayerGraphical.selectedIndex]);
                            }


I would suggest you make that if statement false after you have completed your required steps.
0 Kudos
MarkHuffman
New Contributor III
Mark,

   At the end of the bufferCompleteHandler there are these lines that are causing your loop scenario:

                            if(isGraphicalBufferOp){
                                queryFeaturesGraphical(resultEvent, "esriSpatialRelIntersects", configSearchGraphical[(cboLayerGraphical.selectedIndex < 0)?0:cboLayerGraphical.selectedIndex]);
                            }


I would suggest you make that if statement false after you have completed your required steps.


Hi Robert,

Thanks for your reply.

In this code:
if(isGraphicalBufferOp){
queryFeaturesGraphical(resultEvent, "esriSpatialRelIntersects", configSearchGraphical[(cboLayerGraphical.selectedIndex < 0)?0:cboLayerGraphical.selectedIndex]);
                            }

//Added by Mark 5/13/14
intersectResults("esriSpatialRelIntersects");
       
                        }
catch (error:Error){
showMessage(error.message, false);
                        }

Where would I put the statement, and how do I make false?

Thank you.
Mark
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Mark,

   Hmm... Don't you see the issue? You are using the queryFeaturesGraphical function in your initial steps and then in the results of bufferGeometries you get to the end of that function and you have these lines of code:
                            if(isGraphicalBufferOp){
                                queryFeaturesGraphical(resultEvent, "esriSpatialRelIntersects", configSearchGraphical[(cboLayerGraphical.selectedIndex < 0)?0:cboLayerGraphical.selectedIndex]);
                            }


If the isGraphicalBufferOp is true then you would go right back to the queryFeaturesGraphical function again.

The applyBuffer function has one input (a boolean called isGraphicalBufferOp).
0 Kudos
MarkHuffman
New Contributor III
Robert,

My understanding of your advice is that I should insert the statement
isGraphicalBufferOp = false

before
 if(isGraphicalBufferOp){
                                queryFeaturesGraphical(resultEvent, "esriSpatialRelIntersects", configSearchGraphical[(cboLayerGraphical.selectedIndex < 0)?0:cboLayerGraphical.selectedIndex]);
                            }                
//Added by Mark 5/13/14
intersectResults("esriSpatialRelIntersects");      
          }


I have tried that, and it doesn't prevent the loop, so I don't think I understand. Also, isn't isGraphicalBufferOp false already, according to the functions applyBuffer() and bufferGeometries()?

Or is it that I put the false statement inside the intersectResults() function? There are three paths in that function that lead to queryFeaturesGraphical.

I appreicate you not wanting to just give me the answer, so that I learn better by figuring it out for myself, but I have already spent too many hours on this, so a more direct clue would be very helpful.

Thank you for your continued assistance.

Mark
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Mark,

   Honestly I did not spend the time to run through these changes in the code that you made (your customer not mine). But now I see that the intersectResults is going to call the queryFeaturesGraphical again (as it should). But then you are going to have the applyBuffer at the end and loop through that whole thing again. So you have to limit the applyBuffer to one time through.

So that being said. You need to add a private var to count the number of times thru.

private var xThru:int = 0;
Preferably outside the queryFeaturesGraphical function, and then where you currently have the applyBuffer call change it to this:

                        if(xThru == 0){                             applyBuffer();                             xThru++;                         }


Then you need to clear that private var when you are ready to do the whole operation again (or else you will only be able to do it one time and that's it). So I added this to the clear function:

xThru = 0;
0 Kudos
MarkHuffman
New Contributor III
Robert,

Thank you for your time and effort. It works great!

Mark
0 Kudos
MarkHuffman
New Contributor III
Robert's widget, as further customized by me with help from Robert, is still working wonderfully. My customers love it.

I have changed the <simplefillsymbol> tag in the widget XML file to use 100% transparency (alpha="0.0") for the fill and red for the outline. When the widget finishes running, the selected feature is shown briefly as configured, but then the polygon is filled with purple. I have searched the widget source files far and wide for code that would cause this, but haven't found anything. And no matter what settings I use in the tag, that color shows up.

Any help is appreciated.

Mark
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Mark,

   Did you mess around with the layer.selectionColor in the code anywhere? It sounds like the polygon is geting a glow filter applied and that color along with the red outline is making the appearance of the purple fill.
0 Kudos
MarkHuffman
New Contributor III
Robert,

I don't recall changing layer.selectionColor anywhere in the .mxml, but I could have at some point and forgotten. I will look into that and also into the glow filter.

Thank you.

Mark
0 Kudos