Select to view content in your preferred language

Buffer Geometry of a Dropdown Selection

1473
10
Jump to solution
03-01-2018 10:31 AM
ClintonLunn
Occasional Contributor

Hello all,

I am trying to buffer a polygon of a dropdown selection. I am hoping somebody can point me where I am going wrong.

var TRSSelect = dom.byId("selectTownshipPanel");

on(TRSSelect, "input", function(e) {
  var type =  e.target.value;

  var task = new QueryTask({
    url: panelurl + "2"
  });

  var params = new Query({
    where: "trs = '" + type + "'",
    returnGeometry: true
  });
  task.execute(params)
  .then(function(response) {
    console.log(response.features["0"].geometry);
    console.log(response.features[0].geometry);
    console.log(response.features[0].geometry + " TRS response FEATURES");
    console.log(response.features["0"].geometry + " TRS response FEATURES");

    buffer = geometryEngine.geodesicBuffer(response.features["0"].geometry, 100, "feet", false);
    
    console.log(typeof buffer);
    console.log("buffer completed");
    bufferLayer.add(new Graphic({
      geometry: buffer,
      symbol: polySym
    }));
    
  });
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

My output for this code is: 

It is able to retrieve the geometry, but will not execute the buffer (does not lot to console "buffer completed") and add to the graphic layer.

I have isolated this to the buffer because if I pass in the response.features[0].geometry, the resulting geometry can be added to my graphic layer illustrated here:

    //buffer = geometryEngine.GeodesicBuffer(response.features["0"].geometry, 100, "feet", false);
    
    console.log(typeof buffer);
    console.log("buffer completed");
    bufferLayer.add(new Graphic({
      geometry: response.features[0].geometry,
      symbol: polySym
    }));
    
  });
});‍‍‍‍‍‍‍‍‍‍‍

Graphic layer is displayed now when passing in just geometry of response features:

0 Kudos
1 Solution

Accepted Solutions
MelitaKennedy
Esri Notable Contributor

It's very old. My records show both 102113 (3785) / 102100 (3857) as being added at 9.3.0, but I think that's wrong and 102100 was added at 9.3.1. Anyway, the switch to 102100 / 3857 occurred a lot of releases ago. EPSG:3857 was added by EPSG in 2008.

Other software often can't use the Esri or EPSG definition of 102100 / 3857 because they both use a variant of the "Mercator" map projection. So a software that has the regular Mercator might use EPSG:3785 which uses a sphere-based GCS instead to force the usage of a major auxiliary sphere (radius = semimajor axis). 

The functions might be failing because the input/output GCS are actually different. There is a transformation, 15973, which converts between the two GCS.

View solution in original post

10 Replies
JohnGrayson
Esri Regular Contributor

...check the spelling of the geometryEngine method... geometryEngine.geodesicBuffer

ClintonLunn
Occasional Contributor

John,

While I do feel very silly for that little typo, that did not make it work. I will update the code in my question to reflect that correction. Thank you!

0 Kudos
KenBuja
MVP Esteemed Contributor

What is the spatial reference of the geometry you're attempting to buffer? Is it WGS-84 or Web Mercator? If not, you'll have to use the GeometryService buffer method.

ClintonLunn
Occasional Contributor

Ken, the spatial reference is listed as:

Spatial Reference: 102113 (3785)

This seems as though it is a deprecated form of Web Mercator?

0 Kudos
KenBuja
MVP Esteemed Contributor

Yes, according to this post from Melita Kennedy‌, Esri's guru on projections and spatial references. Although, according to the isWebMercator method, 102113 would return True.

0 Kudos
ClintonLunn
Occasional Contributor

Ken, 


Forgive my ignorance, but does this deprecated spatial reference now mean that the geometryEngine will not work in this case?

In which case, I'd either have to use the GeometryService or change my layer to conform to this spatial reference requirement, correct?

Thank you,

Clinton

0 Kudos
KenBuja
MVP Esteemed Contributor

I don't know, unfortunately.

Is the wkid 3785 correct? That comes up as something else: Popular Visualisation CRS / Mercator: EPSG Projection -- Spatial Reference 

0 Kudos
ClintonLunn
Occasional Contributor

Yes, that is correct. I was puzzled when I searched that wkid too. 

0 Kudos
MelitaKennedy
Esri Notable Contributor

It's very old. My records show both 102113 (3785) / 102100 (3857) as being added at 9.3.0, but I think that's wrong and 102100 was added at 9.3.1. Anyway, the switch to 102100 / 3857 occurred a lot of releases ago. EPSG:3857 was added by EPSG in 2008.

Other software often can't use the Esri or EPSG definition of 102100 / 3857 because they both use a variant of the "Mercator" map projection. So a software that has the regular Mercator might use EPSG:3785 which uses a sphere-based GCS instead to force the usage of a major auxiliary sphere (radius = semimajor axis). 

The functions might be failing because the input/output GCS are actually different. There is a transformation, 15973, which converts between the two GCS.