I'm having troubles adding features to a Local GDB in Qt. Following this code:
Geodatabase {
id: gdb
path: "Test/FS_SNM_ALS_LimpiezaSumideros.geodatabase" onValidChanged: {
if (valid) {
var gdbtables = gdb.geodatabaseFeatureTables;
for(var i in gdbtables) {
console.log (gdbtables.featureServiceLayerName);
}
}
}
}
FeatureLayer {
id: featureLayer
featureTable: gdb.geodatabaseFeatureTableByLayerId(0)
}
function addFeature(mapPoint) {
console.log("x", mapPoint.x);
var featureJson = {
geometry: {
x: mapPoint.x,
y: mapPoint.y,
spatialReference: mapPoint.spatialReference
},
attributes: {
<attributes>
}
}
if (featureLayer.featureTable.featureTableStatus === Enums.FeatureTableStatusInitialized) {
featureLayer.featureTable.addFeature(featureJson);
}
}
When running the code, it seems like the feature was added, but it can't be queried or be seen on the map
Any comment is helpful! Thank you!
cc: jumypansas
Solved! Go to Solution.
Is it related to spatial reference perhaps? What spatial reference is your map and your geodatabase, and where on the earth are you adding your new feature?
What does addFeature return? If -1, then there was an error adding it. Otherwise, it will return the new object id - ArcGIS Runtime SDK for Qt QML API: FeatureTable Class Reference
A common issue is not matching the required schema of the table you are trying to add to.
Lucas,
Thanks for your help
In deed the function response is -1. Actually, we're giving these attributes:
var featureJson = {
geometry: {
x: mapPoint.x,
y: mapPoint.y,
spatialReference: mapPoint.spatialReference
},
attributes: {
IDInstalacion: "1111111",
TipoSumidero: "CAL",
Largo: 1,
Ancho: 1,
MaterialTaza: "HSI",
MaterialAccesorio: "OTR"
}
}
To these schema:
Fields:
Is a weird thing cause when adding features directly to the feature service (URL) it works just fine.
The problem arises when adding features to a local GDB
Can you connect to the error signal, and see if you get any indication of what the problem is? - ArcGIS Runtime SDK for Qt QML API: RuntimeObject Class Reference
Something like the following might do:
featureLayer.featureTable.error.connect(function(error) {
console.log(error.description);
});
I'm sorry but we can't find the error signal in the function!
So far we have managed to get the OBJECTID for the function response (AddFeature is working) but the point doesn't display on the map.
It's like the feature is created with its attributes but without Geometry. A weird thing is that after exiting the function the feature count corresponds to originalfeaturecount + 1 but when we try to query that feature by its OBJECTID it dosen't seem to be there.
Thanks for your help!
Is it related to spatial reference perhaps? What spatial reference is your map and your geodatabase, and where on the earth are you adding your new feature?
Lucas, We've figured out what was happening.
The editions must be made inside the extents in which the Local GDB was set. So features outside of that extent won't be drawn (obviously :/).
Thanks for your help and your time.
Hi
I got the similar issue to unable to add feature to local geodatabase, will you be able to show the example code that is working for you?
Jack, the code goes like this:
Geodatabase {
id: gdb
path: "Test/FS_SNM_ALS_LimpiezaSumideros.geodatabase" onValidChanged: {
if (valid) {
var gdbtables = gdb.geodatabaseFeatureTables;
for(var i in gdbtables) {
console.log (gdbtables[i].featureServiceLayerName);
}
}
}
}
FeatureLayer {
id: featureLayer
featureTable: gdb.geodatabaseFeatureTableByLayerId(0)
}
function addFeature(mapPoint) {
console.log("x", mapPoint.x);
var featureJson = {
geometry: {
x: mapPoint.x,
y: mapPoint.y,
spatialReference: mapPoint.spatialReference
},
attributes: {
IDInstalacion: "1111111",
TipoSumidero: "CAL",
Largo: 1,
Ancho: 1,
MaterialTaza: "HSI",
MaterialAccesorio: "OTR"
}
}
if (featureLayer.featureTable.featureTableStatus === Enums.FeatureTableStatusInitialized) {
featureLayer.featureTable.addFeature(featureJson);
}
}
Thank you Marco, you saved my day. Is there anyway that we can captured the add feature error detail? For example when you add new feature outside the local GB extent, how do you get the error message? I only can get addfeatureStatus = 3 (that means error happened when add feature), but it does not give me more information