Skip to content

Commit c736ba7

Browse files
committed
Add options load via proxy and clamp to ground
1 parent b8694d0 commit c736ba7

File tree

3 files changed

+58
-5
lines changed

3 files changed

+58
-5
lines changed

3dwebclient/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,14 @@
261261
</select>
262262
</td>
263263
</tr>
264+
<tr id="layerProxyAndClampToGround" style="display: none;">
265+
<td>
266+
<label><input type="checkbox" id="layerProxyCheckbox" style="width:auto;" data-bind="checked: layerProxy"/> Load via proxy</label>
267+
</td>
268+
<td>
269+
<label><input type="checkbox" id="layerClampToGroundCheckbox" style="width:auto;" data-bind="checked: layerClampToGround"/> KML clamp to ground</label>
270+
</td>
271+
</tr>
264272
<tr id="gltfVersionDropdownRow" style="display: none;">
265273
<td>glTF version</td>
266274
<td>

3dwebclient/script.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ var addLayerViewModel = {
7878
url: "",
7979
name: "",
8080
layerDataType: "",
81+
layerProxy: false,
82+
layerClampToGround: true,
8183
gltfVersion: "",
8284
thematicDataUrl: "",
8385
thematicDataSource: "",
@@ -287,6 +289,8 @@ function observeActiveLayer() {
287289
addLayerViewModel.url = selectedLayer.url;
288290
addLayerViewModel.name = selectedLayer.name;
289291
addLayerViewModel.layerDataType = selectedLayer.layerDataType;
292+
addLayerViewModel.layerProxy = selectedLayer.layerProxy;
293+
addLayerViewModel.layerClampToGround = selectedLayer.layerClampToGround;
290294
addLayerViewModel.gltfVersion = selectedLayer.gltfVersion;
291295
addLayerViewModel.thematicDataUrl = selectedLayer.thematicDataUrl;
292296
addLayerViewModel.thematicDataSource = selectedLayer.thematicDataSource;
@@ -391,6 +395,8 @@ function getLayersFromUrl() {
391395
url: layerConfig.url,
392396
name: layerConfig.name,
393397
layerDataType: Cesium.defaultValue(layerConfig.layerDataType, "COLLADA/KML/glTF"),
398+
layerProxy: Cesium.defined(layerConfig.layerProxy) ? layerConfig.layerProxy === "true" : false,
399+
layerClampToGround: Cesium.defined(layerConfig.layerProxy) ? layerConfig.layerClampToGround === "true" : true,
394400
gltfVersion: Cesium.defaultValue(layerConfig.gltfVersion, "2.0"),
395401
thematicDataUrl: Cesium.defaultValue(layerConfig.spreadsheetUrl, ""),
396402
thematicDataSource: Cesium.defaultValue(layerConfig.thematicDataSource, "GoogleSheets"),
@@ -476,6 +482,8 @@ function saveLayerSettings() {
476482
applySaving('url', activeLayer);
477483
applySaving('name', activeLayer);
478484
applySaving('layerDataType', activeLayer);
485+
applySaving('layerProxy', activeLayer);
486+
applySaving('layerClampToGround', activeLayer);
479487
applySaving('gltfVersion', activeLayer);
480488
applySaving('thematicDataUrl', activeLayer);
481489
applySaving('thematicDataSource', activeLayer);
@@ -824,6 +832,8 @@ function layersToQuery() {
824832
url: layer.url,
825833
name: layer.name,
826834
layerDataType: layer.layerDataType,
835+
layerProxy: layer.layerProxy,
836+
layerClampToGround: layer.layerClampToGround,
827837
gltfVersion: layer.gltfVersion,
828838
active: layer.active,
829839
spreadsheetUrl: layer.thematicDataUrl,
@@ -1014,6 +1024,8 @@ function addNewLayer() {
10141024
url: addLayerViewModel.url.trim(),
10151025
name: addLayerViewModel.name.trim(),
10161026
layerDataType: addLayerViewModel.layerDataType.trim(),
1027+
layerProxy: (addLayerViewModel.layerProxy.trim() === "true"),
1028+
layerClampToGround: (addLayerViewModel.layerClampToGround.trim() === "true"),
10171029
gltfVersion: addLayerViewModel.gltfVersion.trim(),
10181030
thematicDataUrl: addLayerViewModel.thematicDataUrl.trim(),
10191031
thematicDataSource: addLayerViewModel.thematicDataSource.trim(),
@@ -1321,8 +1333,10 @@ function layerDataTypeDropdownOnchange() {
13211333
var layerDataTypeDropdown = document.getElementById("layerDataTypeDropdown");
13221334
if (layerDataTypeDropdown.options[layerDataTypeDropdown.selectedIndex].value !== "COLLADA/KML/glTF") {
13231335
document.getElementById("gltfVersionDropdownRow").style.display = "none";
1336+
document.getElementById("layerProxyAndClampToGround").style.display = "none";
13241337
} else {
13251338
document.getElementById("gltfVersionDropdownRow").style.display = "";
1339+
document.getElementById("layerProxyAndClampToGround").style.display = "";
13261340
}
13271341
addLayerViewModel["layerDataType"] = layerDataTypeDropdown.options[layerDataTypeDropdown.selectedIndex].value;
13281342
}

js/CitydbKmlLayer.js

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,17 @@
7676
this._mouseOverhighlightColor = new Cesium.Color(0.0, 0.3, 0.0, 1.0);
7777

7878
this._layerDataType = options.layerDataType;
79+
this._layerProxy = options.layerProxy;
80+
this._layerClampToGround = options.layerClampToGround;
7981
this._gltfVersion = options.gltfVersion;
8082

8183
this._configParameters = {
8284
"id": this.id,
8385
"url": this.url,
8486
"name": this.name,
8587
"layerDataType": this.layerDataType,
88+
"layerProxy": this.layerProxy,
89+
"layerClampToGround": this.layerClampToGround,
8690
"gltfVersion": this.gltfVersion,
8791
"thematicDataUrl": this.thematicDataUrl,
8892
"thematicDataSource": this.thematicDataSource,
@@ -319,6 +323,24 @@
319323
}
320324
},
321325

326+
layerProxy: {
327+
get: function () {
328+
return this._layerProxy;
329+
},
330+
set: function (value) {
331+
this._layerProxy = value;
332+
}
333+
},
334+
335+
layerClampToGround: {
336+
get: function () {
337+
return this._layerClampToGround;
338+
},
339+
set: function (value) {
340+
this._layerClampToGround = value;
341+
}
342+
},
343+
322344
gltfVersion: {
323345
get: function () {
324346
return this._gltfVersion;
@@ -346,7 +368,7 @@
346368

347369
function loadMasterJSON(that, isFirstLoad) {
348370
var deferred = Cesium.when.defer();
349-
var jsonUrl = that._url;
371+
var jsonUrl = checkProxyUrl(that, that._url);
350372
new Cesium.Resource({url: jsonUrl}).fetch({responseType: 'json'}).then(function (json) {
351373
that._jsonLayerInfo = json;
352374
that._layerType = json.displayform;
@@ -431,6 +453,15 @@
431453
}
432454
}
433455

456+
function checkProxyUrl(obj, url) {
457+
if (obj._layerProxy === true || obj._layerProxy === "true") {
458+
return (url.substring(0, 5) === "https" ? "https" : "http")
459+
+ "://www.3dcitydb.net/proxy/?" + url;
460+
}
461+
462+
return url;
463+
}
464+
434465
/**
435466
* adds this layer to the given Cesium viewer
436467
* @param {CesiumViewer} cesiumViewer
@@ -455,7 +486,7 @@
455486
canvas: cesiumViewer.scene.canvas
456487
});
457488

458-
this._citydbKmlDataSource.load(this._url).then(function (dataSource) {
489+
this._citydbKmlDataSource.load(checkProxyUrl(this, this._url)).then(function (dataSource) {
459490
assignLayerIdToDataSourceEntites(dataSource.entities, that._id);
460491
if (that._active) {
461492
cesiumViewer.dataSources.add(dataSource);
@@ -467,7 +498,7 @@
467498
} else if (this._urlSuffix == 'czml') {
468499
this._citydbKmlDataSource = new Cesium.CzmlDataSource();
469500

470-
this._citydbKmlDataSource.load(this._url).then(function (dataSource) {
501+
this._citydbKmlDataSource.load(checkProxyUrl(this, this._url)).then(function (dataSource) {
471502
assignLayerIdToDataSourceEntites(dataSource.entities, that._id);
472503
if (that._active) {
473504
cesiumViewer.dataSources.add(dataSource);
@@ -849,7 +880,7 @@
849880
canvas: this._cesiumViewer.scene.canvas
850881
});
851882

852-
this._citydbKmlDataSource.load(this._url).then(function (dataSource) {
883+
this._citydbKmlDataSource.load(checkProxyUrl(this, this._url)).then(function (dataSource) {
853884
assignLayerIdToDataSourceEntites(dataSource.entities, that._id);
854885
that._cesiumViewer.dataSources.add(dataSource);
855886
deferred.resolve(that);
@@ -859,7 +890,7 @@
859890
} else if (this._urlSuffix == 'czml') {
860891
this._citydbKmlDataSource = new Cesium.CzmlDataSource();
861892

862-
this._citydbKmlDataSource.load(this._url).then(function (dataSource) {
893+
this._citydbKmlDataSource.load(checkProxyUrl(this, this._url)).then(function (dataSource) {
863894
assignLayerIdToDataSourceEntites(dataSource.entities, that._id);
864895
cesiumViewer.dataSources.add(dataSource);
865896
deferred.resolve(that);

0 commit comments

Comments
 (0)