ephemeris 1.0.0-beta.6 copy "ephemeris: ^1.0.0-beta.6" to clipboard
ephemeris: ^1.0.0-beta.6 copied to clipboard

Idiomatic Dart bindings for the Taiyin ephemeris C API.

example/ephemeris_example.dart

import 'package:ephemeris/ephemeris.dart';

/// A small end-to-end tour of the Ephemeris Dart API.
///
/// Run with a path to a built ABI-10 Taiyin shared library (or no argument to
/// use the copy bundled in `lib/native/`):
///
/// ```sh
/// dart run example/ephemeris_example.dart
/// ```
void main(List<String> arguments) {
  final ephemeris = Ephemeris.open(libraryPath: arguments.firstOrNull);
  final context = ephemeris.createContext();

  try {
    // Core ephemeris: a Moon position; the native diagnostic lands on
    // context.lastDiagnostic.
    final (value: moon, flags: moonFlags) = context.positionTt(
      Body.moon,
      TtJulianDate.fromDouble(2460409.0),
      flags: {PositionFlag.xyz, PositionFlag.speed},
    );
    print('Taiyin ${ephemeris.libraryVersion}, ABI ${ephemeris.abiVersion}');
    print('Moon position: ${moon.coordinates}');
    print('Moon velocity: ${moon.rates}');
    print('Moon result flags: ${moonFlags.values}');

    // Chinese calendar: solar -> lunar conversion.
    final lunar = context.chineseCalendar
        .fromSolar(const SolarDate(year: 2024, month: 2, day: 10))
        .value;
    print('2024-02-10 -> lunar ${lunar.year}-${lunar.month}-${lunar.day}');

    // Ganzhi: the day pillar of a civil date.
    final dayPillar = context.ganzhi.dayPillar(AstroDateTime(2024, 2, 10));
    print(
      'Day pillar: $dayPillar (nayin ${context.ganzhi.nayinElement(dayPillar)})',
    );
  } finally {
    context.close();
  }
}
0
likes
160
points
377
downloads

Documentation

API reference

Publisher

verified publisherredsc1.com

Weekly Downloads

Idiomatic Dart bindings for the Taiyin ephemeris C API.

Repository (GitHub)
View/report issues

Topics

#astronomy #ephemeris #celestial-mechanics #chinese-calendar #astrology

License

MPL-2.0 (license)

Dependencies

ffi

More

Packages that depend on ephemeris