<?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 Re: Construct Polygon from JSON in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284643#M6761</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the response.&amp;nbsp; I added a small bit of code to add the first vertex to the end of the array.&amp;nbsp; Unfortunately that didn't solve the issue.&amp;nbsp; I've attached a 7z file containing a text file with an example JSON polygon.&amp;nbsp; Any advice would be greatly appreciated.&amp;nbsp; Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for( index = 0; index &amp;lt; result.watershed.rings.length; index++ )
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var polyRingsNew:Array = result.watershed.rings[index];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for( index2 = 0; index2 &amp;lt; polyRingsNew.length; index2++ )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (index2 == 0 &amp;amp;&amp;amp; index == 0) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var firstP:MapPoint = new MapPoint(polyRingsNew[index2][0], polyRingsNew[index2][1], map.spatialReference);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var testP:MapPoint = new MapPoint(polyRingsNew[index2][0], polyRingsNew[index2][1], map.spatialReference);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ringArray.push(testP);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; ringArray.push(firstP);
&amp;nbsp;&amp;nbsp;&amp;nbsp; var arrayOfRings:Array = new Array;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayOfRings.push(ringArray);
&amp;nbsp;&amp;nbsp;&amp;nbsp; waterPoly = new Polygon(arrayOfRings, map.spatialReference);
&amp;nbsp;&amp;nbsp;&amp;nbsp; var newGraphic:Graphic = new Graphic(waterPoly, watSymbol, null);
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; graphicsLayer.add(newGraphic);&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 13:46:12 GMT</pubDate>
    <dc:creator>JesseAdams</dc:creator>
    <dc:date>2021-12-11T13:46:12Z</dc:date>
    <item>
      <title>Construct Polygon from JSON</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284641#M6759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to construct a polygon graphic from a set of coordinates that are returned from a web service as a JSON object.&amp;nbsp; It works very well if the polygon is small and doesn't contain holes.&amp;nbsp; If the polygon that is returned contains holes the polygon draws strange vertices that are incorrect.&amp;nbsp; See the attached image.&amp;nbsp; I've also included the code that constructs the polygon.&amp;nbsp; Any suggestions on how to "clean" a polygon before adding it to a graphics layer?&amp;nbsp; Thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;var result:Object = JSON.decode(event.result as String);&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; var simLineSym:SimpleLineSymbol = new SimpleLineSymbol("solid", 0x000000, 1, 1); &amp;nbsp;&amp;nbsp;&amp;nbsp; var watSymbol:SimpleFillSymbol = new SimpleFillSymbol("solid", 0x000000, 0.64, simLineSym);&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //trace("Watershed Polygon Rings = " + result.watershed.rings.length); &amp;nbsp;&amp;nbsp;&amp;nbsp; var index:int; &amp;nbsp;&amp;nbsp;&amp;nbsp; var index2:int; &amp;nbsp;&amp;nbsp;&amp;nbsp; var ringArray:Array = new Array; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for( index = 0; index &amp;lt; result.watershed.rings.length; index++ ) &amp;nbsp;&amp;nbsp;&amp;nbsp; { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var polyRingsNew:Array = result.watershed.rings[index]; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for( index2 = 0; index2 &amp;lt; polyRingsNew.length; index2++ ) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var testP:MapPoint = new MapPoint(polyRingsNew[index2][0], polyRingsNew[index2][1], map.spatialReference); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ringArray.push(testP); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; var arrayOfRings:Array = new Array; &amp;nbsp;&amp;nbsp;&amp;nbsp; arrayOfRings.push(ringArray); &amp;nbsp;&amp;nbsp;&amp;nbsp; waterPoly = new Polygon(arrayOfRings, map.spatialReference); &amp;nbsp;&amp;nbsp;&amp;nbsp; var newGraphic:Graphic = new Graphic(waterPoly, watSymbol, null); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; graphicsLayer.add(newGraphic);&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jun 2012 02:06:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284641#M6759</guid>
      <dc:creator>JesseAdams</dc:creator>
      <dc:date>2012-06-11T02:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: Construct Polygon from JSON</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284642#M6760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jesse,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; I don't know if your JSON has the first point (POB) in the array again as the last point. But if not you need to do this in your code (add the first vertex in the ring again at the end of the ring). If this does not solve the issue than it would help if you provide a text file with an example JSON response.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jun 2012 10:59:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284642#M6760</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2012-06-11T10:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: Construct Polygon from JSON</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284643#M6761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the response.&amp;nbsp; I added a small bit of code to add the first vertex to the end of the array.&amp;nbsp; Unfortunately that didn't solve the issue.&amp;nbsp; I've attached a 7z file containing a text file with an example JSON polygon.&amp;nbsp; Any advice would be greatly appreciated.&amp;nbsp; Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for( index = 0; index &amp;lt; result.watershed.rings.length; index++ )
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var polyRingsNew:Array = result.watershed.rings[index];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for( index2 = 0; index2 &amp;lt; polyRingsNew.length; index2++ )
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (index2 == 0 &amp;amp;&amp;amp; index == 0) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var firstP:MapPoint = new MapPoint(polyRingsNew[index2][0], polyRingsNew[index2][1], map.spatialReference);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var testP:MapPoint = new MapPoint(polyRingsNew[index2][0], polyRingsNew[index2][1], map.spatialReference);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ringArray.push(testP);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; ringArray.push(firstP);
&amp;nbsp;&amp;nbsp;&amp;nbsp; var arrayOfRings:Array = new Array;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayOfRings.push(ringArray);
&amp;nbsp;&amp;nbsp;&amp;nbsp; waterPoly = new Polygon(arrayOfRings, map.spatialReference);
&amp;nbsp;&amp;nbsp;&amp;nbsp; var newGraphic:Graphic = new Graphic(waterPoly, watSymbol, null);
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; graphicsLayer.add(newGraphic);&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:46:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284643#M6761</guid>
      <dc:creator>JesseAdams</dc:creator>
      <dc:date>2021-12-11T13:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: Construct Polygon from JSON</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284644#M6762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jesse,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; First thing is can you check and see what is going on with the first 3 rings in the JSON. Change your code to draw one specific ring at a time and you will see what I mean.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jun 2012 16:44:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284644#M6762</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2012-06-11T16:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: Construct Polygon from JSON</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284645#M6763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;After inspecting each individual ring I see what you mean.&amp;nbsp; The web service returns each hole in the polygon as a separate array of vertices.&amp;nbsp; Now I just need to figure out how to construct a polygon correctly using the format of the returned JSON.&amp;nbsp; Any ideas how to construct this correctly with holes?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2012 02:19:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284645#M6763</guid>
      <dc:creator>JesseAdams</dc:creator>
      <dc:date>2012-06-12T02:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: Construct Polygon from JSON</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284646#M6764</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jesse,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; I believe it is more than that if you look at 0, 1, 2, 3 together they are very strange (like one pixel squares and a line connecting them) and the fact that 4 is the main outer ring is going to be difficult to deal with. Normally you would be the main outer ring then any sub other ring (islands) and then all inner rings doughnuts.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2012 11:06:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284646#M6764</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2012-06-12T11:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Construct Polygon from JSON</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284647#M6765</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jesse,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; OK, Scratch what I said earlier... Here is an app that use what you provided me and builds a watershed polygon with inner rings just fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Don't forget to &lt;/SPAN&gt;&lt;STRONG&gt;click the Mark as answer check&lt;/STRONG&gt;&lt;SPAN&gt; on this post and to &lt;/SPAN&gt;&lt;STRONG&gt;click the top arrow (promote)&lt;/STRONG&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;Follow the steps&lt;/STRONG&gt;&lt;SPAN&gt; as shown in the below graphic:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://gis.calhouncounty.org/FlexViewer2.5/Answer.jpg"&gt;&lt;IMG src="http://gis.calhouncounty.org/FlexViewer2.5/Answer.jpg" /&gt;&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2012 19:45:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284647#M6765</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2012-06-12T19:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: Construct Polygon from JSON</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284648#M6766</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Robert,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That was it!&amp;nbsp; Should have tried out "waterPoly.addRing(pntsArray);" earlier.&amp;nbsp; Thanks a ton I really appreciate it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Jun 2012 01:21:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/construct-polygon-from-json/m-p/284648#M6766</guid>
      <dc:creator>JesseAdams</dc:creator>
      <dc:date>2012-06-13T01:21:28Z</dc:date>
    </item>
  </channel>
</rss>

