|
76 | 76 | this._mouseOverhighlightColor = new Cesium.Color(0.0, 0.3, 0.0, 1.0);
|
77 | 77 |
|
78 | 78 | this._layerDataType = options.layerDataType;
|
| 79 | + this._layerProxy = options.layerProxy; |
| 80 | + this._layerClampToGround = options.layerClampToGround; |
79 | 81 | this._gltfVersion = options.gltfVersion;
|
80 | 82 |
|
81 | 83 | this._configParameters = {
|
82 | 84 | "id": this.id,
|
83 | 85 | "url": this.url,
|
84 | 86 | "name": this.name,
|
85 | 87 | "layerDataType": this.layerDataType,
|
| 88 | + "layerProxy": this.layerProxy, |
| 89 | + "layerClampToGround": this.layerClampToGround, |
86 | 90 | "gltfVersion": this.gltfVersion,
|
87 | 91 | "thematicDataUrl": this.thematicDataUrl,
|
88 | 92 | "thematicDataSource": this.thematicDataSource,
|
|
319 | 323 | }
|
320 | 324 | },
|
321 | 325 |
|
| 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 | + |
322 | 344 | gltfVersion: {
|
323 | 345 | get: function () {
|
324 | 346 | return this._gltfVersion;
|
|
346 | 368 |
|
347 | 369 | function loadMasterJSON(that, isFirstLoad) {
|
348 | 370 | var deferred = Cesium.when.defer();
|
349 |
| - var jsonUrl = that._url; |
| 371 | + var jsonUrl = checkProxyUrl(that, that._url); |
350 | 372 | new Cesium.Resource({url: jsonUrl}).fetch({responseType: 'json'}).then(function (json) {
|
351 | 373 | that._jsonLayerInfo = json;
|
352 | 374 | that._layerType = json.displayform;
|
|
431 | 453 | }
|
432 | 454 | }
|
433 | 455 |
|
| 456 | + function checkProxyUrl(obj, url) { |
| 457 | + if (obj._layerProxy === true || obj._layerProxy === "true") { |
| 458 | + |
| 459 | + var domain = (new URL(window.location.href )).hostname; |
| 460 | + var validDomain = |
| 461 | + domain === "www.3dcitydb.org" |
| 462 | + || domain === "www.3dcitydb.net" |
| 463 | + || domain === "www.3dcitydb.de" |
| 464 | + || domain === "3dcitydb.org" |
| 465 | + || domain === "3dcitydb.net" |
| 466 | + || domain === "3dcitydb.de"; |
| 467 | + |
| 468 | + if (!validDomain) { |
| 469 | + console.warn("Proxy must be enabled by this domain " + domain + "!"); |
| 470 | + return url; |
| 471 | + } |
| 472 | + |
| 473 | + var ssl = url.substring(0, 5) === "https"; |
| 474 | + |
| 475 | + var result = (ssl ? "https" : "http") + "://" + domain + "/proxy/?" + url; |
| 476 | + |
| 477 | + return result; |
| 478 | + } |
| 479 | + |
| 480 | + return url; |
| 481 | + } |
| 482 | + |
434 | 483 | /**
|
435 | 484 | * adds this layer to the given Cesium viewer
|
436 | 485 | * @param {CesiumViewer} cesiumViewer
|
|
452 | 501 | } else if (this._urlSuffix == 'kml' || this._urlSuffix == 'kmz') {
|
453 | 502 | this._citydbKmlDataSource = new Cesium.KmlDataSource({
|
454 | 503 | camera: cesiumViewer.scene.camera,
|
455 |
| - canvas: cesiumViewer.scene.canvas |
| 504 | + canvas: cesiumViewer.scene.canvas, |
| 505 | + clampToGround: this._layerClampToGround |
456 | 506 | });
|
457 | 507 |
|
458 |
| - this._citydbKmlDataSource.load(this._url).then(function (dataSource) { |
| 508 | + this._citydbKmlDataSource.load(checkProxyUrl(this, this._url)).then(function (dataSource) { |
459 | 509 | assignLayerIdToDataSourceEntites(dataSource.entities, that._id);
|
460 | 510 | if (that._active) {
|
461 | 511 | cesiumViewer.dataSources.add(dataSource);
|
|
467 | 517 | } else if (this._urlSuffix == 'czml') {
|
468 | 518 | this._citydbKmlDataSource = new Cesium.CzmlDataSource();
|
469 | 519 |
|
470 |
| - this._citydbKmlDataSource.load(this._url).then(function (dataSource) { |
| 520 | + this._citydbKmlDataSource.load(checkProxyUrl(this, this._url)).then(function (dataSource) { |
471 | 521 | assignLayerIdToDataSourceEntites(dataSource.entities, that._id);
|
472 | 522 | if (that._active) {
|
473 | 523 | cesiumViewer.dataSources.add(dataSource);
|
|
846 | 896 | } else if (this._urlSuffix == 'kml' || this._urlSuffix == 'kmz') {
|
847 | 897 | this._citydbKmlDataSource = new Cesium.KmlDataSource({
|
848 | 898 | camera: this._cesiumViewer.scene.camera,
|
849 |
| - canvas: this._cesiumViewer.scene.canvas |
| 899 | + canvas: this._cesiumViewer.scene.canvas, |
| 900 | + clampToGround: this._layerClampToGround |
850 | 901 | });
|
851 | 902 |
|
852 |
| - this._citydbKmlDataSource.load(this._url).then(function (dataSource) { |
| 903 | + this._citydbKmlDataSource.load(checkProxyUrl(this, this._url)).then(function (dataSource) { |
853 | 904 | assignLayerIdToDataSourceEntites(dataSource.entities, that._id);
|
854 | 905 | that._cesiumViewer.dataSources.add(dataSource);
|
855 | 906 | deferred.resolve(that);
|
|
859 | 910 | } else if (this._urlSuffix == 'czml') {
|
860 | 911 | this._citydbKmlDataSource = new Cesium.CzmlDataSource();
|
861 | 912 |
|
862 |
| - this._citydbKmlDataSource.load(this._url).then(function (dataSource) { |
| 913 | + this._citydbKmlDataSource.load(checkProxyUrl(this, this._url)).then(function (dataSource) { |
863 | 914 | assignLayerIdToDataSourceEntites(dataSource.entities, that._id);
|
864 | 915 | cesiumViewer.dataSources.add(dataSource);
|
865 | 916 | deferred.resolve(that);
|
|
0 commit comments