AnsweredAssumed Answered

validate polygon within another polygon

Question asked by jamesfreddyc Champion on Oct 12, 2020
Latest reply on Oct 14, 2020 by jamesfreddyc

I have been using this function to validate a polygon in the graphics layer by applying a negative buffer and then using geometryEngine.within to test if that buffer falls inside the selected polygon of another layer.



validateScheduleBoundary: function () {
            this.getScratchGeometry().then(lang.hitch(this, function (serverScratch) {
                this.workplanBoundaryLayer.queryFeatures(this.queryWorkplanLayer(), lang.hitch(this, function (result) {
                    var wpbuffer = geometryEngine.geodesicBuffer([0].geometry, -5, "meters")
                    var withinTest = geometryEngine.within(wpbuffer, result.features[0].geometry);
                    if (withinTest == false) {
                        alert("Schedule must be inside of the workplan boundary.  Try again.");
                        return false
                    else {
                        return true


This has worked until now with simple features however where the polygon used to check against has "holes" within it the within test fails.


Any suggestions on how to rework this?


Thanks for any input!