Fix zodiac traces using Stellarium modern lines
This commit is contained in:
parent
03692a0398
commit
3df13f9a0c
2 changed files with 47 additions and 31 deletions
|
|
@ -1,6 +1,10 @@
|
|||
/* Gerado por tools/build_constellations.py.
|
||||
d3-celestial constellation lines, coordenadas equatoriais J2000.
|
||||
Stellarium Modern constellation lines, coordenadas Hipparcos J2000.
|
||||
|
||||
Constellation lines: Stellarium Modern sky culture, CC BY-SA 4.0.
|
||||
https://github.com/Stellarium/stellarium/tree/master/skycultures/modern
|
||||
|
||||
Hipparcos J2000 coordinates: d3-celestial.
|
||||
Copyright (c) 2015, Olaf Frohn
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -18,4 +22,4 @@
|
|||
AND ANY EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DAMAGES ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE. */
|
||||
const CONSTELLATIONS=[{"id":"Ari","name":"Áries","rank":1,"label":[42.0,22.0],"lines":[[[42.496,27.2605],[31.7934,23.4624],[28.66,20.808],[28.3826,19.2939]]]},{"id":"Tau","name":"Touro","rank":1,"label":[54.0,15.0],"lines":[[[84.4112,21.1425],[68.9802,16.5093],[67.1656,15.8709],[64.9483,15.6276],[65.7337,17.5425],[67.1542,19.1804],[81.573,28.6075]],[[64.9483,15.6276],[60.1701,12.4903],[51.7923,9.7327],[60.7891,5.9893]],[[51.7923,9.7327],[51.2033,9.0289],[54.2183,0.4017]]]},{"id":"Gem","name":"Gêmeos","rank":1,"label":[107.25,23.5],"lines":[[[93.7194,22.5068],[95.7401,22.5136],[100.983,25.1311],[107.7849,30.2452],[113.6494,31.8883],[116.329,28.0262],[113.9806,26.8957],[110.0307,21.9823],[106.0272,20.5703],[99.4279,16.3993],[101.3224,12.8956]],[[110.0307,21.9823],[109.5232,16.5404]]]},{"id":"Cnc","name":"Câncer","rank":2,"label":[128.25,27.0],"lines":[[[134.6218,11.8577],[131.1712,18.1543],[130.8214,21.4685],[131.6666,28.7651]],[[131.1712,18.1543],[124.1288,9.1855]]]},{"id":"Leo","name":"Leão","rank":1,"label":[159.0,15.0],"lines":[[[152.093,11.9672],[151.8331,16.7627],[154.9931,19.8415],[168.5271,20.5237],[177.2649,14.5721],[168.56,15.4296],[152.093,11.9672]],[[154.9931,19.8415],[154.1726,23.4173],[148.1909,26.007],[146.4628,23.7743]]]},{"id":"Vir","name":"Virgem","rank":1,"label":[-160.5,-4.0],"lines":[[[176.4648,6.5294],[177.6738,1.7647],[-175.0235,-0.6668],[-169.5848,-1.4494],[-162.5125,-5.539],[-158.7018,-11.1613],[-145.9964,-6.0005],[-139.2349,-5.6582]],[[-164.4558,10.9592],[-166.0991,3.3975],[-169.5848,-1.4494]],[[-162.5125,-5.539],[-156.3267,-0.5958],[-149.5884,1.5445],[-138.4378,1.8929]]]},{"id":"Lib","name":"Libra","rank":2,"label":[-129.0,-26.0],"lines":[[[-133.9824,-25.282],[-137.2804,-16.0418],[-130.7483,-9.3829],[-126.1184,-14.7895],[-125.744,-28.1351],[-125.336,-29.7778]],[[-137.2804,-16.0418],[-126.1184,-14.7895]]]},{"id":"Sco","name":"Escorpião","rank":1,"label":[-111.0,-38.0],"lines":[[[-120.287,-26.1141],[-119.9166,-22.6217],[-118.6407,-19.8055]],[[-119.9166,-22.6217],[-114.7028,-25.5928],[-112.6481,-26.432],[-111.0294,-28.216],[-107.4591,-34.2932],[-107.0324,-38.0474],[-106.3541,-42.3613],[-101.9617,-43.2392],[-95.6703,-42.9978],[-93.1038,-40.127],[-94.378,-39.03],[-96.5978,-37.1038]]]},{"id":"Sgr","name":"Sagitário","rank":1,"label":[-67.5,-34.0],"lines":[[[-85.5932,-36.7617],[-83.957,-34.3846],[-84.7515,-29.8281],[-83.0073,-25.4217],[-86.5591,-21.0588]],[[-69.3404,-44.459],[-69.0284,-40.6159],[-74.347,-29.8801],[-78.5859,-26.9908],[-83.0073,-25.4217]],[[-61.1846,-41.8683],[-60.0659,-35.2763],[-61.0402,-26.2995],[-65.8232,-24.8836],[-68.6813,-24.5086],[-71.1149,-25.2567],[-76.1836,-26.2967],[-78.5859,-26.9908],[-84.7515,-29.8281],[-88.548,-30.4241],[-83.957,-34.3846],[-74.347,-29.8801],[-73.265,-27.6704],[-76.1836,-26.2967],[-73.8292,-21.7415],[-72.559,-21.0236],[-70.5913,-18.9529],[-69.5818,-17.8472],[-69.5682,-15.955]],[[-73.8292,-21.7415],[-75.5675,-21.1067],[-76.4576,-22.7448],[-76.1836,-26.2967]]]},{"id":"Cap","name":"Capricórnio","rank":2,"label":[-45.0,-22.0],"lines":[[[-55.588,-12.5082],[-54.7472,-14.7814],[-52.7849,-17.8137],[-48.4761,-25.2709],[-47.0446,-26.9191],[-38.3332,-22.4113],[-33.2398,-16.1273],[-34.9773,-16.6623],[-39.4383,-16.8345],[-43.5132,-17.2329],[-55.588,-12.5082]]]},{"id":"Aqr","name":"Aquário","rank":2,"label":[-22.5,-5.0],"lines":[[[-48.081,-9.4958],[-46.8365,-8.9833],[-37.1103,-5.5712],[-28.554,-0.3199],[-24.5859,-1.3873],[-22.792,-0.02],[-21.1609,-0.1175],[-16.8464,-7.5796],[-10.5241,-9.1825],[-12.6383,-21.1724]],[[-37.1103,-5.5712],[-28.3907,-13.8697]],[[-28.554,-0.3199],[-25.7915,-7.7833]],[[-22.792,-0.02],[-23.6807,1.3774]],[[-9.2574,-20.1006],[-10.5241,-9.1825],[-4.5591,-17.8165]]]},{"id":"Psc","name":"Peixes","rank":2,"label":[19.5,15.0],"lines":[[[18.4373,24.5837],[17.9152,30.0896],[19.8666,27.2641],[18.4373,24.5837],[17.8634,21.0347],[22.8709,15.3458],[26.3485,9.1577],[30.5118,2.7638],[28.389,3.1875],[25.3579,5.4876],[22.5463,6.1438],[18.4329,7.5754],[15.7359,7.8901],[12.1706,7.5851],[-0.1721,6.8633],[-5.0123,5.6263],[-8.0079,6.379],[-9.9142,5.3813],[-10.7086,3.2823],[-8.2669,1.2556],[-4.4883,1.78],[-3.402,3.4868],[-5.0123,5.6263]],[[-10.7086,3.2823],[-14.0308,3.82]]]}];
|
||||
const CONSTELLATIONS=[{"id":"Ari","name":"Áries","rank":1,"label":[42.0,22.0],"lines":[[[42.496,27.2605],[31.7934,23.4624],[28.66,20.808],[28.3826,19.2939]]]},{"id":"Tau","name":"Touro","rank":1,"label":[54.0,15.0],"lines":[[[81.573,28.6075],[70.5613,22.9569],[67.1542,19.1804]],[[68.9802,16.5093],[84.4112,21.1425]],[[64.9483,15.6276],[65.7337,17.5425]],[[64.9483,15.6276],[60.1701,12.4903],[51.2033,9.0289]],[[68.9802,16.5093],[67.1542,19.1804]],[[68.9802,16.5093],[67.1656,15.8709],[64.9483,15.6276]],[[67.1542,19.1804],[66.3724,17.9279],[65.7337,17.5425],[57.2906,24.0534]]]},{"id":"Gem","name":"Gêmeos","rank":1,"label":[107.25,23.5],"lines":[[[99.4279,16.3993],[106.0272,20.5703],[110.0307,21.9823],[109.5232,16.5404],[101.3224,12.8956]],[[110.0307,21.9823],[113.9806,26.8957],[116.1119,24.398]],[[113.9806,26.8957],[116.329,28.0262]],[[113.9806,26.8957],[111.4317,27.7981],[107.7849,30.2452],[113.6494,31.8883]],[[107.7849,30.2452],[103.1972,33.9613]],[[107.7849,30.2452],[100.983,25.1311],[97.2408,20.2121]],[[100.983,25.1311],[95.7401,22.5136],[93.7194,22.5068],[91.0301,23.2633]]]},{"id":"Cnc","name":"Câncer","rank":2,"label":[128.25,27.0],"lines":[[[131.6743,28.7599],[130.8214,21.4685],[125.0161,27.2177]],[[130.8214,21.4685],[131.1712,18.1543],[124.1288,9.1855]],[[131.1712,18.1543],[134.6218,11.8577]]]},{"id":"Leo","name":"Leão","rank":1,"label":[159.0,15.0],"lines":[[[177.2649,14.5721],[168.56,15.4296],[152.093,11.9672],[151.8331,16.7627],[154.9931,19.8415],[168.5271,20.5237],[177.2649,14.5721]],[[154.9931,19.8415],[154.1726,23.4173],[148.1909,26.007],[146.4628,23.7743]],[[168.5271,20.5237],[168.56,15.4296]]]},{"id":"Vir","name":"Virgem","rank":1,"label":[-160.5,-4.0],"lines":[[[176.4648,6.5294],[-175.0235,-0.6668],[-169.5848,-1.4494],[-158.7018,-11.1613],[-146.7761,-10.2737],[-145.9964,-6.0005],[-139.2349,-5.6582]],[[-158.7018,-11.1613],[-156.3267,-0.5958],[-149.5884,1.5445],[-138.4378,1.8929]],[[-156.3267,-0.5958],[-166.0991,3.3975],[-164.4558,10.9592]],[[-166.0991,3.3975],[-169.5848,-1.4494]]]},{"id":"Lib","name":"Libra","rank":2,"label":[-129.0,-26.0],"lines":[[[-121.5436,-16.7293],[-126.1184,-14.7895],[-130.7483,-9.3829],[-137.2804,-16.0418],[-133.9824,-25.282],[-126.1184,-14.7895]]]},{"id":"Sco","name":"Escorpião","rank":1,"label":[-111.0,-38.0],"lines":[[[-96.5978,-37.1038],[-94.378,-39.03],[-93.1038,-40.127],[-95.6703,-42.9978],[-101.9617,-43.2392],[-106.5011,-42.362],[-107.0324,-38.0474],[-107.4591,-34.2932],[-111.0294,-28.216],[-112.6481,-26.432],[-119.9166,-22.6217]],[[-112.6481,-26.432],[-120.287,-26.1141]],[[-112.6481,-26.432],[-118.6407,-19.8055]]]},{"id":"Sgr","name":"Sagitário","rank":1,"label":[-67.5,-34.0],"lines":[[[-84.7515,-29.8281],[-83.0073,-25.4217]],[[-85.5932,-36.7617],[-83.957,-34.3846],[-88.548,-30.4241],[-93.1099,-27.8308]],[[-88.548,-30.4241],[-84.7515,-29.8281],[-83.957,-34.3846],[-74.347,-29.8801],[-78.5859,-26.9908],[-84.7515,-29.8281]],[[-78.5859,-26.9908],[-83.0073,-25.4217],[-86.5591,-21.0588]],[[-74.347,-29.8801],[-73.265,-27.6704],[-76.1836,-26.2967],[-78.5859,-26.9908]],[[-76.1836,-26.2967],[-75.5675,-21.1067],[-73.8292,-21.7415],[-70.5913,-18.9529],[-69.5818,-17.8472]],[[-73.265,-27.6704],[-65.9931,-24.7191],[-59.3355,-27.7098],[-60.0659,-35.2763],[-61.1846,-41.8683],[-69.0284,-40.6159]],[[-61.1846,-41.8683],[-69.1953,-44.7998]]]},{"id":"Cap","name":"Capricórnio","rank":2,"label":[-45.0,-22.0],"lines":[[[-55.4864,-12.5449],[-54.7472,-14.7814],[-43.5132,-17.2329],[-39.4383,-16.8345],[-34.9773,-16.6623],[-33.2398,-16.1273]],[[-39.4383,-16.8345],[-38.3332,-22.4113],[-43.5132,-17.2329]],[[-54.7472,-14.7814],[-48.4761,-25.2709]],[[-43.5132,-17.2329],[-47.0446,-26.9191]]]},{"id":"Aqr","name":"Aquário","rank":2,"label":[-22.5,-5.0],"lines":[[[-37.1103,-5.5712],[-28.554,-0.3199],[-24.5859,-1.3873],[-22.792,-0.02],[-21.1609,-0.1175],[-16.8464,-7.5796],[-11.0271,-9.0877],[-9.2574,-20.1006]],[[-28.554,-0.3199],[-25.7915,-7.7833],[-28.3907,-13.8697]],[[-25.7915,-7.7833],[-22.3383,-10.678],[-17.6021,-13.5926],[-16.3374,-15.8208],[-12.6383,-21.1724]],[[-48.081,-9.4958],[-37.1103,-5.5712]]]},{"id":"Psc","name":"Peixes","rank":2,"label":[19.5,15.0],"lines":[[[15.7046,31.8043],[18.4373,24.5837]],[[15.7046,31.8043],[19.8666,27.2641],[18.4373,24.5837],[22.8709,15.3458],[26.3485,9.1577],[30.5118,2.7638],[28.389,3.1875],[25.3579,5.4876],[22.5463,6.1438],[15.7359,7.8901],[12.0725,7.2999],[5.1494,8.1903],[-0.1721,6.8633],[-5.0123,5.6263],[-3.402,3.4868],[-4.4883,1.78],[-8.2669,1.2556],[-10.7086,3.2823],[-9.9142,5.3813],[-8.0079,6.379],[-5.0123,5.6263]]]}];
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Gera constellations.js com os signos zodiacais em coordenadas J2000.
|
||||
|
||||
Fonte: d3-celestial, de Olaf Frohn, licença BSD-3-Clause.
|
||||
Os dados são compactados para uso offline pelo wallpaper.
|
||||
Os traçados são da cultura ``modern`` do Stellarium. As coordenadas J2000
|
||||
dos respectivos identificadores Hipparcos vêm do d3-celestial. Os dados são
|
||||
compactados para uso offline pelo wallpaper.
|
||||
"""
|
||||
|
||||
import json
|
||||
|
|
@ -10,7 +11,11 @@ import urllib.request
|
|||
from pathlib import Path
|
||||
|
||||
|
||||
BASE = "https://raw.githubusercontent.com/ofrohn/d3-celestial/master/data/"
|
||||
STELLARIUM_URL = (
|
||||
"https://raw.githubusercontent.com/Stellarium/stellarium/master/"
|
||||
"skycultures/modern/index.json"
|
||||
)
|
||||
D3_BASE = "https://raw.githubusercontent.com/ofrohn/d3-celestial/master/data/"
|
||||
OUT = Path(__file__).resolve().parent.parent / "plugin/contents/ui/constellations.js"
|
||||
|
||||
ZODIAC = {
|
||||
|
|
@ -28,7 +33,11 @@ ZODIAC = {
|
|||
"Psc": "Peixes",
|
||||
}
|
||||
|
||||
LICENSE = """Copyright (c) 2015, Olaf Frohn
|
||||
LICENSE = """Constellation lines: Stellarium Modern sky culture, CC BY-SA 4.0.
|
||||
https://github.com/Stellarium/stellarium/tree/master/skycultures/modern
|
||||
|
||||
Hipparcos J2000 coordinates: d3-celestial.
|
||||
Copyright (c) 2015, Olaf Frohn
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -48,8 +57,8 @@ OUT OF THE USE OF THIS SOFTWARE.
|
|||
"""
|
||||
|
||||
|
||||
def fetch(name: str) -> dict:
|
||||
req = urllib.request.Request(BASE + name, headers={"User-Agent": "skeledance-build/1.0"})
|
||||
def fetch(url: str) -> dict:
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "skeledance-build/1.0"})
|
||||
return json.loads(urllib.request.urlopen(req, timeout=30).read())
|
||||
|
||||
|
||||
|
|
@ -58,8 +67,13 @@ def rounded_point(point: list[float]) -> list[float]:
|
|||
|
||||
|
||||
def main() -> None:
|
||||
line_data = fetch("constellations.lines.json")["features"]
|
||||
name_data = fetch("constellations.json")["features"]
|
||||
sky_culture = fetch(STELLARIUM_URL)
|
||||
star_data = fetch(D3_BASE + "stars.6.json")["features"]
|
||||
name_data = fetch(D3_BASE + "constellations.json")["features"]
|
||||
stars = {
|
||||
int(feature["id"]): rounded_point(feature["geometry"]["coordinates"])
|
||||
for feature in star_data
|
||||
}
|
||||
metadata = {
|
||||
feature["id"]: {
|
||||
"name": feature["properties"].get("name", feature["id"]),
|
||||
|
|
@ -69,25 +83,23 @@ def main() -> None:
|
|||
}
|
||||
|
||||
merged: dict[str, dict] = {}
|
||||
for feature in line_data:
|
||||
ident = feature["id"]
|
||||
for constellation in sky_culture["constellations"]:
|
||||
ident = constellation["id"].split()[-1]
|
||||
if ident not in ZODIAC:
|
||||
continue
|
||||
item = merged.setdefault(
|
||||
ident,
|
||||
{
|
||||
"id": ident,
|
||||
"name": ZODIAC[ident],
|
||||
"rank": int(feature["properties"].get("rank", 3)),
|
||||
"label": metadata.get(ident, {}).get("label"),
|
||||
"lines": [],
|
||||
},
|
||||
)
|
||||
item["rank"] = min(item["rank"], int(feature["properties"].get("rank", 3)))
|
||||
item["lines"].extend(
|
||||
[[rounded_point(point) for point in line]
|
||||
for line in feature["geometry"]["coordinates"]]
|
||||
)
|
||||
lines = []
|
||||
for hip_line in constellation.get("lines", []):
|
||||
missing = [hip for hip in hip_line if hip not in stars]
|
||||
if missing:
|
||||
raise RuntimeError(f"{ident}: HIP ausente no catálogo: {missing}")
|
||||
lines.append([stars[hip] for hip in hip_line])
|
||||
merged[ident] = {
|
||||
"id": ident,
|
||||
"name": ZODIAC[ident],
|
||||
"rank": 1 if ident in {"Ari", "Tau", "Gem", "Leo", "Vir", "Sco", "Sgr"} else 2,
|
||||
"label": metadata.get(ident, {}).get("label"),
|
||||
"lines": lines,
|
||||
}
|
||||
|
||||
payload = json.dumps(
|
||||
[merged[ident] for ident in ZODIAC],
|
||||
|
|
@ -96,8 +108,8 @@ def main() -> None:
|
|||
)
|
||||
OUT.write_text(
|
||||
"/* Gerado por tools/build_constellations.py.\n"
|
||||
" d3-celestial constellation lines, coordenadas equatoriais J2000.\n\n"
|
||||
+ "\n".join(" " + line for line in LICENSE.rstrip().splitlines())
|
||||
" Stellarium Modern constellation lines, coordenadas Hipparcos J2000.\n\n"
|
||||
+ "\n".join((" " + line) if line else "" for line in LICENSE.rstrip().splitlines())
|
||||
+ " */\nconst CONSTELLATIONS=" + payload + ";\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue