AnsweredAssumed Answered

GeometryEngine.Reshape  "Out of range : " error

Question asked by tugiss on Feb 25, 2016
Latest reply on Apr 25, 2016 by akajanus-esristaff

Hi,

I have an application where user can edit polygon geometries by drawing a polyline. The tool works fine most of the time but sometimes the users are able to draw a polyline that gives the following exception when used to reshape a polygon:

 

{System.Exception: Out of range :

   at RuntimeCoreNet.Interop.HandleException(Boolean retVal)

   at RuntimeCoreNet.CoreGeometryEngine.Reshape(ICoreGeometry geometry, CorePolyline reshaper, CoreSpatialReference sr)

   at Esri.ArcGISRuntime.Geometry.GeometryEngine.Reshape(Geometry geometry, Polyline reshaper)

   at ArcGISRuntime.Samples.DesktopViewer.MainWindow.ReshapeGeometry()}

 

HResult = -2146233088

 

Currently I just handle the exception and notify the user but I was wondering what actually is causing that error because the application would accept the edit otherwise. I was able to reproduce this easily with following code:

 

   
private void ReshapeGeometry()
        {
         
            var segment = new LineSegment(571528.331418344, 7015935.19781517, 571522.829343446, 7015932.7313678);
            var segment1 = new LineSegment(571522.829343446, 7015932.7313678, 571526.821556906, 7015958.60602131);
            var segment2 = new LineSegment(571526.821556906, 7015958.60602131, 571539.179356696, 7015958.48119505);
            var segment3 = new LineSegment(571539.179356696, 7015958.48119505, 571538.650188972, 7015936.78531834);
            var polylinebuilder = new PolylineBuilder(new SpatialReference(3067));
            polylinebuilder.AddPart(new List<Segment>() {segment, segment1, segment2, segment3});
            var polyline = polylinebuilder.ToGeometry();


            var polygonSegmentList = new List<Segment>();
            polygonSegmentList.Add(new LineSegment(571539.1685,7015926.3927,571522.4107,7015930.0191));
            polygonSegmentList.Add(new LineSegment(571522.4107,7015930.0191,571524.1421,7015941.2393));
            polygonSegmentList.Add(new LineSegment(571524.1421,7015941.2393,571539.1685,7015941.582));
            polygonSegmentList.Add(new LineSegment(571539.1685,7015941.582,571539.1685,7015945.6416));
            polygonSegmentList.Add(new LineSegment(571539.1685,7015945.6416,571560.8646,7015942.2022));
            polygonSegmentList.Add(new LineSegment(571560.8646,7015942.2022,571554.5927,7015904.3921));
            polygonSegmentList.Add(new LineSegment(571554.5927,7015904.3921,571567.0612,7015908.2978));
            polygonSegmentList.Add(new LineSegment(571567.0612,7015908.2978,571568.0242,7015907.1421));
            polygonSegmentList.Add(new LineSegment(571568.0242,7015907.1421,571560.4466,7015900.4921));
            polygonSegmentList.Add(new LineSegment(571560.4466,7015900.4921,571561.2404,7015896.259));
            polygonSegmentList.Add(new LineSegment(571561.2404,7015896.259,571577.0933,7015896.259));
            polygonSegmentList.Add(new LineSegment(571577.0933,7015896.259,571578.9674,7015894.0101));
            polygonSegmentList.Add(new LineSegment(571578.9674,7015894.0101,571564.2792,7015888.2747));
            polygonSegmentList.Add(new LineSegment(571564.2792,7015888.2747,571563.5545,7015873.0528));
            polygonSegmentList.Add(new LineSegment(571563.5545,7015873.0528,571574.5472,7015873.5045));
            polygonSegmentList.Add(new LineSegment(571574.5472,7015873.5045,571573.7534,7015854.7191));
            polygonSegmentList.Add(new LineSegment(571573.7534,7015854.7191,571550.2056,7015853.9253));
            polygonSegmentList.Add(new LineSegment(571550.2056,7015853.9253,571557.6253,7015846.5944));
            polygonSegmentList.Add(new LineSegment(571557.6253,7015846.5944,571554.4348,7015834.4702));       
            polygonSegmentList.Add(new LineSegment(571554.4348,7015834.4702,571552.4354,7015825.4736));
            polygonSegmentList.Add(new LineSegment(571552.4354,7015825.4736,571540.9927,7015827.059));
            polygonSegmentList.Add(new LineSegment(571540.9927,7015827.059,571533.5882,7015833.8938));
            polygonSegmentList.Add(new LineSegment(571533.5882,7015833.8938,571529.0315,7015843.577));
            polygonSegmentList.Add(new LineSegment(571529.0315,7015843.577,571523.3354,7015845.8551));
            polygonSegmentList.Add(new LineSegment(571523.3354,7015845.8551,571509.5472,7015846.6466));
            polygonSegmentList.Add(new LineSegment(571509.5472,7015846.6466,571516.6826,7015892.8921));
            polygonSegmentList.Add(new LineSegment(571516.6826,7015892.8921,571518.9382,7015907.5118));
            polygonSegmentList.Add(new LineSegment(571518.9382,7015907.5118,571528.4449,7015904.4416));
            polygonSegmentList.Add(new LineSegment(571528.4449,7015904.4416,571532.7326,7015904.4416));
            polygonSegmentList.Add(new LineSegment(571532.7326,7015904.4416,571533.0657,7015909.2146));
            polygonSegmentList.Add(new LineSegment(571533.0657,7015909.2146,571519.7112,7015912.5242));
            polygonSegmentList.Add(new LineSegment(571519.7112,7015912.5242,571521.0792,7015921.3871));
            polygonSegmentList.Add(new LineSegment(571521.0792,7015921.3871,571533.8691,7015920.7287));
            polygonSegmentList.Add(new LineSegment(571533.8691,7015920.7287,571534.1331,7015924.5101));
            polygonSegmentList.Add(new LineSegment(571534.1331,7015924.5101,571539.1685,7015924.7618));
            polygonSegmentList.Add(new LineSegment(571539.1685, 7015924.7618, 571539.1685, 7015926.3927));


            var polygonbuilder = new PolygonBuilder(new SpatialReference(3067));
            polygonbuilder.AddPart(polygonSegmentList);
            var polygon = polygonbuilder.ToGeometry();


            try
            {
                var reshapeGeometry = GeometryEngine.Reshape(polygon, polyline);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }








Outcomes