Skip to content
Yan Grenier edited this page Jan 27, 2016 · 10 revisions

Swiss Ephemeris for .Net

This project is an Astrodienst Swiss Ephemeris (http://www.astro.com/swisseph/) .Net portage from C to C# in a PCL project for cross platform usage.

Usage

Now SwissEphNet is available as a Nuget package: Install-Package SwissEphNet

Or you can download the binaries in the last release.

SwissEphNet is a Portable Class Library with support for .Net 4+, Silverlight 5, Windows Phone 8, Windows Store apps, Xamarin.Android and Xamarin.iOS.

Read FAQ for some usage informations.

Create an instance

SwissEphNet.SwissEph is IDisposable so you can use it with an using statement.

using (var sweph = new SwissEphNet.SwissEph()) {
    // Use it
}

Loading files

SwissEphNet is a Portable Classe Library and we don't have file access.

As Swiss Ephemeris use some data files, an event exists for loading the files required.

using (var sweph = new SwissEphNet.SwissEph()) {
    sweph.OnLoadFile += (s, e) => {
        // Loading file
    };
    // Use it
}

For more information read this page.

Firsts steps

Our first step is to convert the C source code to C#, and provide some conversions from C like string format.

C code conversion.

Seconds steps

When we got a correct C conversion, we rewrite public methods to use a more .Net/C# friendly code. Using classes and structs instead of array of double, returns values instead of reference parameters, throw exception instead of reference 'serr', etc.

For this we create more classes to manage each domain (date, math, etc.) and the Sweph class federate all this classes.

The 'Swisseph' inherits from 'Sweph', and we replace each 'swe_*' methods by equivalent in 'Sweph'.

References

The Swiss Ephemeris Programming Interface documentation : http://www.astro.com/swisseph/swephprg.htm.

Last code source of Swiss Ephemeris from ftp://ftp.astro.ch/pub/swisseph/.

The NASA JPL resouces : http://www.jpl.nasa.gov/, http://ssd.jpl.nasa.gov/.

Minor planet names : http://www.minorplanetcenter.net/iau/lists/MPNames.html.