FeatureTable.AddFeatureAsync throws exception when outside replica extent

229
3
Jump to solution
03-07-2024 09:27 AM
Labels (3)
Elfendahl
New Contributor II

I am using .NET 8 and ESRI Maps SDK 200.3 in MAUI running on Android 14 to add features to a FeatureLayer. But when I add the feature to the FeatureTable I keep getting an ArcGISRuntimeException with the message

 

Esri.ArcGISRuntime.ArcGISRuntimeException: Geodatabase geometry outside replica extent: Feature geometry is outside the generate geodatabase geometry. Encountered on feature with ID of -9223372036854775808.
at Esri.ArcGISRuntime.Internal.CoreTaskExtensions.TaskCompletedCallbackHandler.CreateInternal(CoreTask task, CancellationToken cancellationToken)
at Esri.ArcGISRuntime.Data.FeatureTable.AddFeatureAsync(Feature feature)

 

The Feature Table was originally downloaded from ArcGIS Online to a mobile geodatabase.

The code that adds the feature looks like this:

Feature feature = featureLayer.FeatureTable.CreateFeature();
feature.Geometry = GeometryEditor.Geometry;
if (featureLayer.FeatureTable.CanAdd())
{
    await featureLayer.FeatureTable.AddFeatureAsync(feature);
}

The code on line #5 throws the exception.

But surely it should be possible to add a new feature that lies outside the extent of the old features? Can anyone help me find a way to accomplish this?

0 Kudos
1 Solution

Accepted Solutions
dotMorten_esri
Esri Notable Contributor

Editing is limited to your replica extent. If you expect to be editing for a larger area, you should increase the replica extent (you don't have to use the layer extent, but can specify an extent much larger than the layer itself).

View solution in original post

0 Kudos
3 Replies
dotMorten_esri
Esri Notable Contributor

Editing is limited to your replica extent. If you expect to be editing for a larger area, you should increase the replica extent (you don't have to use the layer extent, but can specify an extent much larger than the layer itself).

0 Kudos
Elfendahl
New Contributor II

Hi @dotMorten_esri,

Many thanks for your quick reply! What you're saying makes sense, but I have been unable to find a way to increase the extent. The FeatureTable.Extent property has a getter only. And in my case the FeatureTable is in fact a GeodatabaseFeatureTable, and in the documentation it says for the Extent property that

For a GeodatabaseFeatureTable this returns the extent of the features which have been cached; this extent can grow as features are added or edited, but geographic extent will not the shrink.

This to me sounds like the extent should grow automatically. But your reply suggests it does not. So how do I go about increasing the extent?

P.S. I am a big fan of your NmeaParser library! 😁

0 Kudos
Elfendahl
New Contributor II

So, after having played around with this some more I have come to the realization that I was approaching the issue from the wrong direction.

My thought was to increase the FeatureTable extent after the FeatureTable had been created, but this does not seem to be possible. Rather the extent should be defined when the mobile geodatabase is created.

In my case, the geodatabase is created as a replica of a feature layer in ArcGIS online. One step in this process is to define the GenerateGeodatabaseParameters, which I had done using the CreateDefaultGenerateGeodatabaseParametersAsync method with an Envelope parameter. I had defined the Envelope to be the full extent of all the features in the feature layer, because the documentation states that the parameter should be "The extent of the data to be included in the generated geodatabase." But apparently this also sets the Envelope to where new features can be added. Since I want the user to be able to add features anywhere on the map, I changed the Envelope to include basically the entire globe. This resolved the ArcGISRuntimeException I got earlier, and I can now add new features wherever I want on the map.

I also now realize that the above is probably exactly what @dotMorten_esri meant in his reply, just that I didn't immediately catch on.

0 Kudos