feat: limita constelações aos signos do zodíaco
This commit is contained in:
parent
bfb8f31952
commit
03692a0398
3 changed files with 29 additions and 8 deletions
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Gera constellations.js com figuras convencionais em coordenadas J2000.
|
||||
"""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.
|
||||
|
|
@ -13,6 +13,21 @@ from pathlib import Path
|
|||
BASE = "https://raw.githubusercontent.com/ofrohn/d3-celestial/master/data/"
|
||||
OUT = Path(__file__).resolve().parent.parent / "plugin/contents/ui/constellations.js"
|
||||
|
||||
ZODIAC = {
|
||||
"Ari": "Áries",
|
||||
"Tau": "Touro",
|
||||
"Gem": "Gêmeos",
|
||||
"Cnc": "Câncer",
|
||||
"Leo": "Leão",
|
||||
"Vir": "Virgem",
|
||||
"Lib": "Libra",
|
||||
"Sco": "Escorpião",
|
||||
"Sgr": "Sagitário",
|
||||
"Cap": "Capricórnio",
|
||||
"Aqr": "Aquário",
|
||||
"Psc": "Peixes",
|
||||
}
|
||||
|
||||
LICENSE = """Copyright (c) 2015, Olaf Frohn
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -56,11 +71,13 @@ def main() -> None:
|
|||
merged: dict[str, dict] = {}
|
||||
for feature in line_data:
|
||||
ident = feature["id"]
|
||||
if ident not in ZODIAC:
|
||||
continue
|
||||
item = merged.setdefault(
|
||||
ident,
|
||||
{
|
||||
"id": ident,
|
||||
"name": metadata.get(ident, {}).get("name", ident),
|
||||
"name": ZODIAC[ident],
|
||||
"rank": int(feature["properties"].get("rank", 3)),
|
||||
"label": metadata.get(ident, {}).get("label"),
|
||||
"lines": [],
|
||||
|
|
@ -72,7 +89,11 @@ def main() -> None:
|
|||
for line in feature["geometry"]["coordinates"]]
|
||||
)
|
||||
|
||||
payload = json.dumps(list(merged.values()), ensure_ascii=False, separators=(",", ":"))
|
||||
payload = json.dumps(
|
||||
[merged[ident] for ident in ZODIAC],
|
||||
ensure_ascii=False,
|
||||
separators=(",", ":"),
|
||||
)
|
||||
OUT.write_text(
|
||||
"/* Gerado por tools/build_constellations.py.\n"
|
||||
" d3-celestial constellation lines, coordenadas equatoriais J2000.\n\n"
|
||||
|
|
@ -80,7 +101,7 @@ def main() -> None:
|
|||
+ " */\nconst CONSTELLATIONS=" + payload + ";\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
print(f"{len(merged)} constelações -> {OUT} ({OUT.stat().st_size / 1024:.0f} KB)")
|
||||
print(f"{len(merged)} signos -> {OUT} ({OUT.stat().st_size / 1024:.0f} KB)")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue