SpatialReference null after moving polygon using the EditGeometry class

2657
2
02-18-2014 04:04 AM
KathrinWuensch
New Contributor
Hi,

I followed the "Edit Tools - Geometry" to implement editing of my shapes on the map. Everything is working nicely, until I realised that after the GeometryMoved action of a polygon the GeometryEditEventArgs property Geometry.SpatialReference is null. As I need to calculate the area of the moved and previously reshaped polygon, the missing Spatial Reference is a problem (I am using the AreasAndLengths operation).

I am using ArcGIS Runtime for WPF 10.2.

Currently I reset the spatial reference in the code, but was wondering is this is wanted behaviour or if I implement something wrong?

Thanks,
Kathrin
0 Kudos
2 Replies
JoshuaTharp
New Contributor II

Did you figure out what was going on? I seem to have the same problem:

Geometry has a spatial reference before the edit.

Geometry does not have a spatial reference after the edit.

0 Kudos
JenniferNery
Esri Regular Contributor

Hi,

Thank you for reporting this bug.If you had tried to move the geometry using EditGeometry, Editor, or EditorWidget, there is currently a bug that SpatialReference becomes null if geometry was Polyline/Polygon after this operation. We will try to include the fix in future versions.

In the meantime, you can subscribe to EditGeometry.GeometryEdit and correct the geometry

        SpatialReference spatialReference;

        private void EditGeometry_GeometryEdit(object sender, EditGeometry.GeometryEditEventArgs e)

        {

            if (e.Action == EditGeometry.Action.GeometryMoved)

            {

                // this should not happen

                if (e.Geometry.SpatialReference == null)

                {

                    if (spatialReference == null && e.Graphic.Geometry.SpatialReference != null)

                        spatialReference = e.Graphic.Geometry.SpatialReference;

                }

            }

            if (e.Action == EditGeometry.Action.EditCompleted)

            {

               // this is just a workaround

                if(e.Graphic.Geometry.SpatialReference == null && spatialReference != null)

                    e.Graphic.Geometry.SpatialReference = spatialReference;

            }

        }

0 Kudos