Select to view content in your preferred language

EditOperation not updating geometries (sometimes)

502
1
07-31-2017 08:08 AM
TungNghiem
Deactivated User

Hello,

I have a snippet of code below which demonstrates a problem that I'm having

Inspector inspector = new Inspector();
inspector.Load(featurelayer, oid);
Debug.WriteLine("Old: " + GeometryEngine.Instance.ExportToWKT(WKTExportFlags.wktExportDefaults, (Geometry)inspector.GeometryAttribute.CurrentValue));
inspector.GeometryAttribute.CurrentValue = GeometryEngine.Instance.ImportFromWKT(WKTImportFlags.wktImportDefaults, "geometry", featurelayer.GetSpatialReference());
editOperation.Modify(inspector); 
await editOperation.ExecuteAsync();
if (editOperation.IsSucceeded) {
  inspector = new Inspector();
  inspector.Load(featurelayer, oid);
  Debug.WriteLine("New: " + GeometryEngine.Instance.ExportToWKT(WKTExportFlags.wktExportDefaults, (Geometry)inspector.GeometryAttribute.CurrentValue));
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The original geometry of the feature is:

MULTIPOLYGON (((-122.67363299999994 47.583226300000092, -122.67363309999996 47.584105500000078, -122.67385699999994 47.585292400000071, -122.67389429999997 47.586176200000068, -122.67355839999993 47.587312600000075, -122.67370769999997 47.588650900000061, -122.67381969999997 47.590645700000039, -122.67359569999996 47.590999200000056, -122.67337179999998 47.591125500000089, -122.67307319999998 47.590974000000074, -122.67309049999994 47.590798300000074, -122.67303529999998 47.590686300000073, -122.67281189999994 47.59084770000004, -122.67273729999994 47.591075000000046, -122.67299849999995 47.591327500000091, -122.67296119999997 47.591580000000079, -122.67303589999995 47.59205970000005, -122.67381969999997 47.592766700000084, -122.67387239999994 47.592809500000044, -122.67419289999998 47.593069700000058, -122.67415559999995 47.593524200000047, -122.67370769999997 47.593726100000083, -122.67385699999994 47.593877600000042, -122.67456619999996 47.594054400000061, -122.67479009999994 47.594534100000089, -122.67479439999994 47.594537000000059, -122.67507039999998 47.594723700000088, -122.67516339999997 47.594786600000077, -122.67559719999997 47.594878300000062, -122.67576059999993 47.594912800000088, -122.67676099999994 47.594924200000094, -122.67747849999995 47.594830800000068, -122.67765369999995 47.594784000000061, -122.67776569999995 47.594940800000074, -122.67794959999998 47.59503820000009, -122.67820549999993 47.59481100000005, -122.67794769999995 47.594606800000065, -122.67829869999997 47.594029100000057, -122.67833599999994 47.593625200000076, -122.67870929999998 47.593069700000058, -122.67889589999999 47.592716200000041, -122.67874659999995 47.592615200000068, -122.67777619999998 47.592514200000039, -122.67695499999996 47.591908200000091, -122.67691769999993 47.591049700000042, -122.67736559999997 47.590418500000055, -122.67758949999995 47.590014500000052, -122.67725359999997 47.589509400000054, -122.67717899999997 47.588827700000081, -122.67747759999997 47.588019600000052, -122.67766419999998 47.586858100000086, -122.67762689999995 47.585368200000062, -122.67755219999998 47.58491360000005, -122.67695499999996 47.583878200000072, -122.67702969999993 47.583230000000071, -122.67363299999994 47.583226300000092)))

And the updated geometry I'm passing in on line 4 is:

MULTIPOLYGON (((-122.673633 47.583226300000035, -122.67363309999996 47.584105500000078, -122.67385699999994 47.585292400000071, -122.67389429999997 47.586176200000068, -122.67355839999999 47.587312600000075, -122.67370769999997 47.588650900000061, -122.67381969999997 47.590645700000039, -122.67359569999996 47.590999200000056, -122.67337179999998 47.591125500000032, -122.67307319999998 47.590974000000074, -122.67309049999994 47.590798300000074, -122.67303529999998 47.590686300000073, -122.67281189999994 47.59084770000004, -122.67273729999999 47.591075000000046, -122.67299849999995 47.591327500000034, -122.67296119999997 47.591580000000079, -122.67303589999995 47.59205970000005, -122.67381969999997 47.592766700000027, -122.67387239999999 47.592809500000044, -122.67419289999998 47.593069700000058, -122.67415559999995 47.593524200000047, -122.67370769999997 47.593726100000026, -122.67385699999994 47.593877600000042, -122.67456619999996 47.594054400000061, -122.67479009999994 47.594534100000033, -122.67479439999994 47.594537000000059, -122.67507039999998 47.594723700000031, -122.67516339999997 47.594786600000077, -122.67559719999997 47.594878300000062, -122.67576059999999 47.594912800000031, -122.67676099999994 47.594924200000037, -122.67747849999995 47.594830800000068, -122.67765369999995 47.594784000000061, -122.67776569999995 47.594940800000074, -122.67794959999998 47.595038200000033, -122.67820549999999 47.59481100000005, -122.67794769999995 47.594606800000065, -122.67829869999997 47.594029100000057, -122.67833599999994 47.593625200000076, -122.67870929999998 47.593069700000058, -122.67889589999999 47.592716200000041, -122.67874659999995 47.592615200000068, -122.67777619999998 47.592514200000039, -122.67695499999996 47.591908200000034, -122.67691769999999 47.591049700000042, -122.67736559999997 47.590418500000055, -122.67758949999995 47.590014500000052, -122.67725359999997 47.589509400000054, -122.67717899999997 47.588827700000081, -122.67747759999997 47.588019600000052, -122.67766419999998 47.586858100000029, -122.67762689999995 47.585368200000062, -122.67755219999998 47.58491360000005, -122.67695499999996 47.583878200000072, -122.67702979999996 47.583230000000071, -122.673633 47.583226300000035)))

As you can see the difference between the 2 geometries is very minimal, mostly after the 6th decimal places for some vertices. The spatial reference in this case is the WSG84 space, unit is degrees. After this snippet was run, the debug on line 10 printed out the geometry as it was originally - the edit operation did not update the geometry.

If I changed the updated geometry by removing 1 vertex, then the edit operation worked, it printed out the new geometry on line 10.

So my questions are:

  1. Obviously is there anything stupid that I've done in the snippet above? This is trying to provide a reproduction case - in the real code I don't need to do line 7-11, just move on to something else.
  2. If not, why did it not work with the geometries I used?

Thank you for your time.

Tung

Tags (1)
0 Kudos
1 Reply
by Anonymous User
Not applicable

Hi Tung,

What's the XY Resolution and XY Tolerance of the feature class you are writing too?

If its not fine enough then then the updated geometries will snap to the same locations as the original geometry.

See Also: The properties of a spatial reference system

0 Kudos