Home > OS >  Validation in Edit and Sync features
Validation in Edit and Sync features

Time:10-26

I am working on an assignment in QML where a survey worker who works in an area without an internet connection could take a geodatabase of survey features offline at their office, make edits and add new features to the offline geodatabase in the field, and sync the updates with the online feature service after returning to the office.

In the project, user can pan and zoom to position the red rectangle around the area he want to take offline. Click "Generate geodatabase" to take the area offline. When complete, the map will update to only show the offline area. To edit features, click to select a feature, and click again anywhere else on the map to move the selected feature to the clicked location. To sync the edits with the feature service, click the "Sync geodatabase" button.

For me I successfully, completed this, but I am unable to validate the data before syncing. I am sharing the piece of code where I am doing the data validation. Any help?

// create the GeodatabaseSyncTask to generate the local geodatabase
    GeodatabaseSyncTask {
        id: geodatabaseSyncTask
        url: featureServiceUrl
        property var generateJob
        property var syncJob

        function executeGenerate() {
            // execute the asynchronous task and obtain the job
            generateJob = generateGeodatabase(generateParameters, outputGdb);

            
                syncWindow.visible = true;
                statusText = "Generate failed";
                syncWindow.hideWindow(5000);
            }

CodePudding user response:

You will use conditional statements as below to validate your data.

GeodatabaseSyncTask {
        id: geodatabaseSyncTask
        url: featureServiceUrl
        property var generateJob
        property var syncJob

        function executeGenerate() {
            // execute the asynchronous task and obtain the job
            generateJob = generateGeodatabase(generateParameters, outputGdb);

            // check if the job is valid
            if (generateJob) {

                // show the sync window
                syncWindow.visible = true;

                // connect to the job's status changed signal to know once it is done
                generateJob.jobStatusChanged.connect(updateGenerateJobStatus);

                // start the job
                generateJob.start();
            } else {
                // a valid job was not obtained, so show an error
                syncWindow.visible = true;
                statusText = "Generate failed";
                syncWindow.hideWindow(5000);
            }
        }  
  • Related