Data from Service

318
2
12-20-2019 11:35 AM
jaykapalczynski
Frequent Contributor

I am trying to retrieve data from a Service so I can take my application offline.  I have this working to some degree but confused on a few things. 

Right now I am using the populateFromService Method to get my data and display it in the map. 

ServiceFeatureTable QML Type | ArcGIS for Developers 

This supposedly creates a local database and stores the data there?????

*  I can view the datasets in my map

*  I can select and return data from those locations

SO everything is great there......

Problems / Issues:

If I leave the page and then come back to it the data is gone.  This requires me to sync back up with the data.  

The problem is that if I am off grid I cannot do this.  

Questions:  

Where is this geodatabase being created?

Is it being deleted once I leave the page?

Is there a way to store it somewhere else?

Can I update the data in this database by re-syncing at another time?

Are there other options for reading and syncing the data from a service into 3 different feature classes/Tables?

Wants:

I would like this to be a permanent geodatabase on the users phone that gets updated via a button.  

Is there a different import/sync procedure that is more permanent?

Currently I am doing this:

FeatureLayer {
     id: featureLayerBoating

     ServiceFeatureTable {
          id: featureTable0
          url: "https://vvvv.vvvv.vvvv.gov/arcgis/rest/services/Projects/vvvv/FeatureServer/2"

     featureRequestMode: Enums.FeatureRequestModeManualCache

     onPopulateFromServiceStatusChanged: {
         if (populateFromServiceStatus === Enums.TaskStatusCompleted) {
             if (!populateFromServiceResult.iterator.hasNext) {
                   return;
             }
             var count = populateFromServiceResult.iterator.features.length;
             console.log("Retrieved %1 features".arg(count));
         }
      }
   }
}


QueryParameters {
    id: params
    whereClause: "1 = 1"
}

// SNIP

onClicked:{
    if (checked == true){
        featureTable0.populateFromService(params, true, ["*"]);
    }else if (checked == false){
        console.log("false");
    }else{
        console.log("error");
    }
}

// SNIP‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
2 Replies
KeithLarson1
MVP Alum

I believe populateFromService will store a temporary geodatabase in your Temp folder (likely C:\Temp), but as you said, it is only temporary, so it will go away. If you want to download data, you probably want to use a GeodatabaseSyncTask, which you can use to create a job with given parameters. There is a sample application in AppStudio called "Generate Geodatabase" that should be a good reference for how to download your data.

I hope this helps!

- Keith

jaykapalczynski
Frequent Contributor

OK thanks...I will look into that...

Does that have logic to download additional features if you want to sync any new data?  Where it just downloads the new features that were added since the last pull?

0 Kudos