Is there a way to allow a FeatureCollectionTable to update the geometry of existing features?

570
4
01-29-2018 11:56 AM
DanielCharles
New Contributor II

I am using the ArcGIS Runtime SDK for .NET version 100.2. I am new to the SDK in particular and GIS in general. My goal is to take data from a locally available database with associated lat/long and show it on a map. When the database is updated with a new location, I get a push notification and I would like to update that feature on the map.

This is a (contrived) example of what I would like to do.

private async Task<Map> BuildAnUpdateableMap()
{
    var map = new Map(Basemap.CreateTopographic());
    var fields = new[] { new Field(FieldType.Text, "foo", "bar", 10) };
    var table = new FeatureCollectionTable(fields, GeometryType.Point, SpatialReferences.Wgs84);
    var collection = new FeatureCollection(new[] { table });
    var layer = new FeatureCollectionLayer(collection);
    var feature = table.CreateFeature();
    feature.SetAttributeValue(fields[0], "baz");
    feature.Geometry = new MapPoint(-119, 36);

    // Add the feature to the table. This works fine.
    await table.AddFeatureAsync(feature);
    map.OperationalLayers.Add(layer);

    // Update feature geometry.
    feature.Geometry = new MapPoint(-119, 30);
    // Push the updated feature. This throws an exception.
    await table.UpdateFeatureAsync(feature);

    return map;
}

The initial feature and geometry shows up just fine but when trying to update the geometry, an exception is thrown:

Esri.ArcGISRuntime.ArcGISRuntimeException: 'Ownership-based access control does not permit this operation on this feature.: allowGeometryUpdates=false'

I can accomplish the update by first removing the feature from the table and then adding it again after updating the geometry but that results in an unsightly flicker (in the WPF control at least) and I expect that wouldn't scale well either.

Is there a way to update feature geometry with `FeatureCollectionTable`? Or do I need to use something different?

0 Kudos
4 Replies
NagmaYasmin
Occasional Contributor III

Hi Daniel,

Since Geometry is immutable, you couldn't update the existing geometry. You may need to use GeometryBuilder class to update.

GeometryBuilder(T) Class 

Hope that helps. 

0 Kudos
DanielCharles
New Contributor II

Thanks for the response. I get that the Geometry object is immutable. I am actually setting the Feature to a new Geometry rather than changing the values in the existing object. That part compiles and runs fine. The issue is that when I go to update the FeatureCollectionTable I get a runtime error.  See the following snippet from the full sample above.

    ...

    feature.Geometry = new MapPoint(-119, 36);

    // Add the feature to the table. This works fine.
    await table.AddFeatureAsync(feature);

    // Update feature geometry with a new object.
    feature.Geometry = new MapPoint(-119, 30);
    // Push the updated feature. This next line throws an exception.
    await table.UpdateFeatureAsync(feature);

    ....

 

I expected that to work. Am I using FeatureCollectionTable incorrectly?

0 Kudos
DanielCharles
New Contributor II

I posted the same question on GIS StackExchange and got a response that this appears to be a bug in 100.2.

MichaelBranscomb
Esri Frequent Contributor

Hi,

We have logged this as a bug in ArcGIS Runtime SDK for .NET v100.2 and will try to address this issue in a release later this year.

Cheers

Mike

0 Kudos