Select to view content in your preferred language

PolylineBuilderEx.ToGeometry crashes if there's an empty segment

781
3
Jump to solution
10-05-2022 12:48 AM
Konstantin_Ulyanov
New Contributor

Hey, I hope someone from Esri will see this question.

I added a part to a PolylineBuilderEx instance using AddPart(IEnumerable<MapPoint> points). In the points collection I had a couple of equal points going one after another. When I tried to call ToGeometry() to create a polyline out of it, I got an exception saying "Destination array was not long enough".

I decompiled ToGeometry method and started debugging it with a generated pdb. Turns out that ArcGIS.Core.Internal.Geometry.ShapeBufferHelper.GetMultipartBufferFromPartsSize doesn't include empty segments when calculating the buffer size:

 

if (segment.IsPoint)
    --numPoints;

 

But then WriteSegmentToBuffer method is still called for every segment, empty or not. As a result we get an exception for not having enough space in the buffer.

This bug affects a lot of our code, so can you please fix this as soon as you can?

ArcGIS Pro version 3.0.2.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AnnetteLocke
Esri Contributor

Hi Konstantin,

This has been fixed and will be included in an upcoming patch. Thank you for reporting it.

Annette

 

View solution in original post

3 Replies
AnnetteLocke
Esri Contributor

Hi Konstantin,

This has been fixed and will be included in an upcoming patch. Thank you for reporting it.

Annette

 

SteveHossack2
New Contributor

Just curious if the patch has been released yet. I'm currently using the ArcGIS Pro SDK for .NET version 3.0.0.36057 and using ArcGIS Pro 3.0.3. We are still getting the error message. Thanks.

0 Kudos
AnnetteLocke
Esri Contributor

Hi Steve, the patch has not been released yet, but it is coming soon. If you have the SDK installed, Visual Studio has a notification icon that will tell you that an update is available. Also, there is an option in the IDE to "automatically update extensions". If that option is turned on, then you don't have to do anything - it will get automatically updated.

Thanks,

Annette

0 Kudos