import QtQuick 2.12
import QtQuick.Controls 2.12
import Esri.ArcGISRuntime 100.15
import Esri.ArcGISExtras 1.1
import Qt.labs.platform 1.1
import QtQml 2.15
ApplicationWindow {
id: appWindow
width: 800
height: 600
title: "Enc"
// property url dataPath
readonly property url dataPath:
{
Qt.platform.os === "Windows" ?
System.writableLocationUrl(System.StandardPathsDocumentsLocation) + "ArcGIS Runtime SDK Qt 100.15.2\ArcGISRuntimeSDKQt\SetupFiles\Data1" :
System.writableLocationUrl(System.StandardPathsHomeLocation) + "C:\Users\ADMIN\Documents\ArcGIS Runtime SDK Qt 100.15.2\ArcGISRuntimeSDKQt\SetupFiles\Data1"
}
property int loadedEncLayerCount: 0
Component.onCompleted: {
// set resource path
EncEnvironmentSettings.resourcePath = dataPath + "C:/Users/ADMIN/Documents/enc/hydrography";
// EncEnvironmentSettings::setResourcePath(defaultDataPath() + "/ArcGIS/Runtime/Data/ENC/hydrography");
// load the EncExchangeSet
encExchangeSet.load();
console.log("hydrography");
}
//
Rectangle {
id: rootRectangle
clip: true
width: 800
height: 600
MapView {
id: mapView
anchors.fill: parent
Component.onCompleted: {
// Set the focus on MapView to initially enable keyboard navigation
forceActiveFocus();
console.log("component");
// function setupEncEnvironmentSettings() {
// EncEnvironmentSettings.displaySettings.marinerSettings.displayCategories.standardDisplay = true;
// }
}
Map {
id: map
Basemap {
initStyle: Enums.BasemapStyleArcGISOceans
}
EncExchangeSet {
id: encExchangeSet
paths: [dataPath + "C:/Users/ADMIN/Documents/enc/ExchangeSetwithoutUpdates/ENC_ROOT/CATALOG.031"]
property var layers: []
// connect to the load status changed signal
onLoadStatusChanged: {
if (loadStatus === Enums.LoadStatusFailedToLoad) {
console.log("fail to load", error.message, error.additionalMessage);
return;
}
if (loadStatus !== Enums.LoadStatusLoaded) {
console.log("here");
return;
}
// loop through the datasets
for (let i = 0; i < datasets.length; i++) {
// create an EncCell from each dataset
console.log("inside for loop");
const encCell = ArcGISRuntimeEnvironment.createObject("EncCell", {
dataset: datasets[i]
}, map);
// create an EncLayer from each cell
const encLayer = ArcGISRuntimeEnvironment.createObject("EncLayer", {
cell: encCell
}, map);
layers.push(encLayer);
console.log(encLayer);
// connect to loadStatusChanged for each layer
encLayer.loadStatusChanged.connect(()=> {
console.log(encLayer);
console.log(loadStatus);
if(encLayer.loadStatus === Enums.LoadStatusLoaded)
{
loadedEncLayerCount++;
}
// loop through the layers and zoom to the combined full extent
if (loadedEncLayerCount === datasets.length) {
console.log("2");
const fullExtents = [];
map.operationalLayers.forEach(layer => fullExtents.push(layer.fullExtent));
const fullExtentOfLayers = GeometryEngine.combineExtentsOfGeometries(fullExtents);
mapView.setViewpointGeometry(fullExtentOfLayers)
console.log("if2");
}
});
// add the layer to the map
map.operationalLayers.append(encLayer);
}
}
}
}
}
}
}