Select to view content in your preferred language

onRowChangeEvent Determine Geometry Change

444
2
11-01-2017 07:49 AM
MKa
by
Frequent Contributor

I cant seem to figure out how to determine if the Row Change was a geometry change only?  I need to know if the change that triggered this row change was an attribute change, or if someone just moved a vertices or something.  I have tried both of these in my onRowChangeEvent  and neither seem to work for both attribute only changes or geometry only changes.

int shapeIndex = args.Row.GetTable().GetDefinition().FindField("Shape");
bool shapeChanged = args.Row.HasValueChanged(shapeIndex);

bool shapeChanged2 = (Geometry)args.Row.GetOriginalValue(shapeIndex) != (Geometry)args.Row[shapeIndex];

        protected async void onRowChangeEvent(RowChangedEventArgs args)
        {
            //Polygon selectedLine = inspr["SHAPE"] as Polygon;
            int shapeIndex = args.Row.GetTable().GetDefinition().FindField("Shape");
            
            //These both seem to always return true even if it is a attribute only change
            bool shapeChanged = args.Row.HasValueChanged(shapeIndex);
            bool shapeChanged2 = (Geometry)args.Row.GetOriginalValue(shapeIndex) != (Geometry)args.Row[shapeIndex];
        }‍‍‍‍‍‍‍
Tags (1)
0 Kudos
2 Replies
by Anonymous User
Not applicable

A better way to compare geometry is through the Geometry.isEqual method:

      var geomOrig = obj.Row.GetOriginalValue(shapeIndex) as Geometry;
      var geomNew = obj.Row[shapeIndex] as Geometry;
      bool shapeChanged2 = geomOrig.IsEqual(geomNew);

It looks like there's a bug with feature services and RowChangedEvent. Row.GetOriginalValue is returning null for all indexes and consequently Row.HasValueChanged will always return true. All other datasources seem correct.

Are you hitting a feature service as per your other post?

MKa
by
Frequent Contributor

I am indeed using a feature service, and you are correct, HasValueChanged it always returning true even when I don't change anything.  Get Original Value is also always returning null as you mentioned, so i have know way of comparing geometries either in the OnRowChangedEvent.  I need to know if the shape changed or just an attribute.  But it looks like both aren't working.

Thanks for your help on this, and if you can think of any other work around that would be great.  My only option now until the bug is addressed, is to possible calculate the area of the polygon and to see if it matches an already saved area?  Unless you can think of anything easier?

Matt

0 Kudos