-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
3368 lines (3095 loc) · 111 KB
/
index.html
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
130
131
132
133
134
135
136
137
138
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
458
459
460
461
462
463
464
465
466
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
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
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
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
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
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
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
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
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
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<meta name="viewport" content="width=device-width" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta http-equiv="content-script-type" content="text/javascript" />
<meta http-equiv="content-style-type" content="text/css" />
<title>Starlit Night - yet another online planetarium</title>
<link rel="stylesheet" type="text/css" href="base.css" title="default" />
<style type="text/css">
<!--
body{
font: Normal 12px 'Lucida Grande', Verdana, Helvetica, sans-serif;
background-color: #000000;
margin:0 0 0 0;
color: #bbbbbb;
}
#discription{
position:absolute;
top:0;
left:0;
font-size:small;
z-index:100;
}
#time_and_place{
position:absolute;
top:0;
right:0;
font-size:x-small;
color: #555555;
z-index:101;
}
* {-webkit-user-select: none;}
.selectable{-webkit-user-select: auto;}
//-->
</style>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAAosFovQHF7cisY7zEBt8UxQP9PrctsMlg7A-AAMVDBfLMBEwIBRapr0qfk7TELyiJqLPBCRwyLJAPg&hl=en" type="text/javascript"></script>
<script src="lib/terminator.js" type="text/javascript"></script>
<script src="lib/ephemeris.js" type="text/javascript"></script>
<script src="lib/sgp4.js" type="text/javascript"></script>
<script type="text/javascript"><!--
/*
history
0.1.0 (20090825):
initial release.
0.1.1 (20090827):
redesign message dialog for IE, fix malfunctions on opera.
0.1.2 (20090906):
change the date query in permalink from JST to UTC.
0.1.3 (20090924):
the mulfunction with bit.ly is fixed. Methods were changed from "JavaScriptCliantAPI" to "REST API"
0.1.4 (20090927):
malfanction that constellation labels did not dissappere if constellation lines disabled is fixed
scroll bars are removed.
numbers in permalink are shortened.
0.2.0 (20091106):
new feature: satellite pass
0.2.1 (20091107):
accuracy of the satellite's set/rize time is improved.
the starting point of satellite prediction is changed to midnight of the day.
satellite pass will be disabled when place or time is changed.
0.3.0 (20100605):
new feature: special objects (especialy for Hayabusa)
0.3.1 (20100625):
iphone/ipad support
0.3.2 (20100825):
sun altitudes are added on "Satellite" panel
satellite pass is added on "Place" panel
"set as default" checkbox added on "Place" panel
cookies are not saved on unload
0.4.0 (20100906):
new feature: Canvas fillText Labels.
new feature: "Save as image" on Permalink panel.
0.4.1 (20100908):
the error on the position of the sun is fixed
0.4.2 (20110426):
IE9 support
0.4.3 (20110626):
android support
0.4.4 (20110915):
small correction for zoom and scroll algorithm
---
Compatibility
0.4.2 (20110426)
Mac OSX
Safari 5.0
FireFox 3.6
Chrome 10.0
Opera 11.10
Windows
IE 9.0.8112.16421
Safari 5.0.5
Chrome 10.0.648.205
FireFox 3.6.13
FireFox 4.0.1
Opera 11.10
iOS
Android
---
versioning schemes
"major.minor.revision (update)"
The major number is increased when there are significant jumps in functionality,
the minor number is incremented when only minor features or significant fixes have been added,
and the revision number is incremented when minor bugs are fixed.
*/
function Pref(){
this.release = "20110426";
this.version = "0.4.2" ;
}
function createXMLhttpObject(){
XMLhttpObject = false;
if(window.XMLHttpRequest) {
XMLhttpObject = new XMLHttpRequest();
}else if(window.ActiveXObject) {
try {
XMLhttpObject = new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
XMLhttpObject = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return XMLhttpObject;
}
function DataLoader(callback,data,resp,async) {
XMLhttpObject=createXMLhttpObject();
if (!XMLhttpObject){return;}
XMLhttpObject.open("GET", data, async);
XMLhttpObject.send(null);
if(async==false){
try{
if(resp == "xml"){
var data = XMLhttpObject.responseXML;
}else{
var data = XMLhttpObject.responseText;
}
eval(callback + "(data)");
}catch(e){
return;
}
}else{
try{
XMLhttpObject.onreadystatechange = function() {
if(XMLhttpObject.readyState == 4){
if(XMLhttpObject.status == 200){
if(resp == "xml"){
var data = XMLhttpObject.responseXML;
}else{
var data = XMLhttpObject.responseText;
}
eval(callback + "(data)");
}
}else{
return;
}
}
}catch(e){
alert("error!")
return;
}
}
}
function StarLoader(jsonData){
Pref.prototype.star_catalogue = eval("("+jsonData+")");
Pref.prototype.loaded_data += 1;
return;
}
function ConstellationLoader(jsonData){
Pref.prototype.constellation_catalogue = eval("("+jsonData+")");
Pref.prototype.loaded_data += 1;
return;
}
function PlanetLoader(jsonData){
var pref = new Pref();
var data = eval("("+jsonData+")");
Pref.prototype.loaded_data += 1;
switch(data.name){
case "Earth":
Pref.prototype.earth_data = data;
break;
case "Mercury":
Pref.prototype.mercury_data = data;
break;
case "Venus":
Pref.prototype.venus_data = data;
break;
case "Mars":
Pref.prototype.mars_data = data;
break;
case "Jupiter":
Pref.prototype.jupiter_data = data;
break;
case "Saturn":
Pref.prototype.saturn_data = data;
break;
case "Neptune":
Pref.prototype.neptune_data = data;
break;
case "Uranus":
Pref.prototype.uranus_data = data;
break;
}
return;
}
TLELoader = function(xmlData){
var first_line = xmlData.getElementsByTagName('first_line')[0].childNodes[0].nodeValue;
var second_line = xmlData.getElementsByTagName('second_line')[0].childNodes[0].nodeValue;
Pref.prototype.sat_first_line=decodeURI(first_line);
Pref.prototype.sat_second_line=decodeURI(second_line);
Pref.prototype.tle_loaded=true;
}
function SpecialObjectsLoader(jsonData){
Pref.prototype.special_objects_catalogue = eval("("+jsonData+")");
Pref.prototype.special_objects_loaded=true;
return;
}
function drawSky(){
var pref = new Pref();
var scale = Number(pref.scale);
var canvas_height = pref.canvas_height;
var canvas_width = pref.canvas_width;
var max_radius = Number(pref.max_radius);
removeLabels();
conObj.globalAlpha = 1.0;
conObj.fillStyle = "rgba(0,0,0,1)";
conObj.strokeStyle = "rgba(0,0,0,0)";
conObj.clearRect(0,0,canvas_width,canvas_height)
conObj.fillRect(0,0,canvas_width,canvas_height)
conObj.fillStyle = "rgba(255,255,255,0)";
conObj.strokeStyle = "rgba(255,255,255,0)";
var offset_azimuth = pref.offset_azimuth + pref.default_offset_azimuth;
var offset_altitude = pref.offset_altitude + pref.default_offset_altitude;
if(pref.aa_lines=="show"){
showAzimuthLines(offset_azimuth,offset_altitude,pref.quality);
showAltitudeLines(offset_azimuth,offset_altitude,pref.quality);
}
conObj.globalAlpha = 1.0;
if(pref.constellation_labels == "show"||pref.constellation_lines == "show"){
ShowConstellation(offset_azimuth,offset_altitude);
}
conObj.strokeStyle = "rgba(255,255,255,0)";
showStars(offset_azimuth,offset_altitude);
showPlanets(offset_azimuth,offset_altitude);
if(pref.sun_visibility == "true"){
showSun(offset_azimuth,offset_altitude);
}
if(pref.moon_visibility == "true"){
showMoon(offset_azimuth,offset_altitude);
}
if(pref.azi_labels == "show"){
showAzimuthLabel(offset_azimuth,offset_altitude);
}
if(pref.markers == "show"){
showMarkers(offset_azimuth,offset_altitude);
}
if(pref.sat_pass == "show"){
showSatellitePass(offset_azimuth,offset_altitude);
}
if(pref.special_objects != ""){
ShowSpecialObjects(offset_azimuth,offset_altitude);
}
delete pref;
return;
}
function showStars(offset_azimuth,offset_altitude){
var pref = new Pref();
var coord_data = pref.db_stars_coord;
var coord_data_length = coord_data.length
if(pref.quality=="preview"){
var star_num = pref.min_star_num;
}else{
var star_num = coord_data_length;
}
coord_array0 = [];
for(var i=0; i<star_num; i++){
var c0 = new RotateCoord(coord_data[i]["x_axis"],coord_data[i]["y_axis"],coord_data[i]["z_axis"],offset_azimuth,0,0);
var tmp_array=new Array;
tmp_array[0]=c0.x_axis;
tmp_array[1]=c0.y_axis;
tmp_array[2]=c0.z_axis;
coord_array0.push(tmp_array);
}
coord_array1 = [];
for(var i=0; i<star_num; i++){
var c1 = new RotateCoord(coord_array0[i][0],coord_array0[i][1],coord_array0[i][2],0,offset_altitude,0);
var tmp_array=new Array;
tmp_array[0]=c1.x_axis;
tmp_array[1]=c1.y_axis;
tmp_array[2]=c1.z_axis;
coord_array1.push(tmp_array);
}
for(var i=0; i<star_num; i++){
var c = new RotateCoord(coord_array1[i][0],coord_array1[i][1],coord_array1[i][2],90,90,0);
var r = new ZoomCoord(Number(c.x_axis),Number(c.y_axis),Number(c.z_axis));
var x_axis = (-1)*r.x_axis*pref.max_radius*pref.scale + pref.canvas_width/2;
//var z_axis = r.z_axis*pref.max_radius*pref.scale + pref.canvas_height*0.75+pref.canvas_height*0.25*(offset_altitude/90)*pref.scale;
var z_axis = r.z_axis*pref.max_radius*pref.scale + pref.canvas_height*0.5;
//removeLabel(coord_data[i].name);
if(0>c.y_axis){
if(coord_data[i].name && pref.star_labels=="show" && pref.quality!="preview" && x_axis<Number(pref.canvas_width) && z_axis<Number(pref.canvas_height)){
showLabel(coord_data[i].name,x_axis,z_axis,"")
}
drawStar(coord_data[i].vmag,coord_data[i].sp,x_axis,z_axis);
}
}
}
function drawStar(vmag,sp,x_axis,y_axis){
var pref = new Pref();
var stars_img = pref.stars_img;
var sp_value = sp.slice(0, 1);
switch(sp_value){
case "O": var r=200, g=200, b=255, h=0; break;
case "B": var r=227, g=227, b=255, h=10; break;
case "A": var r=255, g=255, b=255, h=20; break;
case "F": var r=255, g=255, b=227, h=30; break;
case "G": var r=255, g=255, b=200, h=40; break;
case "K": var r=255, g=227, b=200, h=50; break;
case "M": var r=255, g=200, b=200, h=60; break;
default: var r=255, g=255, b=255, h=20; break;
}
if(pref.quality=="preview"){
if (vmag<=1.5){
conObj.globalAlpha = 0.7;
conObj.fillStyle = "rgba("+r +"," +g + "," + b + ",0.8)";
conObj.beginPath();
conObj.arc(x_axis,y_axis,2.0,0,Math.PI*2,1);
conObj.stroke();
conObj.fill();
}else if(vmag>1.5 && vmag<=2.5){
conObj.globalAlpha = 0.7;
conObj.fillStyle = "rgba("+r +"," +g + "," + b + ",0.5)";
conObj.beginPath();
conObj.arc(x_axis,y_axis,2.0,0,Math.PI*2,1);
conObj.stroke();
conObj.fill();
}else if(vmag>2.5 && vmag<=3.5){
conObj.globalAlpha = 0.7;
conObj.fillStyle = "rgba("+r +"," +g + "," + b + ",0.8)";
conObj.beginPath();
conObj.arc(x_axis,y_axis,1.5,0,Math.PI*2,1);
conObj.stroke();
conObj.fill();
}else if(vmag>3.5 && vmag<=4.5){
conObj.globalAlpha = 0.7;
conObj.fillStyle = "rgba("+r +"," +g + "," + b + ",0.8)";
conObj.fillRect(x_axis,y_axis,1,1);
}else if(vmag>4.5 && vmag<=5.5){
conObj.globalAlpha = 0.7;
conObj.fillStyle = "rgba("+r +"," +g + "," + b + ",0.5)";
conObj.fillRect(x_axis,y_axis,1,1);
}else if(vmag>5.5){
conObj.globalAlpha = 0.7;
conObj.fillStyle = "rgba("+r +"," +g + "," + b + ",0.3)";
conObj.fillRect(x_axis,y_axis,1,1);
}
}else{
if (vmag<=1.5){
conObj.globalAlpha = 1.0;
conObj.drawImage(stars_img,0,h,10,10,x_axis-5,y_axis-5,10,10);
}else if(vmag>1.5 && vmag<=2.5){
conObj.globalAlpha = 0.7;
conObj.drawImage(stars_img,10,h,10,10,x_axis-5,y_axis-5,10,10);
}else if(vmag>2.5 && vmag<=3.5){
conObj.globalAlpha = 0.7;
conObj.drawImage(stars_img,20,h,10,10,x_axis-5,y_axis-5,10,10);
}else if(vmag>3.5 && vmag<=4.5){
conObj.globalAlpha = 0.7;
conObj.fillStyle = "rgba("+r +"," +g + "," + b + ",.5)";
conObj.beginPath();
conObj.arc(x_axis,y_axis,1.0,0,Math.PI*2,1);
conObj.stroke();
conObj.fill();
}else if(vmag>4.5 && vmag<=5.5){
conObj.globalAlpha = 0.7;
conObj.fillStyle = "rgba("+r +"," +g + "," + b + ",.5)";
conObj.fillRect(x_axis,y_axis,1,1);
}else if(vmag>5.5){
conObj.globalAlpha = 0.7;
conObj.fillStyle = "rgba("+r +"," +g + "," + b + ",.3)";
conObj.fillRect(x_axis,y_axis,1,1);
}
}
delete pref;
}
function showSun(offset_azimuth,offset_altitude){
var pref = new Pref();
var radius = pref.max_radius/90*0.5*pref.scale;
if(radius<16){radius=16}
var r = new calcOrientation(Number(pref.db_sun_coord["x_axis"]),Number(pref.db_sun_coord["y_axis"]),Number(pref.db_sun_coord["z_axis"]),offset_azimuth,offset_altitude);
if(0>r.y_axis){
/*
if(pref.quality=="preview"){
conObj.strokeStyle = "rgba(255,255,255,0)";
conObj.fillStyle = "rgba(255,255,255,0.6)";
conObj.beginPath();
conObj.arc(r.x_axis,r.z_axis,6,0,Math.PI*2,1);
conObj.stroke();
conObj.fill();
}else{
*/
conObj.drawImage(pref.sun_img,0,0,30,30,Number(r.x_axis)-15,Number(r.z_axis)-15,30,30);
// }
}
delete pref;
return;
}
function showMoon(offset_azimuth,offset_altitude){
var rad=Math.PI/180;
var pref = new Pref();
var radius = pref.max_radius/90*0.5*pref.scale;
if(radius<18){radius=18}
var moon_phase = pref.db_moon_coord["moon_phase"]
var h = (60-Math.ceil(moon_phase*2))*20;
if(h>1180){h=1180}
var r = new calcOrientation(Number(pref.db_moon_coord["x_axis"]),Number(pref.db_moon_coord["y_axis"]),Number(pref.db_moon_coord["z_axis"]),offset_azimuth,offset_altitude);
if(0>r.y_axis){
/*
if(pref.quality=="preview"){
conObj.strokeStyle = "rgba(255,255,255,0)";
conObj.fillStyle = "rgba(255,255,255,0.6)";
conObj.beginPath();
conObj.arc(r.x_axis,r.z_axis,6,0,Math.PI*2,1);
conObj.stroke();
conObj.fill();
}else{
*/
var r2 = new calcOrientation(Number(pref.db_moon_coord["ref_x"]),Number(pref.db_moon_coord["ref_y"]),Number(pref.db_moon_coord["ref_z"]),offset_azimuth,offset_altitude);
var tmp_angle = Math.atan2(Number(r.z_axis-r2.z_axis),Number(r.x_axis-r2.x_axis))/rad - pref.default_offset_azimuth
var p_angle = Number(pref.db_moon_coord["p_angle"]);
var angle = tmp_angle+p_angle
if(angle<0){angle=angle%360+360};
if(angle>360){angle=angle%360};
conObj.save();
conObj.translate(r.x_axis,r.z_axis);
conObj.rotate(angle*rad);
conObj.drawImage(pref.moon_img,0,Number(h),20,20,0-radius/2,0-radius/2,radius,radius);
conObj.restore();
// }
}
delete pref;
return;
}
function showPlanets(offset_azimuth,offset_altitude){
var pref = new Pref();
var coord_data =pref.db_planets_coord;
var data_length = coord_data.length;
var coord_array0 = [];
for(var i=0; i<data_length; i++){
var c0 = new RotateCoord(coord_data[i]["x_axis"],coord_data[i]["y_axis"],coord_data[i]["z_axis"],offset_azimuth,0,0);
var tmp_array=new Array;
tmp_array[0]=c0.x_axis;
tmp_array[1]=c0.y_axis;
tmp_array[2]=c0.z_axis;
coord_array0.push(tmp_array);
}
var coord_array1 = [];
for(var i=0; i<data_length; i++){
var c1 = new RotateCoord(coord_array0[i][0],coord_array0[i][1],coord_array0[i][2],0,offset_altitude,0);
var tmp_array=new Array;
tmp_array[0]=c1.x_axis;
tmp_array[1]=c1.y_axis;
tmp_array[2]=c1.z_axis;
coord_array1.push(tmp_array);
}
for(var i=0; i<data_length; i++){
var c = new RotateCoord(coord_array1[i][0],coord_array1[i][1],coord_array1[i][2],90,90,0);
var r = new ZoomCoord(Number(c.x_axis),Number(c.y_axis),Number(c.z_axis));
var x_axis = (-1)*r.x_axis*pref.max_radius*pref.scale + pref.canvas_width/2;
var z_axis = r.z_axis*pref.max_radius*pref.scale + pref.canvas_height*0.5;
if(0>c.y_axis){
drawPlanet(coord_data[i].name,x_axis,z_axis);
if(pref.planet_labels=="show" && pref.quality!="preview" && x_axis<pref.canvas_width && z_axis<pref.canvas_height){
showLabel(coord_data[i].name,x_axis,z_axis,"")
}
}
}
}
function drawPlanet(name,x_axis,z_axis){
var pref = new Pref();
/*
if(pref.quality=="preview"){
conObj.globalAlpha = 0.7;
conObj.fillStyle = "rgba(255,255,255,0.8)";
conObj.beginPath();
conObj.arc(x_axis,z_axis,2.0,0,Math.PI*2,1);
conObj.stroke();
conObj.fill();
}else{
*/
var planets_img = pref.planets_img;
switch(name){
case "Mercury": var h=0; break;
case "Venus": var h=12; break;
case "Mars": var h=24; break;
case "Jupiter": var h=36; break;
case "Saturn": var h=48; break;
case "Neptune": var h=60; break;
case "Uranus": var h=72; break;
}
conObj.globalAlpha = 1.0;
conObj.drawImage(planets_img,0,h,12,12,x_axis-6,z_axis-6,12,12);
//}
delete pref;
return;
}
function ShowConstellation(offset_azimuth,offset_altitude){
var pref = new Pref();
var coord_data =pref.db_constellation_coord;
var data_length = coord_data.length;
for(var i=0; i<data_length; i++){
//removeLabel(coord_data[i].Name);
if(pref.quality !="preview"){
var r = new calcOrientation(Number(coord_data[i].x_axis),Number(coord_data[i].y_axis),Number(coord_data[i].z_axis),offset_azimuth,offset_altitude);
if(0>r.y_axis && coord_data[i].altitude>0 && pref.constellation_labels == "show"){
showLabel(coord_data[i].Name,r.x_axis,r.z_axis,"b29700","")
}
if(pref.constellation_lines == "show"){
var start_array = coord_data[i].line_start;
var start_alt_array = coord_data[i].start_alt;
var end_array = coord_data[i].line_end;
var end_alt_array = coord_data[i].end_alt;
var start_coord_array = new calcOrientation2(start_array,offset_azimuth,offset_altitude);
var end_coord_array = new calcOrientation2(end_array,offset_azimuth,offset_altitude);
for(k=0;k<start_coord_array.length;k++){
if(0>start_coord_array[k][1] && 0>end_coord_array[k][1] && (start_alt_array[k]>0 && end_alt_array[k]>0) ){
conObj.strokeStyle = "rgba(180,150,0,0.6)";
conObj.beginPath();
conObj.moveTo(start_coord_array[k][0],start_coord_array[k][2]);
conObj.lineTo(end_coord_array[k][0],end_coord_array[k][2]);
conObj.stroke()
}
}
}
}
}
}
function showAzimuthLines(offset_azimuth,offset_altitude){
var pref = new Pref();
if(pref.quality=="preview"){
//var v1=17, v2=4, v3=20;
var v1=35, v2=8, v3=10;
}else{
var v1=35, v2=8, v3=10;
}
for(i=0;i<=v1;i++){
for(j=0;j<=v2;j++){
var coord = new ConvertCoord(i*v3,j*v3);
var r = new calcOrientation(coord.x_axis,coord.y_axis,coord.z_axis,offset_azimuth,offset_altitude);
if(0>r.y_axis){
conObj.strokeStyle = "rgba(100,100,100,0.4)";
}else{
conObj.strokeStyle = "rgba(100,100,100,0)";
}
if(j==0){
var prev_x = r.x_axis;
var prev_z = r.z_axis;
}else{
conObj.beginPath();
conObj.moveTo(prev_x,prev_z);
conObj.lineTo(r.x_axis,r.z_axis);
conObj.stroke()
var prev_x = r.x_axis;
var prev_z = r.z_axis;
}
}
}
delete pref;
return;
}
function showAltitudeLines(offset_azimuth,offset_altitude){
var pref = new Pref();
if(pref.user_agent == "ipad" || pref.user_agent == "iphone" || pref.user_agent == "android"){
if(pref.quality=="preview"){
var v1=18,v2=3,v3=20;
}else{
var v1=36,v2=7,v3=10;
}
}else{
var v1=36,v2=7,v3=10;
}
for(i=0;i<=v2;i++){
for(j=0;j<=v1;j++){
var coord = new ConvertCoord(j*v3,i*v3);
var r = new calcOrientation(coord.x_axis,coord.y_axis,coord.z_axis,offset_azimuth,offset_altitude);
if(0>r.y_axis){
conObj.strokeStyle = "rgba(100,100,100,0.4)";
}else{
conObj.strokeStyle = "rgba(100,100,100,0)";
}
if(j==0){
var prev_x = r.x_axis;
var prev_z = r.z_axis;
}else{
conObj.beginPath();
conObj.moveTo(prev_x,prev_z);
conObj.lineTo(r.x_axis,r.z_axis);
conObj.stroke()
var prev_x = r.x_axis;
var prev_z = r.z_axis;
}
}
}
delete pref;
return;
}
function showAzimuthLabel(offset_azimuth,offset_altitude){
var pref = new Pref();
for(i=0;i<=4;i++){
switch(i){
case 0:var azi=0,alt=2,h=0; break;
case 1:var azi=90,alt=2,h=20; break;
case 2:var azi=180,alt=2,h=40; break;
case 3:var azi=270,alt=2,h=60; break;
case 4:var azi=0,alt=90,h=80; break;
}
var coord = new ConvertCoord(azi,alt);
var r = new calcOrientation(coord.x_axis,coord.y_axis,coord.z_axis,offset_azimuth,offset_altitude);
if(0>r.y_axis){
conObj.drawImage(pref.az_text,0,Number(h),20,20,Number(r.x_axis)-10,Number(r.z_axis)-10,20,20);
}
}
delete pref;
return;
}
function showLabel(str,x,y,color,url){
var pref=new Pref();
if(!url&& conObj.fillText && pref.user_agent !="iphone" && pref.user_agent !="ipad" && pref.user_agent !="android"){
conObj.font = "11px Arial"
if(color =="b29700"){
conObj.fillStyle = "rgba(250,200,0,0.8)"
}else{
conObj.fillStyle = "rgba(200,200,200,0.8)"
}
conObj.fillText(str,x+5 ,y);
}else if(x<pref.canvas_width && y<pref.canvas_height){
var label_element = document.createElement('div');
if(!color){color = "#777"}
label_element.id = str
label_element.setAttribute('id', str);
label_element.setAttribute('class', "label");
var label_style = label_element.style;
label_style.cssText = 'font-size:x-small;color:'+ color;
label_style.position = 'absolute';
label_style.top = y;
label_style.left = x + 5;
label_style.zIndex = '100';
if(url){
label_element.innerHTML = '<a href="' + url + '" style="color:#777">' + str + '</a>';
}else{
label_element.innerHTML = str;
}
var perent_obj = document.getElementById("main");
perent_obj.appendChild(label_element);
}
}
function removeLabel(str){
if(document.getElementById(str)){
var label_id=document.getElementById(str);
//var Body = document.getElementsByTagName("body")[0];
var Body = document.getElementById("main");
Body.removeChild(label_id);
return;
}else{
return;
}
}
function removeLabels(){
var div_array = document.getElementsByTagName("div");
var div_array_length = div_array.length;
var label_array = new Array();
for (i=0; i<div_array_length; i++){
if(div_array[i].className == "label"){
label_array.push(div_array[i]);
}
}
var label_array_length = label_array.length;
//var Body = document.getElementsByTagName("body")[0];
var Body = document.getElementById("main");
for(i=0;i<label_array_length;i++){
Body.removeChild(label_array[i]);
}
return;
}
function showMarkers(offset_azimuth,offset_altitude){
var pref = new Pref();
var coord_data =pref.db_markers_coord;
var data_length = coord_data.length;
var coord_array0 = [];
for(var i=0; i<data_length; i++){
var c0 = new RotateCoord(coord_data[i]["x_axis"],coord_data[i]["y_axis"],coord_data[i]["z_axis"],offset_azimuth,0,0);
var tmp_array=new Array;
tmp_array[0]=c0.x_axis;
tmp_array[1]=c0.y_axis;
tmp_array[2]=c0.z_axis;
coord_array0.push(tmp_array);
}
var coord_array1 = [];
for(var i=0; i<data_length; i++){
var c1 = new RotateCoord(coord_array0[i][0],coord_array0[i][1],coord_array0[i][2],0,offset_altitude,0);
var tmp_array=new Array;
tmp_array[0]=c1.x_axis;
tmp_array[1]=c1.y_axis;
tmp_array[2]=c1.z_axis;
coord_array1.push(tmp_array);
}
for(var i=0; i<data_length; i++){
var c = new RotateCoord(coord_array1[i][0],coord_array1[i][1],coord_array1[i][2],90,90,0);
var r = new ZoomCoord(Number(c.x_axis),Number(c.y_axis),Number(c.z_axis));
var x_axis = (-1)*r.x_axis*pref.max_radius*pref.scale + pref.canvas_width/2;
//var z_axis = r.z_axis*pref.max_radius*pref.scale + pref.canvas_height*0.75+pref.canvas_height*0.25*(offset_altitude/90)*pref.scale;
var z_axis = r.z_axis*pref.max_radius*pref.scale + pref.canvas_height*0.5;
//removeLabel(coord_data[i].str);
if(0>c.y_axis){
drawMarker(x_axis,z_axis);
showLabel(coord_data[i].str,x_axis,z_axis)
}
}
}
function drawMarker(x,y){
conObj.strokeStyle = "rgba(255,0,0,0.6)";
conObj.fillStyle = "rgba(255,255,255,0)";
conObj.beginPath();
conObj.arc(x,y,8,0,Math.PI*2,1);
conObj.moveTo(x-10,y)
conObj.lineTo(x-4,y);
conObj.moveTo(x+10,y)
conObj.lineTo(x+4,y);
conObj.moveTo(x,y-10)
conObj.lineTo(x,y-4);
conObj.moveTo(x,y+10)
conObj.lineTo(x,y+4);
conObj.stroke();
conObj.fill();
}
function setMarkerbyRaDec(ra,dec,str){
var pref = new Pref();
if(!pref.marker_catalogue){
Pref.prototype.marker_catalogue = new Array();
}
marker_array = [];
marker_array["str"]=str;
marker_array["ra"]=ra;
marker_array["dec"]=dec;
Pref.prototype.marker_catalogue.push(marker_array);
return;
}
UpdateMarkerPosition = function(){
var pref = new Pref();
var date = pref.date;
var ephem = new Ephemeris();
var db_markers_coord=[];
var data_length=pref.marker_catalogue.length;
for(i=0; i<data_length; i++){
var position = ephem.to_horizontal(date,Number(pref.observers_longitude),Number(pref.observers_latitude),Number(pref.marker_catalogue[i].ra),Number(pref.marker_catalogue[i].dec));
if(position.altitude>0){
var coord = new ConvertCoord(position.azimuth,position.altitude);
var tmp_array=new Array;
tmp_array["x_axis"]=coord.x_axis;
tmp_array["y_axis"]=coord.y_axis;
tmp_array["z_axis"]=coord.z_axis;
tmp_array["str"]=pref.marker_catalogue[i].str;
tmp_array["ra"]=pref.marker_catalogue[i].ra;
tmp_array["dec"]=pref.marker_catalogue[i].dec;
tmp_array["azimuth"]=position.azimuth
tmp_array["altitude"]=position.altitude;
db_markers_coord.push(tmp_array);
}
}
delete pref;
Pref.prototype.db_markers_coord = db_markers_coord;
return;
}
// Change Orientation (Rotate the global and local axis)
calcOrientation = function(x_axis,y_axis,z_axis,offset_azimuth,offset_altitude){
var pref = new Pref();
var c0 = new RotateCoord(x_axis,y_axis,z_axis,Number(offset_azimuth),0,0);
var c1 = new RotateCoord(c0.x_axis,c0.y_axis,c0.z_axis,0,Number(offset_altitude),0);
var c = new RotateCoord(c1.x_axis,c1.y_axis,c1.z_axis,90,90,0);
var r = new ZoomCoord(Number(c.x_axis),Number(c.y_axis),Number(c.z_axis));
var x_axis = (-1)*r.x_axis*pref.max_radius*pref.scale + pref.canvas_width/2;
var z_axis = r.z_axis*pref.max_radius*pref.scale + pref.canvas_height*0.5;
var y_axis = c.y_axis;
this.x_axis = x_axis;
this.z_axis = z_axis;
this.y_axis = y_axis;
delete pref;
return
}
calcOrientation2 = function(coord_data,offset_azimuth,offset_altitude){
var pref = new Pref();
var data_length = coord_data.length;
var results_array = [];
var coord_array0 = [];
for(var i=0; i<data_length; i++){
var c0 = new RotateCoord(coord_data[i][0],coord_data[i][1],coord_data[i][2],offset_azimuth,0,0);
var tmp_array=new Array;
tmp_array[0]=c0.x_axis;
tmp_array[1]=c0.y_axis;
tmp_array[2]=c0.z_axis;
coord_array0.push(tmp_array);
}
var coord_array1 = [];
for(var i=0; i<data_length; i++){
var c1 = new RotateCoord(coord_array0[i][0],coord_array0[i][1],coord_array0[i][2],0,offset_altitude,0);
var tmp_array=new Array;
tmp_array[0]=c1.x_axis;
tmp_array[1]=c1.y_axis;
tmp_array[2]=c1.z_axis;
coord_array1.push(tmp_array);
}
for(var i=0; i<data_length; i++){
var c = new RotateCoord(coord_array1[i][0],coord_array1[i][1],coord_array1[i][2],90,90,0);
var r = new ZoomCoord(Number(c.x_axis),Number(c.y_axis),Number(c.z_axis));
var x_axis = (-1)*r.x_axis*pref.max_radius*pref.scale + pref.canvas_width/2;
//var z_axis = r.z_axis*pref.max_radius*pref.scale + pref.canvas_height*0.75+pref.canvas_height*0.25*(offset_altitude/90)*pref.scale;
var z_axis = r.z_axis*pref.max_radius*pref.scale + pref.canvas_height*0.5;
var y_axis = c.y_axis;
var t = [x_axis,y_axis,z_axis];
results_array.push(t);
}
delete pref;
return results_array;
}
ZoomCoord = function(x1,y1,z1){
var rad=Math.PI/180;
var pref = new Pref();
var focal_length = pref.focal_length
var y2 = pref.distance;
var delta_y = Math.abs(y1)+Math.abs(y2);
var x3 = Number(x1)*(focal_length/delta_y);
var z3 = Number(z1)* (focal_length/delta_y);
this.x_axis = x3
this.z_axis = z3
delete pref;
return;
}
RotateCoord = function(x0,y0,z0,xr,yr,zr){
var rad=Math.PI/180;
if(xr != 0){
var x1 = x0;
var y1 = y0*Math.cos(xr*rad)-z0*Math.sin(xr*rad);
var z1 = y0*Math.sin(xr*rad)+z0*Math.cos(xr*rad);
}else{
var x1 = x0,y1 = y0,z1 = z0;
}
if(yr != 0){
var x2 = x1*Math.cos(yr*rad)+z1*Math.sin(yr*rad);;
var y2 = y1;
var z2 = (-x1)*Math.sin(yr*rad)+z1*Math.cos(yr*rad);
}else{
var x2 = x1,y2 = y1,z2 = z1;
}
if(zr != 0){
var x3 = x2*Math.cos(zr*rad)-y2*Math.sin(zr*rad);
var y3 = x2*Math.sin(zr*rad)+y2*Math.cos(zr*rad);
var z3 = z2;
}else{
var x3=x2, y3=y2, z3=z2;
}
this.x_axis=x3;
this.y_axis=y3;
this.z_axis=z3;
return;
}
//Update Position (Convert RaDec to XYZ on screen)
UpdateStarPosition = function(){
var pref = new Pref();
var date = pref.date;
var ephem = new Ephemeris();
var db_stars_coord=[];
for(i=0; i<pref.max_star_num; i++){
var position = ephem.to_horizontal(date,Number(pref.observers_longitude),Number(pref.observers_latitude),Number(pref.star_catalogue.object[i].RAh),Number(pref.star_catalogue.object[i].DEd));
if(position.altitude>0){
var coord = new ConvertCoord(position.azimuth,position.altitude);
var tmp_array=new Array;
tmp_array["x_axis"]=coord.x_axis;
tmp_array["y_axis"]=coord.y_axis;
tmp_array["z_axis"]=coord.z_axis;
tmp_array["hr"]=pref.star_catalogue.object[i].HR;
tmp_array["name"]=pref.star_catalogue.object[i].Name;
tmp_array["vmag"]=pref.star_catalogue.object[i].Vmag;
tmp_array["sp"]=pref.star_catalogue.object[i].Sp;
db_stars_coord.push(tmp_array);
}
}
delete pref;
Pref.prototype.db_stars_coord = db_stars_coord;
return;
}
UpdatePlanetsPosition = function(){
var pref = new Pref();
var Data = pref.planets_catalogue
var date = pref.date;
var ephem = new Ephemeris();
var db_planets_coord = []
var data_length = Data.length;
for(i=0; i<data_length; i++){
var position = ephem.to_horizontal(date,Number(pref.observers_longitude),Number(pref.observers_latitude),Number(Data[i].ra),Number(Data[i].dec));
if(position.altitude>0){
var coord = new ConvertCoord(Number(position.azimuth),Number(position.altitude));
var tmp_array=new Array;
tmp_array["name"]=Data[i].name;
tmp_array["x_axis"]=coord.x_axis;
tmp_array["y_axis"]=coord.y_axis;
tmp_array["z_axis"]=coord.z_axis;
db_planets_coord.push(tmp_array);
}
}
delete pref;
Pref.prototype.db_planets_coord = db_planets_coord;
return;
}
UpdateSunPosition = function(){
var pref = new Pref();
var date = pref.date;
var ephem = new Ephemeris();
var sun = ephem.Sun(date);
var position = ephem.to_horizontal(date,Number(pref.observers_longitude),Number(pref.observers_latitude),Number(sun.ra),Number(sun.dec));
if(position.altitude<0){