<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Creating a minimum bounding polygon around different geometry types in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/creating-a-minimum-bounding-polygon-around/m-p/199997#M18505</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a layer with several geometries of varying types (currently just points and polygons, but lines/polylines may come in the future). I need to create a minimum bounding polygon around these geometries, preferrably with some way to expand or buffer it so there is some padding around the geometries. I've tried using GeometryService.convexHull, passing in an example list of geometries containing one point and one circle polygon, but this always returns an error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Jul 2013 14:45:19 GMT</pubDate>
    <dc:creator>JeffHobson</dc:creator>
    <dc:date>2013-07-11T14:45:19Z</dc:date>
    <item>
      <title>Creating a minimum bounding polygon around different geometry types</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/creating-a-minimum-bounding-polygon-around/m-p/199997#M18505</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a layer with several geometries of varying types (currently just points and polygons, but lines/polylines may come in the future). I need to create a minimum bounding polygon around these geometries, preferrably with some way to expand or buffer it so there is some padding around the geometries. I've tried using GeometryService.convexHull, passing in an example list of geometries containing one point and one circle polygon, but this always returns an error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 14:45:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/creating-a-minimum-bounding-polygon-around/m-p/199997#M18505</guid>
      <dc:creator>JeffHobson</dc:creator>
      <dc:date>2013-07-11T14:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a minimum bounding polygon around different geometry types</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/creating-a-minimum-bounding-polygon-around/m-p/199998#M18506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Apparently it won't work with points &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;and&lt;/SPAN&gt;&lt;SPAN&gt; polygons. My solution right now is to just use the polygons, but if anyone else comes across this, I would recommend performing two convexHull operations, one with the points and one with the polygons, and then a third to combine the two results.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 18:24:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/creating-a-minimum-bounding-polygon-around/m-p/199998#M18506</guid>
      <dc:creator>JeffHobson</dc:creator>
      <dc:date>2013-07-11T18:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a minimum bounding polygon around different geometry types</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/creating-a-minimum-bounding-polygon-around/m-p/199999#M18507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below are a couple of functions that I use to get the geometry envelope. In my example if the geom is a point or multipoint with only one point in the array I utilize the buffer geometry task.&amp;nbsp; Note that you can simply use the zoomExtent as the geometry that you want to do whatever it is that you need. In my case I take the geometry.envelope and then expand it so that I can zoom to that feature. Also note that my example accepts an array of graphics. This array can have 1 or more graphics and I process them all the same. Finally, I have had minor issues with my buffer function since we changed spatial reference. Meaning that my map now uses webMercator but my data is in geographic.&amp;nbsp; At some point I will have to figure that out ,, but that is essentially why you see me setting so many different spatial ref and distance properties in the buffer function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp; zoomToGraphics: function (map, graphicsArray, expandFactor) { &amp;nbsp;&amp;nbsp;&amp;nbsp; var zoomExtent = esri.graphicsExtent(graphicsArray); &amp;nbsp;&amp;nbsp;&amp;nbsp; //If the extent height and width are 0, null is returned &amp;nbsp;&amp;nbsp;&amp;nbsp; if (!zoomExtent) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var geomArray = esri.getGeometries(graphicsArray); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var deferred = this.bufferGeometry(geomArray, [50], graphicsArray[0].geometry.spatialReference, map.spatialReference); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deferred.then(function (results) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zoomExtent = results[0].getExtent(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (expandFactor) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.setExtent(zoomExtent.expand(expandFactor), false); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.setExtent(zoomExtent, false); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, function (error) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("Error during buffer Geom: " + error.message); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }); &amp;nbsp;&amp;nbsp;&amp;nbsp; } else { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (expandFactor) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.setExtent(zoomExtent.expand(expandFactor), false); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.setExtent(zoomExtent, false); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp; },&amp;nbsp; &amp;nbsp; //require(["esri/tasks/GeometryService", ... ], function(GeometryService, ... ){ ... }); &amp;nbsp; // dojo require dojo.deferred &amp;nbsp; //TODO: need to set up the spatial reference correctly ... &amp;nbsp; bufferGeometry: function (inGeometryArray, distanceArray, inSpatialRef, outSpatialRef) { &amp;nbsp;&amp;nbsp;&amp;nbsp; var geomService = esri.config.defaults.geometryService; //new esri.tasks.GeometryService(geomServiceURL); &amp;nbsp;&amp;nbsp;&amp;nbsp; var bufferParams = new esri.tasks.BufferParameters(); &amp;nbsp;&amp;nbsp;&amp;nbsp; bufferParams.geometries = inGeometryArray; &amp;nbsp;&amp;nbsp;&amp;nbsp; bufferParams.bufferSpatialReference = inSpatialRef; &amp;nbsp;&amp;nbsp;&amp;nbsp; bufferParams.outSpatialReference = outSpatialRef; &amp;nbsp;&amp;nbsp;&amp;nbsp; bufferParams.distances = distanceArray; //units in feet &amp;nbsp;&amp;nbsp;&amp;nbsp; bufferParams.unit = esri.tasks.GeometryService.UNIT_METER;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; var deferred = geomService.buffer(bufferParams); &amp;nbsp;&amp;nbsp;&amp;nbsp; return deferred; &amp;nbsp; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 18:25:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/creating-a-minimum-bounding-polygon-around/m-p/199999#M18507</guid>
      <dc:creator>DianaBenedict</dc:creator>
      <dc:date>2013-07-11T18:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a minimum bounding polygon around different geometry types</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/creating-a-minimum-bounding-polygon-around/m-p/200000#M18508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you very much for the information! Right now I'm happy just having a convex hull to test with, but further down the road I will be needing a buffer, so I'll definitely be referencing your code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jul 2013 18:29:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/creating-a-minimum-bounding-polygon-around/m-p/200000#M18508</guid>
      <dc:creator>JeffHobson</dc:creator>
      <dc:date>2013-07-11T18:29:13Z</dc:date>
    </item>
  </channel>
</rss>

