@@ -80,6 +80,11 @@ var addLayerViewModel = {
80
80
layerDataType : "" ,
81
81
gltfVersion : "" ,
82
82
thematicDataUrl : "" ,
83
+ thematicDataSource : "" ,
84
+ tableType : "" ,
85
+ // googleSheetsApiKey: "",
86
+ // googleSheetsRanges: "",
87
+ // googleSheetsClientId: "",
83
88
cityobjectsJsonUrl : "" ,
84
89
minLodPixels : "" ,
85
90
maxLodPixels : "" ,
@@ -167,7 +172,7 @@ function intiClient() {
167
172
if ( callGeocodingService != true ) {
168
173
var gmlId = cesiumViewer . geocoder . viewModel . searchText ;
169
174
info . cancel = true ;
170
- cesiumViewer . geocoder . viewModel . searchText = "Searching now......."
175
+ cesiumViewer . geocoder . viewModel . searchText = "Searching now......." ;
171
176
zoomToObjectById ( gmlId , function ( ) {
172
177
cesiumViewer . geocoder . viewModel . searchText = gmlId ;
173
178
} , function ( ) {
@@ -279,6 +284,11 @@ function observeActiveLayer() {
279
284
addLayerViewModel . layerDataType = selectedLayer . layerDataType ;
280
285
addLayerViewModel . gltfVersion = selectedLayer . gltfVersion ;
281
286
addLayerViewModel . thematicDataUrl = selectedLayer . thematicDataUrl ;
287
+ addLayerViewModel . thematicDataSource = selectedLayer . thematicDataSource ;
288
+ addLayerViewModel . tableType = selectedLayer . tableType ;
289
+ // addLayerViewModel.googleSheetsApiKey = selectedLayer.googleSheetsApiKey;
290
+ // addLayerViewModel.googleSheetsRanges = selectedLayer.googleSheetsRanges;
291
+ // addLayerViewModel.googleSheetsClientId = selectedLayer.googleSheetsClientId;
282
292
addLayerViewModel . cityobjectsJsonUrl = selectedLayer . cityobjectsJsonUrl ;
283
293
addLayerViewModel . minLodPixels = selectedLayer . minLodPixels ;
284
294
addLayerViewModel . maxLodPixels = selectedLayer . maxLodPixels ;
@@ -378,6 +388,11 @@ function getLayersFromUrl() {
378
388
layerDataType : Cesium . defaultValue ( layerConfig . layerDataType , "COLLADA/KML/glTF" ) ,
379
389
gltfVersion : Cesium . defaultValue ( layerConfig . gltfVersion , "2.0" ) ,
380
390
thematicDataUrl : Cesium . defaultValue ( layerConfig . spreadsheetUrl , "" ) ,
391
+ thematicDataSource : Cesium . defaultValue ( layerConfig . thematicDataSource , "GoogleSheets" ) ,
392
+ tableType : Cesium . defaultValue ( layerConfig . tableType , "Horizontal" ) ,
393
+ // googleSheetsApiKey: Cesium.defaultValue(layerConfig.googleSheetsApiKey, ""),
394
+ // googleSheetsRanges: Cesium.defaultValue(layerConfig.googleSheetsRanges, ""),
395
+ // googleSheetsClientId: Cesium.defaultValue(layerConfig.googleSheetsClientId, ""),
381
396
cityobjectsJsonUrl : Cesium . defaultValue ( layerConfig . cityobjectsJsonUrl , "" ) ,
382
397
active : ( layerConfig . active == "true" ) ,
383
398
minLodPixels : Cesium . defaultValue ( layerConfig . minLodPixels , 140 ) ,
@@ -458,13 +473,21 @@ function saveLayerSettings() {
458
473
applySaving ( 'layerDataType' , activeLayer ) ;
459
474
applySaving ( 'gltfVersion' , activeLayer ) ;
460
475
applySaving ( 'thematicDataUrl' , activeLayer ) ;
476
+ applySaving ( 'thematicDataSource' , activeLayer ) ;
477
+ applySaving ( 'tableType' , activeLayer ) ;
478
+ // applySaving('googleSheetsApiKey', activeLayer);
479
+ // applySaving('googleSheetsRanges', activeLayer);
480
+ // applySaving('googleSheetsClientId', activeLayer);
461
481
applySaving ( 'cityobjectsJsonUrl' , activeLayer ) ;
462
482
applySaving ( 'minLodPixels' , activeLayer ) ;
463
483
applySaving ( 'maxLodPixels' , activeLayer ) ;
464
484
applySaving ( 'maxSizeOfCachedTiles' , activeLayer ) ;
465
485
applySaving ( 'maxCountOfVisibleTiles' , activeLayer ) ;
466
486
console . log ( activeLayer ) ;
467
487
488
+ // Update Data Source
489
+ thematicDataSourceAndTableTypeDropdownOnchange ( ) ;
490
+
468
491
// update GUI:
469
492
var nodes = document . getElementById ( 'citydb_layerlistpanel' ) . childNodes ;
470
493
for ( var i = 0 ; i < nodes . length ; i += 3 ) {
@@ -518,6 +541,8 @@ function loadLayerGroup(_layers) {
518
541
519
542
// show/hide glTF version based on the value of Layer Data Type
520
543
layerDataTypeDropdownOnchange ( ) ;
544
+
545
+ thematicDataSourceAndTableTypeDropdownOnchange ( ) ;
521
546
}
522
547
} ) . otherwise ( function ( error ) {
523
548
CitydbUtil . showAlertWindow ( "OK" , "Error" , error . message ) ;
@@ -792,6 +817,11 @@ function layersToQuery() {
792
817
gltfVersion : layer . gltfVersion ,
793
818
active : layer . active ,
794
819
spreadsheetUrl : layer . thematicDataUrl ,
820
+ thematicDataSource : layer . thematicDataSource ,
821
+ tableType : layer . tableType ,
822
+ // googleSheetsApiKey: layer.googleSheetsApiKey,
823
+ // googleSheetsRanges: layer.googleSheetsRanges,
824
+ // googleSheetsClientId: layer.googleSheetsClientId,
795
825
cityobjectsJsonUrl : layer . cityobjectsJsonUrl ,
796
826
minLodPixels : layer . minLodPixels ,
797
827
maxLodPixels : layer . maxLodPixels == - 1 ? Number . MAX_VALUE : layer . maxLodPixels ,
@@ -881,31 +911,58 @@ function zoomToObjectById(gmlId, callBackFunc, errorCallbackFunc) {
881
911
var activeLayer = webMap . _activeLayer ;
882
912
if ( Cesium . defined ( activeLayer ) ) {
883
913
var cityobjectsJsonData = activeLayer . cityobjectsJsonData ;
884
- var obj = cityobjectsJsonData [ gmlId ] ;
914
+ if ( ! cityobjectsJsonData ) {
915
+ if ( Cesium . defined ( errorCallbackFunc ) ) {
916
+ errorCallbackFunc . call ( this ) ;
917
+ }
918
+ } else {
919
+ var obj = cityobjectsJsonData [ gmlId ] ;
920
+ }
885
921
if ( obj ) {
886
922
var lon = ( obj . envelope [ 0 ] + obj . envelope [ 2 ] ) / 2.0 ;
887
923
var lat = ( obj . envelope [ 1 ] + obj . envelope [ 3 ] ) / 2.0 ;
888
924
flyToMapLocation ( lat , lon , callBackFunc ) ;
889
925
} else {
926
+ // TODO
890
927
var thematicDataUrl = webMap . activeLayer . thematicDataUrl ;
891
- var promise = fetchDataFromGoogleFusionTable ( gmlId , thematicDataUrl ) ;
892
- Cesium . when ( promise , function ( result ) {
893
- var centroid = result [ "CENTROID" ] ;
894
- if ( centroid ) {
895
- var res = centroid . match ( / \( ( [ ^ ) ] + ) \) / ) [ 1 ] . split ( "," ) ;
896
- var lon = parseFloat ( res [ 0 ] ) ;
897
- var lat = parseFloat ( res [ 1 ] ) ;
898
- flyToMapLocation ( lat , lon , callBackFunc ) ;
899
- } else {
928
+ dataSourceController . fetchData ( gmlId , function ( result ) {
929
+ if ( ! result ) {
900
930
if ( Cesium . defined ( errorCallbackFunc ) ) {
901
931
errorCallbackFunc . call ( this ) ;
902
932
}
933
+ } else {
934
+ var centroid = result [ "CENTROID" ] ;
935
+ if ( centroid ) {
936
+ var res = centroid . match ( / \( ( [ ^ ) ] + ) \) / ) [ 1 ] . split ( "," ) ;
937
+ var lon = parseFloat ( res [ 0 ] ) ;
938
+ var lat = parseFloat ( res [ 1 ] ) ;
939
+ flyToMapLocation ( lat , lon , callBackFunc ) ;
940
+ } else {
941
+ if ( Cesium . defined ( errorCallbackFunc ) ) {
942
+ errorCallbackFunc . call ( this ) ;
943
+ }
944
+ }
903
945
}
904
- } , function ( ) {
905
- if ( Cesium . defined ( errorCallbackFunc ) ) {
906
- errorCallbackFunc . call ( this ) ;
907
- }
908
- } ) ;
946
+ } , 1000 ) ;
947
+
948
+ // var promise = fetchDataFromGoogleFusionTable(gmlId, thematicDataUrl);
949
+ // Cesium.when(promise, function (result) {
950
+ // var centroid = result["CENTROID"];
951
+ // if (centroid) {
952
+ // var res = centroid.match(/\(([^)]+)\)/)[1].split(",");
953
+ // var lon = parseFloat(res[0]);
954
+ // var lat = parseFloat(res[1]);
955
+ // flyToMapLocation(lat, lon, callBackFunc);
956
+ // } else {
957
+ // if (Cesium.defined(errorCallbackFunc)) {
958
+ // errorCallbackFunc.call(this);
959
+ // }
960
+ // }
961
+ // }, function () {
962
+ // if (Cesium.defined(errorCallbackFunc)) {
963
+ // errorCallbackFunc.call(this);
964
+ // }
965
+ // });
909
966
}
910
967
} else {
911
968
if ( Cesium . defined ( errorCallbackFunc ) ) {
@@ -949,6 +1006,11 @@ function addNewLayer() {
949
1006
layerDataType : addLayerViewModel . layerDataType . trim ( ) ,
950
1007
gltfVersion : addLayerViewModel . gltfVersion . trim ( ) ,
951
1008
thematicDataUrl : addLayerViewModel . thematicDataUrl . trim ( ) ,
1009
+ thematicDataSource : addLayerViewModel . thematicDataSource . trim ( ) ,
1010
+ tableType : addLayerViewModel . tableType . trim ( ) ,
1011
+ // googleSheetsApiKey: addLayerViewModel.googleSheetsApiKey.trim(),
1012
+ // googleSheetsRanges: addLayerViewModel.googleSheetsRanges.trim(),
1013
+ // googleSheetsClientId: addLayerViewModel.googleSheetsClientId.trim(),
952
1014
cityobjectsJsonUrl : addLayerViewModel . cityobjectsJsonUrl . trim ( ) ,
953
1015
minLodPixels : addLayerViewModel . minLodPixels ,
954
1016
maxLodPixels : addLayerViewModel . maxLodPixels == - 1 ? Number . MAX_VALUE : addLayerViewModel . maxLodPixels ,
@@ -1108,18 +1170,33 @@ function createInfoTable(gmlid, cesiumEntity, citydbLayer) {
1108
1170
var thematicDataUrl = citydbLayer . thematicDataUrl ;
1109
1171
cesiumEntity . description = "Loading feature information..." ;
1110
1172
1111
- fetchDataFromGoogleFusionTable ( gmlid , thematicDataUrl ) . then ( function ( kvp ) {
1112
- console . log ( kvp ) ;
1113
- var html = '<table class="cesium-infoBox-defaultTable" style="font-size:10.5pt"><tbody>' ;
1114
- for ( var key in kvp ) {
1115
- html += '<tr><td>' + key + '</td><td>' + kvp [ key ] + '</td></tr>' ;
1116
- }
1117
- html += '</tbody></table>' ;
1173
+ dataSourceController . fetchData ( gmlid , function ( kvp ) {
1174
+ if ( ! kvp ) {
1175
+ cesiumEntity . description = 'No feature information found' ;
1176
+ } else {
1177
+ console . log ( kvp ) ;
1178
+ var html = '<table class="cesium-infoBox-defaultTable" style="font-size:10.5pt"><tbody>' ;
1179
+ for ( var key in kvp ) {
1180
+ html += '<tr><td>' + key + '</td><td>' + kvp [ key ] + '</td></tr>' ;
1181
+ }
1182
+ html += '</tbody></table>' ;
1118
1183
1119
- cesiumEntity . description = html ;
1120
- } ) . otherwise ( function ( error ) {
1121
- cesiumEntity . description = 'No feature information found' ;
1122
- } ) ;
1184
+ cesiumEntity . description = html ;
1185
+ }
1186
+ } , 1000 ) ;
1187
+
1188
+ // fetchDataFromGoogleFusionTable(gmlid, thematicDataUrl).then(function (kvp) {
1189
+ // console.log(kvp);
1190
+ // var html = '<table class="cesium-infoBox-defaultTable" style="font-size:10.5pt"><tbody>';
1191
+ // for (var key in kvp) {
1192
+ // html += '<tr><td>' + key + '</td><td>' + kvp[key] + '</td></tr>';
1193
+ // }
1194
+ // html += '</tbody></table>';
1195
+ //
1196
+ // cesiumEntity.description = html;
1197
+ // }).otherwise(function (error) {
1198
+ // cesiumEntity.description = 'No feature information found';
1199
+ // });
1123
1200
}
1124
1201
1125
1202
function fetchDataFromGoogleSpreadsheet ( gmlid , thematicDataUrl ) {
@@ -1237,7 +1314,44 @@ function layerDataTypeDropdownOnchange() {
1237
1314
} else {
1238
1315
document . getElementById ( "gltfVersionDropdownRow" ) . style . display = "" ;
1239
1316
}
1317
+ addLayerViewModel [ "layerDataType" ] = layerDataTypeDropdown . options [ layerDataTypeDropdown . selectedIndex ] . value ;
1318
+ }
1319
+
1320
+ function thematicDataSourceAndTableTypeDropdownOnchange ( ) {
1321
+ var thematicDataSourceDropdown = document . getElementById ( "thematicDataSourceDropdown" ) ;
1322
+ var selectedThematicDataSource = thematicDataSourceDropdown . options [ thematicDataSourceDropdown . selectedIndex ] . value ;
1323
+
1324
+ var tableTypeDropdown = document . getElementById ( "tableTypeDropdown" ) ;
1325
+ var selectedTableType = tableTypeDropdown . options [ tableTypeDropdown . selectedIndex ] . value ;
1326
+
1327
+ addLayerViewModel [ "thematicDataSource" ] = selectedThematicDataSource ;
1328
+ addLayerViewModel [ "tableType" ] = selectedTableType ;
1329
+
1330
+ // if (selectedThematicDataSource == "GoogleSheets") {
1331
+ // document.getElementById("rowGoogleSheetsApiKey").style.display = "table-row";
1332
+ // document.getElementById("rowGoogleSheetsRanges").style.display = "table-row";
1333
+ // document.getElementById("rowGoogleSheetsClientId").style.display = "table-row";
1334
+ // } else {
1335
+ // document.getElementById("rowGoogleSheetsApiKey").style.display = "none";
1336
+ // document.getElementById("rowGoogleSheetsRanges").style.display = "none";
1337
+ // document.getElementById("rowGoogleSheetsClientId").style.display = "none";
1338
+ // }
1339
+
1340
+ var options = {
1341
+ // name: "",
1342
+ // type: "",
1343
+ // provider: "",
1344
+ uri : addLayerViewModel . thematicDataUrl ,
1345
+ tableType : selectedTableType ,
1346
+ // ranges: addLayerViewModel.googleSheetsRanges,
1347
+ // apiKey: addLayerViewModel.googleSheetsApiKey,
1348
+ // clientId: addLayerViewModel.googleSheetsClientId
1349
+ } ;
1350
+ dataSourceController = new DataSourceController ( selectedThematicDataSource , options ) ;
1240
1351
}
1241
1352
1242
1353
// Mobile layouts and functionalities
1243
1354
var mobileController = new MobileController ( ) ;
1355
+
1356
+ // Mashup Data Source Service
1357
+ var dataSourceController ;
0 commit comments