Test of SunCalc in SQL
✓ Published0🌍 Public
Aandrewxhill
Last edited Nov 5, 2015
Created on Nov 5, 2015
This example demonstrates how the SunCalc library’s solar position and event calculations can be ported to SQL, using PostgreSQL functions to compute azimuth, altitude, declination, and right ascension for a given time and location. It defines custom types and functions such as `SunCalc_GetPosition`, `SunCalc_SunCoords`, and `SunCalc_solarTransitJ`, mirroring the original JavaScript API. The code relies on plpgsql, PostGIS geometry for coordinates, and standard trigonometric functions, showing how to bring astronomical calculations into a relational database environment.
AI-generated description