Generate Geodatabase Extend Problem

1850
6
Jump to solution
08-05-2016 11:46 AM
tanerkoka1
Occasional Contributor

  Hi,

   We are using Arcgis Runtime SDK for Qt 10.2.6 and Qt 5.4.2 (MSVC 2013, 32 bit) Qt Creator QT\QML side .We have local editing application which edits features within an offline geodatabase and sync back to the service.We are using GeodatabaseSyncTask class's generateGeodatabase (GenerateGeodatabaseParameters parameters, string filename) method to generate geodatabase.

Can I generate geodatabese using without GenerateGeodatabaseParameters's  extent  property ? can I generate using only layerIds or layerQueries​ properties ?

I'm tried to generate witout extent propery with using only layerIds and layerQueries but when I can not generate , here is the console output below:

D/MaksMobil(30477): qrc:/qml/MapNumarataj.qml:291 (onGenerateStatusChanged): qml: Generate Error messageFailed to parse geometry from input JSONcode400

Best Regards

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

extent/geometry is a required parameter from the rest api, so you will need to provide it - Create Replica - Feature Service (Operation) - ArcGIS

View solution in original post

6 Replies
LucasDanzinger
Esri Frequent Contributor

extent/geometry is a required parameter from the rest api, so you will need to provide it - Create Replica - Feature Service (Operation) - ArcGIS

tanerkoka1
Occasional Contributor

Thanks Lucas,

Can we generate geodatabese only within poligon geometry not within poligon geometry envelope using with GeodatabaseSyncTask class's generateGeodatabase, Can we use    generateGeodatabaseParameters.extent=polygon; line of code , not generateGeodatabaseParameters.extent=polygon.queryEnvelope(); line of code  ?

Thanks

0 Kudos
LucasDanzinger
Esri Frequent Contributor

I believe that should work, as it takes a Geometry - ArcGIS Runtime SDK for Qt QML API: GenerateGeodatabaseParameters Class Reference

0 Kudos
tanerkoka1
Occasional Contributor

Hi Lucas ,

I try to generate with poligon (generateGeodatabaseParameters.extent=polygon)  wich has more than one point but gives error when I generate .How can we solve this problem ?

Here is the console output below :

D/MaksMobil(21826): qrc:/qml/MapNumarataj.qml:293 (onGenerateStatusChanged): qml: Generate Error messageError downloading http://......./arcgis/rest/services/ADRES27/FeatureServer/createReplica?async=true&clientTime=1470763815637&dataFormat=sqlite&geometry=%7B%22rings%22:[[[3020466.09516246,4640153.3807131],[3020482.83722159,4640176.85367551],[3020526.18356831,4640237.62827268],[3020617.40875565,4640170.60837935],[3020608.96692701,4640162.67623181],[3020625.20794716,4640131.69018741],[3020622.89849908,4640131.04941413],[3020697.7013947,4639990.20336442],[3020718.4496007,4639951.13879008],[3020740.39523979,4639909.82314925],[3020747.81624781,4639895.80642545],[3020776.48003011,4639841.69178895],[3020797.89121854,4639801.26666006],[3020833.9130704,4639733.24342986],[3020869.70525637,4639665.66376684],[3020871.54603324,4639662.19201904],[3020880.52103087,4639645.23570479],[3020908.33480733,4639594.39883371],[3020950.42257043,4639529.47891321],[3020951.16372939,4639516.10542839],[3020948.52703761,4639475.598364

D/MaksMobil(21826): qrc:/qml/MapNumarataj.qml:293 (onGenerateStatusChanged): qml: Generate Error messageProtocol "" is unknowncode301

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Taner,

The following code works for me, so in general, it does work to have a polygon as your extent in the generate task

import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import ArcGIS.Extras 1.0
import ArcGIS.Runtime 10.26


ApplicationWindow {
    id: root
    width: 700
    height: width


    property double scaleFactor: System.displayScaleFactor
    property int fontSize: 15 * scaleFactor
    property bool isOnline: true
    property string featuresUrl: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Sync/WildfireSync/FeatureServer"
    property string gdbPath: "~/ArcGIS/Runtime/Data/Test/offlineSample.geodatabase"
    property var selectedFeatureId: null


    Envelope {
        id: sfExtent
        xMin: -13643665.582273144
        yMin: 4533030.152110769
        xMax: -13618899.985108782
        yMax: 4554203.2089457335
        spatialReference: mainMap.spatialReference
    }


    Polygon {
        id: samplePolygon
    }


    Map {
        id: mainMap
        anchors.fill: parent
        focus: true


        ArcGISTiledMapServiceLayer {
            url: "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer"
        }


        FeatureLayer {
            id: offLineLayer
            featureTable: root.isOnline ? featureServiceTable : local
            selectionColor: "cyan"


            function hitTestFeatures(x,y) {
                var tolerance = Qt.platform.os === "ios" || Qt.platform.os === "android" ? 4 : 1;
                var featureIds = offLineLayer.findFeatures(x, y, tolerance * scaleFactor, 1);
                if (featureIds.length > 0) {
                    selectedFeatureId = featureIds[0];
                    selectFeature(selectedFeatureId);
                    statusText.text = "Tap anywhere to move the feature";
                }
            }
        }




        GraphicsLayer {
            id: graphicsLayer
        }


        onMouseClicked: {
            if (!root.isOnline) {
                if (offLineLayer.isFeatureSelected(selectedFeatureId)) {
                    var featureToEdit = offLineLayer.featureTable.feature(selectedFeatureId);
                    featureToEdit.geometry = mouse.mapPoint;
                    offLineLayer.featureTable.updateFeature(selectedFeatureId, featureToEdit);
                    offLineLayer.unselectFeature(selectedFeatureId);
                    selectedFeatureId = null;
                    syncButton.enabled = true;
                    statusText.text = "Tap on Sync to update the Feature Service with the edits";
                } else
                    offLineLayer.hitTestFeatures(mouse.x, mouse.y);
            }
        }


        onStatusChanged: {
            if (status === Enums.MapStatusReady) {
                samplePolygon.startPath(-7994031.11, 5092024.86);
                samplePolygon.lineTo(-7992530.05, 4952426.28);
                samplePolygon.lineTo(-7864939.95, 4951675.75);
                samplePolygon.lineTo(-7831916.63, 5069508.96);
                samplePolygon.lineTo(-7832667.16, 5166327.33);
                samplePolygon.lineTo(-7864189.42, 5233124.5);
                samplePolygon.lineTo(-7897963.27, 5071010.02);
                samplePolygon.lineTo(-7969263.62, 5131052.42);
                samplePolygon.lineTo(-8045817.68, 5119043.94);
                samplePolygon.lineTo(-8057826.16, 5045492);
                var graphicClone = polygonGraphic.clone();
                graphicClone.geometry = samplePolygon;
                graphicsLayer.addGraphic(graphicClone);
            }
        }


        Graphic {
            id: polygonGraphic
            symbol: SimpleFillSymbol {
                color: Qt.rgba(0.5, 0, 0.0, 0.25)
                outline:  SimpleLineSymbol {
                    color: "red"
                    style: Enums.SimpleLineSymbolStyleSolid
                    width: 2
                }
            }
        }


        GeodatabaseFeatureTable {
            id: local
            geodatabase: gdb.valid ? gdb : null
            featureServiceLayerId: 0
        }


        GeodatabaseFeatureServiceTable {
            id: featureServiceTable
            url: featuresUrl + "/0"
        }


        ServiceInfoTask {
            id: serviceInfoTask
            url: featuresUrl


            onFeatureServiceInfoStatusChanged: {


                if (featureServiceInfoStatus === Enums.FeatureServiceInfoStatusCompleted) {
                    statusText.text = "Service info received. Tap on the Generate Geodatabase Button";


                    generateButton.enabled = true;
                } else if (featureServiceInfoStatus === Enums.FeatureServiceInfoStatusErrored) {
                    statusText.text = "Error:" + errorString;
                    generateButton.enabled = false;
                    cancelButton.text = "Start Over";
                }
            }
        }


        Feature {
            id: featureToEdit
        }


        Rectangle {
            anchors {
                fill: controlsColumn
                margins: -10 * scaleFactor
            }
            color: "lightgrey"
            radius: 5 * scaleFactor
            border.color: "black"
            opacity: 0.77


            MouseArea {
                anchors.fill: parent
                onClicked: (mouse.accepted = true)
            }
        }


        Column {
            id: controlsColumn
            anchors {
                left: parent.left
                top: parent.top
                margins: 20 * scaleFactor
            }
            spacing: 7


            Button {
                id: generateButton
                text: "Generate Geodatabase"
                enabled: false
                style: ButtonStyle {
                    label: Text {
                        text: control.text
                        color: control.enabled ? "black" : "grey"
                        horizontalAlignment: Text.AlignHCenter
                    }
                }


                onClicked: {
                    generateGeodatabaseParameters.initialize(serviceInfoTask.featureServiceInfo);
                    generateGeodatabaseParameters.extent = samplePolygon;
                    generateGeodatabaseParameters.returnAttachments = false;
                    statusText.text = "Starting generate geodatabase task";
                    geodatabaseSyncTask.generateGeodatabase(generateGeodatabaseParameters, gdbPath);
                }
            }


            Button {
                id: syncButton
                text: "Sync"
                width: generateButton.width
                enabled: false
                style: generateButton.style


                onClicked: {
                    enabled = false;
                    geodatabaseSyncTask.syncGeodatabase(gdb.syncGeodatabaseParameters, gdb);
                    statusText.text = "Starting sync task";
                }
            }


            Button {
                id: cancelButton
                text: "Cancel"
                width: generateButton.width
                enabled: false
                style: generateButton.style


                onClicked: {
                    geodatabaseSyncTask.cancelJob(syncStatusInfo);
                    enabled = false;
                    text = "Cancel";
                }
            }


            Row {
                id: toggleOnlineOffline
                spacing: 10


                Text {
                    id: onlineStatus
                    text: root.isOnline ? "  Online " : "  Offline "
                    color: "black"
                }


                Switch {
                    id: switchToggle
                    checked: root.isOnline
                    enabled: false


                    onCheckedChanged: {
                        root.isOnline = checked;
                        if (checked === true && Enums.GenerateStatusCompleted)
                            statusText.text = "Switch to Offline Mode to continue editing.";
                        else if (checked === false && Enums.GenerateStatusCompleted)
                            statusText.text = "Select a feature.";
                    }
                }
            }
        }


        Geodatabase {
            id: gdb
            path: geodatabaseSyncTask.geodatabasePath


            onValidChanged: {
                if (valid) {
                    var gdbtables = gdb.geodatabaseFeatureTables;
                    for(var i in gdbtables) {
                        console.log (gdbtables.featureServiceLayerName);
                    }
                }
            }
        }


        GeodatabaseSyncStatusInfo {
            id: syncStatusInfo
        }


        GeodatabaseSyncTask {
            id: geodatabaseSyncTask
            url: featuresUrl


            onGenerateStatusChanged: {
                if (generateStatus === Enums.GenerateStatusCompleted) {
                    statusText.text = geodatabasePath;
                    cancelButton.enabled = false;
                    generateButton.enabled = false;
                    root.isOnline = false;
                    statusText.text = "Select a feature";
                } else if (generateStatus === GeodatabaseSyncTask.GenerateError) {
                    statusText.text = "Error: " + generateGeodatabaseError.message + " Code= "  + generateGeodatabaseError.code.toString() + " "  + generateGeodatabaseError.details;
                    generateButton.enabled = false;
                    cancelButton.text = "Start Over";
                }
            }


            onGeodatabaseSyncStatusInfoChanged: {
                if (geodatabaseSyncStatusInfo.status === Enums.GeodatabaseStatusUploadingDelta) {
                    var deltaProgress = geodatabaseSyncStatusInfo.deltaUploadProgress/1000;
                    var deltaSize = geodatabaseSyncStatusInfo.deltaSize/1000;
                    statusText.text = geodatabaseSyncStatusInfo.statusString + " " + String(deltaProgress) + " of " + String(deltaSize) + " KBs...";
                } else
                    statusText.text = geodatabaseSyncStatusInfo.statusString + "...";
                if (geodatabaseSyncStatusInfo.status !== GeodatabaseSyncStatusInfo.Cancelled)
                    cancelButton.enabled = true;
                syncStatusInfo.json = geodatabaseSyncStatusInfo.json;
            }


            onSyncStatusChanged: {
                featureServiceTable.refreshFeatures();
                if (syncStatus === Enums.SyncStatusCompleted) {
                    cancelButton.enabled = false;
                    syncButton.enabled = false;
                    statusText.text = "Sync completed. You may continue editing the features.";
                    switchToggle.enabled = true;
                }
                if (syncStatus === Enums.SyncStatusErrored)
                    statusText.text = "Error: " + syncGeodatabaseError.message + " Code= "  + syncGeodatabaseError.code.toString() + " "  + syncGeodatabaseError.details;
            }
        }


        GenerateGeodatabaseParameters {
            id: generateGeodatabaseParameters
        }


        Rectangle {
            id: textStatusRectangle
            anchors {
                fill: statusText
                margins: -10 * scaleFactor
            }
            visible: statusText.text.length > 0
            color: "lightgrey"
            radius: 5
            border.color: "black"
            opacity: 0.77
        }


        Text {
            id: statusText
            anchors {
                left: parent.left
                right: parent.right
                bottom: parent.bottom
                margins: 20 * scaleFactor
            }
            wrapMode: Text.WordWrap
            color: "black"
        }


        Rectangle {
            anchors.fill: parent
            color: "transparent"
            border {
                width: 0.5 * scaleFactor
                color: "black"
            }
        }


        Component.onCompleted: {
            statusText.text = "Getting service info";
            serviceInfoTask.fetchFeatureServiceInfo();
        }
    }
}


























































































tanerkoka1
Occasional Contributor

Hi Lucas ,

Thanks for example code , works fine but in my example have more then  1000 or 2000 point. Can you try to set over 1000 or 2000 point in polygon maybe there can be limitation points or request limitt in polgon when we  query during the generate geodatabas.How can I solve this urgent problem ?

Thanks

0 Kudos