create new point geometry offline

952
6
Jump to solution
05-29-2019 06:28 AM
DevendraKhatri
New Contributor III

I have app that loads features on my map, and it can generate and store geo-database to my local device.I does edit ans sync the existing features but what I want to achieve next is to create a new point on the map offline and sync back when I am online. I have tried several ways but no success. Also, tips for taking maps offline would be helpful.

0 Kudos
1 Solution

Accepted Solutions
Nicholas-Furness
Esri Regular Contributor

This guide documentation should help: Edit features—ArcGIS Runtime SDK for Android | ArcGIS for Developers 

In short, you create a feature using the table, set the attributes and geometry, and then add it to the table.

Working with offline geodatabases, that is all you need to do. If you are working with a ServiceFeatureTable connected directly to a service, you will also need to call applyEdits.

View solution in original post

6 Replies
Nicholas-Furness
Esri Regular Contributor

This guide documentation should help: Edit features—ArcGIS Runtime SDK for Android | ArcGIS for Developers 

In short, you create a feature using the table, set the attributes and geometry, and then add it to the table.

Working with offline geodatabases, that is all you need to do. If you are working with a ServiceFeatureTable connected directly to a service, you will also need to call applyEdits.

DevendraKhatri
New Contributor III

Thanks, it worked. 

0 Kudos
DevendraKhatri
New Contributor III

Hi Nicholas,

I need some inputs here, have been trying this whole day, no success 

I have geodatabase loaded on the map, I am trying to add a new geometry [ I am drawing geometry using sketch editor ]. Geometry gets drawn on the web, but doesn't persist in the geodatabase. It does not show the new feature if I reload the geodatabase.

Here s my simple code..

Geometry sketchGeometry = mSketchEditor.getGeometry(); // get the drawn geometry
Feature feature = mGeodbFeatureTable.createFeature(attributes, sketchGeometry); // create feature
if(mGeodbFeatureTable.canAdd()){
final ListenableFuture<Void> addFeatureFuture = mGeodbFeatureTable.addFeatureAsync(feature); // add feature async
addFeatureFuture.addDoneListener(()->{
try {
addFeatureFuture.get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
});
}


Would it be because of spatial reference ! Geodb being in different SR than that of my drawn geometry.

I saw few documentations , did not help, android runtime 100.5 what I am using does not have samples for offline-edits , but
shows me this,
Earlier, I had achieved editing the geometry without drawing using sketch editor, is sketch editor unstable ! then what is the alternative to draw polygon, circle, triangle etc!

Any inputs/ samples would be helpful.
0 Kudos
Nicholas-Furness
Esri Regular Contributor

If you're not getting an error when you're writing the feature, then it's very likely the projection. I forget what Runtime does about automatically projecting but for performance we might not be doing that when writing to a local geodatabase. In general it's recommended not to make the Runtime project on the fly (each feature that is displayed from the local geodatabase must be projected to display on the map), so you might try specifying the spatialReference when you set up your GenerateGeodatabaseParameters. Note that when you read features from a service, it's the server that will be doing the projection so Runtime won't experience a hit in that case.

A simple test would be to use GeometryEngine.project() to get a version of the geometry projected to the spatial reference of the geodatabase table and write that then see if that passes your test when you re-run. I'm certainly not aware of any issues with the sketch editor.

0 Kudos
DevendraKhatri
New Contributor III

When I checked the exception, exception was: you are not allowed to perform this operation with your licence.

I had placed one developer licence key to remove watermark, removed the licences, editing started working, strange !

Thanks

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Yes. If there is no license, you will be in Developer Mode (you'll see the watermark). All capabilities are enabled then, but you are not permitted to release an app in Developer Mode. It is for development and testing only.

To do offline editing, you will need a Basic license. The free license provided from your developer account is a Lite license and would only allow connected editing against a public service. A Basic License can be enabled by logging in as a Named User of any role other than Viewer. Or you can buy license packs from your local distributor.

0 Kudos