I used the gE to buffer a polygon but it seems that it ovelaps the whole polygon instead of only the buffer area. Measurement of the buffer area verifies that the area of the polygon itself is included in the buffer area calculation. How the buffer graphic can include only the buffer outside the polygon? I also tried the geometryEngine.difference to substract the polygon from the buffer polygon but I get spatialreference errors. Ideas?
var polySym = new SimpleFillSymbol(SimpleFillSymbol.STYLE_DIAGONAL_CROSS,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,
new Color([255,0,0]), 2),new Color([255,255,0,0.25]));
var buffer = geometryEngine.geodesicBuffer(intersect_geom, thebufferdistance, "miles");
// added to see if difference could result to the buffer area
// var newbuffer = geometryEngine.difference(buffer.geometry,intersect_area)
var buffergraphic = new esri.Graphic(buffer, polySym);
bufferfeatures.push(buffergraphic)
all(bufferfeatures).then(function (results) {
for(j=0;j<results.length;j++){
console.log(results[j])
bufferGraphicsLayer.add(results[j]);
}
})
------
------
this.map.addLayer(bufferGraphicsLayer);
Solved! Go to Solution.
Have you verified that both geometries are the same wkid in your code?
Lefteris,
You are on the right track using Difference method. So what is the wkid or the intersect_area and the buffer?
Robert, the intersect_area if the result of another gE process and it uses the map spatialreference.
intersect_geom= geometryEngine.intersects(firstgraphics[j], secondgraphics[i], this.map.spatialReference)
The buffer should be based on the same SR since it is created from the intersect_area
var buffer = geometryEngine.geodesicBuffer(intersect_geom, thebufferdistance, "miles")
What it puzzles me is why the buffer area includes the polygon area as well? That is not what a buffer is.
That is always what a buffer has been in the JS API.
ok. thanks. I didn't know that buffer in Arcmap (ArcObjects) and JS API are not the same.
Do you know do i get the SR error?
Have you verified that both geometries are the same wkid in your code?
Yes, you are correct. I made the assumption that the SR is already set. So, I include the code below, to ensure that the SR is the same for both geom.
var buffer = geometryEngine.geodesicBuffer(intersect_geom, thebufferdistance, "miles");
buffer.setSpatialReference(this.map.spatialReference);
intersect_geom.setSpatialReference(this.map.spatialReference);
var newbuffer = geometryEngine.difference(buffer.geometry, intersect_geom);
Now I get the error:
"Cannot read property 'spatialReference' of undefined"
So, the buffer is not yet created before the SR is assigned. It seems that I have to use a promise.
Lefteris,
OK, so can you do a console.og to check what the wkids are first?
They are the same.
I changed line #4 above and it works. Thank you.
var newbuffer = geometryEngine.difference(buffer, intersect_geom);