swisseph 0.5.1
swisseph: ^0.5.1 copied to clipboard
Isolate-safe Dart FFI bindings to the Swiss Ephemeris C library.
0.5.1 #
- Fix:
sincos()shim incsrc/compat.ccaused stack overflow on Android. At-O2, Clang foldssin(x)+cos(x)back into asincos()call, creating infinite recursion when the caller issincos. Add__attribute__((optnone))to prevent the optimization. Also mark the symbolweakso the linker prefers Bionic's nativesincos()when available (API 21+), using the shim only as a fallback.
0.5.0 #
- Web: SE1 ephemeris file loading. The WASM build now includes
Emscripten's MEMFS virtual filesystem (
FILESYSTEM=1). NewloadEpheFile(filename, bytes)method writes .se1 files into MEMFS from Dart; callsetEphePath('/ephe')afterward to use them. This enables Swiss Ephemeris precision (~0.001 arcsecond) on web — previously web was locked to Moshier (~1 arcminute). - Fix: WASM module name case mismatch.
DynamicLibrary.open()now passes explicitmoduleName: 'SwissEph'so wasm_ffi finds the Emscripten factory atglobalThis.SwissEph(PascalCase) instead of derivingswisseph(lowercase) from the URL path. Apps no longer need thewindow.swisseph = SwissEphalias workaround in index.html. - WASM assets rebuilt. JS glue grows from 31KB to 81KB (MEMFS implementation); WASM binary unchanged at 539KB.
- Add browser test (
dart test -p chrome) covering Moshier fallback and SE1 file loading with precision assertions.
0.4.7 #
- Fix:
getLibraryPath()could be overrun by one byte. The C function unconditionally writes a NUL at indexAS_MAXCH(256) on its long-path branch, but the Dart wrapper only allocated 256 bytes. Allocate 257 to absorb the trailing NUL. - Fix: Android native builds now compile
csrc/compat.c, which provides asincos()shim required by Bionic. Previously the file existed but was not in the build hook's source list, so an Android build that needed the shim could fail at link/runtime. The shim no-ops outside__ANDROID__, so it is included unconditionally. - API:
SwissEph.load([String? pathOrModule])now accepts an optional path/module argument, plumbed through to both the native and web loaders. Web consumers can serve the WASM module under any URL; native consumers can override the.dart_tool/scan. - API:
CalcResultgains an optionalwarningfield. When the C library populatesserron a non-fatal path (e.g. silent fallback from Swiss/JPL to Moshier when ephemeris files are missing), the message is now exposed instead of being discarded. Fully backwards compatible: existing callers seewarning == nullfor clean calls. - Doc: README clarifies that the Dart native-assets pipeline is the
supported production loading path;
SwissEph.find()and the.dart_tool/scan are dev-only conveniences. - Bind 5 additional Swiss Ephemeris C functions, raising coverage from
89/106 to 94/106:
cotransSp(swe_cotrans_sp) — coordinate transform with speed.heliacalAngle(swe_heliacal_angle) — optimal arcus visionis.topoArcusVisionis(swe_topo_arcus_visionis) — topocentric arc of vision for a body of given magnitude/position.setAstroModels/getAstroModels(swe_set_astro_models/swe_get_astro_models) — override precession/nutation/Delta T model selection. Accompanied byseModelDeltat..seModelSidtindex constants.
- Adds
CoTransSpResult,HeliacalAngleResult, andAstroModelsResultreturn types. wasm/exports.txtupdated with the 5 new symbols (andswe_calc_pctr, which was missing from the export list since 0.4.4). Pre-builtassets/swisseph.{js,wasm}rebuilt via the Docker/Emscripten workflow so the new functions andcalc_pctrare now callable on web as well as native.- The remaining 12 unbound C functions are deliberately skipped: 8
centiseconds utilities (degree equivalents are already exposed), 3
deprecated
swe_fixstar*functions superseded byswe_fixstar2*, and the trivialswe_d2lcast.
0.4.6 #
- Add optional
starNameparameter toriseTransandriseTransTrueHor. When provided, writes the star name into the FFI buffer so the underlyingswe_rise_transcomputes rise/set times for fixed stars (passbody: 0).
0.4.5 #
- Expand
sefstars.txtfrom ~1,100 to ~2,900 star entries. The new catalog was generated from SIMBAD data viamake_swe_stars.pyand includes multiple name aliases per star (traditional name, Bayer designation, Flamsteed number, HIP number), ICRS coordinates with higher precision, and all constellation boundary stars needed for 13-sign true-sidereal zodiac systems. The original catalog is preserved assefstars-original.txt.
0.4.4 #
- Add
calcPctr— planetocentric position calculation (swe_calc_pctr). Computes a body's position as seen from any other body (e.g. Jupiter-centric ephemerides, or asteroid-to-asteroid observations). Takes ET; signature matchescalcwith an additionalcenterBodyparameter.
0.4.3 #
- Fix Windows symbol exports: define
MAKE_DLLduring compilation so thatswephexp.hdecorates functions with__declspec(dllexport). Without this, the built DLL has no exported symbols andDynamicLibrary.lookup()fails at runtime.
0.4.2 #
- Fix Windows build: skip
-lmlinker flag on Windows where math functions are part of the C runtime (ucrt). Them.libfile does not exist on Windows, causingLNK1181fatal link errors during native asset compilation.
0.4.1 #
- Rebuild WASM assets with correct file ownership for pub.dev publishing.
0.4.0 #
Cross-platform FFI architecture for native + web support.
New #
SwissEph.load()— async factory constructor, works on both native and web- WASM build infrastructure (
wasm/) — Emscripten Docker build for web targets - Pre-built
assets/swisseph.{js,wasm}— 88 exported functions, 512 KB
Changed #
- All FFI types routed through conditional import barrel (
ffi_types.dart) - Library loading extracted to conditional barrel (
ffi_loader.dart) swiss_eph.dartno longer importsdart:io— fully platform-agnosticChar→Uint8throughout all 88 bindings (web compatibility)- All methods migrated from
calloc/free/try/finallyto Arena-scopedusing() - Custom UTF-8 string extensions (
utf8_compat.dart) replacingpackage:ffiUtf8 - Added
wasm_ffidependency for web platform support
Migration #
SwissEph(path)andSwissEph.find()still work on native (no changes needed)- For cross-platform code, use
final swe = await SwissEph.load();
0.3.0 #
Breaking: All constants renamed to consistent camelCase.
- Flag prefixes now properly capitalize sub-words:
seflgSwieph→seFlgSwiEph,seflgSpeed→seFlgSpeed, etc. - Node/apsides:
seNodbit*→seNodBit* - Heliacal flags:
seHelflag*→seHelFlag* - Sidereal bits:
seSidbit*→seSidBit* - Eclipse visibility:
seEclPartbegVisible→seEclPartBegVisible, etc. - Rise/set:
seCalcMtransit→seCalcMTransit,seBitGeoctrNoEclLat→seBitGeoCtrNoEclLat - Stress tests excluded from default
dart testrun (usedart test -t stress)
0.2.0 #
Major API expansion — 15 methods to ~88 methods, covering nearly the full Swiss Ephemeris C API surface.
New methods #
Planetary calculations:
calc(ET variant ofcalcUt)nodApsUt,nodAps— planetary nodes and apsidesgetOrbitalElements— osculating orbital elementsorbitMaxMinTrueDistance— orbital distance extremesphenoUt,pheno— phase angle, elongation, magnitude
Fixed stars:
fixstar2Ut,fixstar2— fixed star positionsfixstar2Mag— visual magnitude lookup
Houses (expanded):
housesEx— house cusps with extra flagshousesEx2— house cusps with speedshousesArmc— houses from ARMC (no date needed)housesArmcEx2— houses from ARMC with speedshousePos— house position of a bodygauquelinSector— Gauquelin sector position
Eclipses:
solEclipseWhenLoc,solEclipseWhenGlob— find solar eclipsessolEclipseHow— solar eclipse attributes at a locationsolEclipseWhere— geographic location of greatest eclipselunEclipseWhen,lunEclipseWhenLoc— find lunar eclipseslunEclipseHow— lunar eclipse attributeslunOccultWhenLoc,lunOccultWhenGlob— planetary occultationslunOccultWhere— geographic location of greatest occultation
Crossings:
solCrossUt,solCross— Sun crossing a longitudemoonCrossUt,moonCross— Moon crossing a longitudemoonCrossNodeUt,moonCrossNode— Moon crossing its own nodehelioCrossUt,helioCross— heliocentric longitude crossing
Date/time (expanded):
utcToJd,jdToUtc,jdetToUtc— UTC/JD conversionsutcTimeZone— UTC to local time zonedayOfWeek— day of week for a Julian Daydeltat,deltatEx— Delta T (ET minus UT)timeEqu— equation of timesidTime,sidTime0— sidereal timelmtToLat,latToLmt— local mean/apparent time conversion
Coordinate transforms:
azAlt— ecliptic/equatorial to horizonazAltRev— horizon to ecliptic/equatorialcotrans— ecliptic/equatorial coordinate transformrefrac,refracExtended— atmospheric refractionsplitDeg— decimal degrees to d/m/sradNorm,degMidp,radMidp,difDegn,difDeg2n— degree/radian math
Rise/set (expanded):
riseTransTrueHor— rise/set with true horizon
Heliacal:
heliacalUt— heliacal rising/settingheliacalPhenoUt— heliacal phenomenon datavisLimitMag— limiting visual magnitude
Configuration (expanded):
setJplFile— set JPL ephemeris filegetLibraryPath— path to loaded shared librarygetCurrentFileData— loaded data file infosetInterpolateNut— nutation interpolation togglesetLapseRate— atmospheric lapse ratesetDeltaTUserdef— override Delta TsetTidAcc,getTidAcc— tidal accelerationgetAyanamsa,getAyanamsaEx— ET ayanamsa variants
Bug fixes (from external code review) #
- Gauquelin cusp truncation — house methods now return all 37 cusps
for Gauquelin sectors (
hsys='G'), not just 13. Affected:houses,housesEx,housesEx2,housesArmc,housesArmcEx2. - Crossing function error detection —
solCross*,moonCross*, andmoonCrossNode*now checkresult < jdStart(matching the C error sentinel) instead ofresult < 0, which was a no-op for modern dates. - Missing error throws —
houses(),housesEx(),housesArmc()now throwSweExceptionon failure (consistent withhousesEx2). - FixstarResult returnFlag —
fixstar2Utandfixstar2now populate thereturnFlagfield. - gauquelinSector starName — added optional
starNameparameter for fixed-star sector calculations. - Constant and doc fixes — added
hsysGauquelinconstant, clarifiedseEcl2hor/seHor2ecldocs (direction comes from function, not flag), documentedSplitDegResult.signzodiacal behavior, documentedRiseTransResultcircumpolar behavior (returnFlag -2).
New types #
HouseResultEx, FixstarResult, MoonNodeCrossResult, JulianDayPair,
DateTimeResult, FileDataResult, NodeApsResult,
OrbitalElementsResult, OrbitDistanceResult, PhenoResult,
SolarEclipseLocalResult, SolarEclipseGlobalResult,
SolarEclipseAttrResult, EclipseWhereResult,
LunarEclipseGlobalResult, LunarEclipseLocalResult,
LunarEclipseAttrResult, AzAltResult, AzAltRevResult,
CoTransResult, RefracResult, HeliacalResult,
HeliacalPhenoResult, VisLimitResult, AtmoConditions,
ObserverConditions.
Other #
- FFI bindings expanded from 16 to 75.
- Constants expanded with eclipse flags, node/apsides flags, heliacal event types, sidereal mode bits, split degree flags, and refraction flags.
0.1.2 #
- Fix Android/NDK linking: link
libmexplicitly vialibraries: ['m']in the build hook. Desktop glibc links libm implicitly; Android's Bionic does not, causingdlopenfailures for math symbols (sin,cos,sincos, etc.). - Document ephemeris file discovery for package consumers: use
Isolate.resolvePackageUrito locate the bundledephe/directory at runtime.
0.1.1 #
- Bundle Swiss Ephemeris data files in
ephe/— sub-arcsecond precision out of the box with no extra downloads. - Included: planets, Moon, main asteroids (Ceres, Pallas, Juno, Vesta, Chiron, Pholus), fixed stars, and Hygiea.
- Coverage: ~5400 BC – 5400 AD (~10,800 years).
0.1.0 #
- Initial release.
- 15 methods:
calcUt,houses,julday,revjul,riseTrans,getAyanamsaUt,getAyanamsaExUt,getAyanamsaName,setSidMode,setEphePath,setTopo,getPlanetName,houseName,degnorm,close,version. - All 47 standard ayanamsa modes.
- 11 house systems.
- Moshier, Swiss Ephemeris, and JPL ephemeris support.
- Tropical, sidereal, heliocentric, barycentric, and equatorial coordinates.
- Native asset build hook — C source compiles automatically on
dart pub get. - Isolate-safe via unique
.socopies per isolate. - 26 unit tests + 545-value cross-validation against pyswisseph.