Select to view content in your preferred language

Buffer a polyline

869
2
05-12-2010 02:57 AM
SylvainKerdreux
Emerging Contributor
Hello,

I try to create a buffer around my polyline but I got some very strange results.
Here, the code I use to create my Buffer :

var geometrieService:GeometryService = new GeometryService(geomService);
var bufferParameter:BufferParameters = new BufferParameters();
bufferParameter.bufferSpatialReference = new SpatialReference(4326);
bufferParameter.distances = [10];
bufferParameter.outSpatialReference = new SpatialReference(4326);
bufferParameter.unionResults = false;
bufferParameter.unit = BufferParameters.UNIT_METER;
var geometrie:Graphic = new Graphic(geom);
bufferParameter.features = [geometrie];     
geometrieService.buffer(bufferParameter,new AsyncResponder(bufferOK,bufferNOK));


I use this geometry service :
http://sampleserver2.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer

and here what is sent to geometry service :
bufferSR: 4326
distances: 10
f: json
geometries: {"geometries":[{"paths":[[[5.736132786935889,45.1578318258797],[5.736519877565893,45.157228419897635]]]}],"geometryType":"esriGeometryPolyline"}
inSR: 4326
outSR: 4326
unionResults: false
unit: 9001

but I got back points outside my search Area :
[-2.19740061597649,51.2454461159669],[-1.78226528785385,51.7512899768803],[-1.33493502492961,52.2288996377452],[-0.857325364064774,52.6762299006694],[-0.351481503151357,53.091365228792],[0.180430456739892,53.4725279489051]


I used the same geometryService to get a buffer of a point and I have no problem.

So, any idea ?

Regards,
Sylvain.
Tags (2)
0 Kudos
2 Replies
MehulChoksey
Esri Contributor
Excerpt from the AGS REST API (consumed by AGS API for Flex)help doc:

"Note that when the bufferSR is GCS:

    * Points and Multipoints: if unit is linear such as feet or meters, geodesic buffering is performed.
    * Polylines and Polygons: unit must be angular such as decimal degrees for buffering to be performed."

http://resources.esri.com/help/9.3/arcgisserver/apis/rest/buffer.html
0 Kudos
SylvainKerdreux
Emerging Contributor
Hello,

Thank you for your answer ! 🙂
However I have another question about polyline buffer.

I changed the distance (0.00025° instead of 10°) but I got an error :

{"error":{"code":400,"message":"","details":["'distances' parameter is invalid"]}}


and my parameters are :

bufferSR : 4326
distances : 0.0000250
f : json
geometries : {"geometries":[{"paths":[[[5.736210872771894,45.1577858979162],[5.736419229858297,45.15728200275197]]]}],"geometryType":"esriGeometryPolyline"}
inSR : 4326
unionResults : false
unit : 9001


using this code :

var geometrieService:GeometryService = new GeometryService(geomService);
var bufferParameter:BufferParameters = new BufferParameters();
bufferParameter.bufferSpatialReference = new SpatialReference(4326);
var distance:String = "0.0000250";
bufferParameter.distances = [distance];
bufferParameter.unit = BufferParameters.UNIT_METER;
bufferParameter.features = [new Graphic(geom)];
geometrieService.buffer(bufferParameter,new AsyncResponder(bufferOK,bufferNOK));


I tryed :
bufferParameter.distances = [0.00025];
but I got the same error.
I also tryed :
var distance:String = "0,0000250";
bufferParameter.distances = [distance];

and
bufferParameter.distances = [0,00025];

but it created a buffer of 0° and another one of 250°

So how to use float number with buffer tool ?
0 Kudos