@@ -42,7 +42,9 @@ requirejs(['Cesium'], function(Cesium) {
42
42
Pile . prototype . calcHeights = function ( format ) {
43
43
var out = {
44
44
r : 0 ,
45
+ o : 0 ,
45
46
y : 0 ,
47
+ s : 0 ,
46
48
g : 0 ,
47
49
sum : 0
48
50
} ;
@@ -57,7 +59,11 @@ requirejs(['Cesium'], function(Cesium) {
57
59
if ( people . jps < 2 ) {
58
60
out . r += people . pop ;
59
61
} else if ( people . jps < 3 ) {
62
+ out . o += people . pop ;
63
+ } else if ( people . jps < 4 ) {
60
64
out . y += people . pop ;
65
+ } else if ( people . jps < 5 ) {
66
+ out . s += people . pop ;
61
67
} else {
62
68
out . g += people . pop ;
63
69
}
@@ -208,7 +214,7 @@ requirejs(['Cesium'], function(Cesium) {
208
214
* Gets or sets the name of the series to display. WebGL JSON is designed
209
215
* so that only one series is viewed at a time. Valid values are defined
210
216
* in the seriesNames property.
211
- * @memberof WebGLGlobeDataSource.prototype
217
+ * @memberOf WebGLGlobeDataSource.prototype
212
218
* @type {String }
213
219
*/
214
220
seriesToDisplay : {
@@ -347,14 +353,16 @@ requirejs(['Cesium'], function(Cesium) {
347
353
var peoples = new Pile ( geo . peoples ) ;
348
354
349
355
// TODO make calculation selection a dynamic feature
350
- // var heights = peoples.calcHeights(Peoples .heightFormat.JPS);
351
- var heights = peoples . calcHeights ( Pile . heightFormat . PROFESS ) ;
356
+ var heights = peoples . calcHeights ( Pile . heightFormat . JPS ) ;
357
+ // var heights = peoples.calcHeights(Pile.heightFormat.PROFESS);
352
358
353
359
// TODO break this into more functions so things are more readily callable when user options are made available.
354
360
355
361
// Calculate heights for each colored bar
356
362
heights . g = heights . g >> heightScale ;
363
+ heights . s = heights . s >> heightScale ;
357
364
heights . y = heights . y >> heightScale ;
365
+ heights . o = heights . o >> heightScale ;
358
366
heights . r = heights . r >> heightScale ;
359
367
360
368
@@ -366,9 +374,9 @@ requirejs(['Cesium'], function(Cesium) {
366
374
position : Cesium . Cartesian3 . fromDegrees ( longitude , latitude , heights . g / 2 ) ,
367
375
cylinder : {
368
376
length : heights . g ,
369
- topRadius : widthScale ,
377
+ topRadius : parseInt ( widthScale ) ,
370
378
slices : slices ,
371
- bottomRadius : widthScale ,
379
+ bottomRadius : parseInt ( widthScale ) ,
372
380
material : Cesium . Color . GREEN . withAlpha ( .4 )
373
381
} ,
374
382
seriesName : "g"
@@ -377,17 +385,36 @@ requirejs(['Cesium'], function(Cesium) {
377
385
h ++ ;
378
386
}
379
387
388
+ // Create "SpringGreeen" bar
389
+ if ( heights . s > 1 ) {
390
+ entities . add ( new Cesium . Entity ( {
391
+ id : "s" + ' index ' + x . toString ( ) ,
392
+ show : true ,
393
+ position : Cesium . Cartesian3 . fromDegrees ( longitude , latitude , heights . g + ( heights . s / 2 ) ) ,
394
+ cylinder : {
395
+ length : heights . s ,
396
+ topRadius : parseInt ( widthScale ) ,
397
+ slices : slices ,
398
+ bottomRadius : parseInt ( widthScale ) ,
399
+ material : Cesium . Color . GREENYELLOW . withAlpha ( .4 )
400
+ } ,
401
+ seriesName : "s"
402
+ } ) ) ;
403
+
404
+ h ++ ;
405
+ }
406
+
380
407
// Create Yellow bar
381
408
if ( heights . y > 1 ) {
382
409
entities . add ( new Cesium . Entity ( {
383
410
id : "y" + ' index ' + x . toString ( ) ,
384
411
show : true ,
385
- position : Cesium . Cartesian3 . fromDegrees ( longitude , latitude , heights . g + ( heights . y / 2 ) ) ,
412
+ position : Cesium . Cartesian3 . fromDegrees ( longitude , latitude , heights . g + heights . s + ( heights . y / 2 ) ) ,
386
413
cylinder : {
387
414
length : heights . y ,
388
- topRadius : widthScale ,
415
+ topRadius : parseInt ( widthScale ) ,
389
416
slices : slices ,
390
- bottomRadius : widthScale ,
417
+ bottomRadius : parseInt ( widthScale ) ,
391
418
material : Cesium . Color . YELLOW . withAlpha ( .4 )
392
419
} ,
393
420
seriesName : "y"
@@ -396,17 +423,36 @@ requirejs(['Cesium'], function(Cesium) {
396
423
h ++ ;
397
424
}
398
425
426
+ // Create Orange bar
427
+ if ( heights . o > 1 ) {
428
+ entities . add ( new Cesium . Entity ( {
429
+ id : "o" + ' index ' + x . toString ( ) ,
430
+ show : true ,
431
+ position : Cesium . Cartesian3 . fromDegrees ( longitude , latitude , heights . g + heights . s + heights . y + ( heights . o / 2 ) ) ,
432
+ cylinder : {
433
+ length : heights . o ,
434
+ topRadius : parseInt ( widthScale ) ,
435
+ slices : slices ,
436
+ bottomRadius : parseInt ( widthScale ) ,
437
+ material : Cesium . Color . ORANGE . withAlpha ( .4 )
438
+ } ,
439
+ seriesName : "o"
440
+ } ) ) ;
441
+
442
+ h ++ ;
443
+ }
444
+
399
445
// Create Red bar
400
446
if ( heights . r > 1 ) {
401
447
entities . add ( new Cesium . Entity ( {
402
448
id : "r" + ' index ' + x . toString ( ) ,
403
449
show : true ,
404
- position : Cesium . Cartesian3 . fromDegrees ( longitude , latitude , heights . g + heights . y + ( heights . r / 2 ) ) ,
450
+ position : Cesium . Cartesian3 . fromDegrees ( longitude , latitude , heights . g + heights . s + heights . y + heights . o + ( heights . r / 2 ) ) ,
405
451
cylinder : {
406
452
length : heights . r ,
407
- topRadius : widthScale ,
453
+ topRadius : parseInt ( widthScale ) ,
408
454
slices : slices ,
409
- bottomRadius : widthScale ,
455
+ bottomRadius : parseInt ( widthScale ) ,
410
456
material : Cesium . Color . RED . withAlpha ( .4 )
411
457
} ,
412
458
seriesName : "r"
@@ -437,12 +483,8 @@ requirejs(['Cesium'], function(Cesium) {
437
483
var dataSource = new WebGLGlobeDataSource ( ) ;
438
484
dataSource . loadUrl ( 'data/geo.json' ) . then ( function ( ) {
439
485
440
- //After the initial load, create buttons to let the user switch among series.
441
- function createSeriesSetter ( seriesName ) {
442
- return function ( ) {
443
- dataSource . seriesToDisplay = seriesName ;
444
- } ;
445
- }
486
+ // TODO UI Option population
487
+
446
488
} ) ;
447
489
448
490
Cesium . BingMapsApi . defaultKey = 'AjUK0-UaaYujmmlMT2iXlFADNDnttZM4F5ADqiCfdP-y_JojoP8089gU-nzdGhNe' ;
@@ -493,7 +535,7 @@ requirejs(['Cesium'], function(Cesium) {
493
535
// // layer.brightness = 0.8;
494
536
// }
495
537
496
- viewer . dataSources . add ( dataSource ) ;
538
+ viewer . dataSources . add ( dataSource ) . then ( ) ; // TODO use this to close the loading overlay
497
539
498
540
// Add credit footnote for Joshua Project
499
541
var credit = new Cesium . Credit ( 'Joshua Project' , 'assets/jp_logo_color.png' , 'http://joshuaproject.net' ) ;
0 commit comments