Select to view content in your preferred language

Spatial Query Geometry

1028
5
11-30-2011 02:46 PM
JillianStanford
Frequent Contributor
Hello,
I'm attempting to perform a spatial query task using the geometry returned by a route task but it always fails and the only error I receive is "Deferred object is missing". The geometry appears to be valid, I can draw it on the map as a graphic.

The code below is the route task's solveComplete handler.

function showRoute(solveResult) {
        var routeGeo = solveResult.routeResults[0].route.geometry;
        routeGeo.spatialReference = new esri.SpatialReference({wkid:4326});

        var routeGraphic = new esri.Graphic(routeGeo, routeSymbol);
        map.graphics.add(routeGraphic);

        var routeExtent = routeGraphic.geometry.getExtent();
        routeExtent.spatialReference = new esri.SpatialReference({ wkid: 4326 });
        map.setExtent(routeExtent);
                
        var queryTask = new esri.tasks.QueryTask("http://avalanche/ArcGIS/rest/services/Toll_Calc_Web/MapServer/4");
        var query = new esri.tasks.Query();
        query.outFields = ["*"];
        query.returnGeometry = true;
        query.outSpatialReference = { "wkid": 4326 };
        query.geometry = routeGeo;
        queryTask.execute(query, queryPlazasComplete, errorHandler);
    }


If I swap out routeExtent (the extent of the route geometry) for routeGeo (the route geometry) as the geometry parameter of the query task is executes successfully.

I'm a javascript API newbie so any suggestions are appreciated!

Thank you!!
0 Kudos
5 Replies
HemingZhu
Frequent Contributor
Hello,
I'm attempting to perform a spatial query task using the geometry returned by a route task but it always fails and the only error I receive is "Deferred object is missing". The geometry appears to be valid, I can draw it on the map as a graphic.

The code below is the route task's solveComplete handler.

function showRoute(solveResult) {
        var routeGeo = solveResult.routeResults[0].route.geometry;
        routeGeo.spatialReference = new esri.SpatialReference({wkid:4326});

        var routeGraphic = new esri.Graphic(routeGeo, routeSymbol);
        map.graphics.add(routeGraphic);

        var routeExtent = routeGraphic.geometry.getExtent();
        routeExtent.spatialReference = new esri.SpatialReference({ wkid: 4326 });
        map.setExtent(routeExtent);
                
        var queryTask = new esri.tasks.QueryTask("http://avalanche/ArcGIS/rest/services/Toll_Calc_Web/MapServer/4");
        var query = new esri.tasks.Query();
        query.outFields = ["*"];
        query.returnGeometry = true;
        query.outSpatialReference = { "wkid": 4326 };
        query.geometry = routeGeo;
        queryTask.execute(query, queryPlazasComplete, errorHandler);
    }


If I swap out routeExtent (the extent of the route geometry) for routeGeo (the route geometry) as the geometry parameter of the query task is executes successfully.

I'm a javascript API newbie so any suggestions are appreciated!

Thank you!!


Since route is line feature and the defalut spatialRelationship of query is SPATIAL_REL_INTERSECTS, you will not get the query results unless the features you queried intersect with the route geometry. That's also explained why use route extend worked.
0 Kudos
JillianStanford
Frequent Contributor
Hi!
Thank you so much for your response.

I don't believe this is the problem, for a couple of reasons -
When I use the route geometry, the problem is not that I do not get any results, it is that I get the error, "Deferred object is missing".
I'm moving this functionality from a functioning Silverlight application that is working correctly and the points I'm querying are snapped to the network so I know the query should work.
Finally, if I create a test polyline and populate it with a dummy path the query is executed successfully. Obviously, I don't receive any results but i also don't get an error.

Thank you again for your suggestion!
0 Kudos
PatriceFREYDIERE
Deactivated User
Got the same issue in posting a big geometry with the Geoprocessor (as a FeatureSet), we noticed that is came from the size of the payload.

is the POST http method can be used to send an sumbitJob on the task ? we only had GET requests (that are sized limited) using the geoprocessor.

feed back welcomed

cheers,
Patrice
0 Kudos
JillianStanford
Frequent Contributor
Patrice,
What we discovered is that we were missing the proxy page, which is required to send large requests - http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/ags_proxy.htm.

We were coming from a Silverlight background and didn't realize that it was necessary. Once we set it up according the instructions above the problem was solved.

Hope that helps!
Jill
0 Kudos
PatriceFREYDIERE
Deactivated User
Patrice,
What we discovered is that we were missing the proxy page, which is required to send large requests - http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/ags_proxy.htm.

We were coming from a Silverlight background and didn't realize that it was necessary. Once we set it up according the instructions above the problem was solved.

Hope that helps!
Jill


Hi jill, and thank's for your quick response

i suspected such this issue, this will help us,
i still wonder why the Geoprocessing call cannot be passed as POST for long requests (perhaps the HTTP Method GET as a "read" method, but POST methods are still ambiguious).

Thank's for your experience feed back,

Patrice
0 Kudos