circData.js 27.4 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
$(function () {
  Cesium.Ion.defaultAccessToken =
    "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI5ODI4ZTYyZS1mMTg2LTQ5NGEtYjdiOS02ODg2NzVhNjc0MTAiLCJpZCI6MjkwNCwiaWF0IjoxNTM1MTA5OTAzfQ.kyDX_0ScvJBkYnvXI0DW5NfZbiaRL5ezwtAUhxYnk1Y";

  var imageryViewModels = [];
  imageryViewModels.push(
    new Cesium.ProviderViewModel({
      name: "Sentinel-2",
      iconUrl: Cesium.buildModuleUrl(
        "Widgets/Images/ImageryProviders/sentinel-2.png"
      ),
      tooltip: "Sentinel-2 cloudless.",
      creationFunction: function () {
        return new Cesium.IonImageryProvider({ assetId: 3954 });
      },
    })
  );

  imageryViewModels.push(
    new Cesium.ProviderViewModel({
      name: "Blue Marble",
      iconUrl: Cesium.buildModuleUrl(
        "Widgets/Images/ImageryProviders/blueMarble.png"
      ),
      tooltip: "Blue Marble Next Generation July, 2004 imagery from NASA.",
      creationFunction: function () {
        return new Cesium.IonImageryProvider({ assetId: 3845 });
      },
    })
  );

  var viewer = new Cesium.Viewer("cesiumContainer", {
    imageryProvider: new Cesium.IonImageryProvider({ assetId: 3954 }),

    terrainProvider: new Cesium.CesiumTerrainProvider({
      url: Cesium.IonResource.fromAssetId(1),
    }),
    scene3DOnly: false,
    shouldAnimate: true,
    animation: true,
    infoBox: true,
    baseLayerPicker: true,
    fullscreenButton: false,
    timeline: false,
    navigationHelpButton: true,
    navigationInstructionsInitiallyVisible: false,
    homeButton: false,
    selectionIndicator: true,
    geocoder: true,
    // imageryProviderViewModels: imageryViewModels
  });

  var layer = viewer.imageryLayers.addImageryProvider(
    new Cesium.IonImageryProvider({ assetId: 2 })
  );

  // var imageryLayer = viewer.imageryLayers.addImageryProvider(
  // 	new Cesium.IonImageryProvider({ assetId: 3954 })
  //   );

  var canvas = viewer.canvas;
  canvas.setAttribute("tabindex", "0"); // needed to put focus on the canvas
  canvas.addEventListener("click", function () {
    canvas.focus();
  });
  canvas.focus();
  var scene = viewer.scene;





//   viewer.scene.globe.depthTestAgainstTerrain = false;

//   var osmBuildings = Cesium.createOsmBuildings();
//   osmBuildings.readyPromise
//     .then(function (osmBuildings) {
//       viewer.scene.primitives.add(osmBuildings);
//     })
//     .otherwise(function (error) {
//       console.log(error);
//     });

//   osmBuildings.readyPromise.then(function (osmBuildings) {
//     var height = 60;
//     var cartographic = Cesium.Cartographic.fromCartesian(
//       osmBuildings.boundingSphere.center
//     );
//     var surface = Cesium.Cartesian3.fromRadians(
//       cartographic.longitude,
//       cartographic.latitude,
//       0.0
//     );
//     var offset = Cesium.Cartesian3.fromRadians(
//       cartographic.longitude,
//       cartographic.latitude,
//       height
//     );
//     var translation = Cesium.Cartesian3.subtract(
//       offset,
//       surface,
//       new Cesium.Cartesian3()
//     );

//     osmBuildings.modelMatrix = Cesium.Matrix4.fromTranslation(translation);

//   });

  // 	viewer.terrainProvider = new Cesium.CesiumTerrainProvider({
  // 		url: Cesium.IonResource.fromAssetId(1)
  // })

  const buildingHeightOffset = 60; //53

 


//   --------------------------------------------------------------------
var relativeHeight = 0.0;
var scale = 1.5

function getEastNorthUpTransform(tileset, relativeHeight) {
    var origin = tileset.boundingSphere.center;
    var cartographic = Cesium.Cartographic.fromCartesian(origin);
    cartographic.height = relativeHeight;
    origin = Cesium.Cartographic.toCartesian(cartographic);
    var enu = Cesium.Transforms.eastNorthUpToFixedFrame(origin);
    return enu;
}
130

131
132
133
134
135
136
137
138
function getScaleTransform(tileset, scale, relativeHeight) {
    var toGlobal = getEastNorthUpTransform(tileset, relativeHeight);
    var toLocal = Cesium.Matrix4.inverse(toGlobal, new Cesium.Matrix4());
    var localScale = new Cesium.Cartesian3(scale, scale, scale);
    var localScaleMatrix = Cesium.Matrix4.fromScale(localScale);
    var transform = Cesium.Matrix4.multiply(toGlobal, Cesium.Matrix4.multiply(localScaleMatrix, toLocal, new Cesium.Matrix4()), new Cesium.Matrix4());
    return transform;
}
139
140


141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
 
//////////////////////////////////////////////////////////////////////



  ///////////////////////////// Target  //////////////////////////

  var target_tileset = viewer.scene.primitives.add(
    new Cesium.Cesium3DTileset({
      url: "buildingTiles/circularTiles/target_black/tileset.json",
      show: true,
    })
  );

  target_tileset.readyPromise.then(function (target_tileset) {
  
    var height = buildingHeightOffset;
    var cartographic = Cesium.Cartographic.fromCartesian(
      target_tileset.boundingSphere.center
    );
    var surface = Cesium.Cartesian3.fromRadians(
      cartographic.longitude,
      cartographic.latitude,
      0.0
    );
    var offset = Cesium.Cartesian3.fromRadians(
      cartographic.longitude,
      cartographic.latitude,
      height
    );
    var translation = Cesium.Cartesian3.subtract(
      offset,
      surface,
      new Cesium.Cartesian3()
    );


    target_tileset.modelMatrix = Cesium.Matrix4.fromTranslation(
      translation
    );

  
  });

  target_tileset.readyPromise.then(function (target_tileset) {
    target_tileset.style = new Cesium.Cesium3DTileStyle({
      color: "color('black',0.5)",
    });
  });

//   target_tileset.root.transform = getScaleTransform(target_tileset, scale, relativeHeight);

  ///////////////////////////// Layer one //////////////////////////

  var L1 = viewer.scene.primitives.add(
    new Cesium.Cesium3DTileset({
      url: "buildingTiles/circularTiles/L1_yellow/tileset.json",
      show: true,
    })
  );

  L1.readyPromise.then(function (L1) {
    return zoomAll(L1);
  });

  L1.readyPromise.then(function (L1) {
    var R = 0; // roll
    var P = 0; // pitch
    var Yaw = 0; // yaw
    var height = buildingHeightOffset;
    var cartographic = Cesium.Cartographic.fromCartesian(
      L1.boundingSphere.center
    );
    var surface = Cesium.Cartesian3.fromRadians(
      cartographic.longitude,
      cartographic.latitude,
      0.0
    );
    var offset = Cesium.Cartesian3.fromRadians(
      cartographic.longitude,
      cartographic.latitude,
      height
    );
    var translation = Cesium.Cartesian3.subtract(
      offset,
      surface,
      new Cesium.Cartesian3()
    );

    //var rotMat = new Cesium.Matrix3();
    var rotation = new Cesium.Matrix3.fromHeadingPitchRoll(
      new Cesium.HeadingPitchRoll(Yaw, P, R)
    );

    L1.modelMatrix = Cesium.Matrix4.fromRotationTranslation(
      rotation,
      translation
    );

    return zoomAll(L1);
  });

  L1.readyPromise.then(function (L1) {
    L1.style = new Cesium.Cesium3DTileStyle({
      color: "color('yellow',1)",
    });
  });

  ///////////////////////////// Layer 2 //////////////////////////

  var L2 = viewer.scene.primitives.add(
    new Cesium.Cesium3DTileset({
      url: "buildingTiles/circularTiles/L2_red/tileset.json",
      show: true,
    })
  );

  L2.readyPromise.then(function (L2) {
    return zoomAll(L2);
  });

  L2.readyPromise.then(function (L2) {
    var R = 0; // roll
    var P = 0; // pitch
    var Yaw = 0; // yaw
    var height = buildingHeightOffset;
    var cartographic = Cesium.Cartographic.fromCartesian(
      L2.boundingSphere.center
    );
    var surface = Cesium.Cartesian3.fromRadians(
      cartographic.longitude,
      cartographic.latitude,
      0.0
    );
    var offset = Cesium.Cartesian3.fromRadians(
      cartographic.longitude,
      cartographic.latitude,
      height
    );
    var translation = Cesium.Cartesian3.subtract(
      offset,
      surface,
      new Cesium.Cartesian3()
    );

    //var rotMat = new Cesium.Matrix3();
    var rotation = new Cesium.Matrix3.fromHeadingPitchRoll(
      new Cesium.HeadingPitchRoll(Yaw, P, R)
    );

    L2.modelMatrix = Cesium.Matrix4.fromRotationTranslation(
      rotation,
      translation
    );

    return zoomAll(L2);
  });

  L2.readyPromise.then(function (L2) {
    L2.style = new Cesium.Cesium3DTileStyle({
      color: "color('red',1)",
    });
  });

  ///////////////////////////// Layer 3 //////////////////////////

  var L3 = viewer.scene.primitives.add(
    new Cesium.Cesium3DTileset({
      url: "buildingTiles/circularTiles/L3_green/tileset.json",
      show: true,
    })
  );

  L3.readyPromise.then(function (L3) {
    return zoomAll(L3);
  });

  L3.readyPromise.then(function (L3) {
    var R = 0; // roll
    var P = 0; // pitch
    var Yaw = 0; // yaw
    var height = buildingHeightOffset;
    var cartographic = Cesium.Cartographic.fromCartesian(
      L3.boundingSphere.center
    );
    var surface = Cesium.Cartesian3.fromRadians(
      cartographic.longitude,
      cartographic.latitude,
      0.0
    );
    var offset = Cesium.Cartesian3.fromRadians(
      cartographic.longitude,
      cartographic.latitude,
      height
    );
    var translation = Cesium.Cartesian3.subtract(
      offset,
      surface,
      new Cesium.Cartesian3()
    );

    //var rotMat = new Cesium.Matrix3();
    var rotation = new Cesium.Matrix3.fromHeadingPitchRoll(
      new Cesium.HeadingPitchRoll(Yaw, P, R)
    );

    L3.modelMatrix = Cesium.Matrix4.fromRotationTranslation(
      rotation,
      translation
    );

    return zoomAll(L3);
  });

  L3.readyPromise.then(function (L3) {
    L3.style = new Cesium.Cesium3DTileStyle({
      color: "color('green',1)",
    });
  });

  ///////////////////////////// Layer 3 //////////////////////////

  var L4 = viewer.scene.primitives.add(
    new Cesium.Cesium3DTileset({
      url: "buildingTiles/circularTiles/L4_brown/tileset.json",
      show: true,
    })
  );

  L4.readyPromise.then(function (L4) {
    return zoomAll(L4);
  });

  L4.readyPromise.then(function (L4) {
    var R = 0; // roll
    var P = 0; // pitch
    var Yaw = 0; // yaw
    var height = buildingHeightOffset;
    var cartographic = Cesium.Cartographic.fromCartesian(
      L4.boundingSphere.center
    );
    var surface = Cesium.Cartesian3.fromRadians(
      cartographic.longitude,
      cartographic.latitude,
      0.0
    );
    var offset = Cesium.Cartesian3.fromRadians(
      cartographic.longitude,
      cartographic.latitude,
      height
    );
    var translation = Cesium.Cartesian3.subtract(
      offset,
      surface,
      new Cesium.Cartesian3()
    );

    //var rotMat = new Cesium.Matrix3();
    var rotation = new Cesium.Matrix3.fromHeadingPitchRoll(
      new Cesium.HeadingPitchRoll(Yaw, P, R)
    );

    L4.modelMatrix = Cesium.Matrix4.fromRotationTranslation(
      rotation,
      translation
    );

    return zoomAll(L4);
  });

  L4.readyPromise.then(function (L4) {
    L4.style = new Cesium.Cesium3DTileStyle({
      color: "color('CORAL',1)",
    });
  });

  var camera = viewer.camera;
  var controller = scene.screenSpaceCameraController;
  var r = 0;
  var center = new Cesium.Cartesian3();

  var hpRoll = new Cesium.HeadingPitchRoll();
  var hpRange = new Cesium.HeadingPitchRange();
  var speed = 0.1;
  var deltaRadians = Cesium.Math.toRadians(3.0);

  var position = Cesium.Cartesian3.fromDegrees(9.190471, 48.786782, 0.0);
  var speedVector = new Cesium.Cartesian3();
  var fixedFrameTransform = Cesium.Transforms.localFrameToFixedFrameGenerator(
    "north",
    "west"
  );

  viewer.scene.globe.enableLighting = true; // set lighting to true

  var zoomAll = function (tileset) {
    return new Promise(function (resolve, reject) {
      if (!tileset) {
        reject("Tileset is undifined");
      }
      viewer.camera.viewBoundingSphere(
        tileset.boundingSphere,
        new Cesium.HeadingPitchRange(0, -0.5, 1500)
      );
      viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
      resolve();
    });
  };

   ///////////////// STOECKACH LOD 1

   var stoeckach = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
	url: 'buildingTiles/StoeckachLOD1/tileset.json',
	show: true
}));

stoeckach.readyPromise.then(function (stoeckach) {
458
459

		
460
461
462
463
464
	var height = buildingHeightOffset-1;
	var cartographic = Cesium.Cartographic.fromCartesian(stoeckach.boundingSphere.center);
	var surface = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, 0.0);
	var offset = Cesium.Cartesian3.fromRadians(cartographic.longitude, cartographic.latitude, height);
	var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
465

466
	stoeckach.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
467

468
});
469

470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
stoeckach.readyPromise.then(function(stoeckach){
	stoeckach.style = new Cesium.Cesium3DTileStyle({
		color: "color('white',1)",
	})
});

  // load streamline data from text file and parse it to polyline with multiple colors.

  var pos = [];
  var cols = [];
  var streamID = [];

  // d3.dsv(",", "results/polylines_circularData.csv").then(function(text) {
  d3.dsv(",", "results/Kirchturm1.csv").then(function (text) {
    //	console.log(text); // Hello, world!
    // var temp = text.split(',');

    var temp = text;
    for (var i = 0; i < temp.length; i++) {
      // use i+=7 when parsed as d3.text(...)
      pos.push([
        parseFloat(text[i].x),
        parseFloat(text[i].y),
        parseFloat(text[i].z),
      ]);
      cols.push([
        parseInt(text[i].R),
        parseInt(text[i].G),
        parseInt(text[i].B),
      ]);
      streamID.push(parseInt(text[i].ID));
      // use these lines if parsed as text. i.e. using d3.text(...)
      //pos.push([parseFloat(temp[i+0]), parseFloat(temp[i+1]), parseFloat(temp[i+2])]);
      //colors.push([parseFloat(temp[i+3]),parseFloat(temp[i+4]),parseFloat(temp[i+5])])
      //streamID.push([parseFloat(temp[i+6])]);
    }
506

507
508
509
510
511
    // const maxID = streamID.reduce(function(a, b) {
    // 	return Math.max(a, b);
    // });
    const maxID = text[text.length - 2].ID;
    const StreamHeightOffset = 70; //120;
512

513
514
    //find out the unique ids within the streamID array
    const uniqueStreamID = [...new Set(streamID)];
515

516
517
518
519
520
521
    //get index of each unique id, first element of those
    let sIDidx = [];
    for (var i = 0; i <= maxID; i++) {
      var tmpIdx = streamID.indexOf(i);
      if (tmpIdx !== -1) sIDidx.push(tmpIdx);
    }
522

523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
    for (var line = 1; line < uniqueStreamID.length; line++) {
      // Create and draw a polyline with per vertex colors
      positions = [];
      colors = [];
      for (i = sIDidx[line - 1]; i < sIDidx[line] - 1; ++i) {
        positions.push(
          Cesium.Cartesian3.fromDegrees(
            pos[i][0],
            pos[i][1],
            pos[i][2] + StreamHeightOffset
          )
        );
        colors.push(
          Cesium.Color.fromBytes(cols[i][0], cols[i][1], cols[i][2], 200)
        );
      }
      // For per segment coloring, supply the colors option with
      // an array of colors for each vertex.  Also set the
      // colorsPerVertex option to true.
      viewer.scene.primitives.add(
        new Cesium.Primitive({
          geometryInstances: new Cesium.GeometryInstance({
            geometry: new Cesium.PolylineGeometry({
              positions: positions,
              width: 10.0,
              vertexFormat: Cesium.PolylineColorAppearance.VERTEX_FORMAT,
              colors: colors,
              colorsPerVertex: true,
            }),
          }),
          appearance: new Cesium.PolylineColorAppearance(),
        })
      );
    }
  });

  // HTML overlay for showing feature name on mouseover
  var nameOverlay = document.createElement("div");
  viewer.container.appendChild(nameOverlay);
  nameOverlay.className = "backdrop";
  nameOverlay.style.display = "none";
  nameOverlay.style.position = "absolute";
  nameOverlay.style.bottom = "0";
  nameOverlay.style.left = "0";
  nameOverlay.style["pointer-events"] = "none";
  nameOverlay.style.padding = "4px";
  nameOverlay.style.backgroundColor = "green";

  // Information about the currently selected feature
  var selected = {
    feature: undefined,
    originalColor: new Cesium.Color(),
  };

  // Information about the currently highlighted feature
  var highlighted = {
    feature: undefined,
    originalColor: new Cesium.Color(),
  };

  var selectedEntity = new Cesium.Entity();

  // Color a feature yellow on hover.
  viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(movement) {
    // If a feature was previously highlighted, undo the highlight
    if (Cesium.defined(highlighted.feature)) {
      highlighted.feature.color = highlighted.originalColor;
      highlighted.feature = undefined;
    }
592

593
594
595
596
597
598
    // Pick a new feature
    var pickedFeature = viewer.scene.pick(movement.endPosition);
    if (!Cesium.defined(pickedFeature)) {
      nameOverlay.style.display = "none";
      return;
    }
599

600
601
602
603
604
605
606
607
608
609
    // A feature was picked, so show it's overlay content
    nameOverlay.style.display = "block";
    nameOverlay.style.bottom =
      viewer.canvas.clientHeight - movement.endPosition.y + "px";
    nameOverlay.style.left = movement.endPosition.x + "px";
    var name = pickedFeature.getProperty("name");
    if (!Cesium.defined(name)) {
      name = pickedFeature.getProperty("id");
    }
    nameOverlay.textContent = name;
610

611
612
613
614
615
616
617
    // Highlight the feature if it's not already selected.
    if (pickedFeature !== selected.feature) {
      highlighted.feature = pickedFeature;
      Cesium.Color.clone(pickedFeature.color, highlighted.originalColor);
      pickedFeature.color = Cesium.Color.AQUA;
    }
  }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
618

619
620
621
622
623
  // Color a feature on selection and show metadata in the InfoBox.
  var clickHandler = viewer.screenSpaceEventHandler.getInputAction(
    Cesium.ScreenSpaceEventType.LEFT_CLICK
  );
  viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
624
625
    // If a feature was previously selected, undo the highlight
    if (Cesium.defined(selected.feature)) {
626
627
      selected.feature.color = selected.originalColor;
      selected.feature = undefined;
628
629
630
631
632
    }

    // Pick a new feature
    var pickedFeature = viewer.scene.pick(movement.position);
    if (!Cesium.defined(pickedFeature)) {
633
634
      clickHandler(movement);
      return;
635
636
637
638
    }

    // Select the feature if it's not already selected
    if (selected.feature === pickedFeature) {
639
      return;
640
641
642
643
644
    }
    selected.feature = pickedFeature;

    // Save the selected feature's original color
    if (pickedFeature === highlighted.feature) {
645
646
      Cesium.Color.clone(highlighted.originalColor, selected.originalColor);
      highlighted.feature = undefined;
647
    } else {
648
      Cesium.Color.clone(pickedFeature.color, selected.originalColor);
649
650
651
652
653
654
    }

    // Highlight newly selected feature
    pickedFeature.color = Cesium.Color.WHITE;

    // Set feature infobox description
655
    var featureName = pickedFeature.getProperty("name");
656
    selectedEntity.name = featureName;
657
658
    selectedEntity.description =
      'Loading <div class="cesium-infoBox-loading"></div>';
659
    viewer.selectedEntity = selectedEntity;
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
    selectedEntity.description =
      '<table class="cesium-infoBox-defaultTable"><tbody>' +
      "<tr><th>Bld function</th><td>" +
      pickedFeature.getProperty("Function") +
      "</td></tr>" +
      "<tr><th>gmlID</th><td>" +
      pickedFeature.getProperty("gmlIDStr") +
      "</td></tr>" +
      "<tr><th>Dachgeschossausbau</th><td>" +
      pickedFeature.getProperty("dachgeschossausbau") +
      "</td></tr>" +
      "<tr><th>Lon</th><td>" +
      pickedFeature.getProperty("Longitude") +
      "</td></tr>" +
      "<tr><th>Lat</th><td>" +
      pickedFeature.getProperty("Latitude") +
      "</td></tr>" +
      "<tr><th>Geschossflaeche (sqm)</th><td>" +
      pickedFeature.getProperty("geschossflaeche") +
      "</td></tr>" +
      "<tr><th>YearOfConstruction</th><td>" +
      pickedFeature.getProperty("YearOfConstruction") +
      "</td></tr>" +
      "<tr><th>MeasuredHeight (m):</th><td>" +
      pickedFeature.getProperty("MeasuredHeight") +
      "</td></tr>" +
      "<tr><th>HoeheFirst (m)</th><td>" +
      pickedFeature.getProperty("hoeheFirst") +
      "</td></tr>" +
      "<tr><th>HoeheTrauf (m)</th><td>" +
      pickedFeature.getProperty("hoeheTrauf") +
      "</td></tr>" +
      "<tr><th>Grundflaeche (sqm)</th><td>" +
      pickedFeature.getProperty("grundflaeche") +
      "</td></tr>" +
      "<tr><th>StoreysAboveGround: </th><td>" +
      pickedFeature.getProperty("StoreysAboveGround") +
      "</td></tr>" +
      "<tr><th>StoreysBelowGround: </th><td>" +
      pickedFeature.getProperty("StoreysBelowGround") +
      "</td></tr>" +
      "<tr><th>Durchfahrtsstr.: </th><td>" +
      pickedFeature.getProperty("ThoroughfareName") +
      "</td></tr>" +
      "<tr><th>Hausnummer.: </th><td>" +
      pickedFeature.getProperty("ThoroughfareNumber") +
      "</td></tr>" +
      "</tbody></table>";
  }, Cesium.ScreenSpaceEventType.LEFT_CLICK);

  var scene = viewer.scene;
  var longitude;
  var latitude;
  var fid;
  var featuretype;
  var gmlid;
  var selID = new Array();
  var cnt = 0;
  var lastPickedObject;

  var viewModel = {
    rightClickAction: "properties",
    middleClickAction: "hide",
  };

  Cesium.knockout.track(viewModel);

  var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);

  handler.setInputAction(function (movement) {
    // makes camera go to a certain position given by the coordinates below

    var feature = viewer.scene.pick(movement.position);
    if (!Cesium.defined(feature)) {
      console.log("no feature defined");
      return;
    }
    var propertyNames = feature.getPropertyNames();
    var lat = feature.getProperty("Latitude");
    var lon = feature.getProperty("Longitude");
    var tmp = feature.getProperty("YearOfConstruction");

    viewer.camera.flyTo({
      destination: Cesium.Cartesian3.fromDegrees(lon, lat, 900),
      maximumHeight: 1500.0,
      orientation: {
        heading: Cesium.Math.toRadians(0.0),
        pitch: Cesium.Math.toRadians(-90.0),
        roll: Cesium.Math.toRadians(45.0),
      },
      duration: 2,
    });
  }, Cesium.ScreenSpaceEventType.LEFT_CLICK);

  handler.setInputAction(function (movement) {
    var feature = viewer.scene.pick(movement.position);
    if (!Cesium.defined(feature)) {
      return;
    }
    var action = viewModel.rightClickAction;
    action === "properties";
    printProperties(movement, feature);
  }, Cesium.ScreenSpaceEventType.RIGHT_CLICK);

  function printProperties(movement, feature) {
    console.log("Properties:");
    var propertyNames = feature.getPropertyNames();
    var length = propertyNames.length;
    for (var i = 0; i < length; ++i) {
      var propertyName = propertyNames[i];
      if (
        propertyName == "gmlIdALKISLageBezeichnung_1" ||
        propertyName == "gmlIdALKISLageBezeichnung_2" ||
        propertyName == "gmlIdALKISLageBezeichnung_3" ||
        propertyName == "gmlIdALKISLageBezeichnung_4" ||
        propertyName == "gmlIdALKISLageBezeichnung_5" ||
        propertyName == "gmlIdALKISLageBezeichnung_6"
      )
        console.log("  " + propertyName + ": " + "zensiert");
      else
        console.log(
          "  " + propertyName + ": " + feature.getProperty(propertyName)
        );
    }
784

785
786
787
    // Evaluate feature description
    //console.log('Description : ' + tileset.style.meta.description.evaluate(scene.frameState, feature));
  }
788

789
790
791
792
793
  handler.setInputAction(function (movement) {
    var feature = viewer.scene.pick(movement.position);
    if (!Cesium.defined(feature)) {
      return;
    }
794

795
796
797
798
799
    var action = viewModel.middleClickAction;
    if (action === "hide") {
      feature.show = false;
    }
  }, Cesium.ScreenSpaceEventType.MIDDLE_CLICK);
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835

  /*
	return Cesium.when(tileset.readyPromise).then(function (tileset) {
		tileset.style = new Cesium.Cesium3DTileStyle({

			color: {

				conditions: [
					

					["${Latitude} >= 48.8170", "color('purple', 0.5)"],

					["${Latitude} >= 48.7950", "color('red')"],

					["${Latitude} >= 48.7830", "color('orange')"],

					["${Latitude} >= 48.7710", "color('yellow')"],

					["${Latitude} >= 48.7690", "color('lime')"],

					["${Latitude} >= 48.7570", "color('cyan')"],

					["${Latitude} >= 48.7470", "color('CORNFLOWERBLUE')"],

					["${Latitude} >= 48.7370", "color('DARKMAGENTA')"],

					["true", "color('lightblue')"]

				]

			}

		});
	});
*/

836
  function showLegend() {
837
    $("#legend").css("display", "block");
838
839
  }
  function hideLegend() {
840
    $("#legend").css("display", "none");
841
  }
842

843
844
  // Legend - Colour Table
  function emptyColourTable() {
845
    $(".inner").empty();
846
  }
847

848
  /*
849
850
851
852
853
854
855
856
857
858
859
860
861
function setHeightTable() {
    $(".inner").append( "<table>" +
        "<tr><td class='outlined' bgcolor='red'>&nbsp;&nbsp;&nbsp;&nbsp;</td><td> 113007 </td></tr>" +
        "<tr><td class='outlined' bgcolor='#ff6b21'></td><td> 113001 </td></tr>" +
        "<tr><td class='outlined' bgcolor='#ffb400'></td><td> 112996 </td></tr>" +
		"<tr><td class='outlined' bgcolor='yellow'></td><td> 112991</td></tr>" +
        "<tr><td class='outlined' bgcolor='#00ff00'></td><td> 112986 </td></tr>" +                
       	"<tr><td class='outlined' bgcolor='cyan'></td><td> 112981 </td></tr>" +
        "<tr><td class='outlined' bgcolor='blue'></td><td> 112976 </td></tr>" +
    "</table>" );
}
*/

862
  /*
863
864
865
866
867
868
869
870
871
function setHeightTable() {
    $(".inner").append( "<table>" +
        "<tr><td class='outlined' bgcolor='red'>&nbsp;&nbsp;&nbsp;&nbsp;</td><td> x </td></tr>" +        
        "<tr><td class='outlined' bgcolor='green'></td><td> y </td></tr>" +
        "<tr><td class='outlined' bgcolor='blue'></td><td> z </td></tr>" +
    "</table>" );
}
*/

872
873
874
875
876
877
878
879
880
881
882
883
  function setHeightTable() {
    $(".inner").append(
      "<table>" +
        "<tr><td class='outlined' bgcolor='red'>&nbsp;&nbsp;&nbsp;&nbsp;</td><td> >30 </td></tr>" +
        "<tr><td class='outlined' bgcolor='#ff6b21'></td><td> 24 </td></tr>" +
        "<tr><td class='outlined' bgcolor='#FFB300'></td><td> 18</td></tr>" +
        "<tr><td class='outlined' bgcolor='#BFBF00'></td><td> 12 </td></tr>" +
        "<tr><td class='outlined' bgcolor='#0080FF',0)'></td><td> 6 </td></tr>" +
        "<tr><td class='outlined' bgcolor='#0000FF',0)'></td><td> 0 </td></tr>" +
        "</table>"
    );
  }
884

885
886
  // return Cesium.when(target_tileset.readyPromise).then(function (target_tileset) {
  // 	target_tileset.style = new Cesium.Cesium3DTileStyle({
887

888
  // 		color: "color('black',1)",
889

890
  // 		/*color: {
891

892
  // 			conditions: [
893

894
  // 				['Number(${MeasuredHeight}) >= 40', 'rgb(255,0,0)'],
895

896
  // 				['Number(${MeasuredHeight}) >= 30.', 'rgb(255, 93 , 0)'],
897

898
  // 				['Number(${MeasuredHeight}) >= 25', 'rgb(255, 180, 0)'],
899

900
  // 				['Number(${MeasuredHeight}) >= 20', 'rgb(255,255,0)'],
901

902
  // 				['Number(${MeasuredHeight}) >= 15', 'rgb(0,255,0)'],
903

904
  // 				['Number(${MeasuredHeight}) >= 10', 'rgb(0,0,255)'],
905

906
907
908
909
910
  // 				['Number(${MeasuredHeight}) >= 7.5', 'rgb(75, 0, 130)'],

  // 				['Number(${MeasuredHeight}) >= 4', 'rgb(248, 100, 221)'],

  // 				['Number(${MeasuredHeight}) >= 0.1', 'rgb(248, 100, 221)'],
911

912
  // 				['true', 'color("lightblue")']
913

914
  // 			]
915

916
917
  // 		}
  // 		*/
918

919
920
921
922
923
924
  // 	});
  // 	showLegend();
  // 	setHeightTable();
  // });

  /*
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
	return Cesium.when(tileset.readyPromise).then(function (tileset) {
		tileset.style = new Cesium.Cesium3DTileStyle({

			color: {

				conditions: [
				
					['Number(${YearOfConstruction}) >= 2015', 'rgb(127,201,127)'],

					['Number(${YearOfConstruction}) >= 2005', 'rgb(190,174,212)'],

					['Number(${YearOfConstruction}) >= 1990', 'rgb(253,192,134)'],

					['Number(${YearOfConstruction}) >= 1975', 'rgb(255,255,153)'],

					['Number(${YearOfConstruction}) >= 1950', 'rgb(56,108,176)'],

					['Number(${YearOfConstruction}) >= 1920', 'rgb(240,2,127)'],

					['Number(${YearOfConstruction}) >= 1900', 'rgb(191,91,23)'],

					['Number(${YearOfConstruction}) >= 1800', 'rgb(102,102,102)'],

					['true', 'color("lightblue")']

				]

			}

		});
	});	*/
956
});