Select to view content in your preferred language

geometryEngine.geodesicBuffer for polygon

1172
8
Jump to solution
09-04-2018 11:06 AM
LefterisKoumis
Frequent Contributor

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);
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Have you verified that both geometries are the same wkid in your code?

View solution in original post

0 Kudos
8 Replies
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

  You are on the right track using Difference method. So what is the wkid or the intersect_area and the buffer?

0 Kudos
LefterisKoumis
Frequent Contributor

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.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

That is always what a buffer has been in the JS API.

0 Kudos
LefterisKoumis
Frequent Contributor

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?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Have you verified that both geometries are the same wkid in your code?

0 Kudos
LefterisKoumis
Frequent Contributor

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.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Lefteris,

   OK, so can you do a console.og to check what the wkids are first?

0 Kudos
LefterisKoumis
Frequent Contributor

They are the same. 

I changed line #4 above and it works. Thank you.

var newbuffer = geometryEngine.difference(buffer, intersect_geom);
0 Kudos