AnsweredAssumed Answered

Edit Vertices/Draw: If polygon lines cross, deleted shape, no error

Question asked by sarahclark on Feb 9, 2016
Latest reply on Jan 17, 2017 by rscheitlin

Hello -


Someone recently had the issue that when editing a FeatureLayer in my web app it wouldn't save. We found that when drawing a polygon if the lines cross (for instance, drawing a narrow polygon and the sides accidentally cross/touch), the shape deleted itself. The same goes for editing vertices -- if the user accidentally pulled a vertex such that the polygon sides crossed, the shape deleted itself.


I followed this sample relatively closely but in the sample, there is no issue! I somehow broke it.


In ArcMap, looking at the source dataset, the features drawn with crossed lines were listed in the attribute table with the Shape.STArea() and Shape.STLength() attributes as '0'.


My issue is this: in my own code no error was thrown. The applyEdits function runs successfully and creates the objectid. I don't use the TemplatePicker dijit. However I do use the Draw toolbar and take that graphic to applyEdits - I can see the graphic in the console.log just fine.


Any thoughts on where to start debugging my work?


function finishDraw(event, layer) {
            console.log('finishDraw', event);      
            var newAttributes = templateFields(layer);
            var newGraphic = new Graphic(event.geometry, null, newAttributes);
            var finishDeferred = layer.applyEdits([newGraphic], null, null);
            return finishDeferred.promise;

function templateFields (layer) {
            var fieldObj = {};
            arrayUtils.forEach(layer.fields, function(atts) {
                if ('OBJECTID') == -1) {
                    if ('Shape') == -1) {
                        fieldObj[] = null;
            return fieldObj;