├── .gitattributes
├── .gitignore
├── LICENSE
├── Programs
└── SweWPF
│ ├── App.config
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── Controls
│ ├── DateTimeInput.xaml
│ ├── DateTimeInput.xaml.cs
│ ├── LatitudeInput.xaml
│ ├── LatitudeInput.xaml.cs
│ ├── LongitudeInput.xaml
│ └── LongitudeInput.xaml.cs
│ ├── Converters
│ ├── DoubleToDegreesFormatConverter.cs
│ ├── DoubleToTimeFormatConverter.cs
│ └── StringEmptyToVisibility.cs
│ ├── GlobalSuppressions.cs
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── Models
│ ├── Configuration.cs
│ ├── EphemerisResult.cs
│ ├── HouseValues.cs
│ ├── InputCalculation.cs
│ └── PlanetValues.cs
│ ├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
│ ├── Services
│ ├── CalcService.cs
│ └── ICalcService.cs
│ ├── SweWPF.csproj
│ ├── SwephData
│ └── sedeltat.txt
│ ├── Themes
│ ├── DataTemplates.xaml
│ └── Styles.xaml
│ ├── ViewModels
│ ├── CalculationResultViewModel.cs
│ ├── ConfigViewModel.cs
│ ├── InputDateViewModel.cs
│ ├── InputViewModel.cs
│ ├── MainViewModel.cs
│ ├── RelayCommand.cs
│ ├── ViewModel.cs
│ └── [Enums].cs
│ ├── Views
│ ├── ConfigView.xaml
│ ├── ConfigView.xaml.cs
│ ├── InputDateView.xaml
│ ├── InputDateView.xaml.cs
│ ├── InputView.xaml
│ ├── InputView.xaml.cs
│ ├── ResultView.xaml
│ └── ResultView.xaml.cs
│ └── packages.config
├── README.md
├── SwephNet.sln
├── SwephNet
├── SweNet
│ ├── Date
│ │ ├── DateUT.cs
│ │ ├── EphemerisTime.cs
│ │ ├── IDeltaTReader.cs
│ │ ├── JulianDay.cs
│ │ ├── SideralTime.cs
│ │ ├── StreamDeltaTReader.cs
│ │ ├── SweDate.cs
│ │ └── WeekDay.cs
│ ├── Extensions
│ │ ├── DateTimeExtensions.cs
│ │ └── StringExtensions.cs
│ ├── Geo
│ │ ├── GeoPosition.cs
│ │ ├── Latitude.cs
│ │ └── Longitude.cs
│ ├── Houses
│ │ └── SweHouse.cs
│ ├── Persit
│ │ ├── EmptyDataProvider.cs
│ │ ├── IDataProvider.cs
│ │ ├── IDataReader.cs
│ │ └── StreamDataReader.cs
│ ├── Planets
│ │ ├── IAsteroidNameReader.cs
│ │ ├── Planet.cs
│ │ └── SwePlanet.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SweConfig.cs
│ ├── SweConst.cs
│ ├── SweFormat.cs
│ ├── SweNet.csproj
│ ├── Sweph.cs
│ ├── [Enums].cs
│ ├── [Events].cs
│ └── packages.config
└── SwephNet
│ ├── Date
│ ├── DeltaTRecord.cs
│ ├── DeltaTRecordFile.cs
│ ├── EphemerisTime.cs
│ ├── IDeltaTRecordProvider.cs
│ ├── JulianDay.cs
│ ├── SideralTime.cs
│ ├── SweDate.cs
│ ├── UniversalTime.cs
│ └── [Enums].cs
│ ├── Dependency
│ ├── IDependencyContainer.cs
│ └── SimpleContainer.cs
│ ├── Extensions
│ ├── DateTimeExtensions.cs
│ ├── DependencyExtensions.cs
│ ├── HouseExtensions.cs
│ └── TracerExtensions.cs
│ ├── Geo
│ ├── GeoPosition.cs
│ ├── Latitude.cs
│ └── Longitude.cs
│ ├── Houses
│ ├── HousePoint.cs
│ ├── HouseResult.cs
│ ├── HouseSystem.cs
│ └── SweHouse.cs
│ ├── JPL
│ └── [Enums].cs
│ ├── Locales
│ ├── LSR.Designer.cs
│ ├── LSR.fr.resx
│ └── LSR.resx
│ ├── Persit
│ ├── IStreamProvider.cs
│ └── LoadFileEventArgs.cs
│ ├── Planets
│ ├── AsteroidNameFile.cs
│ ├── IAsteroidNameProvider.cs
│ ├── IOsculatingElementProvider.cs
│ ├── OsculatingElement.cs
│ ├── OsculatingElementFile.cs
│ ├── Planet.cs
│ └── SwePlanet.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── SweError.cs
│ ├── SweFormat.cs
│ ├── SweLib.cs
│ ├── Sweph.cs
│ ├── SwephNet.csproj
│ ├── Utils
│ ├── Check.cs
│ └── ITracer.cs
│ └── [Events].cs
├── Tests
├── SweNet.Tests
│ ├── DateUTTest.cs
│ ├── EphemerisTimeTest.cs
│ ├── GeoPositionTest.cs
│ ├── JulianDayTest.cs
│ ├── LatitudeTest.cs
│ ├── LongitudeTest.cs
│ ├── PlanetTest.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── SideralTimeTest.cs
│ ├── StringExtensionsTest.cs
│ ├── SweDateTest.cs
│ ├── SweNet.Tests.csproj
│ ├── SwePlanetTest.cs
│ ├── SwephTest.Date.cs
│ └── packages.config
└── SwephNet.Tests
│ ├── CheckTest.cs
│ ├── DependencyTest.cs
│ ├── EphemerisTimeTest.cs
│ ├── GeoPositionTest.cs
│ ├── JulianDayTest.cs
│ ├── LatitudeTest.cs
│ ├── LongitudeTest.cs
│ ├── PlanetTest.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── SideralTimeTest.cs
│ ├── SweDateTest.cs
│ ├── SweErrorTest.cs
│ ├── SweFormatTest.cs
│ ├── SweLibTest.cs
│ ├── SwePlanetTest-fr.cs
│ ├── SwePlanetTest.cs
│ ├── SwephDateTest.cs
│ ├── SwephNet.Tests.csproj
│ ├── SwephTest.cs
│ └── UniversalTimeTest.cs
├── appveyor.yml
└── release_notes.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 | [Dd]ebug/
11 | [Dd]ebugPublic/
12 | [Rr]elease/
13 | x64/
14 | build/
15 | bld/
16 | [Bb]in/
17 | [Oo]bj/
18 |
19 | # MSTest test Results
20 | [Tt]est[Rr]esult*/
21 | [Bb]uild[Ll]og.*
22 |
23 | #NUNIT
24 | *.VisualState.xml
25 | TestResult.xml
26 |
27 | # Build Results of an ATL Project
28 | [Dd]ebugPS/
29 | [Rr]eleasePS/
30 | dlldata.c
31 |
32 | *_i.c
33 | *_p.c
34 | *_i.h
35 | *.ilk
36 | *.meta
37 | *.obj
38 | *.pch
39 | *.pdb
40 | *.pgc
41 | *.pgd
42 | *.rsp
43 | *.sbr
44 | *.tlb
45 | *.tli
46 | *.tlh
47 | *.tmp
48 | *.tmp_proj
49 | *.log
50 | *.vspscc
51 | *.vssscc
52 | .builds
53 | *.pidb
54 | *.svclog
55 | *.scc
56 |
57 | # Chutzpah Test files
58 | _Chutzpah*
59 |
60 | # Visual C++ cache files
61 | ipch/
62 | *.aps
63 | *.ncb
64 | *.opensdf
65 | *.sdf
66 | *.cachefile
67 |
68 | # Visual Studio profiler
69 | *.psess
70 | *.vsp
71 | *.vspx
72 |
73 | # TFS 2012 Local Workspace
74 | $tf/
75 |
76 | # Guidance Automation Toolkit
77 | *.gpState
78 |
79 | # ReSharper is a .NET coding add-in
80 | _ReSharper*/
81 | *.[Rr]e[Ss]harper
82 | *.DotSettings.user
83 |
84 | # JustCode is a .NET coding addin-in
85 | .JustCode
86 |
87 | # TeamCity is a build add-in
88 | _TeamCity*
89 |
90 | # DotCover is a Code Coverage Tool
91 | *.dotCover
92 |
93 | # NCrunch
94 | *.ncrunch*
95 | _NCrunch_*
96 | .*crunch*.local.xml
97 |
98 | # MightyMoose
99 | *.mm.*
100 | AutoTest.Net/
101 |
102 | # Web workbench (sass)
103 | .sass-cache/
104 |
105 | # Installshield output folder
106 | [Ee]xpress/
107 |
108 | # DocProject is a documentation generator add-in
109 | DocProject/buildhelp/
110 | DocProject/Help/*.HxT
111 | DocProject/Help/*.HxC
112 | DocProject/Help/*.hhc
113 | DocProject/Help/*.hhk
114 | DocProject/Help/*.hhp
115 | DocProject/Help/Html2
116 | DocProject/Help/html
117 |
118 | # Click-Once directory
119 | publish/
120 |
121 | # Publish Web Output
122 | *.[Pp]ublish.xml
123 | *.azurePubxml
124 |
125 | # NuGet Packages Directory
126 | packages/
127 | ## TODO: If the tool you use requires repositories.config uncomment the next line
128 | #!packages/repositories.config
129 |
130 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
131 | # This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented)
132 | !packages/build/
133 |
134 | # Windows Azure Build Output
135 | csx/
136 | *.build.csdef
137 |
138 | # Windows Store app package directory
139 | AppPackages/
140 |
141 | # Others
142 | sql/
143 | *.Cache
144 | ClientBin/
145 | [Ss]tyle[Cc]op.*
146 | ~$*
147 | *~
148 | *.dbmdl
149 | *.dbproj.schemaview
150 | *.pfx
151 | *.publishsettings
152 | node_modules/
153 |
154 | # RIA/Silverlight projects
155 | Generated_Code/
156 |
157 | # Backup & report files from converting an old project file to a newer
158 | # Visual Studio version. Backup files are not needed, because we have git ;-)
159 | _UpgradeReport_Files/
160 | Backup*/
161 | UpgradeLog*.XML
162 | UpgradeLog*.htm
163 |
164 | # SQL Server files
165 | *.mdf
166 | *.ldf
167 |
168 | # Business Intelligence projects
169 | *.rdl.data
170 | *.bim.layout
171 | *.bim_*.settings
172 |
173 | # Microsoft Fakes
174 | FakesAssemblies/
175 | /README.html
176 | /README.min.html
177 | /release-bin
178 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
2 |
3 | License conditions
4 | ------------------
5 |
6 | This file is part of Swiss Ephemeris.
7 |
8 | Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
9 | or distributor accepts any responsibility for the consequences of using it,
10 | or for whether it serves any particular purpose or works at all, unless he
11 | or she says so in writing.
12 |
13 | Swiss Ephemeris is made available by its authors under a dual licensing
14 | system. The software developer, who uses any part of Swiss Ephemeris
15 | in his or her software, must choose between one of the two license models,
16 | which are
17 | a) GNU public license version 2 or later
18 | b) Swiss Ephemeris Professional License
19 |
20 | The choice must be made before the software developer distributes software
21 | containing parts of Swiss Ephemeris to others, and before any public
22 | service using the developed software is activated.
23 |
24 | If the developer choses the GNU GPL software license, he or she must fulfill
25 | the conditions of that license, which includes the obligation to place his
26 | or her whole software project under the GNU GPL or a compatible license.
27 | See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
28 |
29 | If the developer choses the Swiss Ephemeris Professional license,
30 | he must follow the instructions as found in http://www.astro.com/swisseph/
31 | and purchase the Swiss Ephemeris Professional Edition from Astrodienst
32 | and sign the corresponding license contract.
33 |
34 | The License grants you the right to use, copy, modify and redistribute
35 | Swiss Ephemeris, but only under certain conditions described in the License.
36 | Among other things, the License requires that the copyright notices and
37 | this notice be preserved on all copies.
38 |
39 | Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
40 |
41 | The authors of Swiss Ephemeris have no control or influence over any of
42 | the derived works, i.e. over software or services created by other
43 | programmers which use Swiss Ephemeris functions.
44 |
45 | The names of the authors or of the copyright holder (Astrodienst) must not
46 | be used for promoting any software, product or service which uses or contains
47 | the Swiss Ephemeris. This copyright notice is the ONLY place where the
48 | names of the authors can legally appear, except in cases where they have
49 | given special permission in writing.
50 |
51 | The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
52 | for promoting such software, products or services.
53 | */
54 |
55 |
--------------------------------------------------------------------------------
/Programs/SweWPF/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Programs/SweWPF/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Programs/SweWPF/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Globalization;
6 | using System.Linq;
7 | using System.Threading.Tasks;
8 | using System.Windows;
9 | using System.Windows.Markup;
10 |
11 | namespace SweWPF
12 | {
13 | ///
14 | /// Logique d'interaction pour App.xaml
15 | ///
16 | public partial class App : Application
17 | {
18 |
19 | protected override void OnStartup(StartupEventArgs e) {
20 | base.OnStartup(e);
21 |
22 | FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
23 | new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
24 |
25 | }
26 |
27 | protected override void OnExit(ExitEventArgs e) {
28 | base.OnExit(e);
29 | }
30 |
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Controls/DateTimeInput.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Controls/DateTimeInput.xaml.cs:
--------------------------------------------------------------------------------
1 | using SweNet;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 |
17 | namespace SweWPF.Controls
18 | {
19 | ///
20 | /// Logique d'interaction pour DateTimeInput.xaml
21 | ///
22 | public partial class DateTimeInput : UserControl
23 | {
24 | public DateTimeInput() {
25 | InitializeComponent();
26 | Date = new DateUT(DateTime.Now);
27 | }
28 |
29 | bool _Updating = false;
30 |
31 | private void DateChanged() {
32 | if (_Updating) return;
33 | _Updating = true;
34 | Day = Date.Day;
35 | Month = Date.Month;
36 | Year = Date.Year;
37 | Hours = Date.Hours;
38 | Minutes = Date.Minutes;
39 | Seconds = Date.Seconds;
40 | _Updating = false;
41 | }
42 |
43 | private void ElementDateChanged() {
44 | if (_Updating) return;
45 | try {
46 | _Updating = true;
47 | Date = new DateUT(Year, Month, Day, Hours, Minutes, Seconds);
48 | _Updating = false;
49 | }
50 | catch {
51 | _Updating = false;
52 | DateChanged();
53 | }
54 | }
55 |
56 | public DateUT Date {
57 | get { return (DateUT)GetValue(DateProperty); }
58 | set { SetValue(DateProperty, value); }
59 | }
60 |
61 | public static readonly DependencyProperty DateProperty =
62 | DependencyProperty.Register("Date", typeof(DateUT), typeof(DateTimeInput), new PropertyMetadata(new DateUT(), DatePropertyChanged));
63 |
64 | private static void DatePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
65 | var dti = d as DateTimeInput;
66 | if (dti != null)
67 | dti.DateChanged();
68 | }
69 |
70 |
71 | public int Day {
72 | get { return (int)GetValue(DayProperty); }
73 | set { SetValue(DayProperty, value); }
74 | }
75 | public static readonly DependencyProperty DayProperty =
76 | DependencyProperty.Register("Day", typeof(int), typeof(DateTimeInput), new PropertyMetadata(1, ElementDatePropertyChanged));
77 |
78 | public int Month {
79 | get { return (int)GetValue(MonthProperty); }
80 | set { SetValue(MonthProperty, value); }
81 | }
82 | public static readonly DependencyProperty MonthProperty =
83 | DependencyProperty.Register("Month", typeof(int), typeof(DateTimeInput), new PropertyMetadata(1, ElementDatePropertyChanged));
84 |
85 | public int Year {
86 | get { return (int)GetValue(YearProperty); }
87 | set { SetValue(YearProperty, value); }
88 | }
89 | public static readonly DependencyProperty YearProperty =
90 | DependencyProperty.Register("Year", typeof(int), typeof(DateTimeInput), new PropertyMetadata(1, ElementDatePropertyChanged));
91 |
92 | public int Hours {
93 | get { return (int)GetValue(HoursProperty); }
94 | set { SetValue(HoursProperty, value); }
95 | }
96 | public static readonly DependencyProperty HoursProperty =
97 | DependencyProperty.Register("Hours", typeof(int), typeof(DateTimeInput), new PropertyMetadata(1, ElementDatePropertyChanged));
98 |
99 | public int Minutes {
100 | get { return (int)GetValue(MinutesProperty); }
101 | set { SetValue(MinutesProperty, value); }
102 | }
103 | public static readonly DependencyProperty MinutesProperty =
104 | DependencyProperty.Register("Minutes", typeof(int), typeof(DateTimeInput), new PropertyMetadata(1, ElementDatePropertyChanged));
105 |
106 | public int Seconds {
107 | get { return (int)GetValue(SecondsProperty); }
108 | set { SetValue(SecondsProperty, value); }
109 | }
110 | public static readonly DependencyProperty SecondsProperty =
111 | DependencyProperty.Register("Seconds", typeof(int), typeof(DateTimeInput), new PropertyMetadata(1, ElementDatePropertyChanged));
112 |
113 | private static void ElementDatePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
114 | var dti = d as DateTimeInput;
115 | if (dti != null)
116 | dti.ElementDateChanged();
117 | }
118 |
119 |
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Controls/LatitudeInput.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Controls/LatitudeInput.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace SweWPF.Controls
17 | {
18 | ///
19 | /// Logique d'interaction pour LatitudeInput.xaml
20 | ///
21 | public partial class LatitudeInput : UserControl
22 | {
23 | public LatitudeInput() {
24 | Polarities = new SweNet.LatitudePolarity[]{
25 | SweNet.LatitudePolarity.North,
26 | SweNet.LatitudePolarity.South,
27 | };
28 | InitializeComponent();
29 | }
30 |
31 | bool _Updating = false;
32 |
33 | private void LatitudeChanged() {
34 | if (_Updating) return;
35 | _Updating = true;
36 | Degrees = Latitude.Degrees;
37 | Minutes = Latitude.Minutes;
38 | Seconds = Latitude.Seconds;
39 | Polarity = Latitude.Polarity;
40 | _Updating = false;
41 | }
42 |
43 | private void ComponentChanged() {
44 | if (_Updating) return;
45 | try {
46 | _Updating = true;
47 | Latitude = new SweNet.Latitude(Degrees, Minutes, Seconds, Polarity);
48 | _Updating = false;
49 | }
50 | catch {
51 | _Updating = false;
52 | LatitudeChanged();
53 | }
54 | }
55 |
56 | public SweNet.Latitude Latitude {
57 | get { return (SweNet.Latitude)GetValue(LatitudeProperty); }
58 | set { SetValue(LatitudeProperty, value); }
59 | }
60 | public static readonly DependencyProperty LatitudeProperty =
61 | DependencyProperty.Register("Latitude", typeof(SweNet.Latitude), typeof(LatitudeInput), new PropertyMetadata(new SweNet.Latitude(), LatitudePropertyChanged));
62 |
63 | private static void LatitudePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
64 | var li = d as LatitudeInput;
65 | if (li != null)
66 | li.LatitudeChanged();
67 | }
68 |
69 | public int Degrees {
70 | get { return (int)GetValue(DegreesProperty); }
71 | set { SetValue(DegreesProperty, value); }
72 | }
73 | public static readonly DependencyProperty DegreesProperty =
74 | DependencyProperty.Register("Degrees", typeof(int), typeof(LatitudeInput), new PropertyMetadata(0, LatitudeComponentChanged));
75 |
76 | private static void LatitudeComponentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
77 | var li = d as LatitudeInput;
78 | if (li != null)
79 | li.ComponentChanged();
80 | }
81 |
82 | public int Minutes {
83 | get { return (int)GetValue(MinutesProperty); }
84 | set { SetValue(MinutesProperty, value); }
85 | }
86 | public static readonly DependencyProperty MinutesProperty =
87 | DependencyProperty.Register("Minutes", typeof(int), typeof(LatitudeInput), new PropertyMetadata(0, LatitudeComponentChanged));
88 |
89 | public int Seconds {
90 | get { return (int)GetValue(SecondsProperty); }
91 | set { SetValue(SecondsProperty, value); }
92 | }
93 | public static readonly DependencyProperty SecondsProperty =
94 | DependencyProperty.Register("Seconds", typeof(int), typeof(LatitudeInput), new PropertyMetadata(0, LatitudeComponentChanged));
95 |
96 | public SweNet.LatitudePolarity Polarity {
97 | get { return (SweNet.LatitudePolarity)GetValue(PolarityProperty); }
98 | set { SetValue(PolarityProperty, value); }
99 | }
100 | public static readonly DependencyProperty PolarityProperty =
101 | DependencyProperty.Register("Polarity", typeof(SweNet.LatitudePolarity), typeof(LatitudeInput), new PropertyMetadata(SweNet.LatitudePolarity.North, LatitudeComponentChanged));
102 |
103 | public SweNet.LatitudePolarity[] Polarities { get; private set; }
104 |
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Controls/LongitudeInput.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Controls/LongitudeInput.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace SweWPF.Controls
17 | {
18 | ///
19 | /// Logique d'interaction pour LongitudeInput.xaml
20 | ///
21 | public partial class LongitudeInput : UserControl
22 | {
23 | public LongitudeInput() {
24 | Polarities = new SweNet.LongitudePolarity[]{
25 | SweNet.LongitudePolarity.East,
26 | SweNet.LongitudePolarity.West,
27 | };
28 | InitializeComponent();
29 | }
30 |
31 | bool _Updating = false;
32 |
33 | private void LongitudeChanged() {
34 | if (_Updating) return;
35 | _Updating = true;
36 | Degrees = Longitude.Degrees;
37 | Minutes = Longitude.Minutes;
38 | Seconds = Longitude.Seconds;
39 | Polarity = Longitude.Polarity;
40 | _Updating = false;
41 | }
42 |
43 | private void ComponentChanged() {
44 | if (_Updating) return;
45 | try {
46 | _Updating = true;
47 | Longitude = new SweNet.Longitude(Degrees, Minutes, Seconds, Polarity);
48 | _Updating = false;
49 | }
50 | catch {
51 | _Updating = false;
52 | LongitudeChanged();
53 | }
54 | }
55 |
56 | public SweNet.Longitude Longitude {
57 | get { return (SweNet.Longitude)GetValue(LongitudeProperty); }
58 | set { SetValue(LongitudeProperty, value); }
59 | }
60 | public static readonly DependencyProperty LongitudeProperty =
61 | DependencyProperty.Register("Longitude", typeof(SweNet.Longitude), typeof(LongitudeInput), new PropertyMetadata(new SweNet.Longitude(), LongitudePropertyChanged));
62 |
63 | private static void LongitudePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
64 | var li = d as LongitudeInput;
65 | if (li != null)
66 | li.LongitudeChanged();
67 | }
68 |
69 | public int Degrees {
70 | get { return (int)GetValue(DegreesProperty); }
71 | set { SetValue(DegreesProperty, value); }
72 | }
73 | public static readonly DependencyProperty DegreesProperty =
74 | DependencyProperty.Register("Degrees", typeof(int), typeof(LongitudeInput), new PropertyMetadata(0, LongitudeComponentChanged));
75 |
76 | private static void LongitudeComponentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
77 | var li = d as LongitudeInput;
78 | if (li != null)
79 | li.ComponentChanged();
80 | }
81 |
82 | public int Minutes {
83 | get { return (int)GetValue(MinutesProperty); }
84 | set { SetValue(MinutesProperty, value); }
85 | }
86 | public static readonly DependencyProperty MinutesProperty =
87 | DependencyProperty.Register("Minutes", typeof(int), typeof(LongitudeInput), new PropertyMetadata(0, LongitudeComponentChanged));
88 |
89 | public int Seconds {
90 | get { return (int)GetValue(SecondsProperty); }
91 | set { SetValue(SecondsProperty, value); }
92 | }
93 | public static readonly DependencyProperty SecondsProperty =
94 | DependencyProperty.Register("Seconds", typeof(int), typeof(LongitudeInput), new PropertyMetadata(0, LongitudeComponentChanged));
95 |
96 | public SweNet.LongitudePolarity Polarity {
97 | get { return (SweNet.LongitudePolarity)GetValue(PolarityProperty); }
98 | set { SetValue(PolarityProperty, value); }
99 | }
100 | public static readonly DependencyProperty PolarityProperty =
101 | DependencyProperty.Register("Polarity", typeof(SweNet.LongitudePolarity), typeof(LongitudeInput), new PropertyMetadata(SweNet.LongitudePolarity.East, LongitudeComponentChanged));
102 |
103 | public SweNet.LongitudePolarity[] Polarities { get; private set; }
104 |
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Converters/DoubleToDegreesFormatConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Data;
7 |
8 | namespace SweWPF.Converters
9 | {
10 |
11 | ///
12 | /// Convert double to Degrees format
13 | ///
14 | public class DoubleToDegreesFormatConverter : IValueConverter
15 | {
16 |
17 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
18 | double val = System.Convert.ToDouble(value);
19 | string fmt = parameter != null ? parameter.ToString() : null;
20 | return SwissEphNet.SwissEph.FormatToDegreeMinuteSecond(val, fmt);
21 | }
22 |
23 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
24 | throw new NotImplementedException();
25 | }
26 |
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Converters/DoubleToTimeFormatConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Data;
7 |
8 | namespace SweWPF.Converters
9 | {
10 |
11 | ///
12 | /// Convert double to Time/Hour format
13 | ///
14 | public class DoubleToTimeFormatConverter : IValueConverter
15 | {
16 |
17 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
18 | double val = System.Convert.ToDouble(value);
19 | if (parameter != null && parameter.ToString() == "hour")
20 | return SweNet.SweFormat.FormatAsHour(val);
21 | else
22 | return SweNet.SweFormat.FormatAsTime(val);
23 | }
24 |
25 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
26 | throw new NotImplementedException();
27 | }
28 |
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Converters/StringEmptyToVisibility.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Data;
8 |
9 | namespace SweWPF.Converters
10 | {
11 |
12 | public class StringEmptyToVisibility : IValueConverter
13 | {
14 | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
15 | bool isVisible = !(value == null || String.IsNullOrWhiteSpace(value.ToString()));
16 | if (parameter != null && parameter.ToString() == "not")
17 | isVisible = !isVisible;
18 | return isVisible ? Visibility.Visible : Visibility.Collapsed;
19 | }
20 |
21 | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
22 | throw new NotImplementedException();
23 | }
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/Programs/SweWPF/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ygrenier/SwephNet/164a8b734d7dc5aad06070db7e4d33ce83127e0f/Programs/SweWPF/GlobalSuppressions.cs
--------------------------------------------------------------------------------
/Programs/SweWPF/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/Programs/SweWPF/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace SweWPF
17 | {
18 | ///
19 | /// Logique d'interaction pour MainWindow.xaml
20 | ///
21 | public partial class MainWindow : Window
22 | {
23 | public MainWindow() {
24 | InitializeComponent();
25 | DataContext = new ViewModels.MainViewModel();
26 | }
27 |
28 | public ViewModels.MainViewModel ViewModel { get { return (ViewModels.MainViewModel)DataContext; } }
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Models/Configuration.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace SweWPF.Models
8 | {
9 |
10 | ///
11 | /// Sweph configuration
12 | ///
13 | public class Configuration
14 | {
15 | ///
16 | /// New configuration
17 | ///
18 | public Configuration() {
19 | SearchPaths = new List();
20 | }
21 | ///
22 | /// Liste of file search folders
23 | ///
24 | public List SearchPaths { get; private set; }
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Models/EphemerisResult.cs:
--------------------------------------------------------------------------------
1 | using SweNet;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace SweWPF.Models
9 | {
10 | ///
11 | /// Ephemeris calculations
12 | ///
13 | public class EphemerisResult
14 | {
15 | ///
16 | /// New result
17 | ///
18 | public EphemerisResult() {
19 | Planets = new List();
20 | Houses = new List();
21 | ASMCs = new List();
22 | }
23 |
24 | ///
25 | /// Reset the result
26 | ///
27 | public void Reset() {
28 | DateUTC = new DateUT();
29 | JulianDay = new JulianDay();
30 | EphemerisTime = new EphemerisTime();
31 | SideralTime = 0;
32 | MeanEclipticObliquity = 0;
33 | TrueEclipticObliquity = 0;
34 | NutationLongitude = 0;
35 | NutationObliquity = 0;
36 | Planets.Clear();
37 | Houses.Clear();
38 | ASMCs.Clear();
39 | }
40 |
41 | ///
42 | /// Date UTC
43 | ///
44 | public DateUT DateUTC { get; set; }
45 |
46 | ///
47 | /// Julian Day
48 | ///
49 | public JulianDay JulianDay { get; set; }
50 |
51 | ///
52 | /// Ephemeris time
53 | ///
54 | public EphemerisTime EphemerisTime { get; set; }
55 |
56 | ///
57 | /// Delat T in seconds
58 | ///
59 | public Double DeltaTSec { get { return EphemerisTime.DeltaT * 86400.0; } }
60 |
61 | ///
62 | /// Sideral time
63 | ///
64 | public double SideralTime { get; set; }
65 |
66 | ///
67 | /// Sideral time in degrees
68 | ///
69 | public double SideralTimeInDegrees { get { return SideralTime * 15; } }
70 |
71 | ///
72 | /// ARMC : Sideral time in degrees
73 | ///
74 | public double ARMC { get { return SideralTime * 15; } }
75 |
76 | ///
77 | /// Mean ecliptic obliquity
78 | ///
79 | public Double MeanEclipticObliquity { get; set; }
80 |
81 | ///
82 | /// True ecliptic obliquity
83 | ///
84 | public Double TrueEclipticObliquity { get; set; }
85 |
86 | ///
87 | /// Nutation in longitude
88 | ///
89 | public Double NutationLongitude { get; set; }
90 |
91 | ///
92 | /// Nutation in obliquity
93 | ///
94 | public Double NutationObliquity { get; set; }
95 |
96 | ///
97 | /// Planets calculation result
98 | ///
99 | public List Planets { get; private set; }
100 |
101 | ///
102 | /// Houses
103 | ///
104 | public List Houses { get; private set; }
105 |
106 | ///
107 | /// Ascendants, MC etc.
108 | ///
109 | public List ASMCs { get; private set; }
110 |
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Models/HouseValues.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace SweWPF.Models
8 | {
9 | public class HouseValues
10 | {
11 | public int House { get; set; }
12 | public String HouseName { get; set; }
13 | public Double Cusp { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Models/InputCalculation.cs:
--------------------------------------------------------------------------------
1 | using SweNet;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace SweWPF.Models
9 | {
10 | ///
11 | /// Input values for calculation
12 | ///
13 | public class InputCalculation
14 | {
15 |
16 | public InputCalculation() {
17 | EphemerisMode = SweNet.EphemerisMode.SwissEphemeris;
18 | JplFile = SwissEphNet.SwissEph.SE_FNAME_DFT;
19 | Planets = new List();
20 | DateUT = new DateUT(DateTime.Now);
21 | Longitude = new SweNet.Longitude(5, 20, 0, LongitudePolarity.East);
22 | Latitude = new SweNet.Latitude(47, 52, 0, LatitudePolarity.North);
23 | HouseSystem = HouseSystem.Placidus;
24 | Planets.AddRange(new Planet[] {
25 | Planet.Sun, Planet.Moon, Planet.Mercury, Planet.Venus, Planet.Mars, Planet.Jupiter,
26 | Planet.Saturn, Planet.Uranus, Planet.Neptune, Planet.Pluto,
27 | Planet.MeanNode, Planet.TrueNode,
28 | Planet.MeanApog, Planet.OscuApog, Planet.Earth
29 | });
30 | Planets.AddRange(new Planet[] { Planet.AsAsteroid(433), Planet.AsAsteroid(3045), Planet.AsAsteroid(7066) });
31 | }
32 |
33 | public EphemerisMode EphemerisMode { get; set; }
34 |
35 | public String JplFile { get; set; }
36 |
37 | public DateUT? DateUT { get; set; }
38 |
39 | public DateUT? DateET { get; set; }
40 |
41 | public JulianDay? JulianDay { get; set; }
42 |
43 | public PositionCenter PositionCenter { get; set; }
44 |
45 | ///
46 | /// Latitude
47 | ///
48 | public Latitude Latitude { get; set; }
49 |
50 | ///
51 | /// Longitude
52 | ///
53 | public Longitude Longitude { get; set; }
54 |
55 | ///
56 | /// Altitude
57 | ///
58 | public int Altitude { get; set; }
59 |
60 | ///
61 | /// House system
62 | ///
63 | public HouseSystem HouseSystem { get; set; }
64 |
65 | ///
66 | /// Planets to calculate
67 | ///
68 | public List Planets { get; private set; }
69 |
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Models/PlanetValues.cs:
--------------------------------------------------------------------------------
1 | using SweNet;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace SweWPF.Models
9 | {
10 | public class PlanetValues
11 | {
12 | public Planet Planet { get; set; }
13 | public String PlanetName { get; set; }
14 | public Double HousePosition { get; set; }
15 | public Double Longitude { get; set; }
16 | public Double Latitude { get; set; }
17 | public Double Distance { get; set; }
18 | public Double LongitudeSpeed { get; set; }
19 | public Double LatitudeSpeed { get; set; }
20 | public Double DistanceSpeed { get; set; }
21 | ///
22 | /// Error in calculation
23 | ///
24 | public string ErrorMessage { get; set; }
25 | ///
26 | /// Warning in calculation
27 | ///
28 | public string WarnMessage { get; set; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // Les informations générales relatives à un assembly dépendent de
8 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
9 | // associées à un assembly.
10 | [assembly: AssemblyTitle("SweWPF")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("SweWPF")]
15 | [assembly: AssemblyCopyright("Copyright © 2014")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
20 | // aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
21 | // COM, affectez la valeur true à l'attribut ComVisible sur ce type.
22 | [assembly: ComVisible(false)]
23 |
24 | //Pour commencer à générer des applications localisables, définissez
25 | //CultureYouAreCodingWith dans votre fichier .csproj
26 | //dans . Par exemple, si vous utilisez le français
27 | //dans vos fichiers sources, définissez à fr-FR. Puis, supprimez les marques de commentaire de
28 | //l'attribut NeutralResourceLanguage ci-dessous. Mettez à jour "fr-FR" dans
29 | //la ligne ci-après pour qu'elle corresponde au paramètre UICulture du fichier projet.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //où se trouvent les dictionnaires de ressources spécifiques à un thème
36 | //(utilisé si une ressource est introuvable dans la page,
37 | // ou dictionnaires de ressources de l'application)
38 | ResourceDictionaryLocation.SourceAssembly //où se trouve le dictionnaire de ressources générique
39 | //(utilisé si une ressource est introuvable dans la page,
40 | // dans l'application ou dans l'un des dictionnaires de ressources spécifiques à un thème)
41 | )]
42 |
43 |
44 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes :
45 | //
46 | // Version principale
47 | // Version secondaire
48 | // Numéro de build
49 | // Révision
50 | //
51 | // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
52 | // en utilisant '*', comme indiqué ci-dessous :
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // Ce code a été généré par un outil.
4 | // Version du runtime :4.0.30319.18444
5 | //
6 | // Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
7 | // le code est régénéré.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SweWPF.Properties
12 | {
13 |
14 |
15 | ///
16 | /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées.
17 | ///
18 | // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder
19 | // à l'aide d'un outil, tel que ResGen ou Visual Studio.
20 | // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen
21 | // avec l'option /str ou régénérez votre projet VS.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources() {
34 | }
35 |
36 | ///
37 | /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe.
38 | ///
39 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
40 | internal static global::System.Resources.ResourceManager ResourceManager {
41 | get {
42 | if ((resourceMan == null)) {
43 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SweWPF.Properties.Resources", typeof(Resources).Assembly);
44 | resourceMan = temp;
45 | }
46 | return resourceMan;
47 | }
48 | }
49 |
50 | ///
51 | /// Remplace la propriété CurrentUICulture du thread actuel pour toutes
52 | /// les recherches de ressources à l'aide de cette classe de ressource fortement typée.
53 | ///
54 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
55 | internal static global::System.Globalization.CultureInfo Culture {
56 | get {
57 | return resourceCulture;
58 | }
59 | set {
60 | resourceCulture = value;
61 | }
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.18444
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace SweWPF.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default {
23 | get {
24 | return defaultInstance;
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Services/ICalcService.cs:
--------------------------------------------------------------------------------
1 | using SweWPF.Models;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace SweWPF.Services
9 | {
10 | ///
11 | /// Interface of a Sweph calculation service
12 | ///
13 | public interface ICalcService
14 | {
15 |
16 | ///
17 | /// Make calculation
18 | ///
19 | EphemerisResult Calculate(Configuration config, InputCalculation input);
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Programs/SweWPF/SwephData/sedeltat.txt:
--------------------------------------------------------------------------------
1 | # This file allows to make new Delta T known to the Swiss Ephemeris.
2 | # Note, these values override the values given in the internal Delta T
3 | # table of the Swiss Ephemeris.
4 | #
5 | # If you want to use this file, change its file name and remove the
6 | # the extension '.inactive'. As soon as you do so, the values below
7 | # will be used, i.e. they will override the internal Delta T values
8 | # of the Swiss Ephemeris.
9 | #
10 | # Format: year and seconds (decimal)
11 | 2007 65.15
12 | 2008 65.46
13 | 2009 65.78
14 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Themes/DataTemplates.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Themes/Styles.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/Programs/SweWPF/ViewModels/ConfigViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace SweWPF.ViewModels
8 | {
9 |
10 | ///
11 | ///
12 | ///
13 | public class ConfigViewModel : ViewModel
14 | {
15 | private String _EphemerisPath;
16 |
17 | ///
18 | ///
19 | ///
20 | public ConfigViewModel() {
21 | _EphemerisPath = @".;C:\sweph\ephe";
22 | }
23 |
24 | ///
25 | ///
26 | ///
27 | public Models.Configuration CreateConfigurationData() {
28 | var result = new Models.Configuration();
29 | result.SearchPaths.AddRange(EphemerisPath.Split(new Char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
30 | return result;
31 | }
32 |
33 | ///
34 | /// Ephemeris path
35 | ///
36 | public String EphemerisPath {
37 | get { return _EphemerisPath; }
38 | set {
39 | _EphemerisPath = value;
40 | RaisePropertyChanged("EphemerisPath");
41 | }
42 | }
43 |
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/Programs/SweWPF/ViewModels/MainViewModel.cs:
--------------------------------------------------------------------------------
1 | using SweNet;
2 | using SwissEphNet;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Collections.ObjectModel;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 |
11 | namespace SweWPF.ViewModels
12 | {
13 |
14 | ///
15 | /// Main viewmodel
16 | ///
17 | public class MainViewModel : ViewModel
18 | {
19 | Dictionary _Services = new Dictionary();
20 |
21 | public MainViewModel() {
22 | Config = new ConfigViewModel();
23 | Input = new InputViewModel();
24 | Result = new CalculationResultViewModel();
25 | DoCalculationCommand = new RelayCommand(() => {
26 | DoCalculation();
27 | });
28 | }
29 |
30 | ///
31 | /// Do calculation
32 | ///
33 | public void DoCalculation() {
34 | Result.Apply(
35 | GetService().Calculate(
36 | Config.CreateConfigurationData(),
37 | Input.CreateInputData()
38 | )
39 | );
40 | }
41 |
42 | ///
43 | /// Get a service
44 | ///
45 | public T GetService() {
46 | object r = null;
47 | if (_Services.TryGetValue(typeof(T), out r))
48 | return (T)r;
49 | if (typeof(T) == typeof(Services.ICalcService)) {
50 | r = new Services.CalcService();
51 | _Services[typeof(T)] = r;
52 | }
53 | return (T)r;
54 | }
55 |
56 | ///
57 | /// Configuration
58 | ///
59 | public ConfigViewModel Config { get; private set; }
60 |
61 | ///
62 | /// Input informations
63 | ///
64 | public InputViewModel Input { get; private set; }
65 |
66 | ///
67 | /// Calculation result
68 | ///
69 | public CalculationResultViewModel Result { get; private set; }
70 |
71 | ///
72 | /// Command to calculation
73 | ///
74 | public RelayCommand DoCalculationCommand { get; private set; }
75 |
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/Programs/SweWPF/ViewModels/RelayCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows.Input;
7 |
8 | namespace SweWPF.ViewModels
9 | {
10 |
11 | public class RelayCommand : ICommand
12 | {
13 | Action _Execute;
14 | Func _CanExecute;
15 |
16 | public RelayCommand(Action execute, Func canExecute = null) {
17 | this._Execute = execute;
18 | this._CanExecute = canExecute;
19 | }
20 |
21 | public void RaiseCanExecuteChanged() {
22 | var h = CanExecuteChanged;
23 | if (h != null)
24 | h(this, EventArgs.Empty);
25 | }
26 |
27 | public bool CanExecute(object parameter) {
28 | return _CanExecute != null ? _CanExecute() : true;
29 | }
30 |
31 | public void Execute(object parameter) {
32 | if (CanExecute(parameter))
33 | _Execute();
34 | }
35 |
36 | public event EventHandler CanExecuteChanged;
37 |
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/Programs/SweWPF/ViewModels/ViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace SweWPF.ViewModels
9 | {
10 | ///
11 | /// Base of ViewModel
12 | ///
13 | public abstract class ViewModel : INotifyPropertyChanged
14 | {
15 |
16 | ///
17 | /// Raise a PropertyChanged event
18 | ///
19 | /// Name of the property changed, or empty if all properties are changed
20 | protected virtual void RaisePropertyChanged(String propertyName) {
21 | var h = PropertyChanged;
22 | if (h != null)
23 | h(this, new PropertyChangedEventArgs(propertyName));
24 | }
25 |
26 | ///
27 | /// Event raised when a property changed
28 | ///
29 | public event PropertyChangedEventHandler PropertyChanged;
30 |
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/Programs/SweWPF/ViewModels/[Enums].cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace SweWPF.ViewModels
8 | {
9 | ///
10 | /// Type of date selection
11 | ///
12 | public enum EphemerisDateType
13 | {
14 | ///
15 | /// UT
16 | ///
17 | UniversalTime,
18 | ///
19 | /// ET
20 | ///
21 | EphemerisTime,
22 | ///
23 | /// JD
24 | ///
25 | JulianDay
26 | }
27 |
28 | ///
29 | /// Mode of Day light
30 | ///
31 | public enum DayLightMode
32 | {
33 | ///
34 | /// Use the .Net time zone daylight information
35 | ///
36 | DotNet,
37 | ///
38 | /// No day light
39 | ///
40 | Off,
41 | ///
42 | /// With day light
43 | ///
44 | On
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Views/ConfigView.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Views/ConfigView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace SweWPF.Views
17 | {
18 | ///
19 | /// Logique d'interaction pour ConfigView.xaml
20 | ///
21 | public partial class ConfigView : UserControl
22 | {
23 | public ConfigView() {
24 | InitializeComponent();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Views/InputDateView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace SweWPF.Views
17 | {
18 | ///
19 | /// Logique d'interaction pour InputDateView.xaml
20 | ///
21 | public partial class InputDateView : UserControl
22 | {
23 | public InputDateView() {
24 | InitializeComponent();
25 | cbTimeType.SelectedIndex = 0;
26 | }
27 |
28 | private void cbTimeType_SelectionChanged(object sender, SelectionChangedEventArgs e) {
29 | ViewModels.EphemerisDateType edt = cbTimeType.SelectedValue is ViewModels.EphemerisDateType ? (ViewModels.EphemerisDateType)cbTimeType.SelectedValue : ViewModels.EphemerisDateType.UniversalTime;
30 | VisualStateManager.GoToState(this, edt.ToString() + "State", true);
31 | }
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Views/InputView.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Views/InputView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace SweWPF.Views
17 | {
18 | ///
19 | /// Logique d'interaction pour InputView.xaml
20 | ///
21 | public partial class InputView : UserControl
22 | {
23 | public InputView() {
24 | InitializeComponent();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Programs/SweWPF/Views/ResultView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace SweWPF.Views
17 | {
18 | ///
19 | /// Logique d'interaction pour ResultView.xaml
20 | ///
21 | public partial class ResultView : UserControl
22 | {
23 | public ResultView() {
24 | InitializeComponent();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Programs/SweWPF/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | SwephNet
2 | ===========
3 |
4 | This project is an Astrodienst Swiss Ephemeris (http://www.astro.com/swisseph/) .Net version in a
5 | PCL project for cross platform usage.
6 |
7 | It is a rewrite of the (https://github.com/ygrenier/SwissEphNet) project with the .Net guidelines,
8 | so it's an .Net optimization of the SwissEphNet project but with a different interface.
9 |
10 | The two projects will continue to exist in parallel :
11 | - SwissEphNet : is the direct C to C# portage of the Swiss Ephemeris.
12 | - SwephNet : is the full .Net implementation of the Swiss Ephemeris.
13 |
14 | This project is currently under development, so you can't use it prefer
15 | (https://github.com/ygrenier/SwissEphNet) instead.
16 |
17 | ## Status
18 |
19 | Current version : 2.0.0
20 |
21 | [](https://ci.appveyor.com/project/ygrenier/swephnet)
22 |
--------------------------------------------------------------------------------
/SwephNet.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.30501.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub", "GitHub", "{756E4ACA-F003-46AF-81F4-FE29C948A52D}"
7 | ProjectSection(SolutionItems) = preProject
8 | .gitattributes = .gitattributes
9 | .gitignore = .gitignore
10 | LICENSE = LICENSE
11 | README.md = README.md
12 | release_notes.md = release_notes.md
13 | EndProjectSection
14 | EndProject
15 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{DFEAC440-D29C-4533-A8D5-8A22741703E4}"
16 | EndProject
17 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SwephNet", "SwephNet", "{6570141C-4031-4ED8-BAC0-CA0924EA58B7}"
18 | EndProject
19 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwephNet", "SwephNet\SwephNet\SwephNet.csproj", "{498F82B5-2BD8-47E1-89DB-E5AF071974EC}"
20 | EndProject
21 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwephNet.Tests", "Tests\SwephNet.Tests\SwephNet.Tests.csproj", "{D5B6F916-996F-48E7-B23A-CA573011A041}"
22 | EndProject
23 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SweNet", "SwephNet\SweNet\SweNet.csproj", "{1FB73EE2-380E-460F-A57D-0FBAA73EBA25}"
24 | EndProject
25 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SweNet.Tests", "Tests\SweNet.Tests\SweNet.Tests.csproj", "{2704F962-2890-40DD-9285-52D6877F0E28}"
26 | EndProject
27 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Programs", "Programs", "{CF6594B3-4A1D-4208-B774-5DF3E3CB9EDE}"
28 | EndProject
29 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SweWPF", "Programs\SweWPF\SweWPF.csproj", "{7C117264-88F9-49E7-A45E-F27E3934921B}"
30 | EndProject
31 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{670FCB29-9F3B-46D0-817D-28D3B5F1C086}"
32 | ProjectSection(SolutionItems) = preProject
33 | appveyor.yml = appveyor.yml
34 | EndProjectSection
35 | EndProject
36 | Global
37 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
38 | Debug|Any CPU = Debug|Any CPU
39 | Release|Any CPU = Release|Any CPU
40 | EndGlobalSection
41 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
42 | {498F82B5-2BD8-47E1-89DB-E5AF071974EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43 | {498F82B5-2BD8-47E1-89DB-E5AF071974EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
44 | {498F82B5-2BD8-47E1-89DB-E5AF071974EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
45 | {498F82B5-2BD8-47E1-89DB-E5AF071974EC}.Release|Any CPU.Build.0 = Release|Any CPU
46 | {D5B6F916-996F-48E7-B23A-CA573011A041}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47 | {D5B6F916-996F-48E7-B23A-CA573011A041}.Debug|Any CPU.Build.0 = Debug|Any CPU
48 | {D5B6F916-996F-48E7-B23A-CA573011A041}.Release|Any CPU.ActiveCfg = Release|Any CPU
49 | {D5B6F916-996F-48E7-B23A-CA573011A041}.Release|Any CPU.Build.0 = Release|Any CPU
50 | {1FB73EE2-380E-460F-A57D-0FBAA73EBA25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51 | {1FB73EE2-380E-460F-A57D-0FBAA73EBA25}.Debug|Any CPU.Build.0 = Debug|Any CPU
52 | {1FB73EE2-380E-460F-A57D-0FBAA73EBA25}.Release|Any CPU.ActiveCfg = Release|Any CPU
53 | {1FB73EE2-380E-460F-A57D-0FBAA73EBA25}.Release|Any CPU.Build.0 = Release|Any CPU
54 | {2704F962-2890-40DD-9285-52D6877F0E28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55 | {2704F962-2890-40DD-9285-52D6877F0E28}.Debug|Any CPU.Build.0 = Debug|Any CPU
56 | {2704F962-2890-40DD-9285-52D6877F0E28}.Release|Any CPU.ActiveCfg = Release|Any CPU
57 | {2704F962-2890-40DD-9285-52D6877F0E28}.Release|Any CPU.Build.0 = Release|Any CPU
58 | {7C117264-88F9-49E7-A45E-F27E3934921B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
59 | {7C117264-88F9-49E7-A45E-F27E3934921B}.Debug|Any CPU.Build.0 = Debug|Any CPU
60 | {7C117264-88F9-49E7-A45E-F27E3934921B}.Release|Any CPU.ActiveCfg = Release|Any CPU
61 | {7C117264-88F9-49E7-A45E-F27E3934921B}.Release|Any CPU.Build.0 = Release|Any CPU
62 | EndGlobalSection
63 | GlobalSection(SolutionProperties) = preSolution
64 | HideSolutionNode = FALSE
65 | EndGlobalSection
66 | GlobalSection(NestedProjects) = preSolution
67 | {498F82B5-2BD8-47E1-89DB-E5AF071974EC} = {6570141C-4031-4ED8-BAC0-CA0924EA58B7}
68 | {D5B6F916-996F-48E7-B23A-CA573011A041} = {DFEAC440-D29C-4533-A8D5-8A22741703E4}
69 | {1FB73EE2-380E-460F-A57D-0FBAA73EBA25} = {6570141C-4031-4ED8-BAC0-CA0924EA58B7}
70 | {2704F962-2890-40DD-9285-52D6877F0E28} = {DFEAC440-D29C-4533-A8D5-8A22741703E4}
71 | {7C117264-88F9-49E7-A45E-F27E3934921B} = {CF6594B3-4A1D-4208-B774-5DF3E3CB9EDE}
72 | EndGlobalSection
73 | EndGlobal
74 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Date/EphemerisTime.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet
7 | {
8 | ///
9 | /// Represents a Julian Day as Ephemeris Time
10 | ///
11 | public struct EphemerisTime
12 | {
13 |
14 | ///
15 | /// Create a new Ephemeris Time
16 | ///
17 | /// The Julian Day
18 | /// The DeltaT value
19 | public EphemerisTime(JulianDay day, Double deltaT)
20 | : this() {
21 | this.JulianDay = day;
22 | this.DeltaT = deltaT;
23 | this.Value = this.JulianDay.Value + this.DeltaT;
24 | }
25 |
26 | ///
27 | /// Implicit cast a Ephemeris Time to double
28 | ///
29 | public static implicit operator double(EphemerisTime et) { return et.Value; }
30 |
31 | ///
32 | /// Convert to string
33 | ///
34 | public override string ToString() {
35 | return Value.ToString();
36 | }
37 |
38 | ///
39 | /// The Julian Day
40 | ///
41 | public JulianDay JulianDay { get; private set; }
42 |
43 | ///
44 | /// The DelatT
45 | ///
46 | public Double DeltaT { get; private set; }
47 |
48 | ///
49 | /// The Ephemeris Time value
50 | ///
51 | public double Value { get; private set; }
52 |
53 |
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Date/IDeltaTReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet.Date
7 | {
8 |
9 | ///
10 | /// Interface for read DeltaT records
11 | ///
12 | public interface IDeltaTReader : Persit.IDataReader
13 | {
14 | ///
15 | /// Read the next record
16 | ///
17 | /// Returns the next record or null if it's end of records list
18 | Tuple Read();
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Date/JulianDay.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet
7 | {
8 |
9 | ///
10 | /// Represents a Julian Day in Universal Time
11 | ///
12 | public struct JulianDay
13 | {
14 |
15 | ///
16 | /// Create a new Julian Day from his value
17 | ///
18 | /// The Julian Day value
19 | public JulianDay(double val, DateCalendar? calendar = null)
20 | : this() {
21 | this.Calendar = calendar ?? SweDate.GetCalendar(val);
22 | this.Value = val;
23 | }
24 |
25 | ///
26 | /// Create a new Julian Day from a DateUT
27 | ///
28 | /// Date source
29 | /// Calendar source
30 | public JulianDay(DateUT date, DateCalendar? calendar = null)
31 | : this() {
32 | this.Calendar = calendar ?? SweDate.GetCalendar(date.Year, date.Month, date.Day);
33 | this.Value = SweDate.DateToJulianDay(date, this.Calendar);
34 | }
35 |
36 | ///
37 | /// Returns the DateUT of this Julian Day
38 | ///
39 | public DateUT ToDateUT() {
40 | return SweDate.JulianDayToDate(Value, Calendar);
41 | }
42 |
43 | ///
44 | /// Retourne the DateTime of this JulianDay
45 | ///
46 | ///
47 | public DateTime ToDateTime() {
48 | return ToDateUT().ToDateTime();
49 | }
50 |
51 | ///
52 | /// Convert to string
53 | ///
54 | public override string ToString() {
55 | return Value.ToString();
56 | }
57 |
58 | ///
59 | /// Implicit cast between Julian Day and double
60 | ///
61 | public static implicit operator Double(JulianDay jd) {
62 | return jd.Value;
63 | }
64 |
65 | ///
66 | /// Calendar
67 | ///
68 | public DateCalendar Calendar { get; private set; }
69 |
70 | ///
71 | /// The absolute Julian Day value
72 | ///
73 | public double Value { get; set; }
74 |
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Date/SideralTime.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet
7 | {
8 |
9 | ///
10 | /// Sideral time value
11 | ///
12 | public struct SideralTime
13 | {
14 | ///
15 | /// Create a new sideral time
16 | ///
17 | public SideralTime(Double time)
18 | : this() {
19 | this.Value = time;
20 | }
21 |
22 | ///
23 | /// Convert to string
24 | ///
25 | public override string ToString() {
26 | return SweFormat.FormatAsTime(Value);
27 | }
28 |
29 | ///
30 | /// Value of the sideral time
31 | ///
32 | public Double Value { get; private set; }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Date/StreamDeltaTReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Text.RegularExpressions;
7 |
8 | namespace SweNet.Date
9 | {
10 |
11 | ///
12 | /// DeltaT reader from Stream
13 | ///
14 | public class StreamDeltaTReader : Persit.StreamDataReader, IDeltaTReader
15 | {
16 | ///
17 | /// Create new reader from stream
18 | ///
19 | ///
20 | ///
21 | public StreamDeltaTReader(Stream stream, Encoding encoding = null)
22 | : this(new StreamReader(stream, Sweph.CheckEncoding(encoding))) {
23 | }
24 |
25 | ///
26 | /// Create new reader from text reader
27 | ///
28 | ///
29 | public StreamDeltaTReader(TextReader reader)
30 | : base(null) {
31 | if (reader == null) throw new ArgumentNullException("reader");
32 | BaseReader = reader;
33 | }
34 |
35 | ///
36 | /// Release resource
37 | ///
38 | protected override void Dispose(bool disposing) {
39 | base.Dispose(disposing);
40 | if (disposing && BaseReader != null) {
41 | BaseReader.Dispose();
42 | BaseReader = null;
43 | }
44 | }
45 |
46 | ///
47 | /// Read new record
48 | ///
49 | public Tuple Read() {
50 | if (BaseReader == null) return null;
51 | //
52 | String line;
53 | Regex reg = new Regex(@"(\d{4})\w+(\d+\.\d+)");
54 | while ((line = BaseReader.ReadLine()) != null) {
55 | line = line.Trim(' ', '\t');
56 | if (String.IsNullOrWhiteSpace(line) || line.StartsWith("#"))
57 | continue;
58 | var match = reg.Match(line);
59 | if (!match.Success) continue;
60 | int y;
61 | if (!int.TryParse(match.Groups[1].Value, out y))
62 | continue;
63 | double v;
64 | if (!double.TryParse(match.Groups[2].Value, out v))
65 | continue;
66 | return new Tuple(y, v);
67 | }
68 | return null;
69 | }
70 |
71 | ///
72 | /// Reader
73 | ///
74 | public System.IO.TextReader BaseReader { get; private set; }
75 |
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Date/WeekDay.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet
7 | {
8 | ///
9 | /// Day of week
10 | ///
11 | public enum WeekDay
12 | {
13 | ///
14 | /// Monday
15 | ///
16 | Monday = 0,
17 | ///
18 | /// Tuesday
19 | ///
20 | Tuesday = 1,
21 | ///
22 | /// Wednesday
23 | ///
24 | Wednesday = 2,
25 | ///
26 | /// Thursday
27 | ///
28 | Thursday = 3,
29 | ///
30 | /// Friday
31 | ///
32 | Friday = 4,
33 | ///
34 | /// Saturday
35 | ///
36 | Saturday = 5,
37 | ///
38 | /// Sunday
39 | ///
40 | Sunday = 6,
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Extensions/DateTimeExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet
7 | {
8 | ///
9 | /// Extension methods for DateTime
10 | ///
11 | public static class DateTimeExtensions
12 | {
13 |
14 | ///
15 | /// Return the hour value of a DateTime
16 | ///
17 | ///
18 | /// The hour value is the time as hours and minutes and secons as decimal part.
19 | ///
20 | public static double GetHourValue(this DateTime date) {
21 | if (date == null) return 0.0;
22 | return (Double)date.Hour + (date.Minute / 60.0) + (date.Second / 3600.0);
23 | }
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Extensions/StringExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet
7 | {
8 |
9 | ///
10 | /// String extensions methods
11 | ///
12 | public static class StringExtensions
13 | {
14 |
15 | ///
16 | /// String.Contains() for Char
17 | ///
18 | public static bool Contains(this String s, Char c) {
19 | if (String.IsNullOrEmpty(s)) return false;
20 | return s.Contains(c.ToString());
21 | }
22 |
23 | ///
24 | /// String.Contains() for Char
25 | ///
26 | public static bool Contains(this String s, Char[] charSet) {
27 | if (charSet == null || String.IsNullOrWhiteSpace(s)) return false;
28 | foreach (var c in charSet) {
29 | if (s.Contains(c)) return true;
30 | }
31 | return false;
32 | }
33 |
34 | ///
35 | /// Search index of first char that is not in chars
36 | ///
37 | public static int IndexOfFirstNot(this String s, params char[] chars) {
38 | if (String.IsNullOrEmpty(s) || chars == null || chars.Length == 0) return -1;
39 | for (int i = 0; i < s.Length; i++) {
40 | if (!chars.Contains(s[i])) return i;
41 | }
42 | return -1;
43 | }
44 |
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Geo/GeoPosition.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet
7 | {
8 |
9 | ///
10 | /// Geographic position
11 | ///
12 | public class GeoPosition
13 | {
14 |
15 | ///
16 | /// Create a new position
17 | ///
18 | public GeoPosition() {
19 | }
20 |
21 | ///
22 | /// Create a new position
23 | ///
24 | public GeoPosition(Longitude lon, Latitude lat, Double alt) {
25 | this.Longitude = lon;
26 | this.Latitude = lat;
27 | this.Altitude = alt;
28 | }
29 |
30 | ///
31 | /// String value
32 | ///
33 | public override string ToString() {
34 | return String.Format("{0}, {1}, {2} m", Longitude, Latitude, Altitude);
35 | }
36 |
37 | ///
38 | /// Longitude
39 | ///
40 | public Longitude Longitude { get; set; }
41 |
42 | ///
43 | /// Latitude
44 | ///
45 | public Latitude Latitude { get; set; }
46 |
47 | ///
48 | /// Altitude in meters
49 | ///
50 | public Double Altitude { get; set; }
51 |
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Geo/Latitude.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet
7 | {
8 | ///
9 | /// Latitude
10 | ///
11 | public struct Latitude
12 | {
13 |
14 | ///
15 | /// Create a latitude from a value
16 | ///
17 | ///
18 | public Latitude(Double value)
19 | : this() {
20 | var sig = Math.Sign(value);
21 | value = Math.Abs(value);
22 | Degrees = (int)value;
23 | Minutes = ((int)(value * 60.0)) % 60;
24 | Seconds = ((int)(value * 3600.0)) % 60;
25 | while (Degrees >= 180) Degrees -= 180;
26 | Value = Degrees + (Minutes / 60.0) + (Seconds / 3600.0);
27 | if (sig < 0) Value = -Value;
28 | Polarity = sig < 0 ? LatitudePolarity.South : LatitudePolarity.North;
29 | }
30 |
31 | ///
32 | /// Create a latitude from his components
33 | ///
34 | ///
35 | ///
36 | ///
37 | public Latitude(int degrees, int minutes, int seconds)
38 | : this() {
39 | if (degrees <= -180 || degrees >= 180) throw new ArgumentOutOfRangeException("degrees");
40 | if (minutes < 0 || minutes >= 60) throw new ArgumentOutOfRangeException("minutes");
41 | if (seconds < 0.0 || seconds >= 60.0) throw new ArgumentOutOfRangeException("seconds");
42 | Degrees = Math.Abs(degrees);
43 | Minutes = minutes;
44 | Seconds = seconds;
45 | Value = Degrees + (Minutes / 60.0) + (Seconds / 3600.0);
46 | if (degrees < 0) Value = -Value;
47 | Polarity = degrees < 0 ? LatitudePolarity.South : LatitudePolarity.North;
48 | }
49 |
50 | ///
51 | /// Create a latitude from his components
52 | ///
53 | ///
54 | ///
55 | ///
56 | ///
57 | public Latitude(int degrees, int minutes, int seconds, LatitudePolarity polarity)
58 | : this() {
59 | if (degrees < 0 || degrees >= 180) throw new ArgumentOutOfRangeException("degrees");
60 | if (minutes < 0 || minutes >= 60) throw new ArgumentOutOfRangeException("minutes");
61 | if (seconds < 0.0 || seconds >= 60.0) throw new ArgumentOutOfRangeException("seconds");
62 | Degrees = degrees;
63 | Minutes = minutes;
64 | Seconds = seconds;
65 | Value = Degrees + (Minutes / 60.0) + (Seconds / 3600.0);
66 | if (polarity == LatitudePolarity.South) Value = -Value;
67 | Polarity = polarity;
68 | }
69 |
70 | ///
71 | /// Convert to string
72 | ///
73 | public override string ToString() {
74 | return String.Format("{0}{3}{1:D2}'{2:D2}\"", Degrees, Minutes, Seconds, Polarity.ToString()[0]);
75 | }
76 |
77 | ///
78 | /// Implicit conversion of Latitude to Double
79 | ///
80 | public static implicit operator Double(Latitude lat) {
81 | return lat.Value;
82 | }
83 |
84 | ///
85 | /// Implicit conversion of Double to Latitude
86 | ///
87 | public static implicit operator Latitude(Double val) {
88 | return new Latitude(val);
89 | }
90 |
91 | ///
92 | /// Degrees
93 | ///
94 | public int Degrees { get; private set; }
95 |
96 | ///
97 | /// Minutes
98 | ///
99 | public int Minutes { get; private set; }
100 |
101 | ///
102 | /// Seconds
103 | ///
104 | public int Seconds { get; private set; }
105 |
106 | ///
107 | /// Polarity
108 | ///
109 | public LatitudePolarity Polarity { get; private set; }
110 |
111 | ///
112 | /// Numeric value
113 | ///
114 | public Double Value { get; private set; }
115 |
116 | }
117 |
118 | ///
119 | /// Latitude polarity
120 | ///
121 | public enum LatitudePolarity
122 | {
123 | ///
124 | /// North (Positive)
125 | ///
126 | North,
127 | ///
128 | /// South (Negative)
129 | ///
130 | South
131 | }
132 |
133 | }
134 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Geo/Longitude.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet
7 | {
8 |
9 | ///
10 | /// Longitude
11 | ///
12 | public struct Longitude
13 | {
14 |
15 | ///
16 | /// Create a longitude from a value
17 | ///
18 | ///
19 | public Longitude(Double value)
20 | : this() {
21 | var sig = Math.Sign(value);
22 | value = Math.Abs(value);
23 | Degrees = (int)value;
24 | Minutes = ((int)(value * 60.0)) % 60;
25 | Seconds = ((int)(value * 3600.0)) % 60;
26 | while (Degrees >= 180) Degrees -= 180;
27 | Value = Degrees + (Minutes / 60.0) + (Seconds / 3600.0);
28 | if (sig < 0) Value = -Value;
29 | Polarity = sig < 0 ? LongitudePolarity.West : LongitudePolarity.East;
30 | }
31 |
32 | ///
33 | /// Create a longitude from his components
34 | ///
35 | ///
36 | ///
37 | ///
38 | public Longitude(int degrees, int minutes, int seconds)
39 | : this() {
40 | if (degrees <= -180 || degrees >= 180) throw new ArgumentOutOfRangeException("degrees");
41 | if (minutes < 0 || minutes >= 60) throw new ArgumentOutOfRangeException("minutes");
42 | if (seconds < 0.0 || seconds >= 60.0) throw new ArgumentOutOfRangeException("seconds");
43 | Degrees = Math.Abs(degrees);
44 | Minutes = minutes;
45 | Seconds = seconds;
46 | Value = Degrees + (Minutes / 60.0) + (Seconds / 3600.0);
47 | if (degrees < 0) Value = -Value;
48 | Polarity = degrees < 0 ? LongitudePolarity.West : LongitudePolarity.East;
49 | }
50 |
51 | ///
52 | /// Create a longitude from his components
53 | ///
54 | ///
55 | ///
56 | ///
57 | ///
58 | public Longitude(int degrees, int minutes, int seconds, LongitudePolarity polarity)
59 | : this() {
60 | if (degrees < 0 || degrees >= 180) throw new ArgumentOutOfRangeException("degrees");
61 | if (minutes < 0 || minutes >= 60) throw new ArgumentOutOfRangeException("minutes");
62 | if (seconds < 0.0 || seconds >= 60.0) throw new ArgumentOutOfRangeException("seconds");
63 | Degrees = degrees;
64 | Minutes = minutes;
65 | Seconds = seconds;
66 | Value = Degrees + (Minutes / 60.0) + (Seconds / 3600.0);
67 | if (polarity == LongitudePolarity.West) Value = -Value;
68 | Polarity = polarity;
69 | }
70 |
71 | ///
72 | /// Convert to string
73 | ///
74 | public override string ToString() {
75 | return String.Format("{0}{3}{1:D2}'{2:D2}\"", Degrees, Minutes, Seconds, Polarity.ToString()[0]);
76 | }
77 |
78 | ///
79 | /// Implicit conversion of Longitude to Double
80 | ///
81 | public static implicit operator Double(Longitude lon) {
82 | return lon.Value;
83 | }
84 |
85 | ///
86 | /// Implicit conversion of Double to Longitude
87 | ///
88 | public static implicit operator Longitude(Double val) {
89 | return new Longitude(val);
90 | }
91 |
92 | ///
93 | /// Degrees
94 | ///
95 | public int Degrees { get; private set; }
96 |
97 | ///
98 | /// Minutes
99 | ///
100 | public int Minutes { get; private set; }
101 |
102 | ///
103 | /// Seconds
104 | ///
105 | public int Seconds { get; private set; }
106 |
107 | ///
108 | /// Polarity
109 | ///
110 | public LongitudePolarity Polarity { get; private set; }
111 |
112 | ///
113 | /// Numeric value
114 | ///
115 | public Double Value { get; private set; }
116 |
117 | }
118 |
119 | ///
120 | /// Longitude polarity
121 | ///
122 | public enum LongitudePolarity
123 | {
124 | ///
125 | /// East (Positive)
126 | ///
127 | East,
128 | ///
129 | /// West (Negative)
130 | ///
131 | West
132 | }
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Houses/SweHouse.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet
7 | {
8 |
9 | ///
10 | /// House management
11 | ///
12 | public class SweHouse
13 | {
14 |
15 | #region Helpers
16 |
17 | ///
18 | /// Convert an house system from a char
19 | ///
20 | public static HouseSystem HouseSystemFromChar(char c) {
21 | switch (Char.ToUpper(c)) {
22 | case 'A':
23 | case 'E': return HouseSystem.Equal;
24 | case 'B': return HouseSystem.Alcabitus;
25 | case 'C': return HouseSystem.Campanus;
26 | case 'G': return HouseSystem.GauquelinSector;
27 | case 'H': return HouseSystem.Horizon;
28 | case 'M': return HouseSystem.Morinus;
29 | case 'O': return HouseSystem.Porphyrius;
30 | case 'R': return HouseSystem.Regiomontanus;
31 | case 'T': return HouseSystem.PolichPage;
32 | case 'U': return HouseSystem.KrusinskiPisa;
33 | case 'V': return HouseSystem.VehlowEqual;
34 | case 'W': return HouseSystem.WholeSign;
35 | case 'X': return HouseSystem.MeridianSystem;
36 | case 'Y': return HouseSystem.APC;
37 | default: return HouseSystem.Placidus;
38 | }
39 | }
40 |
41 | ///
42 | /// Convert a char to an house system
43 | ///
44 | public static Char HouseSystemToChar(HouseSystem hs) {
45 | switch (hs) {
46 | case HouseSystem.Koch: return 'K';
47 | case HouseSystem.Porphyrius: return 'O';
48 | case HouseSystem.Regiomontanus: return 'R';
49 | case HouseSystem.Campanus: return 'C';
50 | case HouseSystem.Equal: return 'E';
51 | case HouseSystem.VehlowEqual: return 'V';
52 | case HouseSystem.WholeSign: return 'W';
53 | case HouseSystem.MeridianSystem: return 'X';
54 | case HouseSystem.Horizon: return 'H';
55 | case HouseSystem.PolichPage: return 'T';
56 | case HouseSystem.Alcabitus: return 'B';
57 | case HouseSystem.Morinus: return 'M';
58 | case HouseSystem.KrusinskiPisa: return 'U';
59 | case HouseSystem.GauquelinSector: return 'G';
60 | case HouseSystem.APC: return 'Y';
61 | case HouseSystem.Placidus:
62 | default: return 'P';
63 | }
64 | }
65 |
66 | ///
67 | /// Returns the name of an house system
68 | ///
69 | public static String GetHouseSystemName(HouseSystem hs) {
70 | switch (hs) {
71 | case HouseSystem.Koch: return "Koch";
72 | case HouseSystem.Porphyrius: return "Porphyrius";
73 | case HouseSystem.Regiomontanus: return "Regiomontanus";
74 | case HouseSystem.Campanus: return "Campanus";
75 | case HouseSystem.Equal: return "Equal";
76 | case HouseSystem.VehlowEqual: return "Vehlow equal";
77 | case HouseSystem.WholeSign: return "Whole sign";
78 | case HouseSystem.MeridianSystem: return "Axial rotation system / Meridian system / Zariel";
79 | case HouseSystem.Horizon: return "Azimuthal / Horizontal system";
80 | case HouseSystem.PolichPage: return "Polich/Page (\"topocentric\" system)";
81 | case HouseSystem.Alcabitus: return "Alcabitus";
82 | case HouseSystem.Morinus: return "Morinus";
83 | case HouseSystem.KrusinskiPisa: return "Krusinski-Pisa";
84 | case HouseSystem.GauquelinSector: return "Gauquelin sector";
85 | case HouseSystem.APC: return "APC houses";
86 | case HouseSystem.Placidus:
87 | default: return "Placidus";
88 | }
89 | }
90 |
91 | #endregion
92 |
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Persit/EmptyDataProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet.Persit
7 | {
8 |
9 | ///
10 | /// Empty data provider
11 | ///
12 | public class EmptyDataProvider : IDataProvider
13 | {
14 |
15 | ///
16 | /// Open a record DeltaT reader
17 | ///
18 | public Date.IDeltaTReader OpenDeltaTReader() {
19 | return null;
20 | }
21 |
22 | ///
23 | /// Open a new asteroid name reader
24 | ///
25 | public Planets.IAsteroidNameReader OpenAsteroidNameReader() {
26 | return null;
27 | }
28 |
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Persit/IDataProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet.Persit
7 | {
8 |
9 | ///
10 | /// Interface for data provider
11 | ///
12 | public interface IDataProvider
13 | {
14 |
15 | ///
16 | /// Open a new DeltaT reader
17 | ///
18 | Date.IDeltaTReader OpenDeltaTReader();
19 |
20 | ///
21 | /// Open a new asteroid name reader
22 | ///
23 | Planets.IAsteroidNameReader OpenAsteroidNameReader();
24 |
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Persit/IDataReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet.Persit
7 | {
8 |
9 | ///
10 | /// Interface for the data reader
11 | ///
12 | public interface IDataReader : IDisposable
13 | {
14 |
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Persit/StreamDataReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace SweNet.Persit
8 | {
9 | ///
10 | /// Abstract for DataReader base on a stream
11 | ///
12 | public abstract class StreamDataReader : IDataReader
13 | {
14 |
15 | ///
16 | /// Create new data reader
17 | ///
18 | ///
19 | public StreamDataReader(Stream stream) {
20 | this.Stream = stream;
21 | }
22 |
23 | ///
24 | /// Internal release resources
25 | ///
26 | ///
27 | protected virtual void Dispose(bool disposing) {
28 | if (disposing && Stream != null) {
29 | Stream.Dispose();
30 | Stream = null;
31 | }
32 | }
33 |
34 | ///
35 | /// Release resources
36 | ///
37 | public void Dispose() {
38 | Dispose(true);
39 | }
40 |
41 | ///
42 | /// Stream
43 | ///
44 | public Stream Stream { get; private set; }
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Planets/IAsteroidNameReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet.Planets
7 | {
8 | ///
9 | /// Interface for asteroid name reader
10 | ///
11 | public interface IAsteroidNameReader : Persit.IDataReader
12 | {
13 | ///
14 | /// Read the next name
15 | ///
16 | Tuple Read();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Resources;
2 | using System.Reflection;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | // Les informations générales relatives à un assembly dépendent de
7 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
8 | // associées à un assembly.
9 | [assembly: AssemblyTitle("SweNet")]
10 | [assembly: AssemblyDescription("Swiss Ephemeris .Net portage")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("Yan Grenier")]
13 | [assembly: AssemblyProduct("SwissEpheNet")]
14 | [assembly: AssemblyCopyright("Copyright © Yan Grenier 2014")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: NeutralResourcesLanguage("en")]
18 |
19 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes :
20 | //
21 | // Version principale
22 | // Version secondaire
23 | // Numéro de build
24 | // Révision
25 | //
26 | // Vous pouvez spécifier toutes les valeurs ou utiliser par défaut les numéros de build et de version
27 | // en utilisant '*', comme indiqué ci-dessous :
28 | // [assembly: AssemblyVersion("1.0.*")]
29 | [assembly: AssemblyVersion("2.0.0.0")]
30 | [assembly: AssemblyFileVersion("2.0.0.0")]
31 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/SweConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet
7 | {
8 |
9 | ///
10 | /// Configuration
11 | ///
12 | public class SweConfig
13 | {
14 | ///
15 | /// New configuration
16 | ///
17 | public SweConfig() {
18 | UseEspenakMeeusDeltaT = true;
19 | }
20 |
21 | ///
22 | /// Clone this configuration
23 | ///
24 | ///
25 | public SweConfig Clone() {
26 | return new SweConfig() {
27 | UseEspenakMeeusDeltaT = this.UseEspenakMeeusDeltaT
28 | };
29 | }
30 |
31 | ///
32 | /// Get or set if we use Espenak Meeus in DeltaT calculation
33 | ///
34 | public bool UseEspenakMeeusDeltaT { get; set; }
35 |
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/SweConst.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet
7 | {
8 |
9 | ///
10 | /// Public constants
11 | ///
12 | public static class SweConst
13 | {
14 | #region Date Constants
15 |
16 | ///
17 | /// 2000 January 1.5
18 | ///
19 | public const double J2000 = 2451545.0;
20 |
21 | ///
22 | /// 1950 January 0.923
23 | ///
24 | public const double B1950 = 2433282.42345905;
25 |
26 | ///
27 | /// 1900 January 0.5
28 | ///
29 | public const double J1900 = 2415020.0;
30 |
31 | ///
32 | /// First Julian Day of the Gregorian calendar : October 15, 1582
33 | ///
34 | public const double GregorianFirstJD = 2299160.5;
35 |
36 | #endregion
37 |
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/SweFormat.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet
7 | {
8 |
9 | ///
10 | /// Format methods
11 | ///
12 | public static class SweFormat
13 | {
14 | ///
15 | /// Format a value to format : D ° MM' SS.0000
16 | ///
17 | ///
18 | ///
19 | public static string FormatAsDegrees(Double value) {
20 | bool minus = value < 0;
21 | value = Math.Abs(value);
22 | var deg = (int)value;
23 | var min = (int)((value * 60.0) % 60.0);
24 | var sec = ((value * 3600.0) % 60.0);
25 | return String.Format("{0}{1,3:##0}° {2,2:#0}' {3,7:#0.0000}", minus ? '-' : ' ', deg, min, sec);
26 | }
27 |
28 | ///
29 | /// Format a value to format : HH:mm:ss
30 | ///
31 | public static string FormatAsTime(Double value) {
32 | var deg = (int)value;
33 | value = Math.Abs(value);
34 | var min = (int)((value * 60.0) % 60.0);
35 | var sec = (int)((value * 3600.0) % 60.0);
36 | return String.Format("{0,2:00}:{1:00}:{2:00}", deg, min, sec);
37 | }
38 |
39 | ///
40 | /// Format a value to format : 'HH' h 'mm' m 'ss' s
41 | ///
42 | public static string FormatAsHour(Double value) {
43 | var deg = (int)value;
44 | value = Math.Abs(value);
45 | var min = (int)((value * 60.0) % 60.0);
46 | var sec = (int)((value * 3600.0) % 60.0);
47 | return String.Format("{0,2:#0} h {1:00} m {2:00} s", deg, min, sec);
48 | }
49 |
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/SweNet.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 10.0
6 | Debug
7 | AnyCPU
8 | {1FB73EE2-380E-460F-A57D-0FBAA73EBA25}
9 | Library
10 | Properties
11 | SweNet
12 | SweNet
13 | v4.0
14 | Profile136
15 | 512
16 | {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
17 |
18 |
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | ..\..\packages\SwissEphNet.2.0.0.4\lib\portable-net40+sl50+win+wp80+MonoAndroid10+MonoTouch10\SwissEphNet.dll
71 |
72 |
73 |
74 |
75 |
76 |
77 |
84 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/[Enums].cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SweNet
7 | {
8 |
9 | ///
10 | /// Calendar type
11 | ///
12 | public enum DateCalendar
13 | {
14 | ///
15 | /// Julian
16 | ///
17 | Julian = 0,
18 | ///
19 | /// Gregorian
20 | ///
21 | Gregorian = 1
22 | }
23 |
24 | ///
25 | /// Ephemeris modes
26 | ///
27 | public enum EphemerisMode
28 | {
29 | SwissEphemeris,
30 | Moshier,
31 | JPL,
32 | }
33 |
34 | ///
35 | /// Position center
36 | ///
37 | public enum PositionCenter
38 | {
39 | Geocentric,
40 | Topocentric,
41 | Heliocentric,
42 | Barycentric,
43 | SiderealFagan,
44 | SiderealLahiri
45 | }
46 |
47 | ///
48 | /// House system calculation
49 | ///
50 | public enum HouseSystem : sbyte
51 | {
52 | Placidus,
53 | Koch,
54 | Porphyrius,
55 | Regiomontanus,
56 | Campanus,
57 | Equal,
58 | VehlowEqual,
59 | WholeSign,
60 | MeridianSystem,
61 | Horizon,
62 | PolichPage,
63 | Alcabitus,
64 | Morinus,
65 | KrusinskiPisa,
66 | GauquelinSector,
67 | APC
68 | }
69 |
70 | ///
71 | /// Zodiacal sign
72 | ///
73 | public enum ZodiacSign
74 | {
75 | Aries,
76 | Taurus,
77 | Gemini,
78 | Cancer,
79 | Leo,
80 | Virgo,
81 | Libra,
82 | Scorpio,
83 | Sagittarius,
84 | Capricorn,
85 | Aquarius,
86 | Pisces
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/[Events].cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace SweNet
8 | {
9 | ///
10 | /// Arguments for trace event
11 | ///
12 | public class TraceEventArgs : EventArgs
13 | {
14 | ///
15 | /// Create new arguments
16 | ///
17 | public TraceEventArgs(String message) {
18 | this.Message = message;
19 | }
20 |
21 | ///
22 | /// Message
23 | ///
24 | public String Message { get; private set; }
25 |
26 | }
27 |
28 | ///
29 | /// Arguments for load file event
30 | ///
31 | public class LoadFileEventArgs : EventArgs
32 | {
33 | ///
34 | /// Create new arguments
35 | ///
36 | public LoadFileEventArgs(String fileName) {
37 | this.FileName = fileName;
38 | this.File = null;
39 | }
40 |
41 | ///
42 | /// File to load
43 | ///
44 | public String FileName { get; private set; }
45 |
46 | ///
47 | /// Stream
48 | ///
49 | public Stream File { get; set; }
50 |
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/SwephNet/SweNet/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Date/DeltaTRecord.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet.Date
7 | {
8 | ///
9 | /// Record of DeltaT in a file
10 | ///
11 | public class DeltaTRecord
12 | {
13 | ///
14 | /// Year
15 | ///
16 | public int Year { get; set; }
17 | ///
18 | /// DeltaT value
19 | ///
20 | public Double Value { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Date/DeltaTRecordFile.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Text.RegularExpressions;
8 |
9 | namespace SwephNet.Date
10 | {
11 |
12 | ///
13 | /// DeltaT record provider from a stream
14 | ///
15 | public class DeltaTRecordFile : IDeltaTRecordProvider
16 | {
17 | ///
18 | /// Create a new DeltaTRecordFile
19 | ///
20 | ///
21 | public DeltaTRecordFile(IStreamProvider streamProvider)
22 | {
23 | this.StreamProvider = streamProvider;
24 | }
25 |
26 | ///
27 | /// Read records
28 | ///
29 | public IEnumerable GetRecords()
30 | {
31 | var file = StreamProvider.LoadFile("swe_deltat.txt")
32 | ?? StreamProvider.LoadFile("sedeltat.txt");
33 | if (file != null)
34 | {
35 | using (var reader = new StreamReader(file))
36 | {
37 | String line;
38 | Regex reg = new Regex(@"^(\d{4})\s+(\d+\.\d+)$");
39 | while ((line = reader.ReadLine()) != null)
40 | {
41 | line = line.Trim(' ', '\t');
42 | if (String.IsNullOrWhiteSpace(line) || line.StartsWith("#"))
43 | continue;
44 | var match = reg.Match(line);
45 | if (!match.Success) continue;
46 | int y;
47 | if (!int.TryParse(match.Groups[1].Value, out y))
48 | continue;
49 | double v;
50 | if (!double.TryParse(match.Groups[2].Value, System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture, out v))
51 | continue;
52 | yield return new DeltaTRecord { Year = y, Value = v };
53 | }
54 | }
55 | }
56 | }
57 |
58 | ///
59 | /// Stream provider
60 | ///
61 | public IStreamProvider StreamProvider { get; private set; }
62 |
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Date/EphemerisTime.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 | ///
9 | /// Represents a Julian Day as Ephemeris Time
10 | ///
11 | public struct EphemerisTime
12 | {
13 |
14 | ///
15 | /// Create a new Ephemeris Time
16 | ///
17 | /// The Julian Day
18 | /// The DeltaT value
19 | public EphemerisTime(JulianDay day, Double deltaT)
20 | : this() {
21 | this.JulianDay = day;
22 | this.DeltaT = deltaT;
23 | this.Value = this.JulianDay.Value + this.DeltaT;
24 | }
25 |
26 | ///
27 | /// Implicit cast a Ephemeris Time to double
28 | ///
29 | public static implicit operator double(EphemerisTime et) { return et.Value; }
30 |
31 | ///
32 | /// Convert to string
33 | ///
34 | public override string ToString() {
35 | return Value.ToString();
36 | }
37 |
38 | ///
39 | /// The Julian Day
40 | ///
41 | public JulianDay JulianDay { get; private set; }
42 |
43 | ///
44 | /// The DelatT
45 | ///
46 | public Double DeltaT { get; private set; }
47 |
48 | ///
49 | /// The Ephemeris Time value
50 | ///
51 | public double Value { get; private set; }
52 |
53 |
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Date/IDeltaTRecordProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet.Date
7 | {
8 |
9 | ///
10 | /// Interface for DeltaT records provider
11 | ///
12 | public interface IDeltaTRecordProvider
13 | {
14 | ///
15 | /// Read all records
16 | ///
17 | IEnumerable GetRecords();
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Date/JulianDay.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 |
9 | ///
10 | /// Represents a Julian Day in Universal Time
11 | ///
12 | public struct JulianDay
13 | {
14 |
15 | ///
16 | /// Create a new Julian Day from his value
17 | ///
18 | /// The Julian Day value
19 | public JulianDay(double val, DateCalendar? calendar = null)
20 | : this() {
21 | this.Calendar = calendar ?? SweDate.GetCalendar(val);
22 | this.Value = val;
23 | }
24 |
25 | ///
26 | /// Create a new Julian Day from a DateUT
27 | ///
28 | /// Date source
29 | /// Calendar source
30 | public JulianDay(UniversalTime date, DateCalendar? calendar = null)
31 | : this() {
32 | this.Calendar = calendar ?? SweDate.GetCalendar(date.Year, date.Month, date.Day);
33 | this.Value = SweDate.DateToJulianDay(date, this.Calendar);
34 | }
35 |
36 | ///
37 | /// Returns the DateUT of this Julian Day
38 | ///
39 | public UniversalTime ToDateUT() {
40 | return SweDate.JulianDayToDate(Value, Calendar);
41 | }
42 |
43 | ///
44 | /// Retourne the DateTime of this JulianDay
45 | ///
46 | ///
47 | public DateTime ToDateTime() {
48 | return ToDateUT().ToDateTime();
49 | }
50 |
51 | ///
52 | /// Convert to string
53 | ///
54 | public override string ToString() {
55 | return Value.ToString();
56 | }
57 |
58 | ///
59 | /// Implicit cast between Julian Day and double
60 | ///
61 | public static implicit operator Double(JulianDay jd) {
62 | return jd.Value;
63 | }
64 |
65 | ///
66 | /// Calendar
67 | ///
68 | public DateCalendar Calendar { get; private set; }
69 |
70 | ///
71 | /// The absolute Julian Day value
72 | ///
73 | public double Value { get; set; }
74 |
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Date/SideralTime.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 |
9 | ///
10 | /// Sideral time value
11 | ///
12 | public struct SideralTime
13 | {
14 | ///
15 | /// Create a new sideral time
16 | ///
17 | public SideralTime(Double time)
18 | : this() {
19 | this.Value = time;
20 | }
21 |
22 | ///
23 | /// Convert to string
24 | ///
25 | public override string ToString() {
26 | return SweFormat.FormatAsTime(Value);
27 | }
28 |
29 | ///
30 | /// Value of the sideral time
31 | ///
32 | public Double Value { get; private set; }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Date/[Enums].cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 |
9 | ///
10 | /// Calendar type
11 | ///
12 | public enum DateCalendar
13 | {
14 | ///
15 | /// Julian
16 | ///
17 | Julian = 0,
18 | ///
19 | /// Gregorian
20 | ///
21 | Gregorian = 1
22 | }
23 |
24 | ///
25 | /// Day of week
26 | ///
27 | public enum WeekDay
28 | {
29 | ///
30 | /// Monday
31 | ///
32 | Monday = 0,
33 | ///
34 | /// Tuesday
35 | ///
36 | Tuesday = 1,
37 | ///
38 | /// Wednesday
39 | ///
40 | Wednesday = 2,
41 | ///
42 | /// Thursday
43 | ///
44 | Thursday = 3,
45 | ///
46 | /// Friday
47 | ///
48 | Friday = 4,
49 | ///
50 | /// Saturday
51 | ///
52 | Saturday = 5,
53 | ///
54 | /// Sunday
55 | ///
56 | Sunday = 6,
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Dependency/IDependencyContainer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 |
9 | ///
10 | /// Interface for dependency container
11 | ///
12 | public interface IDependencyContainer : IDisposable
13 | {
14 | ///
15 | /// Register a type resolver
16 | ///
17 | IDependencyContainer Register(Func creator, bool asSingleton = true);
18 |
19 | ///
20 | /// Register a type resolved by another type
21 | ///
22 | IDependencyContainer Register(bool asSingleton = true)
23 | where TConcreteType : class, TToResolved;
24 |
25 | ///
26 | /// Register an instance to resolved a type
27 | ///
28 | IDependencyContainer RegisterInstance(TToResolved instance, bool ownInstance = false);
29 |
30 | ///
31 | /// Indicate if we can resolve a registered type
32 | ///
33 | bool CanResolve(Type type);
34 |
35 | ///
36 | /// Resolve a type, or raise exception if we can't resolve it
37 | ///
38 | object Resolve(Type type);
39 |
40 | ///
41 | /// Try to resolve a registered type. If not registered, try to create a new instance
42 | ///
43 | /// Type to resolved
44 | /// Resolved object
45 | /// True is type can be resolved
46 | ///
47 | /// If the type is not registered, this method returns false.
48 | /// But if the type can be created, contains the
49 | /// instance created, otherwise contains null.
50 | ///
51 | bool TryToResolve(Type type, out object resolved);
52 |
53 | ///
54 | /// Create a new instance of a registered type or if not registered
55 | /// try to create by reflection or null if we can't create it.
56 | ///
57 | object Create(Type type);
58 |
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Extensions/DateTimeExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 | ///
9 | /// Extension methods for DateTime
10 | ///
11 | public static class DateTimeExtensions
12 | {
13 |
14 | ///
15 | /// Return the hour value of a DateTime
16 | ///
17 | ///
18 | /// The hour value is the time as hours and minutes and secons as decimal part.
19 | ///
20 | public static double GetHourValue(this DateTime date) {
21 | if (date == null) return 0.0;
22 | return (Double)date.Hour + (date.Minute / 60.0) + (date.Second / 3600.0);
23 | }
24 |
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Extensions/DependencyExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 | ///
9 | /// Extension methods for dependency container
10 | ///
11 | public static class DependencyExtensions
12 | {
13 |
14 | ///
15 | /// Indicate if we can resolve a type
16 | ///
17 | public static bool CanResolve(this IDependencyContainer container) where T : class
18 | {
19 | if (container == null) return false;
20 | return container.CanResolve(typeof(T));
21 | }
22 |
23 | ///
24 | /// Resolve a type
25 | ///
26 | public static T Resolve(this IDependencyContainer container) where T : class
27 | {
28 | Check.ArgumentNotNull(container, "container");
29 | return (T)container.Resolve(typeof(T));
30 | }
31 |
32 | ///
33 | /// Try to resolve a type
34 | ///
35 | public static bool TryToResolve(this IDependencyContainer container, out T resolved)
36 | {
37 | Check.ArgumentNotNull(container, "container");
38 | object res = null;
39 | var result = container.TryToResolve(typeof(T), out res);
40 | resolved = (T)res;
41 | return result;
42 | }
43 |
44 | ///
45 | /// Create a new instance of a type
46 | ///
47 | public static T Create(this IDependencyContainer container) where T : class
48 | {
49 | Check.ArgumentNotNull(container, "container");
50 | return (T)container.Create(typeof(T));
51 | }
52 |
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Extensions/HouseExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet.Extensions
7 | {
8 | ///
9 | /// House extensions
10 | ///
11 | public static class HouseExtensions
12 | {
13 |
14 | ///
15 | /// Convert an house système to Char
16 | ///
17 | public static char ToChar(this HouseSystem hs)
18 | {
19 | return SweHouse.HouseSystemToChar(hs);
20 | }
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Extensions/TracerExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 | ///
9 | /// Extensions for ITracer
10 | ///
11 | public static class TracerExtensions
12 | {
13 | ///
14 | /// Trace a formatted message
15 | ///
16 | public static void Trace(this ITracer tracer, String message, params object[] args)
17 | {
18 | if (tracer != null)
19 | {
20 | if (args != null && args.Length > 0)
21 | message = String.Format(message, args);
22 | tracer.Trace(message);
23 | }
24 | }
25 |
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Geo/GeoPosition.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 |
9 | ///
10 | /// Geographic position
11 | ///
12 | public class GeoPosition
13 | {
14 |
15 | ///
16 | /// Create a new position
17 | ///
18 | public GeoPosition() {
19 | }
20 |
21 | ///
22 | /// Create a new position
23 | ///
24 | public GeoPosition(Longitude lon, Latitude lat, Double alt) {
25 | this.Longitude = lon;
26 | this.Latitude = lat;
27 | this.Altitude = alt;
28 | }
29 |
30 | ///
31 | /// String value
32 | ///
33 | public override string ToString() {
34 | return String.Format("{0}, {1}, {2} m", Longitude, Latitude, Altitude);
35 | }
36 |
37 | ///
38 | /// Longitude
39 | ///
40 | public Longitude Longitude { get; set; }
41 |
42 | ///
43 | /// Latitude
44 | ///
45 | public Latitude Latitude { get; set; }
46 |
47 | ///
48 | /// Altitude in meters
49 | ///
50 | public Double Altitude { get; set; }
51 |
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Geo/Latitude.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 | ///
9 | /// Latitude
10 | ///
11 | public struct Latitude
12 | {
13 |
14 | ///
15 | /// Create a latitude from a value
16 | ///
17 | ///
18 | public Latitude(Double value)
19 | : this() {
20 | var sig = Math.Sign(value);
21 | value = Math.Abs(value);
22 | Degrees = (int)value;
23 | Minutes = ((int)(value * 60.0)) % 60;
24 | Seconds = ((int)(value * 3600.0)) % 60;
25 | while (Degrees >= 180) Degrees -= 180;
26 | Value = Degrees + (Minutes / 60.0) + (Seconds / 3600.0);
27 | if (sig < 0) Value = -Value;
28 | Polarity = sig < 0 ? LatitudePolarity.South : LatitudePolarity.North;
29 | }
30 |
31 | ///
32 | /// Create a latitude from his components
33 | ///
34 | ///
35 | ///
36 | ///
37 | public Latitude(int degrees, int minutes, int seconds)
38 | : this() {
39 | if (degrees <= -180 || degrees >= 180) throw new ArgumentOutOfRangeException("degrees");
40 | if (minutes < 0 || minutes >= 60) throw new ArgumentOutOfRangeException("minutes");
41 | if (seconds < 0.0 || seconds >= 60.0) throw new ArgumentOutOfRangeException("seconds");
42 | Degrees = Math.Abs(degrees);
43 | Minutes = minutes;
44 | Seconds = seconds;
45 | Value = Degrees + (Minutes / 60.0) + (Seconds / 3600.0);
46 | if (degrees < 0) Value = -Value;
47 | Polarity = degrees < 0 ? LatitudePolarity.South : LatitudePolarity.North;
48 | }
49 |
50 | ///
51 | /// Create a latitude from his components
52 | ///
53 | ///
54 | ///
55 | ///
56 | ///
57 | public Latitude(int degrees, int minutes, int seconds, LatitudePolarity polarity)
58 | : this() {
59 | if (degrees < 0 || degrees >= 180) throw new ArgumentOutOfRangeException("degrees");
60 | if (minutes < 0 || minutes >= 60) throw new ArgumentOutOfRangeException("minutes");
61 | if (seconds < 0.0 || seconds >= 60.0) throw new ArgumentOutOfRangeException("seconds");
62 | Degrees = degrees;
63 | Minutes = minutes;
64 | Seconds = seconds;
65 | Value = Degrees + (Minutes / 60.0) + (Seconds / 3600.0);
66 | if (polarity == LatitudePolarity.South) Value = -Value;
67 | Polarity = polarity;
68 | }
69 |
70 | ///
71 | /// Convert to string
72 | ///
73 | public override string ToString() {
74 | return String.Format("{0}{3}{1:D2}'{2:D2}\"", Degrees, Minutes, Seconds, Polarity.ToString()[0]);
75 | }
76 |
77 | ///
78 | /// Implicit conversion of Latitude to Double
79 | ///
80 | public static implicit operator Double(Latitude lat) {
81 | return lat.Value;
82 | }
83 |
84 | ///
85 | /// Implicit conversion of Double to Latitude
86 | ///
87 | public static implicit operator Latitude(Double val) {
88 | return new Latitude(val);
89 | }
90 |
91 | ///
92 | /// Degrees
93 | ///
94 | public int Degrees { get; private set; }
95 |
96 | ///
97 | /// Minutes
98 | ///
99 | public int Minutes { get; private set; }
100 |
101 | ///
102 | /// Seconds
103 | ///
104 | public int Seconds { get; private set; }
105 |
106 | ///
107 | /// Polarity
108 | ///
109 | public LatitudePolarity Polarity { get; private set; }
110 |
111 | ///
112 | /// Numeric value
113 | ///
114 | public Double Value { get; private set; }
115 |
116 | }
117 |
118 | ///
119 | /// Latitude polarity
120 | ///
121 | public enum LatitudePolarity
122 | {
123 | ///
124 | /// North (Positive)
125 | ///
126 | North,
127 | ///
128 | /// South (Negative)
129 | ///
130 | South
131 | }
132 |
133 | }
134 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Geo/Longitude.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 |
9 | ///
10 | /// Longitude
11 | ///
12 | public struct Longitude
13 | {
14 |
15 | ///
16 | /// Create a longitude from a value
17 | ///
18 | ///
19 | public Longitude(Double value)
20 | : this() {
21 | var sig = Math.Sign(value);
22 | value = Math.Abs(value);
23 | Degrees = (int)value;
24 | Minutes = ((int)(value * 60.0)) % 60;
25 | Seconds = ((int)(value * 3600.0)) % 60;
26 | while (Degrees >= 180) Degrees -= 180;
27 | Value = Degrees + (Minutes / 60.0) + (Seconds / 3600.0);
28 | if (sig < 0) Value = -Value;
29 | Polarity = sig < 0 ? LongitudePolarity.West : LongitudePolarity.East;
30 | }
31 |
32 | ///
33 | /// Create a longitude from his components
34 | ///
35 | ///
36 | ///
37 | ///
38 | public Longitude(int degrees, int minutes, int seconds)
39 | : this() {
40 | if (degrees <= -180 || degrees >= 180) throw new ArgumentOutOfRangeException("degrees");
41 | if (minutes < 0 || minutes >= 60) throw new ArgumentOutOfRangeException("minutes");
42 | if (seconds < 0.0 || seconds >= 60.0) throw new ArgumentOutOfRangeException("seconds");
43 | Degrees = Math.Abs(degrees);
44 | Minutes = minutes;
45 | Seconds = seconds;
46 | Value = Degrees + (Minutes / 60.0) + (Seconds / 3600.0);
47 | if (degrees < 0) Value = -Value;
48 | Polarity = degrees < 0 ? LongitudePolarity.West : LongitudePolarity.East;
49 | }
50 |
51 | ///
52 | /// Create a longitude from his components
53 | ///
54 | ///
55 | ///
56 | ///
57 | ///
58 | public Longitude(int degrees, int minutes, int seconds, LongitudePolarity polarity)
59 | : this() {
60 | if (degrees < 0 || degrees >= 180) throw new ArgumentOutOfRangeException("degrees");
61 | if (minutes < 0 || minutes >= 60) throw new ArgumentOutOfRangeException("minutes");
62 | if (seconds < 0.0 || seconds >= 60.0) throw new ArgumentOutOfRangeException("seconds");
63 | Degrees = degrees;
64 | Minutes = minutes;
65 | Seconds = seconds;
66 | Value = Degrees + (Minutes / 60.0) + (Seconds / 3600.0);
67 | if (polarity == LongitudePolarity.West) Value = -Value;
68 | Polarity = polarity;
69 | }
70 |
71 | ///
72 | /// Convert to string
73 | ///
74 | public override string ToString() {
75 | return String.Format("{0}{3}{1:D2}'{2:D2}\"", Degrees, Minutes, Seconds, Polarity.ToString()[0]);
76 | }
77 |
78 | ///
79 | /// Implicit conversion of Longitude to Double
80 | ///
81 | public static implicit operator Double(Longitude lon) {
82 | return lon.Value;
83 | }
84 |
85 | ///
86 | /// Implicit conversion of Double to Longitude
87 | ///
88 | public static implicit operator Longitude(Double val) {
89 | return new Longitude(val);
90 | }
91 |
92 | ///
93 | /// Degrees
94 | ///
95 | public int Degrees { get; private set; }
96 |
97 | ///
98 | /// Minutes
99 | ///
100 | public int Minutes { get; private set; }
101 |
102 | ///
103 | /// Seconds
104 | ///
105 | public int Seconds { get; private set; }
106 |
107 | ///
108 | /// Polarity
109 | ///
110 | public LongitudePolarity Polarity { get; private set; }
111 |
112 | ///
113 | /// Numeric value
114 | ///
115 | public Double Value { get; private set; }
116 |
117 | }
118 |
119 | ///
120 | /// Longitude polarity
121 | ///
122 | public enum LongitudePolarity
123 | {
124 | ///
125 | /// East (Positive)
126 | ///
127 | East,
128 | ///
129 | /// West (Negative)
130 | ///
131 | West
132 | }
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Houses/HousePoint.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 |
9 | ///
10 | /// The other house points like ascendant
11 | ///
12 | public class HousePoint
13 | {
14 | #region Constants
15 |
16 | ///
17 | /// Ascendant
18 | ///
19 | public static HousePoint Ascendant { get { return Points[0]; } }
20 | ///
21 | /// MC
22 | ///
23 | public static HousePoint MC { get { return Points[1]; } }
24 | ///
25 | /// ARMC
26 | ///
27 | public static HousePoint ARMC { get { return Points[2]; } }
28 | ///
29 | /// Vertex
30 | ///
31 | public static HousePoint Vertex { get { return Points[3]; } }
32 | ///
33 | /// Equatorial ascendant
34 | ///
35 | public static HousePoint EquatorialAscendant { get { return Points[4]; } }
36 | ///
37 | /// "co-ascendant" (W. Koch)
38 | ///
39 | public static HousePoint CoAscendantKoch { get { return Points[5]; } }
40 | ///
41 | /// "co-ascendant" (M. Munkasey)
42 | ///
43 | public static HousePoint CoAscendantMunkasey { get { return Points[6]; } }
44 | ///
45 | /// "polar ascendant" (M. Munkasey)
46 | ///
47 | public static HousePoint PolarAcsendant { get { return Points[7]; } }
48 |
49 | #endregion
50 |
51 | ///
52 | /// Liste of points
53 | ///
54 | public static HousePoint[] Points { get; private set; }
55 |
56 | ///
57 | /// Static constructor
58 | ///
59 | static HousePoint()
60 | {
61 | Points = new HousePoint[]{
62 | new HousePoint(0, "Ascendant"),
63 | new HousePoint(1, "MC"),
64 | new HousePoint(2, "ARMC"),
65 | new HousePoint(3, "Vertex"),
66 | new HousePoint(4, "Equatorial ascendant"),
67 | new HousePoint(5, "Co-Ascendant Koch (W. Koch)"),
68 | new HousePoint(6, "Co-Ascendant (M. Munkasey)"),
69 | new HousePoint(7, "Polar ascendant (M. Munkasey)")
70 | };
71 | }
72 |
73 | ///
74 | /// Private constructor
75 | ///
76 | HousePoint(int id, String name)
77 | {
78 | this.Id = id;
79 | this.Name = name;
80 | }
81 |
82 | ///
83 | /// ID of the point
84 | ///
85 | public int Id { get; private set; }
86 |
87 | ///
88 | /// Name of the point
89 | ///
90 | public String Name { get; private set; }
91 |
92 | ///
93 | /// Convert to int
94 | ///
95 | public static implicit operator int(HousePoint point)
96 | {
97 | return point.Id;
98 | }
99 |
100 | ///
101 | /// Get the housepoint of an id
102 | ///
103 | public static implicit operator HousePoint(int id)
104 | {
105 | if (id < 0 || id >= Points.Length) return null;
106 | return Points[id];
107 | }
108 |
109 | }
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Houses/HouseResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet.Houses
7 | {
8 |
9 | ///
10 | /// House calculation result
11 | ///
12 | public class HouseResult
13 | {
14 | ///
15 | /// Create a new calculation result
16 | ///
17 | public HouseResult(double[] houses, double[] ascmc)
18 | {
19 | this.Houses = houses;
20 | this.AscMc = ascmc;
21 | }
22 |
23 | ///
24 | /// List of houses cuspids
25 | ///
26 | public Double[] Houses { get; private set; }
27 |
28 | ///
29 | /// Liste of asc and mc positions
30 | ///
31 | public Double[] AscMc { get; private set; }
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Houses/HouseSystem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 |
9 | ///
10 | /// House system calculation
11 | ///
12 | public enum HouseSystem : sbyte
13 | {
14 | Placidus,
15 | Koch,
16 | Porphyrius,
17 | Regiomontanus,
18 | Campanus,
19 | Equal,
20 | VehlowEqual,
21 | WholeSign,
22 | MeridianSystem,
23 | Horizon,
24 | PolichPage,
25 | Alcabitus,
26 | Morinus,
27 | KrusinskiPisa,
28 | GauquelinSector,
29 | APC
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/JPL/[Enums].cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet.JPL
7 | {
8 | ///
9 | /// JPL Horizons calculation modes
10 | ///
11 | [Flags]
12 | public enum JplHorizonMode
13 | {
14 | ///
15 | /// None
16 | ///
17 | None = 0,
18 | ///
19 | /// Reproduce JPL Horizons 1962 - today to 0.002 arcsec
20 | ///
21 | JplHorizons = 256 * 1024,
22 | ///
23 | /// Approximate JPL Horizons 1962 - today
24 | ///
25 | JplApproximate = 512 * 1024
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Persit/IStreamProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace SwephNet
8 | {
9 | ///
10 | /// Interface for loading stream
11 | ///
12 | public interface IStreamProvider
13 | {
14 |
15 | ///
16 | /// Load a file
17 | ///
18 | /// Name of file to load
19 | /// The stream or null if the file not exists
20 | Stream LoadFile(String filename);
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Persit/LoadFileEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace SwephNet
8 | {
9 |
10 | ///
11 | /// Arguments for load file event
12 | ///
13 | public class LoadFileEventArgs : EventArgs
14 | {
15 | ///
16 | /// Create new arguments
17 | ///
18 | public LoadFileEventArgs(String fileName)
19 | {
20 | this.FileName = fileName;
21 | this.File = null;
22 | }
23 |
24 | ///
25 | /// File to load
26 | ///
27 | public String FileName { get; private set; }
28 |
29 | ///
30 | /// Stream
31 | ///
32 | public Stream File { get; set; }
33 |
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Planets/AsteroidNameFile.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Text.RegularExpressions;
7 |
8 | namespace SwephNet.Planets
9 | {
10 |
11 | ///
12 | /// Provide asteroid name from file
13 | ///
14 | public class AsteroidNameFile : IAsteroidNameProvider
15 | {
16 | ///
17 | /// Name of the asteroid names file
18 | ///
19 | public const string AsteroidFileName = "seasnam.txt";
20 |
21 | ///
22 | /// Create a new AsteroidNameFile
23 | ///
24 | public AsteroidNameFile(IStreamProvider streamProvider)
25 | {
26 | this.StreamProvider = streamProvider;
27 | }
28 |
29 | ///
30 | /// Find the name of an asteroid
31 | ///
32 | ///
33 | /// The file seasnam.txt may contain comments starting with '#'.
34 | /// There must be at least two columns:
35 | /// 1. asteroid catalog number
36 | /// 2. asteroid name
37 | /// The asteroid number may or may not be in brackets
38 | ///
39 | /// Id of the asteroid
40 | /// Name of the asteroid or null if not found
41 | public String FindAsteroidName(int id)
42 | {
43 | var file = StreamProvider.LoadFile(AsteroidFileName);
44 | if (file != null)
45 | {
46 | using (var reader = new StreamReader(file))
47 | {
48 | Regex reg = new Regex(@"^[\s\(\{\[]*(\d+)[\s\)\}\]]*(.+)$");
49 | String line;
50 | while ((line = reader.ReadLine()) != null)
51 | {
52 | line = line.TrimStart(' ', '\t', '(', '[', '{');
53 | if (String.IsNullOrWhiteSpace(line) || line.StartsWith("#"))
54 | continue;
55 |
56 | // Parse line
57 | var match = reg.Match(line);
58 | if (!match.Success) continue;
59 |
60 | // Read id planet
61 | int idPlan = int.Parse(match.Groups[1].Value);
62 |
63 | // Retourne name if match
64 | if (idPlan == id)
65 | {
66 | return match.Groups[2].Value;
67 | }
68 | }
69 | }
70 | }
71 | return null;
72 | }
73 |
74 | ///
75 | /// Stream provider
76 | ///
77 | public IStreamProvider StreamProvider { get; private set; }
78 |
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Planets/IAsteroidNameProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet.Planets
7 | {
8 | ///
9 | /// Interface for asteroid name provider
10 | ///
11 | public interface IAsteroidNameProvider
12 | {
13 | ///
14 | /// Find the name of an asteroid
15 | ///
16 | /// Id of the asteroid
17 | /// Name of the asteroid or null if not found
18 | String FindAsteroidName(int id);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Planets/IOsculatingElementProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet.Planets
7 | {
8 |
9 | ///
10 | /// Interface for reading an osculating element
11 | ///
12 | public interface IOsculatingElementProvider
13 | {
14 | ///
15 | /// Find an element
16 | ///
17 | OsculatingElement FindElement(int idPlanet, double julianDay, ref int fict_ifl);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Planets/OsculatingElement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet.Planets
7 | {
8 | ///
9 | /// Osculating element informations
10 | ///
11 | public class OsculatingElement
12 | {
13 | public String Name { get; set; }
14 | public double Epoch { get; set; }
15 | public double Equinox { get; set; }
16 | public double MeanAnomaly { get; set; }
17 | public double SemiAxis { get; set; }
18 | public double Eccentricity { get; set; }
19 | public double Perihelion { get; set; }
20 | public double AscendingNode { get; set; }
21 | public double Inclination { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Resources;
2 | using System.Reflection;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 |
6 | // Les informations générales relatives à un assembly dépendent de
7 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
8 | // associées à un assembly.
9 | [assembly: AssemblyTitle("SwephNet")]
10 | [assembly: AssemblyDescription("Swiss Ephemeris for .Net")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("Yan Grenier")]
13 | [assembly: AssemblyProduct("SwephNet")]
14 | [assembly: AssemblyCopyright("Copyright © Yan Grenier 2014")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: NeutralResourcesLanguage("en")]
18 |
19 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes :
20 | //
21 | // Version principale
22 | // Version secondaire
23 | // Numéro de build
24 | // Révision
25 | //
26 | // Vous pouvez spécifier toutes les valeurs ou utiliser par défaut les numéros de build et de version
27 | // en utilisant '*', comme indiqué ci-dessous :
28 | // [assembly: AssemblyVersion("1.0.*")]
29 | [assembly: AssemblyVersion("2.0.0.0")]
30 | [assembly: AssemblyFileVersion("2.0.0.0")]
31 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/SweError.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 | ///
9 | /// Sweph error
10 | ///
11 | public class SweError : Exception
12 | {
13 | ///
14 | /// New error
15 | ///
16 | public SweError(String message)
17 | : base(message)
18 | {
19 | }
20 |
21 | ///
22 | /// New error
23 | ///
24 | public SweError(Exception innerException, String message)
25 | : base(message, innerException)
26 | {
27 | }
28 |
29 | ///
30 | /// New error
31 | ///
32 | public SweError(String message, params object[] args)
33 | : base(String.Format(message, args))
34 | {
35 | }
36 |
37 | ///
38 | /// New error
39 | ///
40 | public SweError(Exception innerException, String message, params object[] args)
41 | : base(String.Format(message, args), innerException)
42 | {
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/SweFormat.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 |
9 | ///
10 | /// Format methods
11 | ///
12 | public static class SweFormat
13 | {
14 | ///
15 | /// Format a value to format : D ° MM' SS.0000
16 | ///
17 | ///
18 | ///
19 | public static string FormatAsDegrees(Double value) {
20 | bool minus = value < 0;
21 | value = Math.Abs(value);
22 | var deg = (int)value;
23 | var min = (int)((value * 60.0) % 60.0);
24 | var sec = ((value * 3600.0) % 60.0);
25 | return String.Format("{0}{1,3:##0}° {2,2:#0}' {3,7:#0.0000}", minus ? '-' : ' ', deg, min, sec);
26 | }
27 |
28 | ///
29 | /// Format a value to format : HH:mm:ss
30 | ///
31 | public static string FormatAsTime(Double value) {
32 | var deg = (int)value;
33 | value = Math.Abs(value);
34 | var min = (int)((value * 60.0) % 60.0);
35 | var sec = (int)((value * 3600.0) % 60.0);
36 | return String.Format("{0,2:00}:{1:00}:{2:00}", deg, min, sec);
37 | }
38 |
39 | ///
40 | /// Format a value to format : 'HH' h 'mm' m 'ss' s
41 | ///
42 | public static string FormatAsHour(Double value) {
43 | var deg = (int)value;
44 | value = Math.Abs(value);
45 | var min = (int)((value * 60.0) % 60.0);
46 | var sec = (int)((value * 3600.0) % 60.0);
47 | return String.Format("{0,2:#0} h {1:00} m {2:00} s", deg, min, sec);
48 | }
49 |
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Utils/Check.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 | ///
9 | /// Some check methods
10 | ///
11 | public static class Check
12 | {
13 |
14 | ///
15 | /// Check if an argument is not null
16 | ///
17 | public static void ArgumentNotNull(object value, String name, String message = null) {
18 | if (value == null) {
19 | if (!String.IsNullOrEmpty(message))
20 | throw new ArgumentNullException(name, message);
21 | else
22 | throw new ArgumentNullException(name);
23 | }
24 | }
25 |
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/Utils/ITracer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 | ///
9 | /// Trace provider
10 | ///
11 | public interface ITracer
12 | {
13 |
14 | ///
15 | /// Trace a message
16 | ///
17 | void Trace(String message);
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/SwephNet/SwephNet/[Events].cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SwephNet
7 | {
8 |
9 | ///
10 | /// Arguments for trace event
11 | ///
12 | public class TraceEventArgs : EventArgs
13 | {
14 | ///
15 | /// Create new arguments
16 | ///
17 | public TraceEventArgs(String message)
18 | {
19 | this.Message = message;
20 | }
21 |
22 | ///
23 | /// Message
24 | ///
25 | public String Message { get; private set; }
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/Tests/SweNet.Tests/EphemerisTimeTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace SweNet.Tests
5 | {
6 | [TestClass]
7 | public class EphemerisTimeTest
8 | {
9 |
10 | [TestMethod]
11 | public void TestCreateEmpty()
12 | {
13 | EphemerisTime et = new EphemerisTime();
14 | Assert.AreEqual(0.0, et.JulianDay.Value);
15 | Assert.AreEqual(0.0, et.DeltaT);
16 | Assert.AreEqual(0.0, et.Value);
17 | }
18 |
19 | [TestMethod]
20 | public void TestCreate()
21 | {
22 | var date = new DateUT(2014, 4, 26, 16, 53, 24);
23 | var jd = new JulianDay(date, DateCalendar.Gregorian);
24 | var dt = 0.456;
25 | EphemerisTime et = new EphemerisTime(jd, dt);
26 | Assert.AreEqual(jd, et.JulianDay);
27 | Assert.AreEqual(dt, et.DeltaT);
28 | Assert.AreEqual(jd.Value + dt, et.Value);
29 | }
30 |
31 | [TestMethod]
32 | public void TestCastToDouble()
33 | {
34 | var date = new DateUT(2014, 4, 26, 16, 53, 24);
35 | var jd = new JulianDay(date, DateCalendar.Gregorian);
36 | var dt = 0.456;
37 | EphemerisTime et = new EphemerisTime(jd, dt);
38 | double cd = et;
39 | Assert.AreEqual(cd, et.Value);
40 | }
41 |
42 | [TestMethod]
43 | public void TestToString()
44 | {
45 | var date = new DateUT(2014, 4, 26, 16, 53, 24);
46 | var jd = new JulianDay(date, DateCalendar.Gregorian);
47 | var dt = 0.456;
48 | EphemerisTime et = new EphemerisTime(jd, dt);
49 | Assert.AreEqual(2456774.65975.ToString(), et.ToString());
50 | }
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Tests/SweNet.Tests/GeoPositionTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 |
7 | namespace SweNet.Tests
8 | {
9 |
10 | [TestClass]
11 | public class GeoPositionTest
12 | {
13 |
14 | [TestMethod]
15 | public void TestCreateEmpty() {
16 | GeoPosition pos = new GeoPosition();
17 | Assert.AreEqual(0, pos.Longitude.Value);
18 | Assert.AreEqual(0, pos.Latitude.Value);
19 | Assert.AreEqual(0, pos.Altitude);
20 | }
21 |
22 | [TestMethod]
23 | public void TestCreate() {
24 | GeoPosition pos = new GeoPosition(46.72, -5.23, 12);
25 | Assert.AreEqual(46.72, pos.Longitude.Value);
26 | Assert.AreEqual(-5.23, pos.Latitude.Value);
27 | Assert.AreEqual(12, pos.Altitude);
28 | }
29 |
30 | [TestMethod]
31 | public void TestToString() {
32 | GeoPosition pos = new GeoPosition(46.72, -5.23, 12);
33 | Assert.AreEqual("46E43'12\", 5S13'48\", 12 m", pos.ToString());
34 | }
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Tests/SweNet.Tests/JulianDayTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace SweNet.Tests
5 | {
6 | [TestClass]
7 | public class JulianDayTest
8 | {
9 | [TestMethod]
10 | public void TestCreateEmpty()
11 | {
12 | JulianDay jd = new JulianDay();
13 | Assert.AreEqual(0.0, jd.Value);
14 | Assert.AreEqual(DateCalendar.Julian, jd.Calendar);
15 | }
16 |
17 | [TestMethod]
18 | public void TestCreateComponents()
19 | {
20 | var date = new DateUT(2014, 4, 26, 16, 53, 24);
21 | JulianDay jd = new JulianDay(date, DateCalendar.Gregorian);
22 | Assert.AreEqual(2456774.20375, jd.Value);
23 | Assert.AreEqual(DateCalendar.Gregorian, jd.Calendar);
24 |
25 | date = new DateUT(2014, 4, 26, 16, 53, 24);
26 | jd = new JulianDay(date, DateCalendar.Julian);
27 | Assert.AreEqual(2456787.20375, jd.Value);
28 | Assert.AreEqual(DateCalendar.Julian, jd.Calendar);
29 |
30 | date = new DateUT(1974, 8, 15, 23, 30, 00);
31 | jd = new JulianDay(date, DateCalendar.Gregorian);
32 | Assert.AreEqual(2442275.47916667, jd.Value, 0.00000001);
33 |
34 | }
35 |
36 | [TestMethod]
37 | public void TestCreateDouble()
38 | {
39 | var date = 2456774.20375;
40 | JulianDay jd = new JulianDay(date, DateCalendar.Gregorian);
41 | Assert.AreEqual(date, jd.Value);
42 | Assert.AreEqual(DateCalendar.Gregorian, jd.Calendar);
43 |
44 | jd = new JulianDay(date, DateCalendar.Julian);
45 | Assert.AreEqual(date, jd.Value);
46 | Assert.AreEqual(DateCalendar.Julian, jd.Calendar);
47 | }
48 |
49 | [TestMethod]
50 | public void TestToDateUT()
51 | {
52 | var date = new DateUT(2014, 4, 26, 16, 53, 24);
53 | var jd = new JulianDay(date, DateCalendar.Gregorian);
54 | Assert.AreEqual(date, jd.ToDateUT());
55 | }
56 |
57 | [TestMethod]
58 | public void TestToDateTime()
59 | {
60 | var date = new DateUT(2014, 4, 26, 16, 53, 24);
61 | var jd = new JulianDay(date, DateCalendar.Gregorian);
62 | Assert.AreEqual(date.ToDateTime(), jd.ToDateTime());
63 | }
64 |
65 | [TestMethod]
66 | public void TestCastToDouble()
67 | {
68 | var date = new DateUT(2014, 4, 26, 16, 53, 24);
69 | var jd = new JulianDay(date, DateCalendar.Gregorian);
70 | double cd = jd;
71 | Assert.AreEqual(cd, jd.Value);
72 | }
73 |
74 | [TestMethod]
75 | public void TestToString()
76 | {
77 | var date = new DateUT(2014, 4, 26, 16, 53, 24);
78 | var jd = new JulianDay(date, DateCalendar.Gregorian);
79 | Assert.AreEqual(2456774.20375.ToString(), jd.ToString());
80 | }
81 |
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/Tests/SweNet.Tests/PlanetTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace SweNet.Tests
5 | {
6 | [TestClass]
7 | public class PlanetTest
8 | {
9 | [TestMethod]
10 | public void TestCreate() {
11 | var planet = new Planet();
12 | Assert.AreEqual(0, planet.Id);
13 | planet = new Planet(1234);
14 | Assert.AreEqual(1234, planet.Id);
15 | }
16 |
17 | [TestMethod]
18 | public void TestIntCast() {
19 | Planet planet = 1234;
20 | Assert.AreEqual(1234, planet.Id);
21 |
22 | int i = planet;
23 | Assert.AreEqual(1234, i);
24 | }
25 |
26 | [TestMethod]
27 | public void TestPlanetType() {
28 | Planet planet = 0;
29 | Assert.AreEqual(false, planet.IsAsteroid);
30 | Assert.AreEqual(false, planet.IsComet);
31 | Assert.AreEqual(false, planet.IsFictitious);
32 | Assert.AreEqual(true, planet.IsPlanet);
33 |
34 | planet = -100;
35 | Assert.AreEqual(false, planet.IsAsteroid);
36 | Assert.AreEqual(false, planet.IsComet);
37 | Assert.AreEqual(false, planet.IsFictitious);
38 | Assert.AreEqual(false, planet.IsPlanet);
39 |
40 | planet = 10;
41 | Assert.AreEqual(false, planet.IsAsteroid);
42 | Assert.AreEqual(false, planet.IsComet);
43 | Assert.AreEqual(false, planet.IsFictitious);
44 | Assert.AreEqual(true, planet.IsPlanet);
45 |
46 | planet = 25;
47 | Assert.AreEqual(false, planet.IsAsteroid);
48 | Assert.AreEqual(false, planet.IsComet);
49 | Assert.AreEqual(false, planet.IsFictitious);
50 | Assert.AreEqual(false, planet.IsPlanet);
51 |
52 | planet = 50;
53 | Assert.AreEqual(false, planet.IsAsteroid);
54 | Assert.AreEqual(false, planet.IsComet);
55 | Assert.AreEqual(true, planet.IsFictitious);
56 | Assert.AreEqual(false, planet.IsPlanet);
57 |
58 | planet = 50;
59 | Assert.AreEqual(false, planet.IsAsteroid);
60 | Assert.AreEqual(false, planet.IsComet);
61 | Assert.AreEqual(true, planet.IsFictitious);
62 | Assert.AreEqual(false, planet.IsPlanet);
63 |
64 | planet = 1000;
65 | Assert.AreEqual(false, planet.IsAsteroid);
66 | Assert.AreEqual(true, planet.IsComet);
67 | Assert.AreEqual(false, planet.IsFictitious);
68 | Assert.AreEqual(false, planet.IsPlanet);
69 |
70 | planet = 2000;
71 | Assert.AreEqual(false, planet.IsAsteroid);
72 | Assert.AreEqual(true, planet.IsComet);
73 | Assert.AreEqual(false, planet.IsFictitious);
74 | Assert.AreEqual(false, planet.IsPlanet);
75 |
76 | planet = 10000;
77 | Assert.AreEqual(true, planet.IsAsteroid);
78 | Assert.AreEqual(false, planet.IsComet);
79 | Assert.AreEqual(false, planet.IsFictitious);
80 | Assert.AreEqual(false, planet.IsPlanet);
81 |
82 | planet = 12000;
83 | Assert.AreEqual(true, planet.IsAsteroid);
84 | Assert.AreEqual(false, planet.IsComet);
85 | Assert.AreEqual(false, planet.IsFictitious);
86 | Assert.AreEqual(false, planet.IsPlanet);
87 | }
88 |
89 | [TestMethod]
90 | public void TestAsAsteroid() {
91 | Planet planet = Planet.AsAsteroid(12);
92 | Assert.AreEqual(Planet.FirstAsteroid + 12, planet.Id);
93 | }
94 |
95 | [TestMethod]
96 | public void TestToString() {
97 | Planet planet = Planet.Venus;
98 | Assert.AreEqual("3", planet.ToString());
99 | }
100 |
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/Tests/SweNet.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // Les informations générales relatives à un assembly dépendent de
6 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
7 | // associées à un assembly.
8 | [assembly: AssemblyTitle("SweNet.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SweNet.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
18 | // aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
19 | // COM, affectez la valeur true à l'attribut ComVisible sur ce type.
20 | [assembly: ComVisible(false)]
21 |
22 | // Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
23 | [assembly: Guid("208ca35e-2f8b-4836-a267-54886bf68fe3")]
24 |
25 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes :
26 | //
27 | // Version principale
28 | // Version secondaire
29 | // Numéro de build
30 | // Révision
31 | //
32 | // Vous pouvez spécifier toutes les valeurs ou vous pouvez définir par défaut les numéros de build et de révision
33 | // en utilisant '*', comme indiqué ci-dessous :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Tests/SweNet.Tests/SideralTimeTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 |
7 | namespace SweNet.Tests
8 | {
9 |
10 | [TestClass]
11 | public class SideralTimeTest
12 | {
13 |
14 | [TestMethod]
15 | public void TestCreateEmpty() {
16 | SideralTime time = new SideralTime();
17 | Assert.AreEqual(0, time.Value);
18 | }
19 |
20 | [TestMethod]
21 | public void TestCreate() {
22 | SideralTime time = new SideralTime(12.3456789);
23 | Assert.AreEqual(12.3456789, time.Value);
24 | }
25 |
26 | [TestMethod]
27 | public void TestToString() {
28 | SideralTime time = new SideralTime(12.3456789);
29 | Assert.AreEqual("12:20:44", time.ToString());
30 | }
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Tests/SweNet.Tests/StringExtensionsTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace SweNet.Tests
5 | {
6 | [TestClass]
7 | public class StringExtensionsTest
8 | {
9 | [TestMethod]
10 | public void TestContainsChar() {
11 | String s = null;
12 | Assert.IsFalse(s.Contains('a'));
13 |
14 | Assert.IsFalse("".Contains('a'));
15 | Assert.IsFalse("AbCd".Contains('a'));
16 | Assert.IsTrue("AbCd".Contains('b'));
17 | Assert.IsFalse("AbCd".Contains('c'));
18 | Assert.IsTrue("AbCd".Contains('d'));
19 | Assert.IsFalse("AbCd".Contains('e'));
20 | Assert.IsTrue("AbCd".Contains('A'));
21 | Assert.IsFalse("AbCd".Contains('B'));
22 | Assert.IsTrue("AbCd".Contains('C'));
23 | Assert.IsFalse("AbCd".Contains('D'));
24 | Assert.IsFalse("AbCd".Contains('E'));
25 | }
26 |
27 | [TestMethod]
28 | public void TestContainsCharSet() {
29 | String s = null;
30 | Char[] charSet = new char[] { 'A', 'c' };
31 |
32 | Assert.IsFalse(s.Contains(charSet));
33 | Assert.IsFalse(s.Contains((Char[])null));
34 | Assert.IsFalse("--".Contains(charSet));
35 | Assert.IsFalse("--".Contains((Char[])null));
36 |
37 | Assert.IsFalse("".Contains(charSet));
38 | Assert.IsTrue("ABCD".Contains(charSet));
39 | Assert.IsTrue("abcd".Contains(charSet));
40 | Assert.IsFalse("xyz".Contains(charSet));
41 |
42 | }
43 |
44 | [TestMethod]
45 | public void TestIndexOfFirstNot() {
46 | String s = null;
47 | Char[] charSet = new char[] { 'A', 'c' };
48 |
49 | Assert.AreEqual(-1, s.IndexOfFirstNot(charSet));
50 | Assert.AreEqual(-1, s.IndexOfFirstNot());
51 | Assert.AreEqual(0, "--".IndexOfFirstNot(charSet));
52 | Assert.AreEqual(-1, "--".IndexOfFirstNot((Char[])null));
53 |
54 | Assert.AreEqual(-1, "".IndexOfFirstNot(charSet));
55 | Assert.AreEqual(1, "ABCD".IndexOfFirstNot(charSet));
56 | Assert.AreEqual(0, "abcd".IndexOfFirstNot(charSet));
57 | Assert.AreEqual(2, "AcEg".IndexOfFirstNot(charSet));
58 | Assert.AreEqual(4, "AcAcEg".IndexOfFirstNot(charSet));
59 | Assert.AreEqual(-1, "AcA".IndexOfFirstNot(charSet));
60 | Assert.AreEqual(0, "xyz".IndexOfFirstNot(charSet));
61 |
62 | }
63 |
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/Tests/SweNet.Tests/SwePlanetTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 | using System.Collections.Generic;
4 | using SwissEphNet;
5 |
6 | namespace SweNet.Tests
7 | {
8 | [TestClass]
9 | public class SwePlanetTest
10 | {
11 |
12 | [TestMethod]
13 | public void TestGetPlanetName() {
14 | using (var swe = new Sweph()) {
15 | Assert.AreEqual("Sun", swe.Planets.GetPlanetName(Planet.Sun));
16 | Assert.AreEqual("Moon", swe.Planets.GetPlanetName(Planet.Moon));
17 | Assert.AreEqual("Mercury", swe.Planets.GetPlanetName(Planet.Mercury));
18 | Assert.AreEqual("Venus", swe.Planets.GetPlanetName(Planet.Venus));
19 | Assert.AreEqual("Earth", swe.Planets.GetPlanetName(Planet.Earth));
20 | Assert.AreEqual("Mars", swe.Planets.GetPlanetName(Planet.Mars));
21 | Assert.AreEqual("Jupiter", swe.Planets.GetPlanetName(Planet.Jupiter));
22 | Assert.AreEqual("Saturn", swe.Planets.GetPlanetName(Planet.Saturn));
23 | Assert.AreEqual("Uranus", swe.Planets.GetPlanetName(Planet.Uranus));
24 | Assert.AreEqual("Neptune", swe.Planets.GetPlanetName(Planet.Neptune));
25 |
26 | Assert.AreEqual("Pluto", swe.Planets.GetPlanetName(Planet.Pluto));
27 | Assert.AreEqual("mean Node", swe.Planets.GetPlanetName(Planet.MeanNode));
28 | Assert.AreEqual("true Node", swe.Planets.GetPlanetName(Planet.TrueNode));
29 | Assert.AreEqual("mean Apogee", swe.Planets.GetPlanetName(Planet.MeanApog));
30 | Assert.AreEqual("osc. Apogee", swe.Planets.GetPlanetName(Planet.OscuApog));
31 | Assert.AreEqual("Chiron", swe.Planets.GetPlanetName(Planet.Chiron));
32 | Assert.AreEqual("Pholus", swe.Planets.GetPlanetName(Planet.Pholus));
33 | Assert.AreEqual("Ceres", swe.Planets.GetPlanetName(Planet.Ceres));
34 | Assert.AreEqual("Pallas", swe.Planets.GetPlanetName(Planet.Pallas));
35 | Assert.AreEqual("Juno", swe.Planets.GetPlanetName(Planet.Juno));
36 | Assert.AreEqual("Vesta", swe.Planets.GetPlanetName(Planet.Vesta));
37 | Assert.AreEqual("intp. Apogee", swe.Planets.GetPlanetName(Planet.IntpApog));
38 | Assert.AreEqual("intp. Perigee", swe.Planets.GetPlanetName(Planet.IntpPerg));
39 |
40 | Assert.AreEqual("Pluto", swe.Planets.GetPlanetName(Planet.AsteroidPluto));
41 | Assert.AreEqual("Ceres", swe.Planets.GetPlanetName(Planet.AsteroidCeres));
42 | Assert.AreEqual("Pallas", swe.Planets.GetPlanetName(Planet.AsteroidPallas));
43 | Assert.AreEqual("Juno", swe.Planets.GetPlanetName(Planet.AsteroidJuno));
44 | Assert.AreEqual("Vesta", swe.Planets.GetPlanetName(Planet.AsteroidVesta));
45 | Assert.AreEqual("Chiron", swe.Planets.GetPlanetName(Planet.AsteroidChiron));
46 | Assert.AreEqual("Pholus", swe.Planets.GetPlanetName(Planet.AsteroidPholus));
47 |
48 | // Call twice the same planet for code coverage in swe_get_planet_name optimization planet name
49 | Assert.AreEqual("Pluto", swe.Planets.GetPlanetName(Planet.Pluto));
50 | Assert.AreEqual("Pluto", swe.Planets.GetPlanetName(Planet.Pluto));
51 |
52 | Assert.AreEqual("9988", swe.Planets.GetPlanetName(Planet.FirstAsteroid - 12));
53 | }
54 | }
55 |
56 | [TestMethod, ExpectedException(typeof(NotImplementedException))]
57 | public void TestGetPlanetName_Fictitious() {
58 | using (var swe = new Sweph()) {
59 | Assert.AreEqual("Cupido", swe.Planets.GetPlanetName(Planet.FirstFictitious));
60 | Assert.AreEqual("name not found", swe.Planets.GetPlanetName(Planet.FirstFictitious + 200));
61 | }
62 | }
63 |
64 | [TestMethod]
65 | public void TestGetPlanetName_Asteroid() {
66 | using (var swe = new Sweph()) {
67 | Assert.AreEqual("0: not found", swe.Planets.GetPlanetName(Planet.FirstAsteroid));
68 | Assert.AreEqual("433: not found", swe.Planets.GetPlanetName(Planet.FirstAsteroid + 433));
69 | }
70 | }
71 |
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/Tests/SweNet.Tests/SwephTest.Date.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 | using System.Collections.Generic;
4 |
5 | namespace SweNet.Tests
6 | {
7 | partial class SwephTest
8 | {
9 |
10 | [TestMethod]
11 | public void TestJulianDay() {
12 | using (var swe = new Sweph()) {
13 |
14 | Assert.AreEqual(0.0, swe.JulianDay(new DateUT(-4713, 11, 24, 12, 0, 0), DateCalendar.Gregorian).Value);
15 | Assert.AreEqual(0.0, swe.JulianDay(-4713, 11, 24, 12, 0, 0, DateCalendar.Gregorian).Value);
16 | Assert.AreEqual(0.0, swe.JulianDay(-4713, 11, 24, 12.0, DateCalendar.Gregorian).Value);
17 | Assert.AreEqual(0.0, swe.JulianDay(-4712, 1, 1, 12.0, DateCalendar.Julian).Value);
18 |
19 | Assert.AreEqual(2000000.0, swe.JulianDay(763, 9, 18, 12.0, DateCalendar.Gregorian).Value);
20 | Assert.AreEqual(2000000.0, swe.JulianDay(763, 9, 14, 12.0, DateCalendar.Julian).Value);
21 |
22 | Assert.AreEqual(1063884.0, swe.JulianDay(-1800, 9, 18, 12.0, DateCalendar.Gregorian).Value);
23 | Assert.AreEqual(1063865.0, swe.JulianDay(-1800, 9, 14, 12.0, DateCalendar.Julian).Value);
24 | }
25 | }
26 |
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Tests/SweNet.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Tests/SwephNet.Tests/CheckTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | namespace SwephNet.Tests
7 | {
8 | ///
9 | /// Description résumée pour CheckTest
10 | ///
11 | [TestClass]
12 | public class CheckTest
13 | {
14 |
15 | [TestMethod]
16 | public void TestArgumentNotNull()
17 | {
18 | Check.ArgumentNotNull(123, "name");
19 | Check.ArgumentNotNull(123, "name", "message");
20 | }
21 |
22 | [TestMethod]
23 | [ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes=false)]
24 | public void TestArgumentNotNull_Null_WithoutMessage()
25 | {
26 | Check.ArgumentNotNull(null, "name");
27 | }
28 |
29 | [TestMethod]
30 | [ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes=false)]
31 | public void TestArgumentNotNull_Null_WithMessage()
32 | {
33 | Check.ArgumentNotNull(null, "name", "message");
34 | }
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Tests/SwephNet.Tests/EphemerisTimeTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace SwephNet.Tests
5 | {
6 | [TestClass]
7 | public class EphemerisTimeTest
8 | {
9 |
10 | [TestMethod]
11 | public void TestCreateEmpty()
12 | {
13 | EphemerisTime et = new EphemerisTime();
14 | Assert.AreEqual(0.0, et.JulianDay.Value);
15 | Assert.AreEqual(0.0, et.DeltaT);
16 | Assert.AreEqual(0.0, et.Value);
17 | }
18 |
19 | [TestMethod]
20 | public void TestCreate()
21 | {
22 | var date = new UniversalTime(2014, 4, 26, 16, 53, 24);
23 | var jd = new JulianDay(date, DateCalendar.Gregorian);
24 | var dt = 0.456;
25 | EphemerisTime et = new EphemerisTime(jd, dt);
26 | Assert.AreEqual(jd, et.JulianDay);
27 | Assert.AreEqual(dt, et.DeltaT);
28 | Assert.AreEqual(jd.Value + dt, et.Value);
29 | }
30 |
31 | [TestMethod]
32 | public void TestCastToDouble()
33 | {
34 | var date = new UniversalTime(2014, 4, 26, 16, 53, 24);
35 | var jd = new JulianDay(date, DateCalendar.Gregorian);
36 | var dt = 0.456;
37 | EphemerisTime et = new EphemerisTime(jd, dt);
38 | double cd = et;
39 | Assert.AreEqual(cd, et.Value);
40 | }
41 |
42 | [TestMethod]
43 | public void TestToString()
44 | {
45 | var date = new UniversalTime(2014, 4, 26, 16, 53, 24);
46 | var jd = new JulianDay(date, DateCalendar.Gregorian);
47 | var dt = 0.456;
48 | EphemerisTime et = new EphemerisTime(jd, dt);
49 | Assert.AreEqual(2456774.65975.ToString(), et.ToString());
50 | }
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Tests/SwephNet.Tests/GeoPositionTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 |
7 | namespace SwephNet.Tests
8 | {
9 |
10 | [TestClass]
11 | public class GeoPositionTest
12 | {
13 |
14 | [TestMethod]
15 | public void TestCreateEmpty() {
16 | GeoPosition pos = new GeoPosition();
17 | Assert.AreEqual(0, pos.Longitude.Value);
18 | Assert.AreEqual(0, pos.Latitude.Value);
19 | Assert.AreEqual(0, pos.Altitude);
20 | }
21 |
22 | [TestMethod]
23 | public void TestCreate() {
24 | GeoPosition pos = new GeoPosition(46.72, -5.23, 12);
25 | Assert.AreEqual(46.72, pos.Longitude.Value);
26 | Assert.AreEqual(-5.23, pos.Latitude.Value);
27 | Assert.AreEqual(12, pos.Altitude);
28 | }
29 |
30 | [TestMethod]
31 | public void TestToString() {
32 | GeoPosition pos = new GeoPosition(46.72, -5.23, 12);
33 | Assert.AreEqual("46E43'12\", 5S13'48\", 12 m", pos.ToString());
34 | }
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Tests/SwephNet.Tests/JulianDayTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace SwephNet.Tests
5 | {
6 | [TestClass]
7 | public class JulianDayTest
8 | {
9 | [TestInitialize]
10 | public void Initialize()
11 | {
12 | System.Globalization.CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
13 | System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = System.Globalization.CultureInfo.InvariantCulture;
14 | }
15 |
16 | [TestMethod]
17 | public void TestCreateEmpty() {
18 | JulianDay jd = new JulianDay();
19 | Assert.AreEqual(0.0, jd.Value);
20 | Assert.AreEqual(DateCalendar.Julian, jd.Calendar);
21 | }
22 |
23 | [TestMethod]
24 | public void TestCreateComponents() {
25 | var date = new UniversalTime(2014, 4, 26, 16, 53, 24);
26 | JulianDay jd = new JulianDay(date, DateCalendar.Gregorian);
27 | Assert.AreEqual(2456774.20375, jd.Value);
28 | Assert.AreEqual(DateCalendar.Gregorian, jd.Calendar);
29 |
30 | date = new UniversalTime(2014, 4, 26, 16, 53, 24);
31 | jd = new JulianDay(date, DateCalendar.Julian);
32 | Assert.AreEqual(2456787.20375, jd.Value);
33 | Assert.AreEqual(DateCalendar.Julian, jd.Calendar);
34 |
35 | date = new UniversalTime(1974, 8, 15, 23, 30, 00);
36 | jd = new JulianDay(date, DateCalendar.Gregorian);
37 | Assert.AreEqual(2442275.47916667, jd.Value, 0.00000001);
38 |
39 | }
40 |
41 | [TestMethod]
42 | public void TestCreateDouble() {
43 | var date = 2456774.20375;
44 | JulianDay jd = new JulianDay(date, DateCalendar.Gregorian);
45 | Assert.AreEqual(date, jd.Value);
46 | Assert.AreEqual(DateCalendar.Gregorian, jd.Calendar);
47 |
48 | jd = new JulianDay(date, DateCalendar.Julian);
49 | Assert.AreEqual(date, jd.Value);
50 | Assert.AreEqual(DateCalendar.Julian, jd.Calendar);
51 | }
52 |
53 | [TestMethod]
54 | public void TestToDateUT() {
55 | var date = new UniversalTime(2014, 4, 26, 16, 53, 24);
56 | var jd = new JulianDay(date, DateCalendar.Gregorian);
57 | Assert.AreEqual(date, jd.ToDateUT());
58 | }
59 |
60 | [TestMethod]
61 | public void TestToDateTime() {
62 | var date = new UniversalTime(2014, 4, 26, 16, 53, 24);
63 | var jd = new JulianDay(date, DateCalendar.Gregorian);
64 | Assert.AreEqual(date.ToDateTime(), jd.ToDateTime());
65 | }
66 |
67 | [TestMethod]
68 | public void TestCastToDouble() {
69 | var date = new UniversalTime(2014, 4, 26, 16, 53, 24);
70 | var jd = new JulianDay(date, DateCalendar.Gregorian);
71 | double cd = jd;
72 | Assert.AreEqual(cd, jd.Value);
73 | }
74 |
75 | [TestMethod]
76 | public void TestToString() {
77 | var date = new UniversalTime(2014, 4, 26, 16, 53, 24);
78 | var jd = new JulianDay(date, DateCalendar.Gregorian);
79 | Assert.AreEqual("2456774.20375", jd.ToString());
80 | }
81 |
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/Tests/SwephNet.Tests/PlanetTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace SwephNet.Tests
5 | {
6 | [TestClass]
7 | public class PlanetTest
8 | {
9 | [TestMethod]
10 | public void TestCreate() {
11 | var planet = new Planet();
12 | Assert.AreEqual(0, planet.Id);
13 | planet = new Planet(1234);
14 | Assert.AreEqual(1234, planet.Id);
15 | }
16 |
17 | [TestMethod]
18 | public void TestIntCast() {
19 | Planet planet = 1234;
20 | Assert.AreEqual(1234, planet.Id);
21 |
22 | int i = planet;
23 | Assert.AreEqual(1234, i);
24 | }
25 |
26 | [TestMethod]
27 | public void TestPlanetType() {
28 | Planet planet = 0;
29 | Assert.AreEqual(false, planet.IsAsteroid);
30 | Assert.AreEqual(false, planet.IsComet);
31 | Assert.AreEqual(false, planet.IsFictitious);
32 | Assert.AreEqual(true, planet.IsPlanet);
33 |
34 | planet = -100;
35 | Assert.AreEqual(false, planet.IsAsteroid);
36 | Assert.AreEqual(false, planet.IsComet);
37 | Assert.AreEqual(false, planet.IsFictitious);
38 | Assert.AreEqual(false, planet.IsPlanet);
39 |
40 | planet = 10;
41 | Assert.AreEqual(false, planet.IsAsteroid);
42 | Assert.AreEqual(false, planet.IsComet);
43 | Assert.AreEqual(false, planet.IsFictitious);
44 | Assert.AreEqual(true, planet.IsPlanet);
45 |
46 | planet = 25;
47 | Assert.AreEqual(false, planet.IsAsteroid);
48 | Assert.AreEqual(false, planet.IsComet);
49 | Assert.AreEqual(false, planet.IsFictitious);
50 | Assert.AreEqual(false, planet.IsPlanet);
51 |
52 | planet = 50;
53 | Assert.AreEqual(false, planet.IsAsteroid);
54 | Assert.AreEqual(false, planet.IsComet);
55 | Assert.AreEqual(true, planet.IsFictitious);
56 | Assert.AreEqual(false, planet.IsPlanet);
57 |
58 | planet = 50;
59 | Assert.AreEqual(false, planet.IsAsteroid);
60 | Assert.AreEqual(false, planet.IsComet);
61 | Assert.AreEqual(true, planet.IsFictitious);
62 | Assert.AreEqual(false, planet.IsPlanet);
63 |
64 | planet = 1000;
65 | Assert.AreEqual(false, planet.IsAsteroid);
66 | Assert.AreEqual(true, planet.IsComet);
67 | Assert.AreEqual(false, planet.IsFictitious);
68 | Assert.AreEqual(false, planet.IsPlanet);
69 |
70 | planet = 2000;
71 | Assert.AreEqual(false, planet.IsAsteroid);
72 | Assert.AreEqual(true, planet.IsComet);
73 | Assert.AreEqual(false, planet.IsFictitious);
74 | Assert.AreEqual(false, planet.IsPlanet);
75 |
76 | planet = 10000;
77 | Assert.AreEqual(true, planet.IsAsteroid);
78 | Assert.AreEqual(false, planet.IsComet);
79 | Assert.AreEqual(false, planet.IsFictitious);
80 | Assert.AreEqual(false, planet.IsPlanet);
81 |
82 | planet = 12000;
83 | Assert.AreEqual(true, planet.IsAsteroid);
84 | Assert.AreEqual(false, planet.IsComet);
85 | Assert.AreEqual(false, planet.IsFictitious);
86 | Assert.AreEqual(false, planet.IsPlanet);
87 | }
88 |
89 | [TestMethod]
90 | public void TestAsAsteroid() {
91 | Planet planet = Planet.AsAsteroid(12);
92 | Assert.AreEqual(Planet.FirstAsteroid + 12, planet.Id);
93 | }
94 |
95 | [TestMethod]
96 | public void TestToString() {
97 | Planet planet = Planet.Venus;
98 | Assert.AreEqual("3", planet.ToString());
99 | }
100 |
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/Tests/SwephNet.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // Les informations générales relatives à un assembly dépendent de
6 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
7 | // associées à un assembly.
8 | [assembly: AssemblyTitle("SwephNet.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SwephNet.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
18 | // aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
19 | // COM, affectez la valeur true à l'attribut ComVisible sur ce type.
20 | [assembly: ComVisible(false)]
21 |
22 | // Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
23 | [assembly: Guid("9b145cd6-2658-44ac-b61b-e4aec6ace721")]
24 |
25 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes :
26 | //
27 | // Version principale
28 | // Version secondaire
29 | // Numéro de build
30 | // Révision
31 | //
32 | // Vous pouvez spécifier toutes les valeurs ou vous pouvez définir par défaut les numéros de build et de révision
33 | // en utilisant '*', comme indiqué ci-dessous :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Tests/SwephNet.Tests/SideralTimeTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using Microsoft.VisualStudio.TestTools.UnitTesting;
6 |
7 | namespace SwephNet.Tests
8 | {
9 |
10 | [TestClass]
11 | public class SideralTimeTest
12 | {
13 |
14 | [TestMethod]
15 | public void TestCreateEmpty() {
16 | SideralTime time = new SideralTime();
17 | Assert.AreEqual(0, time.Value);
18 | }
19 |
20 | [TestMethod]
21 | public void TestCreate() {
22 | SideralTime time = new SideralTime(12.3456789);
23 | Assert.AreEqual(12.3456789, time.Value);
24 | }
25 |
26 | [TestMethod]
27 | public void TestToString() {
28 | SideralTime time = new SideralTime(12.3456789);
29 | Assert.AreEqual("12:20:44", time.ToString());
30 | }
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Tests/SwephNet.Tests/SweErrorTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using System.Collections.Generic;
4 | using Microsoft.VisualStudio.TestTools.UnitTesting;
5 |
6 | namespace SwephNet.Tests
7 | {
8 | ///
9 | /// Description résumée pour SweErrorTest
10 | ///
11 | [TestClass]
12 | public class SweErrorTest
13 | {
14 | [TestMethod]
15 | public void TestCreate()
16 | {
17 |
18 | var target = new SweError("Message");
19 | Assert.AreEqual("Message", target.Message);
20 | Assert.IsNull(target.InnerException);
21 |
22 | target = new SweError("Message {0}", 2);
23 | Assert.AreEqual("Message 2", target.Message);
24 | Assert.IsNull(target.InnerException);
25 |
26 | var ex = new ArgumentException();
27 |
28 | target = new SweError(null, "Message");
29 | Assert.AreEqual("Message", target.Message);
30 | Assert.IsNull(target.InnerException);
31 |
32 | target = new SweError(null, "Message {0}", 2);
33 | Assert.AreEqual("Message 2", target.Message);
34 | Assert.IsNull(target.InnerException);
35 |
36 | target = new SweError(ex, "Message");
37 | Assert.AreEqual("Message", target.Message);
38 | Assert.AreSame(ex, target.InnerException);
39 |
40 | target = new SweError(ex, "Message {0}", 2);
41 | Assert.AreEqual("Message 2", target.Message);
42 | Assert.AreSame(ex, target.InnerException);
43 |
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Tests/SwephNet.Tests/SweFormatTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace SwephNet.Tests
5 | {
6 | [TestClass]
7 | public class SweFormatTest
8 | {
9 | [TestInitialize]
10 | public void Initialize()
11 | {
12 | System.Globalization.CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
13 | System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = System.Globalization.CultureInfo.InvariantCulture;
14 | }
15 |
16 | [TestMethod]
17 | public void TestFormatAsDegrees() {
18 | Assert.AreEqual(" 0° 0' 0.0000", SweFormat.FormatAsDegrees(0));
19 | Assert.AreEqual(" 123° 27' 24.4080", SweFormat.FormatAsDegrees(123.45678));
20 | Assert.AreEqual("-123° 27' 24.4080", SweFormat.FormatAsDegrees(-123.45678));
21 | }
22 |
23 | [TestMethod]
24 | public void TestFormatAsTime() {
25 | Assert.AreEqual("00:00:00", SweFormat.FormatAsTime(0));
26 | Assert.AreEqual("123:27:24", SweFormat.FormatAsTime(123.45678));
27 | Assert.AreEqual("-123:27:24", SweFormat.FormatAsTime(-123.45678));
28 | }
29 |
30 | [TestMethod]
31 | public void TestFormatAsHour() {
32 | Assert.AreEqual(" 0 h 00 m 00 s", SweFormat.FormatAsHour(0));
33 | Assert.AreEqual("123 h 27 m 24 s", SweFormat.FormatAsHour(123.45678));
34 | Assert.AreEqual("-123 h 27 m 24 s", SweFormat.FormatAsHour(-123.45678));
35 | }
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Tests/SwephNet.Tests/SweLibTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace SwephNet.Tests
5 | {
6 | [TestClass]
7 | public class SweLibTest
8 | {
9 |
10 | [TestMethod]
11 | public void TestDegNorm()
12 | {
13 | Assert.AreEqual(0, SweLib.DegNorm(0));
14 | Assert.AreEqual(180, SweLib.DegNorm(180));
15 | Assert.AreEqual(180, SweLib.DegNorm(-180));
16 | Assert.AreEqual(0, SweLib.DegNorm(360));
17 | Assert.AreEqual(0, SweLib.DegNorm(-360));
18 | Assert.AreEqual(90, SweLib.DegNorm(450));
19 | Assert.AreEqual(270, SweLib.DegNorm(-450));
20 | }
21 |
22 | [TestMethod]
23 | public void TestDegToRad()
24 | {
25 | double delta = 0.00000000000001;
26 | Assert.AreEqual(0, SweLib.DegToRad(0), delta);
27 | Assert.AreEqual(3.14159265358979, SweLib.DegToRad(180), delta);
28 | Assert.AreEqual(-3.14159265358979, SweLib.DegToRad(-180), delta);
29 | Assert.AreEqual(6.28318530717959, SweLib.DegToRad(360), delta);
30 | Assert.AreEqual(-6.28318530717959, SweLib.DegToRad(-360), delta);
31 | Assert.AreEqual(7.85398163397448, SweLib.DegToRad(450), delta);
32 | Assert.AreEqual(-7.85398163397448, SweLib.DegToRad(-450), delta);
33 | }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Tests/SwephNet.Tests/SwePlanetTest-fr.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 | using System.Collections.Generic;
4 |
5 | namespace SwephNet.Tests
6 | {
7 | [TestClass]
8 | public class SwePlanetTest_fr
9 | {
10 | System.Globalization.CultureInfo _SaveCulture, _SaveUICulture;
11 |
12 | [TestInitialize]
13 | public void Init()
14 | {
15 | _SaveCulture = System.Globalization.CultureInfo.DefaultThreadCurrentCulture;
16 | _SaveUICulture = System.Globalization.CultureInfo.DefaultThreadCurrentUICulture;
17 | System.Globalization.CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("fr");
18 | System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo("fr");
19 | }
20 |
21 | [TestCleanup]
22 | public void Restore()
23 | {
24 | System.Globalization.CultureInfo.DefaultThreadCurrentCulture = _SaveCulture;
25 | System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = _SaveUICulture;
26 | }
27 |
28 | [TestMethod]
29 | public void TestGetPlanetName() {
30 | using (var swe = new Sweph()) {
31 | Assert.AreEqual("Soleil", swe.Planet.GetPlanetName(Planet.Sun));
32 | Assert.AreEqual("Lune", swe.Planet.GetPlanetName(Planet.Moon));
33 | Assert.AreEqual("Mercure", swe.Planet.GetPlanetName(Planet.Mercury));
34 | Assert.AreEqual("Vénus", swe.Planet.GetPlanetName(Planet.Venus));
35 | Assert.AreEqual("Terre", swe.Planet.GetPlanetName(Planet.Earth));
36 | Assert.AreEqual("Mars", swe.Planet.GetPlanetName(Planet.Mars));
37 | Assert.AreEqual("Jupiter", swe.Planet.GetPlanetName(Planet.Jupiter));
38 | Assert.AreEqual("Saturne", swe.Planet.GetPlanetName(Planet.Saturn));
39 | Assert.AreEqual("Uranus", swe.Planet.GetPlanetName(Planet.Uranus));
40 | Assert.AreEqual("Neptune", swe.Planet.GetPlanetName(Planet.Neptune));
41 | }
42 | }
43 |
44 | [TestMethod]
45 | public void TestGetPlanetName_Fictitious() {
46 | using (var swe = new Sweph()) {
47 | Assert.AreEqual("Cupido", swe.Planet.GetPlanetName(Planet.FirstFictitious));
48 | Assert.AreEqual("Nom inconnu", swe.Planet.GetPlanetName(Planet.FirstFictitious + 200));
49 | }
50 | }
51 |
52 | [TestMethod]
53 | public void TestGetPlanetName_Asteroid() {
54 | using (var swe = new Sweph()) {
55 | Assert.AreEqual("0: nom inconnu", swe.Planet.GetPlanetName(Planet.FirstAsteroid));
56 | Assert.AreEqual("433: nom inconnu", swe.Planet.GetPlanetName(Planet.FirstAsteroid + 433));
57 | }
58 | }
59 |
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Tests/SwephNet.Tests/SwephDateTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 |
4 | namespace SwephNet.Tests
5 | {
6 | [TestClass]
7 | public class SwephDateTest
8 | {
9 |
10 | [TestMethod]
11 | public void TestJulianDay()
12 | {
13 | using (var swe = new Sweph())
14 | {
15 |
16 | Assert.AreEqual(0.0, swe.JulianDay(new UniversalTime(-4713, 11, 24, 12, 0, 0), DateCalendar.Gregorian).Value);
17 | Assert.AreEqual(0.0, swe.JulianDay(-4713, 11, 24, 12, 0, 0, DateCalendar.Gregorian).Value);
18 | Assert.AreEqual(0.0, swe.JulianDay(-4713, 11, 24, 12.0, DateCalendar.Gregorian).Value);
19 | Assert.AreEqual(0.0, swe.JulianDay(-4712, 1, 1, 12.0, DateCalendar.Julian).Value);
20 |
21 | Assert.AreEqual(2000000.0, swe.JulianDay(763, 9, 18, 12.0, DateCalendar.Gregorian).Value);
22 | Assert.AreEqual(2000000.0, swe.JulianDay(763, 9, 14, 12.0, DateCalendar.Julian).Value);
23 |
24 | Assert.AreEqual(1063884.0, swe.JulianDay(-1800, 9, 18, 12.0, DateCalendar.Gregorian).Value);
25 | Assert.AreEqual(1063865.0, swe.JulianDay(-1800, 9, 14, 12.0, DateCalendar.Julian).Value);
26 | }
27 | }
28 |
29 | [TestMethod]
30 | public void TestDateUT()
31 | {
32 | using (var swe = new Sweph())
33 | {
34 | // From JulianDay
35 | Assert.AreEqual(new UniversalTime(-4712, 1, 1, 12.0), swe.DateUT(new JulianDay()));
36 | Assert.AreEqual(new UniversalTime(-4712, 1, 1, 12.0), swe.DateUT(new JulianDay(0)));
37 | Assert.AreEqual(new UniversalTime(-4713, 11, 24, 12, 0, 0), swe.DateUT(new JulianDay(0, DateCalendar.Gregorian)));
38 | Assert.AreEqual(new UniversalTime(-4712, 1, 1, 12.0), swe.DateUT(new JulianDay(0, DateCalendar.Julian)));
39 |
40 | // From EphemerisTime
41 | Assert.AreEqual(new UniversalTime(-4712, 1, 1, 12.0), swe.DateUT(new EphemerisTime()));
42 | Assert.AreEqual(new UniversalTime(-4712, 1, 1, 12.0), swe.DateUT(new EphemerisTime(new JulianDay(), 0)));
43 | }
44 | }
45 |
46 | [TestMethod]
47 | public void TestEphemerisTime()
48 | {
49 | using (var swe = new Sweph())
50 | {
51 | double prec = 0.00000001;
52 | Assert.AreEqual(1.5716511059188, swe.EphemerisTime(new JulianDay()), prec);
53 | Assert.AreEqual(2442275.52135549, swe.EphemerisTime(new JulianDay(new UniversalTime(1974, 8, 16, 0.5))), prec);
54 |
55 | }
56 | }
57 |
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/Tests/SwephNet.Tests/SwephTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.VisualStudio.TestTools.UnitTesting;
3 | using System.IO;
4 | using System.Collections.Generic;
5 | using SwephNet;
6 |
7 | namespace SwephNet.Tests
8 | {
9 | [TestClass]
10 | public class SwephTest
11 | {
12 |
13 | [TestMethod]
14 | public void TestCreate() {
15 | using (var swe = new Sweph()) {
16 | Assert.IsNotNull(swe.Date);
17 | }
18 | }
19 |
20 | [TestMethod]
21 | public void TestLoadFile()
22 | {
23 | using (var swe = new Sweph())
24 | {
25 | Assert.IsNull(swe.LoadFile(null));
26 | Assert.IsNull(swe.LoadFile("file"));
27 | swe.OnLoadFile += (s, e) => {
28 | if (e.FileName == "file")
29 | {
30 | e.File = new MemoryStream(System.Text.Encoding.Default.GetBytes("This is the file content."));
31 | }
32 | };
33 | Assert.IsNull(swe.LoadFile(null));
34 | Assert.IsNull(swe.LoadFile("test"));
35 | var str = swe.LoadFile("file");
36 | Assert.IsNotNull(str);
37 | using (var r = new StreamReader(str))
38 | {
39 | Assert.AreEqual("This is the file content.", r.ReadToEnd());
40 | }
41 | }
42 | }
43 |
44 | [TestMethod]
45 | public void TestTrace()
46 | {
47 | using (var swe = new Sweph())
48 | {
49 | List messages = new List();
50 | swe.Trace(null);
51 | swe.Trace("Message 1");
52 | swe.OnTrace += (s, e) => {
53 | messages.Add(e.Message);
54 | };
55 | swe.Trace(null);
56 | swe.Trace("Message 2");
57 | swe.Trace("Message {0}", 3);
58 | CollectionAssert.AreEqual(new String[]{
59 | null,
60 | "Message 2",
61 | "Message 3",
62 | }, messages.ToArray());
63 | }
64 | }
65 |
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | #---------------------------------#
2 | # general configuration #
3 | #---------------------------------#
4 |
5 | # version format
6 | version: 2.0.0.{build}
7 |
8 | # branches to build
9 | branches:
10 | # whitelist
11 | only:
12 | - master
13 |
14 | # blacklist
15 | except:
16 | - gh-pages
17 |
18 | #---------------------------------#
19 | # build configuration #
20 | #---------------------------------#
21 |
22 | # build platform, i.e. x86, x64, AnyCPU. This setting is optional.
23 | platform: AnyCPU
24 |
25 | # to add several configurations to build matrix:
26 | configuration:
27 | # - Debug
28 | - Release
29 |
30 | # scripts to run before build
31 | before_build:
32 | - cmd: nuget restore
33 |
34 | # scripts to run after build
35 | #after_build:
36 |
37 | # to run your custom scripts instead of automatic MSBuild
38 | #build_script:
39 |
40 | # to disable automatic builds
41 | #build: off
42 |
43 | #---------------------------------#
44 | # tests configuration #
45 | #---------------------------------#
46 |
47 | # to disable automatic tests
48 | test:
49 | assemblies:
50 | - SwephNet.Tests.dll
51 |
52 | #---------------------------------#
53 | # artifacts configuration #
54 | #---------------------------------#
55 |
56 | #artifacts:
57 | #
58 | # # pushing a single file
59 | # - path: test.zip
60 | #
61 | # # pushing a single file with environment variable in path and "Deployment name" specified
62 | # - path: MyProject\bin\$(configuration)
63 | # name: myapp
64 | #
65 | # # pushing entire folder as a zip archive
66 | # - path: logs
67 | #
68 | # # pushing all *.nupkg files in directory
69 | # - path: out\*.nupkg
70 |
71 |
--------------------------------------------------------------------------------
/release_notes.md:
--------------------------------------------------------------------------------
1 | ### Current development
2 | - [#1](https://github.com/ygrenier/SwephNet/pull/1) : AppVeyor integration
3 |
4 | [Commits](https://github.com/ygrenier/SwephNet/compare/v2.0.0...master)
5 |
6 | ### v2.0.0 - 2014-06-06
7 | #### Initial commit after split
8 |
9 | We can't retreive the history from the original SwissEphNet project, so we restart. You
10 | can look the history from (https://github.com/ygrenier/SwissEphNet).
11 |
12 |
13 |
--------------------------------------------------------------------------------