Qt and Tables in a Feature Service

3790
2
Jump to solution
04-15-2015 12:15 PM
ChrisGoz
New Contributor

I have a feature service that is hosted on ArcGIS.com, and the service contains a feature layer and a plain table. I want to update an attribute in the table from my Qt application, but I cannot. I do catch the signal onApplyFeatureEditsStatusChanged() and the status is indeed Enums.ApplyEditsStatusErrored, but I don't understand how to handle the actual error object: applyFeatureEditsErrors. That is,  applyFeatureEditsErrors.error is undefined.

The things that I CAN do:

- query the table, and loop through the results logging all the attribute values,

- update attributes in the table using the REST interface in a browser.

To check my code, I used the feature layer endpoint instead, created a feature layer from it, and added it to the map:

GeodatabaseFeatureServiceTable {
     id: myTableFromURL
     url:someFeatureServiceRESTEndpointURL

     onApplyFeatureEditsStatusChanged: {...}
}

featureLayer.featureTable = myTableFromURL;
appMap.addLayer(featureLayer);

Then I waited for the FeatureLayer to initialize and verified that my table did too:

if (myTableFromURL.featureTableStatus === Enums.FeatureTableStatusInitialized) {
    updatesEnabled = true;
}

I can run a query to get features from the table/layer, and when the query is completed, loop through the records, updating data as I go:

thisRecord.setAttributeValue("SOME_ATTRIBUTE","SOME_NEW_VALUE");
myTableFromURL.updateFeature(thisRecord.uniqueId, thisRecord);

And finally, once all the edits have been made to the features, tell the table to apply the changes:

myTableFromURL.applyFeatureEdits();

The edits are visible in the feature layer on arcgis.com.

Same process with the flat table (minus making and adding a feature layer to the map) does not work.

Is there a similar method to initialize a flat table (non-geo-enabled) as what happens when a feature layer is added to a map?

Thanks in advance,

Chris

0 Kudos
1 Solution

Accepted Solutions
ChrisGoz
New Contributor

There is indeed an issue with editing tables that are not feature layers at the current release of the Qt Runtime SDK.

So for anyone interested, our solution was to add (fake point) geometry to the flat table so we could expose it as a feature layer in the REST service. Within the Qt code, I use the table and make it a (fake) feature layer that never gets added to the map.

//initialize the fake feature layer from the table and initialize the layer

someTable.url = someRESTEndpointUrl;

someTableFakeFeaturelayer.featureTable = userTable;

someTableFakeFeaturelayer.initialize();

When the feature layer’s status changes to LayerStatusInitialized, I run a query to get the data I want to update:

if (someTable.featureTableStatus === Enums.FeatureTableStatusInitialized) {

   //run a query to download the data we want from the service

   userQuery.where = aQueryString;

   someTable.queryServiceFeatures(userQuery);

}

And when the table’s QueryServiceFeaturesStatusChanged === QueryFeaturesStatusCompleted, I update the feature records that are returned and then finally apply the edits to the table:

var iterator_edits = queryServiceFeaturesResult.iterator;

var thisRecord;

while (iterator_edits.hasNext()) {

    //update some information

    thisRecord = iterator_edits.next();

    thisRecord.setAttributeValue(m_NameOfAttribute, newValue);

    //apply the edits to the feature (i.e., this data record)

    updateFeature(thisRecord.uniqueId, thisRecord);

}

//apply the edits to the table

someTable.applyFeatureEdits();

And everything updates as expected.

Thanks for the insight on this Lucas!

View solution in original post

0 Kudos
2 Replies
LucasDanzinger
Esri Frequent Contributor

Chris-

Can you please email me a copy of your project? ldanzinger@esri.com

Thanks,

Luke

0 Kudos
ChrisGoz
New Contributor

There is indeed an issue with editing tables that are not feature layers at the current release of the Qt Runtime SDK.

So for anyone interested, our solution was to add (fake point) geometry to the flat table so we could expose it as a feature layer in the REST service. Within the Qt code, I use the table and make it a (fake) feature layer that never gets added to the map.

//initialize the fake feature layer from the table and initialize the layer

someTable.url = someRESTEndpointUrl;

someTableFakeFeaturelayer.featureTable = userTable;

someTableFakeFeaturelayer.initialize();

When the feature layer’s status changes to LayerStatusInitialized, I run a query to get the data I want to update:

if (someTable.featureTableStatus === Enums.FeatureTableStatusInitialized) {

   //run a query to download the data we want from the service

   userQuery.where = aQueryString;

   someTable.queryServiceFeatures(userQuery);

}

And when the table’s QueryServiceFeaturesStatusChanged === QueryFeaturesStatusCompleted, I update the feature records that are returned and then finally apply the edits to the table:

var iterator_edits = queryServiceFeaturesResult.iterator;

var thisRecord;

while (iterator_edits.hasNext()) {

    //update some information

    thisRecord = iterator_edits.next();

    thisRecord.setAttributeValue(m_NameOfAttribute, newValue);

    //apply the edits to the feature (i.e., this data record)

    updateFeature(thisRecord.uniqueId, thisRecord);

}

//apply the edits to the table

someTable.applyFeatureEdits();

And everything updates as expected.

Thanks for the insight on this Lucas!

0 Kudos