@zendir/ui 0.2.9 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -102,47 +102,15 @@ function createStationDivIcon(statusColor, type, status) {
102
102
  tooltipAnchor: [0, -14]
103
103
  });
104
104
  }
105
- function calculateSubSolarPoint(date) {
106
- const dayOfYear = Math.floor((date.getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 864e5);
107
- const declination = -23.44 * Math.cos(2 * Math.PI / 365 * (dayOfYear + 10));
108
- const B = 2 * Math.PI / 365 * (dayOfYear - 81);
109
- const eotMinutes = 9.87 * Math.sin(2 * B) - 7.53 * Math.cos(B) - 1.5 * Math.sin(B);
110
- const utcHours = date.getUTCHours() + date.getUTCMinutes() / 60 + date.getUTCSeconds() / 3600;
111
- const solarHours = utcHours + eotMinutes / 60;
112
- const lon = -(solarHours - 12) * 15;
113
- return [declination, (lon + 540) % 360 - 180];
114
- }
115
- function calculateSubLunarPoint(date) {
116
- const J2000 = Date.UTC(2e3, 0, 1, 12, 0, 0);
117
- const d = (date.getTime() - J2000) / 864e5;
118
- const DEG = Math.PI / 180;
119
- const L2 = (218.316 + 13.176396 * d) % 360;
120
- const M = (134.963 + 13.064993 * d) % 360;
121
- const F = (93.272 + 13.22935 * d) % 360;
122
- const lon_ecl = L2 + 6.289 * Math.sin(M * DEG);
123
- const lat_ecl = 5.128 * Math.sin(F * DEG);
124
- const obliquity = 23.439 - 36e-8 * d;
125
- const sinRA = Math.sin(lon_ecl * DEG) * Math.cos(obliquity * DEG) - Math.tan(lat_ecl * DEG) * Math.sin(obliquity * DEG);
126
- const cosRA = Math.cos(lon_ecl * DEG);
127
- let RA = Math.atan2(sinRA, cosRA) / DEG;
128
- if (RA < 0) RA += 360;
129
- const dec = Math.asin(
130
- Math.sin(lat_ecl * DEG) * Math.cos(obliquity * DEG) + Math.cos(lat_ecl * DEG) * Math.sin(obliquity * DEG) * Math.sin(lon_ecl * DEG)
131
- ) / DEG;
132
- const GMST = (280.46061837 + 360.98564736629 * d) % 360;
133
- let geoLon = RA - GMST;
134
- geoLon = (geoLon + 540) % 360 - 180;
135
- return [dec, geoLon];
136
- }
137
105
  function calculateTerminatorContinuous(date, depressionDeg = 0, numPoints = 360) {
138
- const dayOfYear = Math.floor((date.getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 864e5);
106
+ const dayOfYear = Math.floor((date.getTime() - Date.UTC(date.getUTCFullYear(), 0, 0)) / 864e5);
139
107
  const declination = -23.44 * Math.cos(2 * Math.PI / 365 * (dayOfYear + 10));
140
108
  const decRad = declination * Math.PI / 180;
141
109
  const B = 2 * Math.PI / 365 * (dayOfYear - 81);
142
110
  const eotMinutes = 9.87 * Math.sin(2 * B) - 7.53 * Math.cos(B) - 1.5 * Math.sin(B);
143
111
  const utcHours = date.getUTCHours() + date.getUTCMinutes() / 60 + date.getUTCSeconds() / 3600;
144
112
  const solarHours = utcHours + eotMinutes / 60;
145
- const hourAngle = solarHours / 24 * 360 - 180;
113
+ const subSolarLon = -(solarHours - 12) * 15;
146
114
  const depRad = depressionDeg * Math.PI / 180;
147
115
  const sunset = [];
148
116
  const sunrise = [];
@@ -152,12 +120,12 @@ function calculateTerminatorContinuous(date, depressionDeg = 0, numPoints = 360)
152
120
  const cosH = -(Math.sin(depRad) + Math.sin(latRad) * Math.sin(decRad)) / (Math.cos(latRad) * Math.cos(decRad));
153
121
  if (cosH < -1) ;
154
122
  else if (cosH > 1) {
155
- sunset.push([lat, hourAngle]);
156
- sunrise.push([lat, hourAngle + 360]);
123
+ sunset.push([lat, subSolarLon]);
124
+ sunrise.push([lat, subSolarLon + 360]);
157
125
  } else {
158
126
  const H = Math.acos(cosH) * 180 / Math.PI;
159
- sunset.push([lat, hourAngle + H]);
160
- sunrise.push([lat, hourAngle + 360 - H]);
127
+ sunset.push([lat, subSolarLon + H]);
128
+ sunrise.push([lat, subSolarLon + 360 - H]);
161
129
  }
162
130
  }
163
131
  return { sunset, sunrise };
@@ -385,20 +353,18 @@ function GroundTrackMapLeaflet({
385
353
  }
386
354
  if (internalTerminator) {
387
355
  const now = terminatorTime ?? /* @__PURE__ */ new Date();
356
+ const isSatelliteTile = tileStyle === "satellite";
388
357
  const BAND_STEP = 1.5;
389
358
  const MAX_DEP = 30;
390
- const NIGHT_OPACITY = 0.6;
359
+ const NIGHT_OPACITY = isSatelliteTile ? 0.75 : 0.38;
360
+ const NIGHT_COLOR = isSatelliteTile ? "#030810" : "#2a3a52";
391
361
  const bandSteps = [];
392
362
  for (let d = 0; d <= MAX_DEP; d += BAND_STEP) {
393
363
  const t = Math.min(d / 18, 1);
394
- const opacity = t * t * (NIGHT_OPACITY * 0.78) + (d > 18 ? (d - 18) / 12 * (NIGHT_OPACITY * 0.22) : 0);
395
- let color;
396
- if (d <= 6) color = "#1a3a5c";
397
- else if (d <= 12) color = "#0f2440";
398
- else color = "#060e1a";
399
- bandSteps.push({ depression: d, opacity: Math.min(opacity, NIGHT_OPACITY), color });
364
+ const opacity = Math.pow(t, 1.6) * (NIGHT_OPACITY * 0.85) + (d > 18 ? (d - 18) / 12 * (NIGHT_OPACITY * 0.15) : 0);
365
+ bandSteps.push({ depression: d, opacity: Math.min(opacity, NIGHT_OPACITY), color: NIGHT_COLOR });
400
366
  }
401
- bandSteps.push({ depression: 90, opacity: NIGHT_OPACITY, color: "#060e1a" });
367
+ bandSteps.push({ depression: 90, opacity: NIGHT_OPACITY, color: NIGHT_COLOR });
402
368
  let prevOpacity = 0;
403
369
  for (const b of bandSteps) {
404
370
  const terminator = calculateTerminatorContinuous(now, Math.min(b.depression, 89));
@@ -421,70 +387,42 @@ function GroundTrackMapLeaflet({
421
387
  prevOpacity = b.opacity;
422
388
  }
423
389
  const terminatorEdge = calculateTerminatorContinuous(now, 0);
390
+ const glowColor = isSatelliteTile ? "#6aa0cc" : "#8faec8";
391
+ const glowOpacity = isSatelliteTile ? 0.15 : 0.08;
392
+ const coreColor = isSatelliteTile ? "#8cc4e8" : "#9ab8d8";
393
+ const coreOpacity = isSatelliteTile ? 0.5 : 0.35;
424
394
  if (terminatorEdge.sunset.length > 2) {
425
395
  const sunsetLine = terminatorEdge.sunset.map(([lat, lon]) => [lat, lon]);
426
396
  const sunriseLine = terminatorEdge.sunrise.map(([lat, lon]) => [lat, lon]);
427
397
  [0, 360, -360].forEach((offset) => {
428
398
  addLayer(L.polyline(
429
399
  sunsetLine.map(([lat, lon]) => [lat, lon + offset]),
430
- { color: "#5a8ec8", weight: 4, opacity: 0.12, interactive: false, smoothFactor: 1.5 }
400
+ { color: glowColor, weight: 3, opacity: glowOpacity, interactive: false, smoothFactor: 1.5 }
431
401
  ));
432
402
  addLayer(L.polyline(
433
403
  sunriseLine.map(([lat, lon]) => [lat, lon + offset]),
434
- { color: "#5a8ec8", weight: 4, opacity: 0.12, interactive: false, smoothFactor: 1.5 }
404
+ { color: glowColor, weight: 3, opacity: glowOpacity, interactive: false, smoothFactor: 1.5 }
435
405
  ));
436
406
  addLayer(L.polyline(
437
407
  sunsetLine.map(([lat, lon]) => [lat, lon + offset]),
438
- { color: "#7aa4d4", weight: 1, opacity: 0.5, interactive: false, smoothFactor: 1.5 }
408
+ { color: coreColor, weight: 1, opacity: coreOpacity, interactive: false, smoothFactor: 1.5 }
439
409
  ));
440
410
  addLayer(L.polyline(
441
411
  sunriseLine.map(([lat, lon]) => [lat, lon + offset]),
442
- { color: "#7aa4d4", weight: 1, opacity: 0.5, interactive: false, smoothFactor: 1.5 }
412
+ { color: coreColor, weight: 1, opacity: coreOpacity, interactive: false, smoothFactor: 1.5 }
443
413
  ));
444
414
  });
445
415
  }
446
- const celestialEnabled = showCelestialMarkers !== void 0 ? showCelestialMarkers : true;
447
- if (celestialEnabled) {
448
- const [sunLat, sunLon] = calculateSubSolarPoint(now);
449
- const sunIcon = L.divIcon({
450
- className: "",
451
- iconSize: [28, 28],
452
- iconAnchor: [14, 14],
453
- html: `<svg width="28" height="28" viewBox="0 0 28 28" xmlns="http://www.w3.org/2000/svg">
454
- <defs><filter id="sun-glow"><feGaussianBlur stdDeviation="1.5" result="blur"/><feMerge><feMergeNode in="blur"/><feMergeNode in="SourceGraphic"/></feMerge></filter></defs>
455
- <circle cx="14" cy="14" r="6" fill="#FFB300" stroke="#FF8F00" stroke-width="1.2" filter="url(#sun-glow)"/>
456
- ${[0, 45, 90, 135, 180, 225, 270, 315].map((a) => {
457
- const r1 = 8, r2 = 12, rad = a * Math.PI / 180;
458
- return `<line x1="${14 + r1 * Math.cos(rad)}" y1="${14 + r1 * Math.sin(rad)}" x2="${14 + r2 * Math.cos(rad)}" y2="${14 + r2 * Math.sin(rad)}" stroke="#FFB300" stroke-width="1.4" stroke-linecap="round" opacity="0.85"/>`;
459
- }).join("")}
460
- </svg>`
461
- });
462
- addLayer(L.marker([sunLat, sunLon], { icon: sunIcon, interactive: false, zIndexOffset: 800 }));
463
- const [moonLat, moonLon] = calculateSubLunarPoint(now);
464
- const moonIcon = L.divIcon({
465
- className: "",
466
- iconSize: [22, 22],
467
- iconAnchor: [11, 11],
468
- html: `<svg width="22" height="22" viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg">
469
- <defs><filter id="moon-glow"><feGaussianBlur stdDeviation="1" result="blur"/><feMerge><feMergeNode in="blur"/><feMergeNode in="SourceGraphic"/></feMerge></filter></defs>
470
- <circle cx="11" cy="11" r="6.5" fill="#e0e0e0" stroke="#9e9e9e" stroke-width="0.8" filter="url(#moon-glow)" opacity="0.9"/>
471
- <circle cx="9" cy="9.5" r="1.6" fill="#bdbdbd" opacity="0.5"/>
472
- <circle cx="13" cy="12" r="1.0" fill="#bdbdbd" opacity="0.4"/>
473
- <circle cx="10.5" cy="13.5" r="0.7" fill="#bdbdbd" opacity="0.35"/>
474
- </svg>`
475
- });
476
- addLayer(L.marker([moonLat, moonLon], { icon: moonIcon, interactive: false, zIndexOffset: 790 }));
477
- }
478
416
  }
479
417
  if (lightSources && lightSources.length > 0 && internalTerminator) {
480
418
  const now = terminatorTime ?? /* @__PURE__ */ new Date();
481
- const dayOfYear = Math.floor((now.getTime() - new Date(now.getFullYear(), 0, 0).getTime()) / 864e5);
419
+ const dayOfYear = Math.floor((now.getTime() - Date.UTC(now.getUTCFullYear(), 0, 0)) / 864e5);
482
420
  const declination = -23.44 * Math.cos(2 * Math.PI / 365 * (dayOfYear + 10));
483
421
  const decRad = declination * Math.PI / 180;
484
- const hourAngle = (now.getUTCHours() + now.getUTCMinutes() / 60) / 24 * 360 - 180;
422
+ const lsSubSolarLon = -(now.getUTCHours() + now.getUTCMinutes() / 60 - 12) * 15;
485
423
  for (const light of lightSources) {
486
424
  const latRad = light.latitude * Math.PI / 180;
487
- const sinAlt = Math.sin(latRad) * Math.sin(decRad) + Math.cos(latRad) * Math.cos(decRad) * Math.cos((light.longitude - hourAngle) * Math.PI / 180);
425
+ const sinAlt = Math.sin(latRad) * Math.sin(decRad) + Math.cos(latRad) * Math.cos(decRad) * Math.cos((light.longitude - lsSubSolarLon) * Math.PI / 180);
488
426
  const solarAltDeg = Math.asin(sinAlt) * 180 / Math.PI;
489
427
  let nightFactor;
490
428
  if (solarAltDeg >= 0) nightFactor = 0;
@@ -721,6 +659,7 @@ function GroundTrackMapLeaflet({
721
659
  internalGrid,
722
660
  showEquator,
723
661
  showLegend,
662
+ tileStyle,
724
663
  tokens.colors.text.secondary,
725
664
  addLayer,
726
665
  clearLayers,