wmbeers / cmv-app

CMV - The Configurable Map Viewer - A community supported open source mapping framework built with the Esri JavaScript API and the Dojo Toolkit
https://demo.cmv.io/
MIT License
1 stars 2 forks source link

AOI Analysis Area Creation Sometimes Fails #71

Closed wmbeers closed 2 years ago

wmbeers commented 3 years ago

How often can you reproduce it: Sometimes

Description:

Under certain circumstances the behind-the-scenes creation of analysis areas (features in S_AOI representing the geographic union of buffers of features created by the user) fails, resulting in errors running analysis and reports. It often can recover if you close the AOI, re-open it, and try again, but not always.

I do not have clear steps to reproduce, but it can sometimes be triggered by using the undo/redo functionality in conjunction with deleting a feature, or by extracting a zero-length line from the RCI basemap (an issue to be addressed separately).

wmbeers commented 3 years ago

See also #72, a fairly reliable way to trigger this problem.

wmbeers commented 3 years ago

Errors captured when investigating this with the user:

description: "Unable to get property 'spatialReference' of undefined or null reference", message: "Unable to get property 'spatialReference' of undefined or null reference", name: "TypeError", number: -2146823281, stack: "TypeError: Unable to get property 'spatialReference' of undefined or null reference at simplify (https://js.arcgis.com/3.29/:2697:351) at Anonymous function (https://www.fla-etat.org/est/secure/map/js/gis/dijit/AoiEditor.js:6:19670) at _buildAnalysisAreaBufferEdits (https://www.fla-etat.org/est/secure/map/js/gis/dijit/AoiEditor.js:6:19549) at saveAnalysisAreaBuffers (https://www.fla-etat.org/est/secure/map/js/gis/dijit/AoiEditor.js:6:7266) at Anonymous function (https://www.fla-etat.org/est/secure/map/js/gis/dijit/AoiEditor.js:6:6203) at l (https://js.arcgis.com/3.29/:108:242) at k (https://js.arcgis.com/3.29/:108:174) at resolve (https://js.arcgis.com/3.29/:110:267) at Anonymous function (https://www.fla-etat.org/est/secure/map/js/gis/dijit/AoiEditor.js:6:7192)" }

TypeError: Cannot read property 'spatialReference' of undefined at Object.simplify ((index):2697) at AoiEditor.js:formatted:793 at Array.forEach () at Object._buildAnalysisAreaBufferEdits (AoiEditor.js:formatted:787) at Object.saveAnalysisAreaBuffers (AoiEditor.js:formatted:287) at AoiEditor.js:formatted:229 at l ((index):108) at k ((index):108) at e.resolve ((index):110) at callback (AoiEditor.js:formatted:274) "TypeError: Cannot read property 'spatialReference' of undefined at Object.simplify (https://js.arcgis.com/3.29/:2697:362) at https://www.fla-etat.org/est/secure/map/js/gis/dijit/AoiEditor.js:6:19706 at Array.forEach () at Object._buildAnalysisAreaBufferEdits (https://www.fla-etat.org/est/secure/map/js/gis/dijit/AoiEditor.js:6:19558) at Object.saveAnalysisAreaBuffers (https://www.fla-etat.org/est/secure/map/js/gis/dijit/AoiEditor.js:6:7278) at https://www.fla-etat.org/est/secure/map/js/gis/dijit/AoiEditor.js:6:6205 at l (https://js.arcgis.com/3.29/:108:248) at k (https://js.arcgis.com/3.29/:108:174) at e.resolve (https://js.arcgis.com/3.29/:110:267) at callback (https://www.fla-etat.org/est/secure/map/js/gis/dijit/AoiEditor.js:6:7111)

rejected at a (https://js.arcgis.com/3.29/:109:154)
at l (https://js.arcgis.com/3.29/:108:407)
at k (https://js.arcgis.com/3.29/:108:174)
at e.resolve (https://js.arcgis.com/3.29/:110:267)
at callback (https://www.fla-etat.org/est/secure/map/js/gis/dijit/AoiEditor.js:6:7111)
at https://www.fla-etat.org/est/dwr3/engine.js:1037:35
at Object.logHandlerEx (https://www.fla-etat.org/est/dwr3/engine.js:2553:9)
at Object.handleCallback (https://www.fla-etat.org/est/dwr3/engine.js:1033:29)
at eval (eval at dwr.engine._executeScript (https://www.fla-etat.org/est/dwr3/engine.js:720:6), <anonymous>:10:19)
at eval (eval at dwr.engine._executeScript (https://www.fla-etat.org/est/dwr3/engine.js:720:6), <anonymous>:11:3)
----------------------------------------

Error at e.then.b.then (https://js.arcgis.com/3.29/:111:77) at Object.saveAnalysisAreasAndShowAnalysisOptions (https://www.fla-etat.org/est/secure/map/js/gis/dijit/AoiEditor.js:6:6187) at HTMLSpanElement. (https://www.fla-etat.org/est/secure/map/js/knockout-latest.js:6:42326) at HTMLSpanElement.dispatch (https://code.jquery.com/jquery-3.3.1.min.js:2:41772) at HTMLSpanElement.y.handle (https://code.jquery.com/jquery-3.3.1.min.js:2:39791)" m @ (index):115 (anonymous) @ (index):115 filter @ (index):72 l @ (index):115

relevant minified/expanded (but enough to narrow down in real source) code: _buildAnalysisAreaBufferEdits: function() { var a = this; this._buildAnalysisAreasFromFeatures(), this.loadingOverlay.show("Constructing analysis area buffers..."); var e = this.layers.analysisAreaBuffer.graphics , t = this.analysisAreas() , n = { adds: [], updates: [], deletes: e.filter(function(e) { return !this.getAnalysisAreaModel(e.attributes.FK_PROJECT_ALT) }, this) } , s = new b , o = []; return t.forEach(function(i) { var r = new b , e = i.features().map(function(e) { return (e.buffer || e.graphic).geometry }); o.push(r), esriConfig.defaults.geometryService.simplify(e).then(function(e) {

Stepping through t.forEach above, altNumber=1, features [{...geometry.paths[42]... seems ok But it still wants to try to work through the empty analysis area, even after I delete the feature and reload, and remnant record in t_project_alt_aoi is a problem somehow reload whole viewer

wmbeers commented 3 years ago

Perhaps related, I note a few new issues not reported by users:

wmbeers commented 2 years ago

Further testing with Mike today, we observed behavior which seems to indicate that clicking Next too quickly after finishing the creation of a line (not extracting) gets it into the state where the "Unable to get property 'spatialReference' of undefined or null reference" exception occurs. First attempt to fix will be disabling the Next button while the user is interactively working on a feature (still in drawing mode, or a recent drag of a feature vertex), and re-enabling after on-the-fly saving is complete.