Select to view content in your preferred language

union and then buffer not working

859
2
Jump to solution
11-30-2016 07:42 AM
by Anonymous User
Not applicable

Hi all,

I am trying to dissolve features using geometry serveice union then buffer the dissolve features 200' but I am getting errors. Any idea why?

Here is my code:

featureLayer.selectFeatures(selectQuery, FeatureLayer.SELECTION_NEW, function (targetGeometry) {
                          map.setExtent(graphicsUtils.graphicsExtent(featureLayer.getSelectedFeatures()), true);
                          targetGeometry = graphicsUtils.getGeometries(featureLayer.getSelectedFeatures());
                          console.log(targetGeometry);
                          geometryService.union(targetGeometry, function (geometry) {
                              geom = geometry;
                              featureLayer.clearSelection();
                              //Graphics to be shown on web map
                              var symbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([180, 50, 250]), 4);
                              graphic = new Graphic(geometry, symbol);
                              map.graphics.add(graphic);
                              //feature set to feed the geoprocessing service
                              var features = [];
                              FeaturesetGraphs = new FeatureSet();
                              FeaturesetGraphs.features = features;
                              features.push(graphic);
                              //Make a buffer from the features
                              //setup the buffer parameters
                              var params = new BufferParameters();
                              params.distances = [200];
                              params.outSpatialReference = map.spatialReference;
                              params.unit = geometryService.UNIT_FOOT;
                              params.geometries = [geometry];
                              geometryService.buffer(params, function (bufferedGeometries) {
                                      var symbol2 = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0, 0, 0]), 4), new Color([247, 242, 89, 0.6]));
                                      var graphic2 = new Graphic(bufferedGeometries, symbol2);
                                      map.graphics.add(graphic2);

                              });

                              //Area calculations for the project definition
                              var areasAndLengthParams = new AreasAndLengthsParameters();
                              areasAndLengthParams.areaUnit = GeometryService.UNIT_ACRES;
                              areasAndLengthParams.calculationType = "geodesic";
                              geometryService.simplify([geometry], function (simplifiedGeometries) {
                                  areasAndLengthParams.polygons = simplifiedGeometries;
                                  geometryService.areasAndLengths(areasAndLengthParams);
                              });
                          }, function (err) {
                              console.log(err);
                          });
                          
                      });
                  });
              }
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Alex,

  I would try simplifying the geometry before you buffer it (just like you are doing before you do the area calculations).

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Alex,

  I would try simplifying the geometry before you buffer it (just like you are doing before you do the area calculations).

by Anonymous User
Not applicable

That was it thanks Robert!

0 Kudos