Select to view content in your preferred language

Buffer multiple drawings - error when drawing are of different types

3221
6
Jump to solution
07-26-2013 10:14 AM
BhavdeepSachdev
Deactivated User
I'm trying to buffer multiple drawings. It works great when the drawing types are the same but errors out with the drawing types are different.
e.g.
If I draw 4 lines/polylines on a map and hit buffer, all 4 are buffered.
If I draw 3 polygons and buffer, all 3 are buffered.

But when I draw one line and one polygon, I get an error.

I tracked the network response and I got this:
"error":
"code":400,"
message":" Unable to complete Buffer operation.",
"details":["The specified geometry is not in the correct format."]}

Code is here:
http://jsfiddle.net/x7WDQ/4/

I modified the ESRI sample so you can draw the lines/polygons initially and then click on a button to draw all buffers together.

The following steps will work:
Click on "Clear Graphics" button
Click on the "Line" button.
Draw 3 lines.
Click on "Draw Buffer" button.
This will draw 3 buffers around the 3 lines.

The following steps will work:
Click on "Clear Graphics" button
Click on the "polygon" button.
Draw 1 polygon.
Click on the "freehand polygon" button.
Draw 1 polygon.
Click on "Draw Buffer" button.
This will draw 2 buffers around the 2 different types of polygons.

Produce the Error:
Click on "Clear Graphics" button
Click on the "Line" button.
Draw 1 line.
Click on the "polygon" button.
Draw 1 polygon.

This will error out on a couple of seconds.

I saw the "gsvc.simplify" statement in the sample but it looks like I don't really need it for the polygons.
0 Kudos
1 Solution

Accepted Solutions
BenFousek
Deactivated User
GeometryServer-->Buffer only accepts one geometry type at a time. ArcMap is sorting the geometry by type, buffering and returning the buffers with the "wizard" which someone wrote to take advantage of multiple functionalities within ArcMap. To do the same in jsapi you'll need to develop the functionality yourself. Write a series of functions that:

1) check number of geometry types

IF 1 GEOMETRY TYPE:
2) execute simple buffer task

3) add results to map

ELSE IF 2 OR MORE GEOMETRY TYPES:
2) sort the geometry by type

3) create a deferred list of buffer tasks; one deferred for each geometry type being buffered

4) add the collective results to the map when all the tasks are complete

View solution in original post

0 Kudos
6 Replies
JohnGravois
Deactivated User
based on my experience with buffering in ArcGIS Desktop, i am under the impression that the entire collection of geometries you pass to the buffer operation of the geometry service must share the same geometry type.

this means that you'll have to submit your polylines in one request and your polygons in another.
0 Kudos
BhavdeepSachdev
Deactivated User
Thanks for the reply.
Just tried buffering different geometry types in ArcGIS Desktop 10.1.
It works fine. So it is possible in Desktop.
0 Kudos
JohnGravois
Deactivated User
i was referring to the buffer geoprocessing tool in ArcMap (which only accepts one layer with one geometry type at a time). 

i'm not sure where/how you're buffering multiple geometry types.
0 Kudos
BhavdeepSachdev
Deactivated User
In ArcMap, I can make drawings of 3 different geometry types and then I can run a Buffer wizard to create buffers around it.
I'm trying to replicate this using ArcGIS JavaScript API.

Screen captures of what I did on ArcMap are attached.

[ATTACH=CONFIG]26331[/ATTACH]

[ATTACH=CONFIG]26332[/ATTACH]
0 Kudos
BenFousek
Deactivated User
GeometryServer-->Buffer only accepts one geometry type at a time. ArcMap is sorting the geometry by type, buffering and returning the buffers with the "wizard" which someone wrote to take advantage of multiple functionalities within ArcMap. To do the same in jsapi you'll need to develop the functionality yourself. Write a series of functions that:

1) check number of geometry types

IF 1 GEOMETRY TYPE:
2) execute simple buffer task

3) add results to map

ELSE IF 2 OR MORE GEOMETRY TYPES:
2) sort the geometry by type

3) create a deferred list of buffer tasks; one deferred for each geometry type being buffered

4) add the collective results to the map when all the tasks are complete
0 Kudos
BhavdeepSachdev
Deactivated User
Thanks. Maybe I should add this as a suggestion for ESRI to include in their APIs.
0 Kudos