Select to view content in your preferred language

Passing set of geometries to a single Querytask object

917
4
04-06-2011 12:46 PM
nidhiarora
Deactivated User
I have a set of geometries and need to overlay them on a point layer to determine points falling under the set of geometries.
I use the Union function of  Geometry service to combine the geometries and pass the unioned geometry to the Querytask object of point layer.
The union works fine for small subset of geometries , but when large set of geometries are passed to Geometry service , the  process takes a lot of time , often resulting in scripting error message ??????.Script is causing IE to slow down.??? .

Is there any alternative of passing a set of geometries (Array or List ) to a single  Querytask object?  I tried passing the extent of set of geometries to querytask , but extent picks up lot of additional points.

Regards,
Nidhi Arora.
0 Kudos
4 Replies
derekswingley1
Deactivated User
Can you post some of your code? If you're using GeometryService.union(), the geometry operation should be happening on the server, not on the client so you shouldn't be getting a warning about slow javascript.
0 Kudos
HemingZhu
Frequent Contributor
I have a set of geometries and need to overlay them on a point layer to determine points falling under the set of geometries.
I use the Union function of  Geometry service to combine the geometries and pass the unioned geometry to the Querytask object of point layer.
The union works fine for small subset of geometries , but when large set of geometries are passed to Geometry service , the  process takes a lot of time , often resulting in scripting error message �?��?�.Script is causing IE to slow down.�?� .

Is there any alternative of passing a set of geometries (Array or List ) to a single  Querytask object?  I tried passing the extent of set of geometries to querytask , but extent picks up lot of additional points.

Regards,
Nidhi Arora.


For a large set of geometries, Union is not an option. I had similar exprience.
What i did is create a javascript function and do it on client... Here is my functin for your reference:
function mergeGeometries(features) {
    /* STR search might result
    * multi polygons
    * merge them into a single one
    */
    var polygon = features[0].geometry;
    for (i = 1; i < features.length; i++) {
        var poly = features.geometry;
        for (j = 0; j < poly.rings.length; j++) {
            polygon.addRing(poly.rings);
        }
    }
    return polygon;
}
hope it will help.
0 Kudos
MarkSmith
Occasional Contributor
Hi,

I've hit a snag with the union JavaScript code above.  The code breaks with the following cases:

If I have a polygon with a hole in it, but that hole is occupied by 2 more polygons that exactly fit the space, each taking up about half the hole space, together they fill the hole.  Put another way imagine a polygon with a square hole in it, and that hole is filled by 2 rectangular polygons. i.e. trying to union 3 polygons to create one seamless/holeless shape.

If I have a polygon with 2 holes in it, and each hole is filled with a perfectly fitting polygon. i.e. trying to union 3 polygons to create one seamless/holeless shape.

Has anyone come up with some JS code to handle this please?

Thanks.
0 Kudos
HemingZhu
Frequent Contributor
Hi,

I've hit a snag with the union JavaScript code above.  The code breaks with the following cases:

If I have a polygon with a hole in it, but that hole is occupied by 2 more polygons that exactly fit the space, each taking up about half the hole space, together they fill the hole.  Put another way imagine a polygon with a square hole in it, and that hole is filled by 2 rectangular polygons. i.e. trying to union 3 polygons to create one seamless/holeless shape.

If I have a polygon with 2 holes in it, and each hole is filled with a perfectly fitting polygon. i.e. trying to union 3 polygons to create one seamless/holeless shape.

Has anyone come up with some JS code to handle this please?

Thanks.


Mark, When this this thread was posted, the GeometryService class did not have function to deal with your case. Now, you might be able to use GeometryService.union(geometries, callback?, errback?) for your case.
0 Kudos