Select to view content in your preferred language

Error when Querying with a geometry

3841
5
04-13-2011 06:58 AM
CoreySchafer
Deactivated User
I asked this question earlier, but not very clear.

I'm running some Querys (which are all working the way I want them to) until applying a geometry using query.geometry = myGeometry. Here is a section of code...

var queryLayer:String = rbeQueryLayer;
    var queryTask:QueryTask = new QueryTask(queryLayer);
    var query:Query = new Query();
    
    queryTask.disableClientCaching = true;
    query.outFields                = queryFields.split(",");
    query.returnGeometry           = true;
    queryTask.useAMF               = false;
    
    if(borderCheckBox.selected == true){
     query.geometry = wvBorderGeom;
    }
query.where                    = rbeQuery;
query.outSpatialReference      = map.spatialReference;
queryTask.execute(query, new AsyncResponder(onRbeResult, onFault));


I have a checkBox that someone can check if they only want to display results within a certain state's border. So what I am doing is taking the geometry I have for the state and passing that as the geometry for the query if the checkBox is selected. I'm new to using queries, so is this the best way to do this?

The weird part is that for most of my URL's this technique works fine, but for a select few (for example: http://rmgsc.cr.usgs.gov/ArcGIS/rest/services/nhss_usdata/MapServer/0) I get an error only when I apply the query.geometry. Error is: RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request"...text="Error #2032: Stream Error.

So I guess my question is, is there a reason I would get an HTTP request error when the only change I am making to the query is the query.geometry?

Thanks for any help!
Tags (2)
0 Kudos
5 Replies
DasaPaddock
Esri Regular Contributor
The server may be returning a 500 error. Try using a tool like HttpFox to see what the actual server response is.
0 Kudos
IvanBespalov
Frequent Contributor
Some things before I make any query in web application:

1 - open service in web browser and click QUERY in Supported Operations field. Set query params and click Find button (screen1.png). As a result I see all features in my layer and url in browser address bar contains all query parameters(screen2.png).

2 - playing this variations of query parameters in step 1 helps understand where my bug is.

3 - API Reference also has a lot of interesting Examples and Descriptions (screen3.png).
0 Kudos
CoreySchafer
Deactivated User
Here are some screen images I grouped together from FireBug. Hopefully they aren't too small for you to read.

The two pictures for Example 1 are an example of one that works with and without the geometry applied.

The two pictures for Example 2 are an example of one that works without the geometry applied but not WITH the geometry applied...

Thanks!
0 Kudos
MarkSmith3
New Contributor
Hi Corey,

I happened to find this thread when searching for solutions for the very same problem. Have you solved this?

I have a similar issue where my widget uses the geometry from a polygon to find/select all points inside it. For some reason, the widget fails for about half of my polygons while the others run fine. I get an HTTP 500 error from the server for the polygons that don't work.

Any info would be appreciated.

Thanks!
Mark
0 Kudos
CoreySchafer
Deactivated User
Hi Mark,

I asked this a long time ago, but to the best I can remember, I solved my problem just by using a more simple polygon than the one I was using. Still not sure why the complex polygon would work for a query on some URLs and not for others.

I had a similar problem in another project of mine. It turns out the polygon was complex enough that it was actually bigger than the maximum character limit for JSON (not sure where this was set). Anyways, I got around the problem by rigging up a for loop to go through and cut down on how precise the decimals were for the JSON. For example if I had a mapPoint that was 79.987654321 then I would trim i down to 79.98765 with no real noticable changes to where it was placed on the map.

Not sure if it was the best approach or not but worked and continues to work.

In Short, cut down on your JSON character size you are using for your geometry or raise you maximum JSON character limit (Which I don't know how to do). Hope this helps.
0 Kudos