Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

index.html 9.6 KB
Raw

You have to be logged in to leave a comment. Sign In
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
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>FitsMap</title>
  5. <meta charset="utf-8" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
  8. <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css" integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA==" crossorigin=""/>
  9. <link rel='stylesheet' href='https://unpkg.com/leaflet-search@2.9.8/dist/leaflet-search.src.css'/>
  10. <link rel='stylesheet' href='css/MarkerCluster.Default.css'/>
  11. <link rel='stylesheet' href='css/MarkerCluster.css'/>
  12. <link rel='stylesheet' href='css/TileNearestNeighbor.css'/>
  13. <script src='https://unpkg.com/leaflet@1.3.4/dist/leaflet.js' integrity='sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA==' crossorigin=''></script>
  14. <script type='text/javascript' src='https://code.jquery.com/jquery-3.6.0.slim.min.js' charset='utf-8'></script>
  15. <script src='https://unpkg.com/leaflet.markercluster@1.4.1/dist/leaflet.markercluster-src.js' crossorigin=''></script>
  16. <script src='https://unpkg.com/leaflet-search@2.9.8/dist/leaflet-search.src.js' crossorigin=''></script>
  17. <script src='js/phot.cat.js'></script>
  18. <script src='js/l.ellipse.min.js'></script>
  19. <style>
  20. html, body {
  21. height: 100%;
  22. margin: 0;
  23. }
  24. #map {
  25. width: 100%;
  26. height: 100%;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <div id="map"></div>
  32. <script>
  33. L.CRS.FitsMap = L.extend({}, L.CRS.Simple, {
  34. transformation: new L.Transformation(1/16, 0, -1/16, 256)
  35. });
  36. var j002616p0121_f606w = L.tileLayer("j002616p0121_f606w/{z}/{y}/{x}.png", { attribution:"<a href='https://github.com/ryanhausen/fitsmap'>FitsMap</a>",minZoom: 2,maxZoom: 9,maxNativeZoom: 4,});
  37. var j002616p0121_f814w = L.tileLayer("j002616p0121_f814w/{z}/{y}/{x}.png", { attribution:"<a href='https://github.com/ryanhausen/fitsmap'>FitsMap</a>",minZoom: 2,maxZoom: 9,maxNativeZoom: 4,});
  38. var j002616p0121_f110w = L.tileLayer("j002616p0121_f110w/{z}/{y}/{x}.png", { attribution:"<a href='https://github.com/ryanhausen/fitsmap'>FitsMap</a>",minZoom: 2,maxZoom: 9,maxNativeZoom: 4,});
  39. var j002616p0121_f140w = L.tileLayer("j002616p0121_f140w/{z}/{y}/{x}.png", { attribution:"<a href='https://github.com/ryanhausen/fitsmap'>FitsMap</a>",minZoom: 2,maxZoom: 9,maxNativeZoom: 4,});
  40. var j002616p0121_ir = L.tileLayer("j002616p0121_ir/{z}/{y}/{x}.png", { attribution:"<a href='https://github.com/ryanhausen/fitsmap'>FitsMap</a>",minZoom: 2,maxZoom: 9,maxNativeZoom: 4,});
  41. var j002616p0121_seg = L.tileLayer("j002616p0121_seg/{z}/{y}/{x}.png", { attribution:"<a href='https://github.com/ryanhausen/fitsmap'>FitsMap</a>",minZoom: 2,maxZoom: 9,maxNativeZoom: 4,});
  42. var j002616p0121_rgb = L.tileLayer("j002616p0121_rgb/{z}/{y}/{x}.png", { attribution:"<a href='https://github.com/ryanhausen/fitsmap'>FitsMap</a>",minZoom: 2,maxZoom: 9,maxNativeZoom: 4,});
  43. var map = L.map("map", {
  44. crs: L.CRS.FitsMap,
  45. zoom: 2,
  46. minZoom: 2,
  47. preferCanvas: true,
  48. layers: j002616p0121_rgb,
  49. });
  50. var markers = [
  51. L.markerClusterGroup({ }),
  52. ];
  53. var markerList = [
  54. [],
  55. ];
  56. var collections = [
  57. phot_cat_var,
  58. ];
  59. var labels = [
  60. 'phot',
  61. ];
  62. let colors = [
  63. "#4C72B0",
  64. "#DD8452",
  65. "#55A868",
  66. "#C44E52",
  67. "#8172B3",
  68. "#937860",
  69. "#DA8BC3",
  70. "#8C8C8C",
  71. "#CCB974",
  72. "#64B5CD",
  73. ];
  74. for (i = 0; i < collections.length; i++){
  75. collection = collections[i];
  76. for (j = 0; j < collection.length; j++){
  77. src = collection[j];
  78. var width = '650px';
  79. var include_img = src.include_img ? 2 : 1;
  80. var height = '440px';
  81. let p = L.popup({ maxWidth: "auto" })
  82. .setLatLng([src.y, src.x])
  83. .setContent("<iframe src='catalog_assets/" + src.cat_path + "/" + src.catalog_id + ".html' width='" + width + "' height='" + height + "'></iframe>");
  84. let marker;
  85. if (src.a==-1){
  86. marker = L.circleMarker([src.y, src.x], {
  87. catalog_id: labels[i] + ':' + src.catalog_id + ':',
  88. color: colors[i % colors.length]
  89. }).bindPopup(p);
  90. } else {
  91. marker = L.ellipse([src.y, src.x], [src.a, src.b], (src.theta * (180/Math.PI) * -1), {
  92. catalog_id: labels[i] + ':' + src.catalog_id + ':',
  93. color: colors[i % colors.length]
  94. }).bindPopup(p);
  95. }
  96. markerList[i].push(marker);
  97. }
  98. }
  99. for (i = 0; i < collections.length; i++){
  100. markers[i].addLayers(markerList[i]);
  101. }
  102. var marker_layers = L.layerGroup(markers);
  103. function searchHelp(e) {
  104. map.setView(e.latlng, 4);
  105. e.layer.addTo(map);
  106. };
  107. var searchBar = L.control.search({
  108. layer: marker_layers,
  109. initial: false,
  110. propertyName: 'catalog_id',
  111. textPlaceholder: 'Enter catalog_id ID',
  112. hideMarkerOnCollapse: true,
  113. });
  114. searchBar.on('search:locationfound', searchHelp);
  115. searchBar.addTo(map);
  116. // hack for turning off markers at start. Throws exception but doesn't
  117. // crash page. This should be updated when I understand this library better
  118. for (l of markers){
  119. l.remove()
  120. }
  121. var baseLayers = {
  122. "j002616p0121_f606w": j002616p0121_f606w,
  123. "j002616p0121_f814w": j002616p0121_f814w,
  124. "j002616p0121_f110w": j002616p0121_f110w,
  125. "j002616p0121_f140w": j002616p0121_f140w,
  126. "j002616p0121_ir": j002616p0121_ir,
  127. "j002616p0121_seg": j002616p0121_seg,
  128. "j002616p0121_rgb": j002616p0121_rgb,
  129. };
  130. var overlays = {}
  131. for(i = 0; i < markers.length; i++) {
  132. overlays[labels[i]] = markers[i];
  133. }
  134. var layerControl = L.control.layers(baseLayers, overlays);
  135. layerControl.addTo(map);
  136. urlParam = function(name){
  137. // Parse parameters from window.location,
  138. // e.g., .../index.html?zoom=8
  139. // urlParam(zoom) = 8
  140. var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
  141. if (results==null){
  142. return null;
  143. }
  144. else{
  145. return decodeURI(results[1]) || 0;
  146. }
  147. }
  148. pixToSky = function(xy){
  149. // Convert from zero-index pixel to sky coordinate assuming
  150. // simple North-up WCS
  151. if (xy.hasOwnProperty('lng')){
  152. var dx = xy.lng - crpix[0] + 1;
  153. var dy = xy.lat - crpix[1] + 1;
  154. } else {
  155. var dx = xy[0] - crpix[0] + 1;
  156. var dy = xy[1] - crpix[1] + 1;
  157. }
  158. var dra = dx * cdmatrix[0][0];
  159. var ddec = dy * cdmatrix[1][1];
  160. var ra = crval[0] + dra / Math.cos(crval[1]/180*3.14159);
  161. var dec = crval[1] + ddec;
  162. return [ra, dec];
  163. }
  164. skyToPix = function(rd){
  165. // Convert from sky to zero-index pixel coordinate assuming
  166. // simple North-up WCS
  167. var dx = (rd[0] - crval[0]) * Math.cos(crval[1]/180*3.14159);
  168. var dy = (rd[1] - crval[1]);
  169. var x = crpix[0] - 1 + dx / cdmatrix[0][0];
  170. var y = crpix[1] - 1 + dy / cdmatrix[1][1];
  171. return [x,y];
  172. }
  173. skyToLatLng = function(rd){
  174. // Convert from sky to Leaflet.latLng coordinate assuming
  175. // simple North-up WCS
  176. var xy = skyToPix(rd);
  177. return L.latLng(xy[1], xy[0]);
  178. }
  179. setZoomFromUrl = function(map){
  180. // Read "zoom" from url bar
  181. var zoom = urlParam('zoom');
  182. if (zoom !== null){
  183. // console.log("zoom to " + zoom);
  184. map.setZoom(zoom);
  185. }
  186. }
  187. panToSky = function(rd, map){
  188. // Pan map to celestial coordinates
  189. var ll = skyToLatLng(rd)
  190. map.panTo(ll, map.getZoom());
  191. console.log("pan to: " + rd + " / ll: " + ll.lng + ',' + ll.lat);
  192. }
  193. panFromUrl = function(map){
  194. // Pan map based on ra/dec/[zoom] variables in location bar
  195. var ra = urlParam('ra');
  196. var dec = urlParam('dec');
  197. if ((ra !== null) & (dec !== null)) {
  198. panToSky([ra,dec], map);
  199. } else {
  200. // Pan to crval
  201. panToSky(crval, map);
  202. }
  203. setZoomFromUrl(map);
  204. }
  205. updateLocationBar = function(){
  206. var rd = pixToSky(map.getCenter());
  207. var params = 'ra=' + rd[0].toFixed(7);
  208. params += '&dec=' + rd[1].toFixed(7);
  209. params += '&zoom=' + map.getZoom();
  210. var param_url = window.location.href.split('?')[0] + '?' + params;
  211. window.history.pushState('', '', param_url);
  212. }
  213. clearOverlays = function(){
  214. if (markers !== null){
  215. for(i = 0; i < markers.length; i++) {
  216. overlays[labels[i]].remove();
  217. console.log('clear overlays: ' + labels[i])
  218. }
  219. }
  220. }
  221. // WCS parameters
  222. var crpix = [2018.0, 2016.5];
  223. var crval = [6.566492082363771, 1.341782473802276];
  224. var cdmatrix = [[-2.7777777777777e-05, 0.0], [0.0, 2.77777777777777e-05]];
  225. $( document ).ready(function() {
  226. // Set pan from URL bar, if ra/dec/zoom specified
  227. panFromUrl(map);
  228. // Clear any catalog overlays
  229. clearOverlays();
  230. // Event handlers to update location bar when view changes
  231. map.on('moveend', updateLocationBar);
  232. map.on('zoomend', updateLocationBar);
  233. });
  234. </script>
  235. </script>
  236. </body>
  237. </html>
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...