<?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: Bug: Sketch widget auto-splits user's drawn polygon, sometimes. in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-sketch-widget-auto-splits-user-s-drawn-polygon/m-p/157951#M14742</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let us investigate the issue. I will update you once we identify the issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for bringing up to your attention.&lt;/P&gt;&lt;P&gt;Undral&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Feb 2019 18:38:51 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2019-02-08T18:38:51Z</dc:date>
    <item>
      <title>Bug: Sketch widget auto-splits user's drawn polygon, sometimes.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-sketch-widget-auto-splits-user-s-drawn-polygon/m-p/157950#M14741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The attached 2.5m video explains better than my words below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apart from nice, non-intersecting polygons, the user is able to create two types of self-intersecting polygon: a polygon with a hole in it, and a 'twisted' complex polygon.&lt;/P&gt;&lt;P&gt;My problem is primarily with the twisted/complex polygons.&lt;/P&gt;&lt;P&gt;In the video I create a 4 point polygon that intersects itself.&lt;/P&gt;&lt;P&gt;(My code sets the symbol of the users drawn polygon as red if the polygons 'isSelfIntersecting' is true.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sometimes the creation will result in a correctly identified 'selfintersecting' polygon, sometimes it shows that the polygon is in fact non-intersecting - but at this point it has &lt;STRONG&gt;broken the polygon into two polygons&lt;/STRONG&gt;!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the Sketch widget has decided it is a self-intersecting polygon, you can move it as a whole, or edit it's points.&amp;nbsp; During this movement or editing,&amp;nbsp;during the drag operations you can see it changes it's mind as to whether it's self intersecting or not.&amp;nbsp; If you complete the move or edit in a state&amp;nbsp;where it has decided it is not self-intersecting, it will still split the polygon into multiple polygons.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as a user-story is concerned, "the user should be told the polygon fails some validation,&amp;nbsp;and they&amp;nbsp;should then have the opportunity to fix it."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NB: If the user &lt;EM&gt;creates&lt;/EM&gt; a&amp;nbsp;regular polygon, then &lt;EM&gt;edits&lt;/EM&gt; it, there is no problem in them making it self-intersecting, moving it, then fixing the self-intersection.&amp;nbsp; The problems only seem to trigger if initially created&amp;nbsp;with&amp;nbsp;self-intersections.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Feb 2019 12:51:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-sketch-widget-auto-splits-user-s-drawn-polygon/m-p/157950#M14741</guid>
      <dc:creator>NathanSummers1</dc:creator>
      <dc:date>2019-02-07T12:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: Sketch widget auto-splits user's drawn polygon, sometimes.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-sketch-widget-auto-splits-user-s-drawn-polygon/m-p/157951#M14742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let us investigate the issue. I will update you once we identify the issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for bringing up to your attention.&lt;/P&gt;&lt;P&gt;Undral&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2019 18:38:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-sketch-widget-auto-splits-user-s-drawn-polygon/m-p/157951#M14742</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2019-02-08T18:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: Sketch widget auto-splits user's drawn polygon, sometimes.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-sketch-widget-auto-splits-user-s-drawn-polygon/m-p/157952#M14743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually could you provide your snippet where you are setting the symbol when the polygon intersects itself? Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2019 18:43:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-sketch-widget-auto-splits-user-s-drawn-polygon/m-p/157952#M14743</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2019-02-08T18:43:48Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: Sketch widget auto-splits user's drawn polygon, sometimes.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-sketch-widget-auto-splits-user-s-drawn-polygon/m-p/157953#M14744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Undral,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this collection of method&amp;nbsp;paint a good enough picture - you can also see how I have tried&amp;nbsp;to&amp;nbsp;stop the user creating more than one polygon (there may be bugs in there!).&amp;nbsp; Note I have referred to 'self-intersecting' as 'complex'...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;  

 public initSketchDrawingTools( sketch: esri.Sketch ): void {
 this.sketchDrawingTools = sketch;

 this.sketchDrawingTools.on('create', (e) =&amp;gt; this.handleSketchCreate( e ) );
 this.sketchDrawingTools.on('update', (e) =&amp;gt; this.handleSketchUpdate( e ) );

 // Warning: This was undocumented for ESRI 4.10's API, but was found with some JS hacking
 // https://community.esri.com/message/829602-sketch-widget-delete-event-410
 // https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch.html
 this.sketchDrawingTools.on('reset', (e) =&amp;gt; this.handleSketchReset( e ) );

 this.initialiseListeners();
 }

 
 public handleSketchCreate( e:any ): void {
 this.identifyComplexPolygons( [e.graphic] );
 if( e.state == 'start' ) {
 this.cancelCreatingMultiplePolygons( e.state );
 } else if ( e.state === 'complete' ) {
 this.cancelCreatingMultiplePolygons( e.state);
 this.handleUpdatesFromUser( [e.graphic] );
 }
 }


 public handleSketchUpdate( e:any ): void {
 this.identifyComplexPolygons( e.graphics );
 if ( e.state === 'complete' ) {
 this.handleUpdatesFromUser();
 }
 }


 public handleSketchReset( e:any ): void {
 this.handleUpdatesFromUser();
 }


 /**
 * There will be a more polite-to-the-user way of stopping multiple polygons, but this works adequately for now
 * The complication of 'start'|'complete' is simply becuase even creating the first polygon seemed to be able to create multiple (esrt 4.10 bug?)
 */
 private cancelCreatingMultiplePolygons( state:'start'|'complete'): void {
 let maxExistingGraphics = 0;
 if( state == 'complete' ) maxExistingGraphics = 1;

 if( this.graphicsLayer.graphics.length &amp;gt; maxExistingGraphics ) {
 this.sketchDrawingTools.cancel(); // intended to cancel a current Create operation
 // It seems creating a polygon can SOMETIMES create multiple polygons (simple complexities seem to do this)
 // So we also need to REMOVE these extra polygons. The user will have to learn the hard way (until the back-end supports multiple areas)
 // This is a bug in the esri 4.10 library, hopefully it will be fixed.
 this.graphicsLayer.removeMany( this.graphicsLayer.graphics.slice( 1 ).toArray() );
 let geometry = this.graphicsLayer.graphics.getItemAt(0).geometry;
 if( geometry.type == 'polygon' ) {
 let polygon = geometry as esri.Polygon;
 polygon.rings = [polygon.rings[0]]; // remove any posibility of a single polygon having multiple rings.
 }
 
 // Since the user has been blocked creating a polygon, maybe they didnt know there was one already in use.
 // Slip the map over to the existing polygon - hopefully this is enough to help them.
 if( state == 'start' ) this.mapView.goTo( this.graphicsLayer.graphics.getItemAt( 0 ), {duration:1200,easing:'ease-in-out'} );
 }
 }

 private identifyComplexPolygons( graphics:esri.Graphic[] ): void {
 // Show the user that the polygon is not usable
 graphics.forEach( graphic=&amp;gt; {
 const polygon = (graphic.geometry as esri.Polygon);
 let symbol = polygon.isSelfIntersecting? this.badGeometrySymbol : this.geometrySymbol;
 if( graphic.symbol != symbol ) graphic.symbol = symbol;
 })
 }


&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:07:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-sketch-widget-auto-splits-user-s-drawn-polygon/m-p/157953#M14744</guid>
      <dc:creator>NathanSummers1</dc:creator>
      <dc:date>2021-12-12T16:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: Sketch widget auto-splits user's drawn polygon, sometimes.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-sketch-widget-auto-splits-user-s-drawn-polygon/m-p/157954#M14745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/51882"&gt;Undral Batsukh&lt;/A&gt;‌, any conclusions yet?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2019 08:31:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-sketch-widget-auto-splits-user-s-drawn-polygon/m-p/157954#M14745</guid>
      <dc:creator>NathanSummers1</dc:creator>
      <dc:date>2019-02-19T08:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: Sketch widget auto-splits user's drawn polygon, sometimes.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-sketch-widget-auto-splits-user-s-drawn-polygon/m-p/157955#M14746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have this exact same issue when drawing self-intersecting polygons using the sketch widget. Polygon.isSelfIntersecting values can end up being false randomly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/51882"&gt;Undral Batsukh&lt;/A&gt;‌ any updates?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2020 20:53:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/bug-sketch-widget-auto-splits-user-s-drawn-polygon/m-p/157955#M14746</guid>
      <dc:creator>ShaneBuscher1</dc:creator>
      <dc:date>2020-02-28T20:53:46Z</dc:date>
    </item>
  </channel>
</rss>

