Skip to content

Draw the Sun and the planets - #18

Merged
rhannequin merged 4 commits into
mainfrom
draw-the-planets
Oct 28, 2026
Merged

rhannequin merged 4 commits into
mainfrom
draw-the-planets

Conversation

@rhannequin

@rhannequin rhannequin commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Adds two layers that draw the Sun and the planets where they are in the sky:

ephem = Astronoby::Ephem.load("inpop19a.bsp")

chart.render(
  Skymap::Layers::Stars.new(stars: stars),
  Skymap::Layers::Sun.new(ephem: ephem),
  Skymap::Layers::Planets.new(ephem: ephem),
  Skymap::Layers::Moon.new(ephem: ephem)
)

Like the Moon, they need an ephemeris, and they are left out when below the horizon.

  • Planets draws Mercury to Neptune as a star would be, using the apparent magnitude from Astronoby, with the same sizes as the stars and a warm tint. It has a magnitude_limit: that defaults to 5 as for the stars, so Uranus (5.7) and Neptune (7.7) are out unless it is raised. Planets are not labeled yet
  • Sun is a disc at 3% of the radius of the sky, the same size as the Moon, as the Sun and the Moon look about the same size from the ground
  • StarSize.for takes the sizing of the stars out of the Stars layer, so both layers share it. Stars are sized exactly as before
  • The ephemeris of the tests keeps the barycenters of Mercury to Neptune, and is renamed de440s_2025_2030_excerpt.bsp since it is not only about the Moon anymore. It goes from 508 KB to 710 KB, and is cut with ruby-ephem excerpt from DE440s. While at it, its comment area now follows the DAF layout (1,000 characters per record), which the previous one did not, so tools that read the comments now show it correctly
  • The map of the README now shows Saturn, the only planet above the horizon on September 24, 2026 at 22:00 UTC. The Sun is below the horizon

Planets are sized like stars, so the sizing moves to StarSize.for to be shared by both layers.
The fixture keeps the barycenters of Mercury to Neptune besides the Sun, the Moon and the Earth, still from 2025 to 2030. Its comment area is laid out in DAF records, as in the original kernel.
Adds the Sun and Planets layers, drawn from an ephemeris like the Moon, and shows Saturn on the map of the README.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Bright magnitude cutoffs reverse the planet-sizing interval, incorrectly shrinking all accepted planets to the minimum radius.

1 open issue
What changed in this PR

Adds Sun and planet layers to Skymap’s existing sky-map rendering, using ephemerides to position bodies and omit those below the horizon.

Changes:

  • Adds Sun discs and magnitude-sized, warm-tinted planets.
  • Shares sizing logic between stars and planets without changing existing star sizing.
  • Adds rendering tests and updates documentation, the sample map, and the test ephemeris reference.
File Description
spec/​support/​astronomy_helpers.rb Uses the renamed ephemeris fixture.
spec/​skymap/​star_size_spec.rb Tests the shared sizing factory.
spec/​skymap/​renderer/​svg_spec.rb Tests Sun and planet SVG output.
spec/​skymap/​layers/​sun_spec.rb Tests Sun placement, sizing, and visibility.
spec/​skymap/​layers/​planets_spec.rb Tests planet placement, filtering, and sizing.
sky_map.svg Adds Saturn to the sample map.
README.md Documents the new layers and updated fixture.
lib/​skymap/​star_size.rb Extracts shared sizing defaults and factory.
lib/​skymap/​renderer/​svg.rb Draws Sun and planet elements.
lib/​skymap/​renderer/​sun.rb Defines the Sun render element.
lib/​skymap/​renderer/​planet.rb Defines the planet render element.
lib/​skymap/​layers/​sun.rb Projects and sizes the visible Sun.
lib/​skymap/​layers/​stars.rb Uses the shared sizing factory.
lib/​skymap/​layers/​planets.rb Projects, filters, and sizes planets.
lib/​skymap.rb Loads the new layers and render elements.
CHANGELOG.md Records the Sun and planet features.

Review effort: Balanced

Comment thread lib/skymap/layers/planets.rb Resolved
A magnitude limit brighter than -1.5 made the brightest end of the scale fainter than its faintest end, which shrank every object to the minimum radius. The scale now starts one magnitude brighter than the limit when it needs to.
@rhannequin
rhannequin merged commit 8af631a into main Oct 28, 2026
4 checks passed
@rhannequin
rhannequin deleted the draw-the-planets branch October 28, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants