19 | * // Tropical, the Moon in opposition with the Sun.
20 | * Transit transit = new TransitBuilder(event)
21 | * .planet("Moon")
22 | * .toPlanet("Sun")
23 | * .aspect(180.0)
24 | * .build();
25 | *
26 | * System.out.println( transit.getTransit() );
27 | *
28 | * // Sidereal, the Moon in trine with the point 36.3° in zodiac.
29 | * Planet transit = new PlanetBuilder(event)
30 | * .planet('Moon')
31 | * .toPoint(36.3)
32 | * .aspect(120.0)
33 | * .zodiac("Fagan Bradley")
34 | * .backwards(true)
35 | * .build();
36 | *
37 | * System.out.println( transit.getTransit() );
38 | *
39 | *
40 | * @author Tomas Jurman tomasjurman@gmail.com
41 | */
42 | public class TransitBuilder extends Builder{
43 |
44 | private final LocalDateTime event;
45 | private Coordinates coords;
46 | private Integer planet;
47 | private Integer planet2;
48 | private Double point;
49 | private int iflags = 0; // tropical default
50 | private double aspect = 0.0; // default
51 | private boolean backwards = false;
52 |
53 | /**
54 | * Creates Transit builder.
55 | *
56 | * @param event The start date and the time in Universal Time (UT).
57 | */
58 | public TransitBuilder( LocalDateTime event ) {
59 | this.event = event;
60 | }
61 |
62 | /**
63 | * Sets the transiting planets.
64 | *
65 | * @param planet The transiting planet.
66 | * @return
67 | */
68 | public TransitBuilder planet( String planetName) {
69 | this.planet = super.getPlanet(planetName);
70 | return this;
71 | }
72 |
73 | /**
74 | * Sets the transiting planets.
75 | *
76 | * Note: It is possible set transiting planet or point. Not both together.
77 | *
78 | * @param planet The second planet that will be transited by the first planet.
79 | * @return
80 | */
81 | public TransitBuilder toPlanet( String planetName) {
82 | this.point = null; // planet2 or point
83 | this.planet2 = super.getPlanet(planetName);
84 | return this;
85 | }
86 |
87 | /**
88 | * Sets the transiting point.
89 | *
90 | * Note: It is possible set point or transiting planet. Not both together.
91 | *
92 | * @param point The desired transit degree.
93 | * @return
94 | */
95 | public TransitBuilder toPoint( Double point) {
96 | this.planet2 = null; // point or planet2
97 | this.point = point;
98 | return this;
99 | }
100 |
101 | /**
102 | * Sets the aspect to point or planet.
103 | *
104 | * @param aspect the aspect in degree. For example: 0, 60, 90, 120, 180,...
105 | * @return
106 | */
107 | public TransitBuilder aspect( Double aspect ) {
108 | this.aspect = aspect;
109 | return this;
110 | }
111 |
112 | /**
113 | * Sets the direction of counting
114 | *
115 | * @param backwards
116 | * @return
117 | */
118 | public TransitBuilder backwards( boolean backwards ) {
119 | this.backwards = backwards;
120 | return this;
121 | }
122 |
123 | /**
124 | * Sets sidereal mode
125 | *
126 | * @param siderealMode sidereal mode
127 | * @return
128 | */
129 | public TransitBuilder zodiac(String siderealMode) {
130 | this.iflags = super.getSiderealFlags(siderealMode);
131 | return this;
132 | }
133 |
134 | /**
135 | * Sets topocentric cordinate system.
136 | *
137 | * @param lon The Longitude in degrees
138 | * @param lat The Latitude in degrees
139 | * @param geoalt The height above sea level in meters
140 | * @return
141 | */
142 | public TransitBuilder topo(double lon, double lat, double geoalt) {
143 | this.coords = super.getCoordinates(lon, lat, geoalt);
144 | return this;
145 | }
146 |
147 | /**
148 | * Builds query
149 | *
150 | * @return
151 | */
152 | public Transit build() {
153 |
154 | Transit trasit;
155 |
156 | if(this.point == null) { // to planet
157 |
158 | if(this.coords == null) { // geocentric
159 | trasit = new Transit(this.event, this.planet, this.planet2, this.aspect, this.iflags, this.backwards);
160 |
161 | }else { // topocentric
162 | trasit = new Transit(this.event, this.planet, this.planet2, this.aspect, this.coords, this.iflags, this.backwards);
163 | }
164 |
165 | }else { // to point
166 |
167 | if(this.coords == null) { // geocentric
168 | trasit = new Transit(this.event, this.planet, (this.point + this.aspect), this.iflags, this.backwards);
169 |
170 | }else { // topocentric
171 | trasit = new Transit(this.event, this.planet, (this.point + this.aspect), this.coords, this.iflags, this.backwards);
172 | }
173 | }
174 |
175 | return trasit;
176 | }
177 |
178 | @Override
179 | public int hashCode() {
180 | final int prime = 31;
181 | int result = 1;
182 | result = prime * result + ((event == null) ? 0 : event.hashCode());
183 | return result;
184 | }
185 |
186 | @Override
187 | public boolean equals(Object obj) {
188 | if (this == obj)
189 | return true;
190 | if (obj == null)
191 | return false;
192 | if (getClass() != obj.getClass())
193 | return false;
194 | TransitBuilder other = (TransitBuilder) obj;
195 | if (event == null) {
196 | if (other.event != null)
197 | return false;
198 | } else if (!event.equals(other.event))
199 | return false;
200 | return true;
201 | }
202 |
203 | @Override
204 | public String toString() {
205 | return "TransitBuilder [event=" + event + "]";
206 | }
207 | }
208 |
--------------------------------------------------------------------------------
/src/main/java/cz/kibo/api/astrology/domain/Coordinates.java:
--------------------------------------------------------------------------------
1 | package cz.kibo.api.astrology.domain;
2 |
3 | public class Coordinates {
4 |
5 | private final double latitude;
6 | private final double longitude;
7 | private final double geoalt;
8 |
9 | /**
10 | *
11 | * @param lon The Longitude in degrees
12 | * @param lat The Latitude in degrees
13 | * @param geoalt The height above sea level in meters
14 | */
15 | public Coordinates(double lon, double lat, double geoalt) {
16 | super();
17 | this.longitude = lon;
18 | this.latitude = lat;
19 | this.geoalt = geoalt;
20 | }
21 |
22 | public double getLatitude() {
23 | return latitude;
24 | }
25 |
26 | public double getLongitude() {
27 | return longitude;
28 | }
29 |
30 | public double getGeoalt() {
31 | return geoalt;
32 | }
33 |
34 | @Override
35 | public int hashCode() {
36 | final int prime = 31;
37 | int result = 1;
38 | long temp;
39 | temp = Double.doubleToLongBits(geoalt);
40 | result = prime * result + (int) (temp ^ (temp >>> 32));
41 | temp = Double.doubleToLongBits(latitude);
42 | result = prime * result + (int) (temp ^ (temp >>> 32));
43 | temp = Double.doubleToLongBits(longitude);
44 | result = prime * result + (int) (temp ^ (temp >>> 32));
45 | return result;
46 | }
47 |
48 | @Override
49 | public boolean equals(Object obj) {
50 | if (this == obj)
51 | return true;
52 | if (obj == null)
53 | return false;
54 | if (getClass() != obj.getClass())
55 | return false;
56 | Coordinates other = (Coordinates) obj;
57 | if (Double.doubleToLongBits(geoalt) != Double.doubleToLongBits(other.geoalt))
58 | return false;
59 | if (Double.doubleToLongBits(latitude) != Double.doubleToLongBits(other.latitude))
60 | return false;
61 | if (Double.doubleToLongBits(longitude) != Double.doubleToLongBits(other.longitude))
62 | return false;
63 | return true;
64 | }
65 |
66 | @Override
67 | public String toString() {
68 | return "lat=" + latitude + ", lon=" + longitude + ", geoalt=" + geoalt;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/cz/kibo/api/astrology/domain/Cusp.java:
--------------------------------------------------------------------------------
1 | package cz.kibo.api.astrology.domain;
2 |
3 | import java.time.LocalDateTime;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | import cz.kibo.api.astrology.json.Convertor;
9 | import swisseph.SweConst;
10 | import swisseph.SweDate;
11 | import swisseph.SwissEph;
12 |
13 | /**
14 | * Representation of cusps positions at a certain date and time.
15 | *
16 | * All time events - input and output - are in Universal Time (UT).
17 | * This class should not be used alone. Use {@link cz.kibo.api.astrology.builder.PlanetBuilder} to create the correct instance of this class.
18 | *
19 | * @author Tomas Jurman tomasjurman@gmail.com
20 | *
21 | */
22 | public class Cusp extends Ephemeris{
23 |
24 | private List cuspsPositions;
25 |
26 | private final LocalDateTime event;
27 | private Coordinates coords;
28 | private Integer houseSystem;
29 | private int iflag;
30 |
31 | private SwissEph sw;
32 | private SweDate sd;
33 |
34 | /**
35 | * Calculates cusps positions with specific options.
36 | *
37 | * @param event The date and the time of the event in Universal Time (UT).
38 | * @param coords longitude, latitude, geoalt.
39 | * @param houseSystem The house system as a character given as an integer.
40 | * @param iflag Options for sidereal or tropical calculation. 0 - tropical, SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_* - for sidereal. Dont use other flags!.
41 | *
42 | * @see iflag @http://th-mack.de/download/swisseph-doc/swisseph/SwissEph.html#swe_set_sid_mode(int)
43 | */
44 | public Cusp( LocalDateTime event, Coordinates coords, Integer houseSystem, int iflag) {
45 | super();
46 | this.event = event;
47 | this.coords = coords;
48 | this.houseSystem = houseSystem;
49 | this.iflag = iflag;
50 |
51 | sw = new SwissEph( super.getPathToEphemeris() );
52 | sd = new SweDate(event.getYear(), event.getMonthValue(), event.getDayOfMonth(), event.getHour() + event.getMinute()/60.0 + event.getSecond()/3600.0, SweDate.SE_GREG_CAL);
53 |
54 | if( (this.iflag & 0xF0000) == SweConst.SEFLG_SIDEREAL ) {
55 | sw.swe_set_sid_mode( this.iflag & 0x00FF );
56 | }
57 |
58 | this.cuspsPositions = calculateCusps(this.sw, this.sd, this.houseSystem, this.coords, this.iflag);
59 | }
60 |
61 | public List getCusps() {
62 | return this.cuspsPositions;
63 | }
64 |
65 | public Coordinates getCoordinates() {
66 | return new Coordinates(this.coords.getLatitude(), this.coords.getLongitude(), this.coords.getGeoalt());
67 | }
68 |
69 | public LocalDateTime getEvent() {
70 | return this.event;
71 | }
72 |
73 | /**
74 | * Converts cusps positions to JSON string
75 | * @return
76 | */
77 | public String toJSON() {
78 | Convertor convertor = new Convertor( getCusps() );
79 | return convertor.getJSON().toString();
80 | }
81 |
82 | private List calculateCusps( SwissEph calculator, SweDate date, Integer hSystem, Coordinates coordinates, int flags ){
83 |
84 | List cPositions = new ArrayList();
85 |
86 | double[] cusps = new double[13];
87 | double[] acsc = new double[10];
88 | int result = sw.swe_houses(sd.getJulDay(),
89 | flags,
90 | coordinates.getLatitude(),
91 | coordinates.getLongitude(),
92 | hSystem,
93 | cusps,
94 | acsc);
95 |
96 | if(result == SweConst.ERR) {
97 | System.err.println("Error! Cusps calculation was not possible.");
98 | //TODO Exception
99 | }
100 |
101 | for(int i = 1; i <= 12; i++){
102 | cPositions.add(cusps[i]);
103 | }
104 |
105 | return cPositions;
106 | }
107 |
108 | @Override
109 | public int hashCode() {
110 | final int prime = 31;
111 | int result = 1;
112 | result = prime * result + ((cuspsPositions == null) ? 0 : cuspsPositions.hashCode());
113 | result = prime * result + ((event == null) ? 0 : event.hashCode());
114 | return result;
115 | }
116 |
117 | @Override
118 | public boolean equals(Object obj) {
119 | if (this == obj)
120 | return true;
121 | if (obj == null)
122 | return false;
123 | if (getClass() != obj.getClass())
124 | return false;
125 | Cusp other = (Cusp) obj;
126 | if (cuspsPositions == null) {
127 | if (other.cuspsPositions != null)
128 | return false;
129 | } else if (!cuspsPositions.equals(other.cuspsPositions))
130 | return false;
131 | if (event == null) {
132 | if (other.event != null)
133 | return false;
134 | } else if (!event.equals(other.event))
135 | return false;
136 | return true;
137 | }
138 |
139 | @Override
140 | public String toString() {
141 | StringBuilder sb = new StringBuilder();
142 | sb.append( (this.iflag & 0xF0000) == SweConst.SEFLG_SIDEREAL ? "Sidereal - " : "Tropical \n");
143 | if( (this.iflag & 0xF0000) == SweConst.SEFLG_SIDEREAL ) {
144 | sb.append( sw.swe_get_ayanamsa_name(this.iflag & 0x00FF) + "\n");
145 | }
146 | sb.append("[ UTC: " + this.event + ", ");
147 | sb.append(", " + this.coords + ", ");
148 | sb.append(this.sw.swe_house_name( (char)(this.houseSystem.intValue())) + " ]\n");
149 | sb.append(this.cuspsPositions + " ]\n");
150 | return sb.toString();
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/src/main/java/cz/kibo/api/astrology/domain/Ephemeris.java:
--------------------------------------------------------------------------------
1 | package cz.kibo.api.astrology.domain;
2 |
3 | import java.io.IOException;
4 | import java.util.Properties;
5 |
6 | public abstract class Ephemeris {
7 |
8 | private final Properties settings = new Properties();
9 |
10 | protected String getPathToEphemeris(){
11 | try {
12 | settings.load( this.getClass().getResourceAsStream("/settings.properties") );
13 | } catch (IOException e) {
14 | e.printStackTrace();
15 | }
16 |
17 | return settings.getProperty("ephemeris.path");
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/cz/kibo/api/astrology/domain/Planet.java:
--------------------------------------------------------------------------------
1 | package cz.kibo.api.astrology.domain;
2 |
3 | import java.time.LocalDateTime;
4 | import java.util.ArrayList;
5 | import java.util.HashMap;
6 | import java.util.List;
7 | import java.util.Map;
8 |
9 | import cz.kibo.api.astrology.json.Convertor;
10 | import swisseph.SweConst;
11 | import swisseph.SweDate;
12 | import swisseph.SwissEph;
13 |
14 | /**
15 | * Representation of planet ephemeris at a certain date and time.
16 | *
17 | * All time events - input and output - are in Universal Time (UT).
18 | * This class should not be used alone. Use {@link cz.kibo.api.astrology.builder.PlanetBuilder} to create the correct instance of this class.
19 | *
20 | * @author Tomas Jurman tomasjurman@gmail.com
21 | *
22 | */
23 | public class Planet extends Ephemeris{
24 |
25 | private Map> planetsPositions;
26 |
27 | private final LocalDateTime event;
28 | private List planets;
29 | private Coordinates coords;
30 | private int iflag;
31 |
32 | private SwissEph sw;
33 | private SweDate sd;
34 |
35 |
36 | /**
37 | * Calculates planets positions. Planets in geocentric coordinate system.
38 | *
39 | * @param event The date and the time of the event in Universal Time (UT).
40 | * @param planets List of planets for position calculation. Constants of planets are in {@link swisseph.SweConst}.
41 | * @param iflag Options for sidereal or tropical calculation. 0 - tropical, SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_* - for sidereal .Dont use other flags!.
42 | * @see swisseph.SweConst
43 | */
44 | public Planet( LocalDateTime event, List planets, int iflag) {
45 | super();
46 | this.event = event;
47 | this.planets = planets;
48 | this.iflag = SweConst.SEFLG_SWIEPH | SweConst.SEFLG_SPEED;
49 |
50 | sw = new SwissEph( super.getPathToEphemeris() );
51 | sd = new SweDate(event.getYear(), event.getMonthValue(), event.getDayOfMonth(), event.getHour() + event.getMinute()/60.0 + event.getSecond()/360.0, SweDate.SE_GREG_CAL);
52 |
53 | if( (iflag & 0xF0000) == SweConst.SEFLG_SIDEREAL ) {
54 | sw.swe_set_sid_mode( iflag & 0x00FF );
55 | this.iflag |= SweConst.SEFLG_SIDEREAL;
56 | }
57 |
58 | this.planetsPositions = calculatePlanets( planets, sw, sd, this.iflag);
59 | }
60 |
61 | /**
62 | * Calculates planets positions. Planets in topocentric cordinate system.
63 | *
64 | * @param event The date and the time of the event in Universal Time (UT).
65 | * @param planets List of planets for position calculation. Constants of planets are in {@link swisseph.SweConst}.
66 | * @param coords longitude, latitude, geoalt for topocentric. Calculations relative to the observer on some place on the earth rather than relative to the center of the earth.
67 | * @param iflag Options for sidereal or tropical calculation. 0 - tropical, SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_* - for sidereal. Dont use other flags!.
68 | *
69 | * @see swisseph.SweConst
70 | */
71 | public Planet( LocalDateTime event, List planets, Coordinates coords, int iflag ) {
72 | super();
73 | this.event = event;
74 | this.planets = planets;
75 | this.coords = coords;
76 | this.iflag = SweConst.SEFLG_SWIEPH | SweConst.SEFLG_SPEED | SweConst.SEFLG_TOPOCTR;
77 |
78 | sw = new SwissEph( getPathToEphemeris() );
79 | sw.swe_set_topo(this.coords.getLongitude(), this.coords.getLatitude(), this.coords.getGeoalt());
80 | sd = new SweDate(event.getYear(), event.getMonthValue(), event.getDayOfMonth(), event.getHour() + event.getMinute()/60.0 + event.getSecond()/360.0, SweDate.SE_GREG_CAL);
81 |
82 | if( (iflag & 0xF0000) == SweConst.SEFLG_SIDEREAL ) {
83 | sw.swe_set_sid_mode( iflag & 0x00FF );
84 | this.iflag |= SweConst.SEFLG_SIDEREAL;
85 | }
86 |
87 | this.planetsPositions = calculatePlanets( planets, sw, sd, this.iflag);
88 | }
89 |
90 | public Map> getPlanets() {
91 | return this.planetsPositions;
92 | }
93 |
94 | public Coordinates getCoordinates() {
95 | return new Coordinates(this.coords.getLatitude(), this.coords.getLongitude(), this.coords.getGeoalt());
96 | }
97 |
98 | public LocalDateTime getEvent() {
99 | return this.event;
100 | }
101 |
102 | /**
103 | * Converts planets positions to JSON string
104 | * @return
105 | */
106 | public String toJSON() {
107 | Convertor convertor = new Convertor( getPlanets() );
108 | return convertor.getJSON().toString();
109 | }
110 |
111 | private Map> calculatePlanets( List planets, SwissEph calculator, SweDate date, int flags ) {
112 | Map> data = new HashMap>();
113 |
114 | for (Integer planet : planets) {
115 |
116 | double[] xp= new double[6];
117 | StringBuffer serr = new StringBuffer();
118 | int ret = sw.swe_calc_ut(date.getJulDay(),
119 | planet,
120 | flags,
121 | xp,
122 | serr);
123 |
124 | if (ret != flags) {
125 | if (serr.length() > 0) {
126 | System.err.println("Warning: " + serr);
127 | } else {
128 | System.err.println( String.format("Warning, different flags used (0x%x)", ret));
129 | }
130 | }
131 |
132 | // @see swisseph.SwissEph.swe_calc
133 | List values = new ArrayList();
134 | values.add(xp[0]); //longitude
135 | values.add(xp[3]); //speed in longitude
136 |
137 | data.put( getPlanetName(planet), values);
138 | }
139 |
140 | return data;
141 | }
142 |
143 | /*
144 | * @param planet - int from swisseph.SweConst
145 | *
146 | * @see swisseph.SwissEph.swe_get_planet_name(int ipl)
147 | */
148 | private String getPlanetName(int planet) {
149 |
150 | String name = sw.swe_get_planet_name(planet);
151 |
152 | if(planet == SweConst.SE_MEAN_APOG){
153 | name = "Lilith";
154 | }
155 |
156 | if(planet == SweConst.SE_MEAN_NODE){
157 | name = "NNode";
158 | }
159 |
160 | return name;
161 | }
162 |
163 | @Override
164 | public int hashCode() {
165 | final int prime = 31;
166 | int result = 1;
167 | result = prime * result + ((event == null) ? 0 : event.hashCode());
168 | result = prime * result + ((planetsPositions == null) ? 0 : planetsPositions.hashCode());
169 | return result;
170 | }
171 |
172 | @Override
173 | public boolean equals(Object obj) {
174 | if (this == obj)
175 | return true;
176 | if (obj == null)
177 | return false;
178 | if (getClass() != obj.getClass())
179 | return false;
180 | Planet other = (Planet) obj;
181 | if (event == null) {
182 | if (other.event != null)
183 | return false;
184 | } else if (!event.equals(other.event))
185 | return false;
186 | if (planetsPositions == null) {
187 | if (other.planetsPositions != null)
188 | return false;
189 | } else if (!planetsPositions.equals(other.planetsPositions))
190 | return false;
191 | return true;
192 | }
193 |
194 | @Override
195 | public String toString() {
196 | StringBuilder sb = new StringBuilder();
197 | sb.append("[ UTC: " + this.event);
198 |
199 | if(this.coords != null) {
200 | sb.append(", " + this.coords + " ]\n");
201 | }else {
202 | sb.append(" ]\n");
203 | }
204 |
205 | for (Map.Entry> planet : this.planetsPositions.entrySet()){
206 | sb.append(planet.getKey() + ": " + planet.getValue() +"\n");
207 | }
208 |
209 | return sb.toString();
210 | }
211 | }
--------------------------------------------------------------------------------
/src/main/java/cz/kibo/api/astrology/domain/Transit.java:
--------------------------------------------------------------------------------
1 | package cz.kibo.api.astrology.domain;
2 |
3 | import java.time.LocalDateTime;
4 | import java.time.ZoneOffset;
5 | import java.util.List;
6 |
7 | import swisseph.SweConst;
8 | import swisseph.SweDate;
9 | import swisseph.SwissEph;
10 | import swisseph.TCPlanet;
11 | import swisseph.TCPlanetPlanet;
12 | import swisseph.TransitCalculator;
13 |
14 | /**
15 | * Representation of transit positions at a certain date and time.
16 | *
17 | * All time events - input and output - are in Universal Time (UT).
18 | * This class should not be used alone. Use {@link cz.kibo.api.astrology.builder.TransitBuilder} to create the correct instance of this class.
19 | *
20 | * @author Tomas Jurman tomasjurman@gmail.com
21 | *
22 | */
23 | public class Transit extends Ephemeris{
24 |
25 | private final LocalDateTime event;
26 | private Integer planet;
27 | private Integer planet2;
28 | private Double point;
29 | private Double offset;
30 | private Coordinates coords;
31 | private int iflag;
32 | private Double transit;
33 |
34 | private SwissEph sw;
35 | private SweDate sd;
36 |
37 | /**
38 | * Calculates planets transit to point in zodiac. Planets in geocentric cordinate system.
39 | *
40 | * @param event Start date in Universal Time (UT).
41 | * @param planet The transiting planet. Constants of planets are in {@link swisseph.SweConst}.
42 | * @param point The desired transit degree.
43 | * @param iflag Options for sidereal or tropical calculation. 0 - tropical, SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_* - for sidereal .Dont use other flags!.
44 | * @param backwards
45 | *
46 | * @see swisseph.SweConst
47 | */
48 | public Transit( LocalDateTime event, Integer planet, Double point, int iflag, boolean backwards) {
49 | super();
50 | this.event = event;
51 | this.planet = planet;
52 | this.point = point;
53 | this.iflag = SweConst.SEFLG_SWIEPH | SweConst.SEFLG_TRANSIT_LONGITUDE;
54 |
55 | sw = new SwissEph( super.getPathToEphemeris() );
56 | sd = new SweDate(event.getYear(), event.getMonthValue(), event.getDayOfMonth(), event.getHour() + event.getMinute()/60.0 + event.getSecond()/360.0, SweDate.SE_GREG_CAL);
57 |
58 | if( (iflag & 0xF0000) == SweConst.SEFLG_SIDEREAL ) {
59 | sw.swe_set_sid_mode( iflag & 0x00FF );
60 | this.iflag |= SweConst.SEFLG_SIDEREAL;
61 | }
62 |
63 | TransitCalculator tc = new TCPlanet(
64 | sw,
65 | this.planet,
66 | this.iflag,
67 | this.point);
68 |
69 | this.transit = sw.getTransitUT(tc, sd.getJulDay(), backwards);
70 | }
71 |
72 | /**
73 | * Calculates planets transit to point in zodiac. Planets in geocentric cordinate system.
74 | *
75 | * @param event Start date in Universal Time (UT).
76 | * @param planet The transiting planet. Constants of planets are in {@link swisseph.SweConst}.
77 | * @param point The desired transit degree.
78 | * @param iflag Options for sidereal or tropical calculation. 0 - tropical, SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_* - for sidereal .Dont use other flags!.
79 | *
80 | * @see swisseph.SweConst
81 | */
82 | public Transit( LocalDateTime event, Integer planet, Double point, int iflag) {
83 | this( event, planet, point, iflag, false);
84 | }
85 |
86 | /**
87 | * Calculates planets transit to point in zodiac. Planets in topocentric cordinate system.
88 | *
89 | * @param event Start date in Universal Time (UT).
90 | * @param planet The transiting planet. Constants of planets are in {@link swisseph.SweConst}.
91 | * @param point The desired transit degree.
92 | * @param iflag Options for sidereal or tropical calculation. 0 - tropical, SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_* - for sidereal .Dont use other flags!.
93 | * @param backwards
94 | *
95 | * @see swisseph.SweConst
96 | */
97 | public Transit( LocalDateTime event, Integer planet, Double point, Coordinates coords, int iflag, boolean backwards) {
98 | super();
99 | this.event = event;
100 | this.planet = planet;
101 | this.point = point;
102 | this.coords = coords;
103 | this.iflag = SweConst.SEFLG_SWIEPH | SweConst.SEFLG_TRANSIT_LONGITUDE | SweConst.SEFLG_TOPOCTR;
104 |
105 | sw = new SwissEph( super.getPathToEphemeris() );
106 | sw.swe_set_topo(this.coords.getLongitude(), this.coords.getLatitude(), this.coords.getGeoalt());
107 | sd = new SweDate(event.getYear(), event.getMonthValue(), event.getDayOfMonth(), event.getHour() + event.getMinute()/60.0 + event.getSecond()/360.0, SweDate.SE_GREG_CAL);
108 |
109 | if( (iflag & 0xF0000) == SweConst.SEFLG_SIDEREAL ) {
110 | sw.swe_set_sid_mode( iflag & 0x00FF );
111 | this.iflag |= SweConst.SEFLG_SIDEREAL;
112 | }
113 |
114 | TransitCalculator tc = new TCPlanet(
115 | sw,
116 | this.planet,
117 | this.iflag,
118 | this.point);
119 |
120 | this.transit = sw.getTransitUT(tc, sd.getJulDay(), backwards);
121 | }
122 |
123 | /**
124 | * Calculates planets transit to point in zodiac. Planets in topocentric cordinate system.
125 | *
126 | * @param event Start date in Universal Time (UT).
127 | * @param planet The transiting planet. Constants of planets are in {@link swisseph.SweConst}.
128 | * @param point The desired transit degree.
129 | * @param iflag Options for sidereal or tropical calculation. 0 - tropical, SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_* - for sidereal .Dont use other flags!.
130 | *
131 | * @see swisseph.SweConst
132 | */
133 | public Transit( LocalDateTime event, Integer planet, Double point, Coordinates coords, int iflag) {
134 | this( event, planet, point, coords, iflag, false);
135 | }
136 |
137 | /**
138 | * Calculates transit of two different planets to each other. Planets in geocentric cordinate system.
139 | *
140 | * @param event Start date in Universal Time (UT).
141 | * @param planet The transiting planet. Constants of planets are in {@link swisseph.SweConst}.
142 | * @param planet2 The second planet that will be transited by the first planet.
143 | * @param offset The desired transit degree.
144 | * @param iflag Options for sidereal or tropical calculation. 0 - tropical, SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_* - for sidereal .Dont use other flags!.
145 | * @param backwards
146 | *
147 | * @see swisseph.SweConst
148 | */
149 | public Transit( LocalDateTime event, Integer planet, Integer planet2, double offset, int iflag, boolean backwards) {
150 | super();
151 | this.event = event;
152 | this.planet = planet;
153 | this.planet2 = planet2;
154 | this.offset = offset;
155 | this.iflag = SweConst.SEFLG_SWIEPH | SweConst.SEFLG_TRANSIT_LONGITUDE;
156 |
157 | sw = new SwissEph( super.getPathToEphemeris() );
158 | sd = new SweDate(event.getYear(), event.getMonthValue(), event.getDayOfMonth(), event.getHour() + event.getMinute()/60.0 + event.getSecond()/360.0, SweDate.SE_GREG_CAL);
159 |
160 | if( (iflag & 0xF0000) == SweConst.SEFLG_SIDEREAL ) {
161 | sw.swe_set_sid_mode( iflag & 0x00FF );
162 | this.iflag |= SweConst.SEFLG_SIDEREAL;
163 | }
164 |
165 | TransitCalculator tc = new TCPlanetPlanet(
166 | sw,
167 | this.planet,
168 | this.planet2,
169 | this.iflag,
170 | this.offset);
171 |
172 | this.transit = sw.getTransitUT(tc, sd.getJulDay(), backwards);
173 | }
174 |
175 | /**
176 | * Calculates transit of two different planets to each other. Planets in geocentric cordinate system.
177 | *
178 | * @param event Start date in Universal Time (UT).
179 | * @param planet The transiting planet. Constants of planets are in {@link swisseph.SweConst}.
180 | * @param planet2 The second planet that will be transited by the first planet.
181 | * @param offset The desired transit degree.
182 | * @param iflag Options for sidereal or tropical calculation. 0 - tropical, SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_* - for sidereal .Dont use other flags!.
183 | *
184 | * @see swisseph.SweConst
185 | */
186 | public Transit( LocalDateTime event, Integer planet, Integer planet2, double offset, int iflag) {
187 | this( event, planet, planet2, offset, iflag, false );
188 | }
189 |
190 |
191 | /**
192 | * Calculates transit of two different planets to each other. Planets in topocentric cordinate system.
193 | *
194 | * @param event Start date in Universal Time (UT).
195 | * @param planet The transiting planet. Constants of planets are in {@link swisseph.SweConst}.
196 | * @param planet2 The second planet that will be transited by the first planet.
197 | * @param offset The desired transit degree.
198 | * @param coords longitude, latitude, geoalt for topocentric.
199 | * @param iflag Options for sidereal or tropical calculation. 0 - tropical, SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_* - for sidereal .Dont use other flags!.
200 | * @param backwards
201 | *
202 | * @see swisseph.SweConst
203 | */
204 | public Transit( LocalDateTime event, Integer planet, Integer planet2, double offset, Coordinates coords, int iflag, boolean backwards) {
205 | super();
206 | this.event = event;
207 | this.planet = planet;
208 | this.planet2 = planet2;
209 | this.coords = coords;
210 | this.offset = offset;
211 | this.iflag = SweConst.SEFLG_SWIEPH | SweConst.SEFLG_TRANSIT_LONGITUDE | SweConst.SEFLG_TOPOCTR;
212 |
213 | sw = new SwissEph( super.getPathToEphemeris());
214 | sw.swe_set_topo(this.coords.getLongitude(), this.coords.getLatitude(), this.coords.getGeoalt());
215 | sd = new SweDate(event.getYear(), event.getMonthValue(), event.getDayOfMonth(), event.getHour() + event.getMinute()/60.0 + event.getSecond()/360.0, SweDate.SE_GREG_CAL);
216 |
217 | if( (iflag & 0xF0000) == SweConst.SEFLG_SIDEREAL ) {
218 | sw.swe_set_sid_mode( iflag & 0x00FF );
219 | this.iflag |= SweConst.SEFLG_SIDEREAL;
220 | }
221 |
222 | TransitCalculator tc = new TCPlanetPlanet(
223 | sw,
224 | this.planet,
225 | this.planet2,
226 | this.iflag,
227 | this.offset);
228 |
229 | this.transit = sw.getTransitUT(tc, sd.getJulDay(), backwards);
230 | }
231 |
232 | /**
233 | * Calculates transit of two different planets to each other. Planets in topocentric cordinate system.
234 | *
235 | * @param event Start date in Universal Time (UT).
236 | * @param planet The transiting planet. Constants of planets are in {@link swisseph.SweConst}.
237 | * @param planet2 The second planet that will be transited by the first planet.
238 | * @param offset The desired transit degree.
239 | * @param coords longitude, latitude, geoalt for topocentric.
240 | * @param iflag Options for sidereal or tropical calculation. 0 - tropical, SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_* - for sidereal .Dont use other flags!.
241 | *
242 | * @see swisseph.SweConst
243 | */
244 | public Transit( LocalDateTime event, Integer planet, Integer planet2, double offset, Coordinates coords, int iflag) {
245 | this( event, planet, planet2, offset, coords, iflag, false);
246 | }
247 |
248 |
249 | public LocalDateTime getDate() {
250 | SweDate sweDate = new SweDate(this.transit, SweDate.SE_GREG_CAL);
251 | return LocalDateTime.ofInstant(sweDate.getDate(0).toInstant(), ZoneOffset.UTC);
252 | }
253 |
254 | @Override
255 | public int hashCode() {
256 | final int prime = 31;
257 | int result = 1;
258 | result = prime * result + ((event == null) ? 0 : event.hashCode());
259 | result = prime * result + iflag;
260 | result = prime * result + ((planet == null) ? 0 : planet.hashCode());
261 | result = prime * result + ((transit == null) ? 0 : transit.hashCode());
262 | return result;
263 | }
264 |
265 | @Override
266 | public boolean equals(Object obj) {
267 | if (this == obj)
268 | return true;
269 | if (obj == null)
270 | return false;
271 | if (getClass() != obj.getClass())
272 | return false;
273 | Transit other = (Transit) obj;
274 | if (event == null) {
275 | if (other.event != null)
276 | return false;
277 | } else if (!event.equals(other.event))
278 | return false;
279 | if (iflag != other.iflag)
280 | return false;
281 | if (planet == null) {
282 | if (other.planet != null)
283 | return false;
284 | } else if (!planet.equals(other.planet))
285 | return false;
286 | if (transit == null) {
287 | if (other.transit != null)
288 | return false;
289 | } else if (!transit.equals(other.transit))
290 | return false;
291 | return true;
292 | }
293 |
294 | @Override
295 | public String toString() {
296 | return "UTC: " + getDate();
297 | }
298 | }
299 |
--------------------------------------------------------------------------------
/src/main/java/cz/kibo/api/astrology/json/Convertor.java:
--------------------------------------------------------------------------------
1 | package cz.kibo.api.astrology.json;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 |
6 | import org.json.JSONArray;
7 | import org.json.JSONObject;
8 |
9 | /**
10 | * Helper class for data conversion to JSON.
11 | *
12 | * @author Tomas Jurman tomasjurman@gmail.com
13 | *
14 | */
15 | public class Convertor {
16 |
17 | private final String PLANETS_KEY_NAME = "planets";
18 | private final String CUSPS_KEY_NAME = "cusps";
19 |
20 |
21 | private JSONObject dataset = new JSONObject();
22 |
23 | /**
24 | * Creates Planetary Convertor
25 | *
26 | * @param planets The output from class cz.kibo.api.astrology.domain.Planet
27 | */
28 | public Convertor( Map> planetsPositions ) {
29 |
30 | JSONObject planets = new JSONObject();
31 |
32 | for (Map.Entry> entry : planetsPositions.entrySet()){
33 | String planet = entry.getKey();
34 | List xp = entry.getValue();
35 |
36 | JSONArray data = new JSONArray();
37 | for(Double value : xp) {
38 | data.put(value);
39 | }
40 |
41 | planets.put(planet, data);
42 | }
43 |
44 | dataset.put(PLANETS_KEY_NAME, planets);
45 | }
46 |
47 | /**
48 | * Creates Cusps Convertor
49 | *
50 | * @param planets The output from class cz.kibo.api.astrology.domain.Cusp
51 | */
52 | public Convertor( List cuspsPositions ) {
53 | JSONArray cusps = new JSONArray();
54 |
55 | for(Double cup : cuspsPositions) {
56 | cusps.put(cup);
57 | }
58 |
59 | dataset.put(CUSPS_KEY_NAME, cusps);
60 | }
61 |
62 | /**
63 | * @return Returns the converted data
64 | */
65 | public JSONObject getJSON() {
66 | return dataset;
67 | }
68 |
69 | @Override
70 | public int hashCode() {
71 | final int prime = 31;
72 | int result = 1;
73 | result = prime * result + ((dataset == null) ? 0 : dataset.hashCode());
74 | return result;
75 | }
76 |
77 | @Override
78 | public boolean equals(Object obj) {
79 | if (this == obj)
80 | return true;
81 | if (obj == null)
82 | return false;
83 | if (getClass() != obj.getClass())
84 | return false;
85 | Convertor other = (Convertor) obj;
86 | if (dataset == null) {
87 | if (other.dataset != null)
88 | return false;
89 | } else if (!dataset.equals(other.dataset))
90 | return false;
91 | return true;
92 | }
93 |
94 | @Override
95 | public String toString() {
96 | return dataset.toString();
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/main/java/swisseph/AyaInit.java:
--------------------------------------------------------------------------------
1 | /*
2 | This is a port of the Swiss Ephemeris Free Edition, Version 2.00.00
3 | of Astrodienst AG, Switzerland from the original C Code to Java. For
4 | copyright see the original copyright notices below and additional
5 | copyright notes in the file named LICENSE, or - if this file is not
6 | available - the copyright notes at http://www.astro.ch/swisseph/ and
7 | following.
8 |
9 | For any questions or comments regarding this port to Java, you should
10 | ONLY contact me and not Astrodienst, as the Astrodienst AG is not involved
11 | in this port in any way.
12 |
13 | Thomas Mack, mack@ifis.cs.tu-bs.de, 23rd of April 2001
14 |
15 | */
16 | /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
17 |
18 | License conditions
19 | ------------------
20 |
21 | This file is part of Swiss Ephemeris.
22 |
23 | Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
24 | or distributor accepts any responsibility for the consequences of using it,
25 | or for whether it serves any particular purpose or works at all, unless he
26 | or she says so in writing.
27 |
28 | Swiss Ephemeris is made available by its authors under a dual licensing
29 | system. The software developer, who uses any part of Swiss Ephemeris
30 | in his or her software, must choose between one of the two license models,
31 | which are
32 | a) GNU public license version 2 or later
33 | b) Swiss Ephemeris Professional License
34 |
35 | The choice must be made before the software developer distributes software
36 | containing parts of Swiss Ephemeris to others, and before any public
37 | service using the developed software is activated.
38 |
39 | If the developer choses the GNU GPL software license, he or she must fulfill
40 | the conditions of that license, which includes the obligation to place his
41 | or her whole software project under the GNU GPL or a compatible license.
42 | See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
43 |
44 | If the developer choses the Swiss Ephemeris Professional license,
45 | he must follow the instructions as found in http://www.astro.com/swisseph/
46 | and purchase the Swiss Ephemeris Professional Edition from Astrodienst
47 | and sign the corresponding license contract.
48 |
49 | The License grants you the right to use, copy, modify and redistribute
50 | Swiss Ephemeris, but only under certain conditions described in the License.
51 | Among other things, the License requires that the copyright notices and
52 | this notice be preserved on all copies.
53 |
54 | Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
55 |
56 | The authors of Swiss Ephemeris have no control or influence over any of
57 | the derived works, i.e. over software or services created by other
58 | programmers which use Swiss Ephemeris functions.
59 |
60 | The names of the authors or of the copyright holder (Astrodienst) must not
61 | be used for promoting any software, product or service which uses or contains
62 | the Swiss Ephemeris. This copyright notice is the ONLY place where the
63 | names of the authors can legally appear, except in cases where they have
64 | given special permission in writing.
65 |
66 | The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
67 | for promoting such software, products or services.
68 | */
69 | package swisseph;
70 |
71 | /**
72 | * A class to contain all the data for different ayanamsas.
73 | * t0 is the epoch at which ayanamsha = 0.
74 | * For internal use only - the data is packed into an array[21] of AyaInit.
75 | * The available Ayanamshas are:
76 | *
77 | *
0: Fagan/Bradley (Default)
78 | *
1: Lahiri (Robert Hand)
79 | *
2: De Luce (Robert Hand)
80 | *
3: Raman (Robert Hand)
81 | *
4: Ushashashi (Robert Hand)
82 | *
5: Krishnamurti (Robert Hand)
83 | *
6: Djwhal Khool; (Graham Dawson)
84 | *
7: Yukteshwar; (David Cochrane)
85 | *
8: JN Bhasin; (David Cochrane)
86 | *
9: Babylonian, Kugler 1
87 | *
10: Babylonian, Kugler 2
88 | *
11: Babylonian, Kugler 3
89 | *
12: Babylonian, Huber
90 | *
13: Babylonian, Mercier
91 | *
14: t0 is defined by Aldebaran at 15 Taurus
92 | *
15: Hipparchos
93 | *
16: Sassanian
94 | *
17: Galactic Center at 0 Sagittarius
95 | *
18: J2000
96 | *
19: J1900
97 | *
20: B1950
98 | *
21: Suryasiddhanta, assuming ingress of mean Sun into Aries at point of mean equinox of date on 21.3.499, noon, Ujjain (75.7684565 E) = 7:30:31.57 UT
99 | *
22: Suryasiddhanta, assuming ingress of mean Sun into Aries at true position of mean Sun at same epoch
100 | *
23: Aryabhata, same date, but UT 6:56:55.57 analogous 21
101 | *
24: Aryabhata, analogous 22
102 | *
25: SS, Revati/zePsc at polar long. 359°50'
103 | *
26: SS, Citra/Spica at polar long. 180°
104 | *
105 | *
You will find the complete documentation for the original
106 | * SwissEphemeris package at
107 | * http://www.astro.ch/swisseph/sweph_g.htm. By far most of the information
108 | * there is directly valid for this port to Java as well.
109 | * @version 1.0.0a
110 | */
111 | class AyaInit
112 | implements java.io.Serializable
113 | {
114 | double t0;
115 | double ayan_t0;
116 |
117 | AyaInit(double t0, double ayan_t0) {
118 | this.t0=t0;
119 | this.ayan_t0=ayan_t0;
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/src/main/java/swisseph/DblObj.java:
--------------------------------------------------------------------------------
1 | /*
2 | This is a port of the Swiss Ephemeris Free Edition, Version 2.00.00
3 | of Astrodienst AG, Switzerland from the original C Code to Java. For
4 | copyright see the original copyright notices below and additional
5 | copyright notes in the file named LICENSE, or - if this file is not
6 | available - the copyright notes at http://www.astro.ch/swisseph/ and
7 | following.
8 |
9 | For any questions or comments regarding this port to Java, you should
10 | ONLY contact me and not Astrodienst, as the Astrodienst AG is not involved
11 | in this port in any way.
12 |
13 | Thomas Mack, mack@ifis.cs.tu-bs.de, 23rd of April 2001
14 |
15 | */
16 | /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
17 |
18 | License conditions
19 | ------------------
20 |
21 | This file is part of Swiss Ephemeris.
22 |
23 | Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
24 | or distributor accepts any responsibility for the consequences of using it,
25 | or for whether it serves any particular purpose or works at all, unless he
26 | or she says so in writing.
27 |
28 | Swiss Ephemeris is made available by its authors under a dual licensing
29 | system. The software developer, who uses any part of Swiss Ephemeris
30 | in his or her software, must choose between one of the two license models,
31 | which are
32 | a) GNU public license version 2 or later
33 | b) Swiss Ephemeris Professional License
34 |
35 | The choice must be made before the software developer distributes software
36 | containing parts of Swiss Ephemeris to others, and before any public
37 | service using the developed software is activated.
38 |
39 | If the developer choses the GNU GPL software license, he or she must fulfill
40 | the conditions of that license, which includes the obligation to place his
41 | or her whole software project under the GNU GPL or a compatible license.
42 | See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
43 |
44 | If the developer choses the Swiss Ephemeris Professional license,
45 | he must follow the instructions as found in http://www.astro.com/swisseph/
46 | and purchase the Swiss Ephemeris Professional Edition from Astrodienst
47 | and sign the corresponding license contract.
48 |
49 | The License grants you the right to use, copy, modify and redistribute
50 | Swiss Ephemeris, but only under certain conditions described in the License.
51 | Among other things, the License requires that the copyright notices and
52 | this notice be preserved on all copies.
53 |
54 | Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
55 |
56 | The authors of Swiss Ephemeris have no control or influence over any of
57 | the derived works, i.e. over software or services created by other
58 | programmers which use Swiss Ephemeris functions.
59 |
60 | The names of the authors or of the copyright holder (Astrodienst) must not
61 | be used for promoting any software, product or service which uses or contains
62 | the Swiss Ephemeris. This copyright notice is the ONLY place where the
63 | names of the authors can legally appear, except in cases where they have
64 | given special permission in writing.
65 |
66 | The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
67 | for promoting such software, products or services.
68 | */
69 | package swisseph;
70 |
71 | /**
72 | * This class enables methods to return doubles by reference. We need this
73 | * here, as this is a very direct port from C to Java, where reference
74 | * parameters are used from time to time.
75 | *
You will find the complete documentation for the original
76 | * SwissEphemeris package at
77 | * http://www.astro.ch/swisseph/sweph_g.htm. By far most of the information
78 | * there is directly valid for this port to Java as well.
79 | * @version 1.0.0b
80 | */
81 | public class DblObj
82 | implements java.io.Serializable
83 | {
84 | public DblObj() {
85 | this.val = 0;
86 | }
87 | public DblObj(double val) {
88 | this.val = val;
89 | }
90 |
91 | /**
92 | * This is the double value that has become wrapped up into a real object.
93 | */
94 | public double val;
95 | }
96 |
--------------------------------------------------------------------------------
/src/main/java/swisseph/Epsilon.java:
--------------------------------------------------------------------------------
1 | /*
2 | This is a port of the Swiss Ephemeris Free Edition, Version 2.00.00
3 | of Astrodienst AG, Switzerland from the original C Code to Java. For
4 | copyright see the original copyright notices below and additional
5 | copyright notes in the file named LICENSE, or - if this file is not
6 | available - the copyright notes at http://www.astro.ch/swisseph/ and
7 | following.
8 |
9 | For any questions or comments regarding this port to Java, you should
10 | ONLY contact me and not Astrodienst, as the Astrodienst AG is not involved
11 | in this port in any way.
12 |
13 | Thomas Mack, mack@ifis.cs.tu-bs.de, 23rd of April 2001
14 |
15 | */
16 | /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
17 |
18 | License conditions
19 | ------------------
20 |
21 | This file is part of Swiss Ephemeris.
22 |
23 | Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
24 | or distributor accepts any responsibility for the consequences of using it,
25 | or for whether it serves any particular purpose or works at all, unless he
26 | or she says so in writing.
27 |
28 | Swiss Ephemeris is made available by its authors under a dual licensing
29 | system. The software developer, who uses any part of Swiss Ephemeris
30 | in his or her software, must choose between one of the two license models,
31 | which are
32 | a) GNU public license version 2 or later
33 | b) Swiss Ephemeris Professional License
34 |
35 | The choice must be made before the software developer distributes software
36 | containing parts of Swiss Ephemeris to others, and before any public
37 | service using the developed software is activated.
38 |
39 | If the developer choses the GNU GPL software license, he or she must fulfill
40 | the conditions of that license, which includes the obligation to place his
41 | or her whole software project under the GNU GPL or a compatible license.
42 | See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
43 |
44 | If the developer choses the Swiss Ephemeris Professional license,
45 | he must follow the instructions as found in http://www.astro.com/swisseph/
46 | and purchase the Swiss Ephemeris Professional Edition from Astrodienst
47 | and sign the corresponding license contract.
48 |
49 | The License grants you the right to use, copy, modify and redistribute
50 | Swiss Ephemeris, but only under certain conditions described in the License.
51 | Among other things, the License requires that the copyright notices and
52 | this notice be preserved on all copies.
53 |
54 | Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
55 |
56 | The authors of Swiss Ephemeris have no control or influence over any of
57 | the derived works, i.e. over software or services created by other
58 | programmers which use Swiss Ephemeris functions.
59 |
60 | The names of the authors or of the copyright holder (Astrodienst) must not
61 | be used for promoting any software, product or service which uses or contains
62 | the Swiss Ephemeris. This copyright notice is the ONLY place where the
63 | names of the authors can legally appear, except in cases where they have
64 | given special permission in writing.
65 |
66 | The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
67 | for promoting such software, products or services.
68 | */
69 | package swisseph;
70 |
71 | class Epsilon
72 | implements java.io.Serializable
73 | {
74 | /* obliquity of ecliptic */
75 | double teps, eps, seps, ceps; /* jd, eps, sin(eps), cos(eps) */
76 |
77 | void clearData() {
78 | teps=0.0;
79 | eps=0.0;
80 | seps=0.0;
81 | ceps=0.0;
82 | }
83 |
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/src/main/java/swisseph/Extensions.java:
--------------------------------------------------------------------------------
1 | /*
2 | This is an extension to the Java port of the Swiss Ephemeris package
3 | of Astrodienst AG, Zuerich (Switzerland).
4 |
5 | Thomas Mack, mack@ifis.cs.tu-bs.de, 3rd of December, 2001
6 |
7 | */
8 |
9 | package swisseph;
10 |
11 |
12 | class Extensions
13 | implements java.io.Serializable
14 | {
15 |
16 | SwissEph sw;
17 |
18 | Extensions(SwissEph sw) {
19 | this.sw = sw;
20 | }
21 |
22 |
23 |
24 |
25 | // getTransit() will return the current date and time, when the
26 | // transit ist occuring on that date. If you really want the next
27 | // transit AFTER that date, add at least calcTimePrecision(...) to
28 | // your jdET, as this is the minimum time difference, for which the
29 | // available precision allows.
30 | // You can NOT rely on the assumption that you will get realistically
31 | // differentiable transit values with a time difference of
32 | // calcTimePrecision(...), but at least it does not make ANY sense
33 | // to recalculate a transit with a time difference SMALLER than the
34 | // value returned by calcTimePrecision().
35 | //
36 | // A problem:
37 | // When a transit takes a long time, this means, when the planet
38 | // stays a long time very near to the transit point, the program
39 | // may appear to be abitrary in its results. The reason is, that
40 | // it does not look for the EXACT transit point, but for an area
41 | // around the exact transit point that is defined by the maximum
42 | // available precision for the position calculation.
43 |
44 | // You may get many transits for just one planetary transit, as we
45 | // cannot differentiate transits, when they are in an area of values
46 | // which is beyond the maximum available precision. E.g., when the
47 | // sun is in the latitudinal area of 0.0019 to 0.0021 for maybe two
48 | // days, there is no chance to differentiate between any dates in
49 | // this area of time: You will get the input date returned as the
50 | // transit date always, when the input date is in the range of these
51 | // two days.
52 | double getTransit(TransitCalculator tc, double jdET, boolean back,
53 | double jdMax)
54 | throws IllegalArgumentException, SwissephException {
55 | jdET = tc.preprocessDate(jdET, back);
56 | double max = tc.getMaxSpeed();
57 | double min = tc.getMinSpeed();
58 |
59 | double jdPlus, jdMinus;
60 | double lastJD = jdET;
61 |
62 | boolean found = false;
63 | boolean above;
64 | double lastVal;
65 | double val;
66 | double offset = tc.getOffset();
67 |
68 |
69 |
70 | boolean xneg = (max < 0);
71 | boolean mneg = (min < 0);
72 | if (!xneg && !mneg) { min = max; }
73 | if (xneg && mneg) { max = min; }
74 |
75 | double degPrec = tc.getDegreePrecision(jdET)/2.; // Divided by two to have a range of +-degPrec
76 | double timePrec = tc.getTimePrecision(degPrec);
77 |
78 |
79 | val = tc.calc(jdET);
80 | if (tc.checkIdenticalResult(offset, val)) { // If not 0.0 but "very small", then
81 | // interpolate after another calculation
82 | // in the calculation loop below
83 | return val;
84 | }
85 |
86 |
87 | if (max == 0. && min == 0.) { // No possible change in position or speed
88 | throw new SwissephException(jdET, SwissephException.OUT_OF_TIME_RANGE,
89 | "No transit possible due to lack of variation of speed or position.");
90 | }
91 |
92 | while (true) {
93 | if (tc.rollover) {
94 | while (val >= tc.rolloverVal) { val -= tc.rolloverVal; }
95 | while (val < 0.) { val += tc.rolloverVal; }
96 | }
97 | above = (val >= offset);
98 |
99 | lastJD = jdET;
100 | lastVal = val;
101 |
102 | //while (tc.rollover && val= tc.rolloverVal) { val %= tc.rolloverVal; }
120 | while (tc.rollover && val < 0.) { val += tc.rolloverVal; }
121 |
122 | // Hits the transiting point exactly...:
123 | if(tc.checkIdenticalResult(offset, val)) {
124 | return val;
125 | }
126 |
127 | // The planet may have moved forward or backward, in one of these
128 | // directions it would have crossed the transit point.
129 | //
130 | // Whatever distance could have been reached in lesser time (forward or
131 | // backward move), we take it to be the direction of movement.
132 | boolean pxway = true;
133 | if (tc.rollover) {
134 | double deltadeg1 = val-lastVal;
135 | if (deltadeg1<0) { deltadeg1+=tc.rolloverVal; }
136 | double deltadeg2 = lastVal-val;
137 | if (deltadeg2<0) { deltadeg2+=tc.rolloverVal; }
138 | pxway = SMath.abs(deltadeg1/max) 300.) { // How to do it formally correct???
149 | // Probably one value is about 359.99 and the other one is in the area of 0.01
150 | if (val > lastVal) { lastVal += tc.rolloverVal; } else { val += tc.rolloverVal; }
151 | if (offset < 10.) { offset += tc.rolloverVal; } // How to do it formally correct???
152 | }
153 | // offset-lastVal and val-lastVal have to have equal signs
154 | if (val-lastVal < 0 && offset-lastVal > 0) {
155 | val += tc.rolloverVal;
156 | } else if (val-lastVal > 0 && offset-lastVal < 0) {
157 | offset += tc.rolloverVal;
158 | }
159 | }
160 | double jdRet = lastJD+(jdET-lastJD)*(offset-lastVal)/(val-lastVal);
161 | if (back) {
162 | return SMath.max(jdRet, jdET);
163 | } else {
164 | return SMath.min(jdRet, jdET);
165 | }
166 | }
167 | if ((back && jdET < jdMax) ||
168 | (!back && jdET > jdMax)) {
169 | throw new SwissephException(jdET, SwissephException.BEYOND_USER_TIME_LIMIT,
170 | -1, "User time limit of " + jdMax + " has been reached.");
171 | }
172 | }
173 | }
174 |
175 |
176 |
177 |
178 | // The precision of a distance calculation is related to the barycentric
179 | // distance
180 | // E.g.: java Swetest -b1.1.0 -p0 -n100000 -fR -bary | sort -n
181 | protected double maxBaryDist[] = new double[] {
182 | 0.009570999, // 0 Sun == 0 1.017545559
183 | 1.028809521, // 1 Moon == 1
184 | 0.466604085, // 2 Mercury == 2
185 | 0.728698831, // 3 Venus == 3
186 | 0.728698831, // 4 Mars == 4
187 | 4.955912195, // 5 Jupiter == 5
188 | 8.968685733, // 6 Saturn == 6
189 | 19.893326756, // 7 Uranus == 7
190 | 30.326750627, // 8 Neptune == 8
191 | 41.499626899, // 9 Pluto == 9
192 | 0.002569555, // m MeanNode == 10
193 | 0.002774851, // t TrueNode == 11
194 | 1.0, // A Mean Apog. == 12 // Does not vary distance anyway
195 | 0.002782378, // B Oscu.Apog. == 13
196 | 0.0, // C Earth == 14 (skip)
197 | 0.05, // D Chiron == 15 // No distance available, is 0.05 good???
198 | 31.901319663, // E Pholus == 16
199 | 3.012409508, // F Ceres == 17
200 | 3.721614106, // G Pallas == 18
201 | 3.326307148, // H Juno == 19
202 | 2.570197288, // I Vesta == 20
203 | };
204 |
205 |
206 |
207 | }
208 |
--------------------------------------------------------------------------------
/src/main/java/swisseph/Extlib.java:
--------------------------------------------------------------------------------
1 | /*
2 | This is an extension to the Java port of the Swiss Ephemeris package
3 | of Astrodienst AG, Zuerich (Switzerland).
4 |
5 | Thomas Mack, mack@ifis.cs.tu-bs.de, 25th of November, 2004
6 |
7 | */
8 |
9 | package swisseph;
10 |
11 |
12 | import java.text.*; // DateFormat etc.
13 | import java.util.*; // Locale etc.
14 |
15 | /**
16 | * Some supportive methods, mainly for internationalization.
17 | * These methods are not available in the original Swiss
18 | * Ephemeris package.
19 | */
20 | public class Extlib
21 | implements java.io.Serializable
22 | {
23 |
24 | double transitVal = 0.;
25 | SimpleDateFormat df = null;
26 | String decTimeSeparator = ".";
27 | String decNumSeparator = ".";
28 | int secondsIdx = 0;
29 |
30 |
31 |
32 | /**
33 | * This class contains some additional method not contained
34 | * in the original Swiss Ephemeris package.
35 | * Currently, these methods deal with internationalization
36 | * primarily.
37 | */
38 | public Extlib() { }
39 |
40 | /**
41 | * This method is for debugging purposes only.
42 | */
43 | public static void main(String argv[]) {
44 | new Extlib();
45 | }
46 |
47 | //////////----------------------
48 |
49 | /**
50 | * This method returns all available locale strings
51 | */
52 | public String[] getLocales() {
53 | Locale[] locs = DateFormat.getAvailableLocales();
54 | String[] locStrings = new String[locs.length];
55 |
56 | for (int r=0; r 0) {
59 | locStrings[r] += "_"+locs[r].getCountry();
60 | if (locs[r].getVariant().length() > 0) {
61 | locStrings[r] += "_"+locs[r].getVariant(); // e.g. th_TH_TH
62 | }
63 | }
64 | }
65 | return locStrings;
66 | }
67 |
68 | /**
69 | * Returns the requested locale from a locale string.
70 | * @param locString A String describing the locale as a two letter
71 | * language code, a two letter language code plus a "_" plus a two
72 | * letter country code, or null or the empty string. Null or the
73 | * empty string will return the default locale, all others will
74 | * return the requested locale.
75 | * @return The locale
76 | */
77 | public Locale getLocale(String locString) {
78 | String lang = locString;
79 | String cntry = "";
80 | if (locString == null || "".equals(locString)) {
81 | return Locale.getDefault();
82 | }
83 | int idx = locString.indexOf("_");
84 | if (idx >= 0) {
85 | lang = locString.substring(0,idx);
86 | cntry = locString.substring(idx+1);
87 | }
88 | Locale loc = null;
89 | if (cntry.equals("")) {
90 | loc = new Locale(lang);
91 | } else {
92 | loc = new Locale(lang, cntry);
93 | }
94 |
95 | return loc;
96 | }
97 |
98 |
99 | /**
100 | * Creates a localized date time formatter suitable for tabular output with
101 | * 4 digit years and UTC timezone. You will format dates like this:
108 | * Years B.C. will be prefixed by a "-". Years are counted including year
109 | * "0", which differs from normal DateFormat output.
110 | * @param locString The input locale for which this date time format
111 | * should be created. See getLocale() for more infos.
112 | * @return The normalized form of the DateFormat.
113 | */
114 | public SimpleDateFormat createLocDateTimeFormatter(String locString, boolean force24h) {
115 |
116 | // Get date format:
117 | Locale loc = getLocale(locString);
118 | SimpleDateFormat df = (SimpleDateFormat)DateFormat.getDateTimeInstance(
119 | java.text.DateFormat.SHORT, java.text.DateFormat.MEDIUM, loc);
120 |
121 | // Revert to UTC:
122 | df.getCalendar().setTimeZone(TimeZone.getTimeZone("GMT"));
123 |
124 | // Change output pattern to our needs, this means 4 letter year etc.:
125 | String pattern = getNormalizedDatePattern(df.toPattern(), force24h);
126 | df.applyPattern(pattern);
127 |
128 | return df;
129 | }
130 |
131 | /**
132 | * Ensures a date pattern with four letter year, two letter month and day
133 | * and 24h time format, if requested.
134 | */
135 | public String getNormalizedDatePattern(String pattern, boolean force24h) {
136 | int idx = 0;
137 | //System.out.println(pattern);
138 |
139 | // force year, month, day, hour, minutes and seconds to appear with two digits:
140 | final String pats = ("yMdHhms");
141 | for (int n = 0; n < pats.length(); n++) {
142 | char ch = pats.charAt(n);
143 | String out = ch + "" + ch;
144 | idx = pattern.indexOf(out);
145 | if (idx < 0) {
146 | idx = pattern.indexOf(ch);
147 | if (idx >= 0) {
148 | pattern = pattern.substring(0,idx) + ch + pattern.substring(idx);
149 | }
150 | }
151 | }
152 | // force year to appear with four digits:
153 | idx = pattern.indexOf("yyyy");
154 | if (idx < 0) {
155 | idx = pattern.indexOf("yy");
156 | if (idx >= 0) {
157 | pattern = pattern.substring(0,idx) + "yy" + pattern.substring(idx);
158 | }
159 | }
160 | // Locale "mk" does not have a "seconds" part in its time pattern
161 | // (Java 1.4.2 / Linux).
162 | // Append it after the minutes pattern ("m"):
163 | if (pattern.indexOf("s") < 0) {
164 | idx = pattern.indexOf("mm");
165 | if (idx >= 0) { // If not, it not even has a minutes part???
166 | try {
167 | // We assume some non-digit char AFTER "mm" as it is the
168 | // case with "mk" here ("d.M.yy HH:mm:" original, "dd.MM.yyyy HH:mm:"
169 | // when changed):
170 | pattern = pattern.substring(0,idx+3) + "ss" + pattern.substring(idx+3);
171 | } catch (StringIndexOutOfBoundsException sb) {
172 | // In zh_SG, the format looks like dd/MM/yyyy a hh:mm (above assumption fails)
173 | pattern = pattern.substring(0,idx+2) + pattern.substring(idx-1,idx) + "ss" + pattern.substring(idx+2);
174 | }
175 | }
176 | }
177 |
178 | if (force24h) {
179 | idx = pattern.indexOf("a");
180 | if (idx >= 0) {
181 | pattern = pattern.substring(0,idx) + pattern.substring(idx+1);
182 | idx = pattern.indexOf("hh");
183 | pattern = pattern.substring(0,idx) + "HH" + pattern.substring(idx+2);
184 | }
185 | }
186 |
187 | return pattern;
188 | }
189 |
190 | /**
191 | * Returns the decimal separator of the NumberFormat
192 | */
193 | public String getDecimalSeparator(NumberFormat nf) {
194 | if (nf instanceof DecimalFormat) {
195 | return String.valueOf(((DecimalFormat)nf).getDecimalFormatSymbols().getDecimalSeparator());
196 | }
197 | return null;
198 | }
199 |
200 | /**
201 | * Returns the index in the formatter pattern of the given pattern 'what'
202 | * recalculated to the APPLIED pattern of the formatter.
203 | * E.g. for locale zh_HK the pattern is:
204 | * yyyy'年'MM'月'dd'日' ahh:mm:ss
205 | * The index of 'ss' would NOT be 25, which we would get when simply counting in
206 | * the pattern string, but rather 20, when counting in the resulting string.
207 | */
208 | public int getPatternLastIdx(String pattern, String what, SimpleDateFormat dof) {
209 | // If we want to append fractions of a second, we have to know
210 | // at which position in the string this is to happen. We can
211 | // look for the "ss" part in the pattern string, but the pattern
212 | // can contain string constants delimited by the ' character.
213 | // Moreover, it can contain patterns expanding to more than
214 | // one letter when applied to a date and time. This is so far
215 | // known to be true for the 'a' pattern expanding to AM or PM
216 | // in english locales and expanding to still different values
217 | // in other locales.
218 |
219 | int idx = pattern.lastIndexOf(what) + 1;
220 |
221 | // Strip string constant delimiters from found pattern position:
222 | int last = idx;
223 | int i = 0;
224 | while (i < last) {
225 | if (pattern.charAt(i) == '\'') {
226 | idx--;
227 | }
228 | i++;
229 | }
230 |
231 | if (pattern.indexOf("a") >= 0 &&
232 | pattern.indexOf("a") < pattern.indexOf(what)) {
233 | int len = dof.getDateFormatSymbols().getAmPmStrings()[0].length(); // No input with fractions of a second?
234 | // We have to know the time when the length of the AM-String is
235 | // different from the length of the PM-String...
236 | // We don't care for now...
237 | idx += len - 1;
238 | }
239 |
240 | return idx;
241 | }
242 |
243 | } // End of class Extlib
244 |
--------------------------------------------------------------------------------
/src/main/java/swisseph/GenConst.java:
--------------------------------------------------------------------------------
1 | /*
2 | This is a port of the Swiss Ephemeris Free Edition, Version 2.00.00
3 | of Astrodienst AG, Switzerland from the original C Code to Java. For
4 | copyright see the original copyright notices below and additional
5 | copyright notes in the file named LICENSE, or - if this file is not
6 | available - the copyright notes at http://www.astro.ch/swisseph/ and
7 | following.
8 |
9 | For any questions or comments regarding this port to Java, you should
10 | ONLY contact me and not Astrodienst, as the Astrodienst AG is not involved
11 | in this port in any way.
12 |
13 | Thomas Mack, mack@ifis.cs.tu-bs.de, 23rd of April 2001
14 |
15 | */
16 | /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
17 |
18 | License conditions
19 | ------------------
20 |
21 | This file is part of Swiss Ephemeris.
22 |
23 | Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
24 | or distributor accepts any responsibility for the consequences of using it,
25 | or for whether it serves any particular purpose or works at all, unless he
26 | or she says so in writing.
27 |
28 | Swiss Ephemeris is made available by its authors under a dual licensing
29 | system. The software developer, who uses any part of Swiss Ephemeris
30 | in his or her software, must choose between one of the two license models,
31 | which are
32 | a) GNU public license version 2 or later
33 | b) Swiss Ephemeris Professional License
34 |
35 | The choice must be made before the software developer distributes software
36 | containing parts of Swiss Ephemeris to others, and before any public
37 | service using the developed software is activated.
38 |
39 | If the developer choses the GNU GPL software license, he or she must fulfill
40 | the conditions of that license, which includes the obligation to place his
41 | or her whole software project under the GNU GPL or a compatible license.
42 | See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
43 |
44 | If the developer choses the Swiss Ephemeris Professional license,
45 | he must follow the instructions as found in http://www.astro.com/swisseph/
46 | and purchase the Swiss Ephemeris Professional Edition from Astrodienst
47 | and sign the corresponding license contract.
48 |
49 | The License grants you the right to use, copy, modify and redistribute
50 | Swiss Ephemeris, but only under certain conditions described in the License.
51 | Among other things, the License requires that the copyright notices and
52 | this notice be preserved on all copies.
53 |
54 | Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
55 |
56 | The authors of Swiss Ephemeris have no control or influence over any of
57 | the derived works, i.e. over software or services created by other
58 | programmers which use Swiss Ephemeris functions.
59 |
60 | The names of the authors or of the copyright holder (Astrodienst) must not
61 | be used for promoting any software, product or service which uses or contains
62 | the Swiss Ephemeris. This copyright notice is the ONLY place where the
63 | names of the authors can legally appear, except in cases where they have
64 | given special permission in writing.
65 |
66 | The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
67 | for promoting such software, products or services.
68 | */
69 | package swisseph;
70 |
71 | class GenConst
72 | implements java.io.Serializable
73 | {
74 | double clight,
75 | aunit,
76 | helgravconst,
77 | ratme,
78 | sunradius;
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/swisseph/Houses.java:
--------------------------------------------------------------------------------
1 | /*
2 | This is a port of the Swiss Ephemeris Free Edition, Version 2.00.00
3 | of Astrodienst AG, Switzerland from the original C Code to Java. For
4 | copyright see the original copyright notices below and additional
5 | copyright notes in the file named LICENSE, or - if this file is not
6 | available - the copyright notes at http://www.astro.ch/swisseph/ and
7 | following.
8 |
9 | For any questions or comments regarding this port to Java, you should
10 | ONLY contact me and not Astrodienst, as the Astrodienst AG is not involved
11 | in this port in any way.
12 |
13 | Thomas Mack, mack@ifis.cs.tu-bs.de, 23rd of April 2001
14 |
15 | */
16 | /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
17 |
18 | License conditions
19 | ------------------
20 |
21 | This file is part of Swiss Ephemeris.
22 |
23 | Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
24 | or distributor accepts any responsibility for the consequences of using it,
25 | or for whether it serves any particular purpose or works at all, unless he
26 | or she says so in writing.
27 |
28 | Swiss Ephemeris is made available by its authors under a dual licensing
29 | system. The software developer, who uses any part of Swiss Ephemeris
30 | in his or her software, must choose between one of the two license models,
31 | which are
32 | a) GNU public license version 2 or later
33 | b) Swiss Ephemeris Professional License
34 |
35 | The choice must be made before the software developer distributes software
36 | containing parts of Swiss Ephemeris to others, and before any public
37 | service using the developed software is activated.
38 |
39 | If the developer choses the GNU GPL software license, he or she must fulfill
40 | the conditions of that license, which includes the obligation to place his
41 | or her whole software project under the GNU GPL or a compatible license.
42 | See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
43 |
44 | If the developer choses the Swiss Ephemeris Professional license,
45 | he must follow the instructions as found in http://www.astro.com/swisseph/
46 | and purchase the Swiss Ephemeris Professional Edition from Astrodienst
47 | and sign the corresponding license contract.
48 |
49 | The License grants you the right to use, copy, modify and redistribute
50 | Swiss Ephemeris, but only under certain conditions described in the License.
51 | Among other things, the License requires that the copyright notices and
52 | this notice be preserved on all copies.
53 |
54 | Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
55 |
56 | The authors of Swiss Ephemeris have no control or influence over any of
57 | the derived works, i.e. over software or services created by other
58 | programmers which use Swiss Ephemeris functions.
59 |
60 | The names of the authors or of the copyright holder (Astrodienst) must not
61 | be used for promoting any software, product or service which uses or contains
62 | the Swiss Ephemeris. This copyright notice is the ONLY place where the
63 | names of the authors can legally appear, except in cases where they have
64 | given special permission in writing.
65 |
66 | The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
67 | for promoting such software, products or services.
68 | */
69 | package swisseph;
70 |
71 | /**
72 | * A class to contain all the data that are relevant to houses in astrology.
73 | * Does not seem to be relevant outside this package...
74 | *
You will find the complete documentation for the original
75 | * SwissEphemeris package at
76 | * http://www.astro.ch/swisseph/sweph_g.htm. By far most of the information
77 | * there is directly valid for this port to Java as well.
78 | * @version 1.0.0a
79 | */
80 | class Houses
81 | implements java.io.Serializable
82 | {
83 | /**
84 | * The twelve house cusps from cusp[1] to cusp[12] plus many additional
85 | * points.
86 | */
87 | double cusp[]=new double[37];
88 | /**
89 | * The double value of the ascendant.
90 | */
91 | double ac;
92 | /**
93 | * The double value of the MC (=Medium Coeli = the midpoint of the heaven).
94 | */
95 | double mc;
96 | /**
97 | * The double value of the vertex.
98 | */
99 | double vertex;
100 | /**
101 | * The double value of the "equatorial ascendant".
102 | */
103 | double equasc;
104 | /**
105 | * The double value of the "co-ascendant" (Walter Koch).
106 | */
107 | double coasc1;
108 | /**
109 | * The double value of the "co-ascendant" (Michael Munkasey).
110 | */
111 | double coasc2;
112 | /**
113 | * The double value of the "polar ascendant" (Michael Munkasey).
114 | */
115 | double polasc;
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/src/main/java/swisseph/IntObj.java:
--------------------------------------------------------------------------------
1 | /*
2 | This is a port of the Swiss Ephemeris Free Edition, Version 2.00.00
3 | of Astrodienst AG, Switzerland from the original C Code to Java. For
4 | copyright see the original copyright notices below and additional
5 | copyright notes in the file named LICENSE, or - if this file is not
6 | available - the copyright notes at http://www.astro.ch/swisseph/ and
7 | following.
8 |
9 | For any questions or comments regarding this port to Java, you should
10 | ONLY contact me and not Astrodienst, as the Astrodienst AG is not involved
11 | in this port in any way.
12 |
13 | Thomas Mack, mack@ifis.cs.tu-bs.de, 23rd of April 2001
14 |
15 | */
16 | /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
17 |
18 | License conditions
19 | ------------------
20 |
21 | This file is part of Swiss Ephemeris.
22 |
23 | Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
24 | or distributor accepts any responsibility for the consequences of using it,
25 | or for whether it serves any particular purpose or works at all, unless he
26 | or she says so in writing.
27 |
28 | Swiss Ephemeris is made available by its authors under a dual licensing
29 | system. The software developer, who uses any part of Swiss Ephemeris
30 | in his or her software, must choose between one of the two license models,
31 | which are
32 | a) GNU public license version 2 or later
33 | b) Swiss Ephemeris Professional License
34 |
35 | The choice must be made before the software developer distributes software
36 | containing parts of Swiss Ephemeris to others, and before any public
37 | service using the developed software is activated.
38 |
39 | If the developer choses the GNU GPL software license, he or she must fulfill
40 | the conditions of that license, which includes the obligation to place his
41 | or her whole software project under the GNU GPL or a compatible license.
42 | See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
43 |
44 | If the developer choses the Swiss Ephemeris Professional license,
45 | he must follow the instructions as found in http://www.astro.com/swisseph/
46 | and purchase the Swiss Ephemeris Professional Edition from Astrodienst
47 | and sign the corresponding license contract.
48 |
49 | The License grants you the right to use, copy, modify and redistribute
50 | Swiss Ephemeris, but only under certain conditions described in the License.
51 | Among other things, the License requires that the copyright notices and
52 | this notice be preserved on all copies.
53 |
54 | Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
55 |
56 | The authors of Swiss Ephemeris have no control or influence over any of
57 | the derived works, i.e. over software or services created by other
58 | programmers which use Swiss Ephemeris functions.
59 |
60 | The names of the authors or of the copyright holder (Astrodienst) must not
61 | be used for promoting any software, product or service which uses or contains
62 | the Swiss Ephemeris. This copyright notice is the ONLY place where the
63 | names of the authors can legally appear, except in cases where they have
64 | given special permission in writing.
65 |
66 | The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
67 | for promoting such software, products or services.
68 | */
69 | package swisseph;
70 |
71 | /**
72 | * This class enables methods to return an integer by reference. We need this
73 | * here, as this is a very direct port from C to Java, where reference
74 | * parameters are used from time to time.
75 | *
You will find the complete documentation for the original
76 | * SwissEphemeris package at
77 | * http://www.astro.ch/swisseph/sweph_g.htm. By far most of the information
78 | * there is directly valid for this port to Java as well.
79 | * @version 1.0.0a
80 | */
81 | public class IntObj
82 | implements java.io.Serializable
83 | {
84 | /**
85 | * This is the integer value that has become wrapped up into a real object.
86 | */
87 | public int val;
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/src/main/java/swisseph/Nut.java:
--------------------------------------------------------------------------------
1 | /*
2 | This is a port of the Swiss Ephemeris Free Edition, Version 2.00.00
3 | of Astrodienst AG, Switzerland from the original C Code to Java. For
4 | copyright see the original copyright notices below and additional
5 | copyright notes in the file named LICENSE, or - if this file is not
6 | available - the copyright notes at http://www.astro.ch/swisseph/ and
7 | following.
8 |
9 | For any questions or comments regarding this port to Java, you should
10 | ONLY contact me and not Astrodienst, as the Astrodienst AG is not involved
11 | in this port in any way.
12 |
13 | Thomas Mack, mack@ifis.cs.tu-bs.de, 23rd of April 2001
14 |
15 | */
16 | /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
17 |
18 | License conditions
19 | ------------------
20 |
21 | This file is part of Swiss Ephemeris.
22 |
23 | Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
24 | or distributor accepts any responsibility for the consequences of using it,
25 | or for whether it serves any particular purpose or works at all, unless he
26 | or she says so in writing.
27 |
28 | Swiss Ephemeris is made available by its authors under a dual licensing
29 | system. The software developer, who uses any part of Swiss Ephemeris
30 | in his or her software, must choose between one of the two license models,
31 | which are
32 | a) GNU public license version 2 or later
33 | b) Swiss Ephemeris Professional License
34 |
35 | The choice must be made before the software developer distributes software
36 | containing parts of Swiss Ephemeris to others, and before any public
37 | service using the developed software is activated.
38 |
39 | If the developer choses the GNU GPL software license, he or she must fulfill
40 | the conditions of that license, which includes the obligation to place his
41 | or her whole software project under the GNU GPL or a compatible license.
42 | See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
43 |
44 | If the developer choses the Swiss Ephemeris Professional license,
45 | he must follow the instructions as found in http://www.astro.com/swisseph/
46 | and purchase the Swiss Ephemeris Professional Edition from Astrodienst
47 | and sign the corresponding license contract.
48 |
49 | The License grants you the right to use, copy, modify and redistribute
50 | Swiss Ephemeris, but only under certain conditions described in the License.
51 | Among other things, the License requires that the copyright notices and
52 | this notice be preserved on all copies.
53 |
54 | Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
55 |
56 | The authors of Swiss Ephemeris have no control or influence over any of
57 | the derived works, i.e. over software or services created by other
58 | programmers which use Swiss Ephemeris functions.
59 |
60 | The names of the authors or of the copyright holder (Astrodienst) must not
61 | be used for promoting any software, product or service which uses or contains
62 | the Swiss Ephemeris. This copyright notice is the ONLY place where the
63 | names of the authors can legally appear, except in cases where they have
64 | given special permission in writing.
65 |
66 | The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
67 | for promoting such software, products or services.
68 | */
69 | package swisseph;
70 |
71 | class Nut
72 | implements java.io.Serializable
73 | {
74 | /* nutation */
75 | double tnut;
76 | double nutlo[]; /* nutation in longitude and obliquity */
77 | double snut, cnut; /* sine and cosine of nutation in obliquity */
78 | double matrix[][];
79 |
80 | Nut() {
81 | nutlo = new double[2];
82 | matrix = new double[3][3];
83 | }
84 |
85 | void clearData() {
86 | int i,j;
87 | tnut=0.0;
88 | snut=0.0;
89 | cnut=0.0;
90 | for(j=0; j
73 | * Use it for UTC time conversions.
74 | * @author Thomas Mack / mack@ifis.cs.tu-bs.de
75 | * @version 1.0.0a
76 | */
77 |
78 | public class SDate {
79 | public int year;
80 | public int month;
81 | public int day;
82 | public int hour;
83 | public int minute;
84 | public double second;
85 |
86 | public SDate(int year, int month, int day, double hour) {
87 | this.year = year;
88 | this.month = month;
89 | this.day = day;
90 | this.hour = (int)hour;
91 | double d = hour;
92 | d -= this.hour;
93 | d *= 60.;
94 | this.minute = (int) d;
95 | this.second = (d - this.minute) * 60.0;
96 | }
97 | public SDate(int year, int month, int day, int hour, int minute, double second) {
98 | this.year = year;
99 | this.month = month;
100 | this.day = day;
101 | this.hour = hour;
102 | this.minute = minute;
103 | this.second = second;
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/main/java/swisseph/SMath.java:
--------------------------------------------------------------------------------
1 | /* java.lang.SMath -- common mathematical functions
2 | Copyright (C) Sourav.*/
3 |
4 |
5 | /*
6 | * Some of the algorithms in this class are in the public domain, as part
7 | * of fdlibm (freely-distributable math library), available at
8 | * http://www.netlib.org/fdlibm/, and carry the following copyright:
9 | * ====================================================
10 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
11 | *
12 | * Developed at SunSoft, a Sun Microsystems, Inc. business.
13 | * Permission to use, copy, modify, and distribute this
14 | * software is freely granted, provided that this notice
15 | * is preserved.
16 | * ====================================================
17 | */
18 | package swisseph;
19 |
20 | /**
21 | * Helper class mapping all mathematical functions and constants to
22 | * the java.lang.Math class.
23 | */
24 | public class SMath
25 | implements java.io.Serializable
26 | {
27 | public static final double E = Math.E;
28 | public static final double PI = Math.PI;
29 | public static int abs(int i) { return Math.abs(i); }
30 | public static long abs(long l) { return Math.abs(l); }
31 | public static float abs(float f) { return Math.abs(f); }
32 | public static double abs(double d) { return Math.abs(d); }
33 | public static int min(int a, int b) {return Math.min(a, b); }
34 | public static long min(long a, long b) {return Math.min(a, b); }
35 | public static float min(float a, float b) {return Math.min(a, b); }
36 | public static double min(double a, double b) {return Math.min(a, b); }
37 | public static int max(int a, int b) { return Math.max(a, b); }
38 | public static long max(long a, long b) { return Math.max(a, b); }
39 | public static float max(float a, float b) { return Math.max(a, b); }
40 | public static double max(double a, double b) { return Math.max(a, b); }
41 | public static double sin(double a) { return Math.sin(a); }
42 | public static double cos(double a) { return Math.cos(a); }
43 | public static double tan(double a) { return Math.tan(a); }
44 | public static double asin(double x) { return Math.asin(x); }
45 | public static double acos(double x) { return Math.acos(x); }
46 | public static double atan(double x) { return Math.atan(x); }
47 | public static double atan2(double y, double x) { return Math.atan2(y, x); }
48 | public static double exp(double x) { return Math.exp(x); }
49 | public static double log(double x) { return Math.log(x); }
50 | public static double sqrt(double x) { return Math.sqrt(x); }
51 | public static double pow(double x, double y) { return Math.pow(x, y); }
52 | public static double IEEEremainder(double x, double y) { return Math.IEEEremainder(x, y); }
53 | public static double ceil(double a) { return Math.ceil(a); }
54 | public static double floor(double a) { return Math.floor(a); }
55 | public static double rint(double a) { return Math.rint(a); }
56 | public static int round(float f) { return Math.round(f); }
57 | public static long round(double d) { return Math.round(d); }
58 | public static synchronized double random() { return Math.random(); }
59 | // public static double toRadians(double degrees) { return Math.toRadians(degrees); }
60 | // public static double toDegrees(double rads) { return Math.toDegrees(rads); }
61 | // public static double signum(double a)
62 | // public static float signum(float a)
63 | // public static double ulp(double d)
64 | // public static float ulp(float f)
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/swisseph/SarosData.java:
--------------------------------------------------------------------------------
1 | /*
2 | This is a port of the Swiss Ephemeris Free Edition, Version 2.00.00
3 | of Astrodienst AG, Switzerland from the original C Code to Java. For
4 | copyright see the original copyright notices below and additional
5 | copyright notes in the file named LICENSE, or - if this file is not
6 | available - the copyright notes at http://www.astro.ch/swisseph/ and
7 | following.
8 |
9 | For any questions or comments regarding this port to Java, you should
10 | ONLY contact me and not Astrodienst, as the Astrodienst AG is not involved
11 | in this port in any way.
12 |
13 | Thomas Mack, mack@ifis.cs.tu-bs.de, 23rd of April 2001
14 |
15 | */
16 | /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
17 |
18 | License conditions
19 | ------------------
20 |
21 | This file is part of Swiss Ephemeris.
22 |
23 | Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
24 | or distributor accepts any responsibility for the consequences of using it,
25 | or for whether it serves any particular purpose or works at all, unless he
26 | or she says so in writing.
27 |
28 | Swiss Ephemeris is made available by its authors under a dual licensing
29 | system. The software developer, who uses any part of Swiss Ephemeris
30 | in his or her software, must choose between one of the two license models,
31 | which are
32 | a) GNU public license version 2 or later
33 | b) Swiss Ephemeris Professional License
34 |
35 | The choice must be made before the software developer distributes software
36 | containing parts of Swiss Ephemeris to others, and before any public
37 | service using the developed software is activated.
38 |
39 | If the developer choses the GNU GPL software license, he or she must fulfill
40 | the conditions of that license, which includes the obligation to place his
41 | or her whole software project under the GNU GPL or a compatible license.
42 | See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
43 |
44 | If the developer choses the Swiss Ephemeris Professional license,
45 | he must follow the instructions as found in http://www.astro.com/swisseph/
46 | and purchase the Swiss Ephemeris Professional Edition from Astrodienst
47 | and sign the corresponding license contract.
48 |
49 | The License grants you the right to use, copy, modify and redistribute
50 | Swiss Ephemeris, but only under certain conditions described in the License.
51 | Among other things, the License requires that the copyright notices and
52 | this notice be preserved on all copies.
53 |
54 | Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
55 |
56 | The authors of Swiss Ephemeris have no control or influence over any of
57 | the derived works, i.e. over software or services created by other
58 | programmers which use Swiss Ephemeris functions.
59 |
60 | The names of the authors or of the copyright holder (Astrodienst) must not
61 | be used for promoting any software, product or service which uses or contains
62 | the Swiss Ephemeris. This copyright notice is the ONLY place where the
63 | names of the authors can legally appear, except in cases where they have
64 | given special permission in writing.
65 |
66 | The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
67 | for promoting such software, products or services.
68 | */
69 | package swisseph;
70 |
71 | class SarosData
72 | implements java.io.Serializable
73 | {
74 | int series_no;
75 | double tstart;
76 |
77 | SarosData(int series_no, double tstart) {
78 | this.series_no = series_no;
79 | this.tstart = tstart;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/swisseph/SavePositions.java:
--------------------------------------------------------------------------------
1 | /*
2 | This is a port of the Swiss Ephemeris Free Edition, Version 2.00.00
3 | of Astrodienst AG, Switzerland from the original C Code to Java. For
4 | copyright see the original copyright notices below and additional
5 | copyright notes in the file named LICENSE, or - if this file is not
6 | available - the copyright notes at http://www.astro.ch/swisseph/ and
7 | following.
8 |
9 | For any questions or comments regarding this port to Java, you should
10 | ONLY contact me and not Astrodienst, as the Astrodienst AG is not involved
11 | in this port in any way.
12 |
13 | Thomas Mack, mack@ifis.cs.tu-bs.de, 23rd of April 2001
14 |
15 | */
16 | /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
17 |
18 | License conditions
19 | ------------------
20 |
21 | This file is part of Swiss Ephemeris.
22 |
23 | Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
24 | or distributor accepts any responsibility for the consequences of using it,
25 | or for whether it serves any particular purpose or works at all, unless he
26 | or she says so in writing.
27 |
28 | Swiss Ephemeris is made available by its authors under a dual licensing
29 | system. The software developer, who uses any part of Swiss Ephemeris
30 | in his or her software, must choose between one of the two license models,
31 | which are
32 | a) GNU public license version 2 or later
33 | b) Swiss Ephemeris Professional License
34 |
35 | The choice must be made before the software developer distributes software
36 | containing parts of Swiss Ephemeris to others, and before any public
37 | service using the developed software is activated.
38 |
39 | If the developer choses the GNU GPL software license, he or she must fulfill
40 | the conditions of that license, which includes the obligation to place his
41 | or her whole software project under the GNU GPL or a compatible license.
42 | See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
43 |
44 | If the developer choses the Swiss Ephemeris Professional license,
45 | he must follow the instructions as found in http://www.astro.com/swisseph/
46 | and purchase the Swiss Ephemeris Professional Edition from Astrodienst
47 | and sign the corresponding license contract.
48 |
49 | The License grants you the right to use, copy, modify and redistribute
50 | Swiss Ephemeris, but only under certain conditions described in the License.
51 | Among other things, the License requires that the copyright notices and
52 | this notice be preserved on all copies.
53 |
54 | Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
55 |
56 | The authors of Swiss Ephemeris have no control or influence over any of
57 | the derived works, i.e. over software or services created by other
58 | programmers which use Swiss Ephemeris functions.
59 |
60 | The names of the authors or of the copyright holder (Astrodienst) must not
61 | be used for promoting any software, product or service which uses or contains
62 | the Swiss Ephemeris. This copyright notice is the ONLY place where the
63 | names of the authors can legally appear, except in cases where they have
64 | given special permission in writing.
65 |
66 | The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
67 | for promoting such software, products or services.
68 | */
69 | package swisseph;
70 |
71 | class SavePositions
72 | implements java.io.Serializable
73 | {
74 | int ipl;
75 | double tsave=0.;
76 | int iflgsave;
77 | /* position at t = tsave,
78 | * in ecliptic polar (offset 0),
79 | * ecliptic cartesian (offset 6),
80 | * equatorial polar (offset 12),
81 | * and equatorial cartesian coordinates (offset 18).
82 | * 6 doubles each for position and speed coordinates.
83 | */
84 | double xsaves[]=new double[24];
85 |
86 | void clearData() {
87 | for (int i=0; i
73 | * t0(?) / ayan_t0(?) is the epoch at which ayanamsha = 0.
74 | * This should be for internal use only - no necessity to have it outside
75 | * this package. You will set these data via swe_set_sid_mode normally.
76 | *
You will find the complete documentation for the original
77 | * SwissEphemeris package at
78 | * http://www.astro.ch/swisseph/sweph_g.htm. By far most of the information
79 | * there is directly valid for this port to Java as well.
80 | * @see SwissEph#swe_set_sid_mode
81 | * @version 1.0.0a
82 | */
83 | class SidData
84 | implements java.io.Serializable
85 | {
86 | int sid_mode=0;
87 | double ayan_t0=0.;
88 | double t0=0.;
89 |
90 |
91 | void clearData() {
92 | sid_mode=0;
93 | ayan_t0 = t0 = 0.;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/src/main/java/swisseph/SwissData.java:
--------------------------------------------------------------------------------
1 | /*
2 | This is a port of the Swiss Ephemeris Free Edition, Version 2.00.00
3 | of Astrodienst AG, Switzerland from the original C Code to Java. For
4 | copyright see the original copyright notices below and additional
5 | copyright notes in the file named LICENSE, or - if this file is not
6 | available - the copyright notes at http://www.astro.ch/swisseph/ and
7 | following.
8 |
9 | For any questions or comments regarding this port to Java, you should
10 | ONLY contact me and not Astrodienst, as the Astrodienst AG is not involved
11 | in this port in any way.
12 |
13 | Thomas Mack, mack@ifis.cs.tu-bs.de, 23rd of April 2001
14 |
15 | */
16 | /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
17 |
18 | License conditions
19 | ------------------
20 |
21 | This file is part of Swiss Ephemeris.
22 |
23 | Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
24 | or distributor accepts any responsibility for the consequences of using it,
25 | or for whether it serves any particular purpose or works at all, unless he
26 | or she says so in writing.
27 |
28 | Swiss Ephemeris is made available by its authors under a dual licensing
29 | system. The software developer, who uses any part of Swiss Ephemeris
30 | in his or her software, must choose between one of the two license models,
31 | which are
32 | a) GNU public license version 2 or later
33 | b) Swiss Ephemeris Professional License
34 |
35 | The choice must be made before the software developer distributes software
36 | containing parts of Swiss Ephemeris to others, and before any public
37 | service using the developed software is activated.
38 |
39 | If the developer choses the GNU GPL software license, he or she must fulfill
40 | the conditions of that license, which includes the obligation to place his
41 | or her whole software project under the GNU GPL or a compatible license.
42 | See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
43 |
44 | If the developer choses the Swiss Ephemeris Professional license,
45 | he must follow the instructions as found in http://www.astro.com/swisseph/
46 | and purchase the Swiss Ephemeris Professional Edition from Astrodienst
47 | and sign the corresponding license contract.
48 |
49 | The License grants you the right to use, copy, modify and redistribute
50 | Swiss Ephemeris, but only under certain conditions described in the License.
51 | Among other things, the License requires that the copyright notices and
52 | this notice be preserved on all copies.
53 |
54 | Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
55 |
56 | The authors of Swiss Ephemeris have no control or influence over any of
57 | the derived works, i.e. over software or services created by other
58 | programmers which use Swiss Ephemeris functions.
59 |
60 | The names of the authors or of the copyright holder (Astrodienst) must not
61 | be used for promoting any software, product or service which uses or contains
62 | the Swiss Ephemeris. This copyright notice is the ONLY place where the
63 | names of the authors can legally appear, except in cases where they have
64 | given special permission in writing.
65 |
66 | The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
67 | for promoting such software, products or services.
68 | */
69 | package swisseph;
70 |
71 | public class SwissData
72 | implements java.io.Serializable
73 | {
74 |
75 | /**
76 | * The character to be used as the degree character. Only textmode
77 | * applications (and probably awt applications in Java 1.1 and below?)
78 | * will require to differentiate between different characters, awt /
79 | * swing components of Java 1.2 and above will use the unicode encoding
80 | * always!
81 | */
82 | // public String ODEGREE_CHAR=""+'\u00b0'; // Unicode degree character 176
83 | // // Identical in most ISO-8859 sets
84 | public String ODEGREE_STRING="°"; /* degree as string, utf8 encoding */
85 |
86 |
87 | public static final String ayanamsa_name[] = {
88 | "Fagan/Bradley",
89 | "Lahiri",
90 | "De Luce",
91 | "Raman",
92 | "Ushashashi",
93 | "Krishnamurti",
94 | "Djwhal Khul",
95 | "Yukteshwar",
96 | "J.N. Bhasin",
97 | "Babylonian/Kugler 1",
98 | "Babylonian/Kugler 2",
99 | "Babylonian/Kugler 3",
100 | "Babylonian/Huber",
101 | "Babylonian/Eta Piscium",
102 | "Babylonian/Aldebaran = 15 Tau",
103 | "Hipparchos",
104 | "Sassanian",
105 | "Galact. Center = 0 Sag",
106 | "J2000",
107 | "J1900",
108 | "B1950",
109 | "Suryasiddhanta",
110 | "Suryasiddhanta, mean Sun",
111 | "Aryabhata",
112 | "Aryabhata, mean Sun",
113 | "SS Revati",
114 | "SS Citra",
115 | "True Citra",
116 | "True Revati",
117 | "True Pushya",
118 | };
119 |
120 | //////////////////////////////////////////////////////////////////////////////
121 | // sweodef.h: ////////////////////////////////////////////////////////////////
122 | //////////////////////////////////////////////////////////////////////////////
123 | public static final int AS_MAXCH=256; // used for string declarations,
124 | // allowing 255 char+\0
125 |
126 | static final double DEGTORAD=0.0174532925199433;
127 | static final double RADTODEG=57.2957795130823;
128 |
129 | static final int DEG=360000; // degree expressed in centiseconds
130 | static final int DEG7_30=2700000; // 7.5 degrees
131 | static final int DEG15=15 * DEG;
132 | static final int DEG24=24 * DEG;
133 | static final int DEG30=30 * DEG;
134 | static final int DEG60=60 * DEG;
135 | static final int DEG90=90 * DEG;
136 | static final int DEG120=120 * DEG;
137 | static final int DEG150=150 * DEG;
138 | static final int DEG180=180 * DEG;
139 | static final int DEG270=270 * DEG;
140 | static final int DEG360=360 * DEG;
141 |
142 | static final double CSTORAD=4.84813681109536E-08; // centisec to rad:
143 | // pi / 180 /3600/100
144 | static final double RADTOCS=2.06264806247096E+07; // rad to centisec
145 | // 180*3600*100/pi
146 |
147 | static final double CS2DEG=1.0/360000.0; // centisec to degree
148 |
149 | static final String BFILE_R_ACCESS="r"; // open binary file for reading
150 | static final String BFILE_RW_ACCESS="r+";// open binary file for writing and reading
151 | static final String BFILE_W_CREATE="w"; // create/open binary file for write
152 | static final String BFILE_A_ACCESS="a+"; // create/open binary file for append
153 | static final String FILE_R_ACCESS="r"; // open text file for reading
154 | static final String FILE_RW_ACCESS="r+"; // open text file for writing and reading
155 | static final String FILE_W_CREATE="w"; // create/open text file for write
156 | static final String FILE_A_ACCESS="a+"; // create/open text file for append
157 | static final int O_BINARY=0; // for open(), not defined in Unix
158 | static final int OPEN_MODE=0666; // default file creation mode
159 | // file.separator may be null with JavaME
160 | public static final String DIR_GLUE = (System.getProperty("file.separator") == null ? "/" : System.getProperty("file.separator")); // glue string for directory/file
161 | public static final String PATH_SEPARATOR=";:"; // semicolon or colon may be used
162 |
163 |
164 | //////////////////////////////////////////////////////////////////////////////
165 | // swephexp.h: ///////////////////////////////////////////////////////////////
166 | //////////////////////////////////////////////////////////////////////////////
167 | public static final int SE_NSIDM_PREDEF =30;
168 |
169 | // static final int SE_MAX_STNAME=20; // maximum size of fixstar name;
170 | // // the parameter star in swe_fixstar
171 | // // must allow twice this space for
172 | // // the returned star name.
173 | //
174 |
175 | static final int pnoext2int[] = {SwephData.SEI_SUN, SwephData.SEI_MOON,
176 | SwephData.SEI_MERCURY, SwephData.SEI_VENUS, SwephData.SEI_MARS,
177 | SwephData.SEI_JUPITER, SwephData.SEI_SATURN, SwephData.SEI_URANUS,
178 | SwephData.SEI_NEPTUNE, SwephData.SEI_PLUTO, 0, 0, 0, 0, SwephData.SEI_EARTH,
179 | SwephData.SEI_CHIRON, SwephData.SEI_PHOLUS, SwephData.SEI_CERES,
180 | SwephData.SEI_PALLAS, SwephData.SEI_JUNO, SwephData.SEI_VESTA, };
181 |
182 | //////////////////////////////////////////////////////////////////////////////
183 | //////////////////////////////////////////////////////////////////////////////
184 | //////////////////////////////////////////////////////////////////////////////
185 | boolean ephe_path_is_set=false; /* ephe_path_is_set = FALSE */
186 | boolean jpl_file_is_open=false; /* jpl_file_is_open = FALSE */
187 | FilePtr fixfp=null; /* fixfp, fixed stars file pointer */
188 | String ephepath = SweConst.SE_EPHE_PATH; /* ephepath, ephemeris path */
189 | String jplfnam = SweConst.SE_FNAME_DFT; /* jplfnam, JPL file name, default */
190 | int jpldenum = 0; /* jpldenum */
191 | double eop_tjd_beg;
192 | double eop_tjd_beg_horizons;
193 | double eop_tjd_end;
194 | double eop_tjd_end_add;
195 | int eop_dpsi_loaded;
196 | boolean geopos_is_set=false; /* geopos_is_set, for topocentric */
197 | boolean ayana_is_set=false; /* ayana_is_set, ayanamsa is set */
198 | boolean is_old_starfile=false; /* is_old_starfile, fixstars.cat is used (default is sefstars.txt) */
199 |
200 | FileData fidat[] = new FileData[SwephData.SEI_NEPHFILES];
201 | GenConst gcdat;
202 | PlanData pldat[] = new PlanData[SwephData.SEI_NPLANETS];
203 | PlanData nddat[] = new PlanData[SwephData.SEI_NNODE_ETC];
204 | SavePositions savedat[] = new SavePositions[SweConst.SE_NPLANETS+1];
205 | Epsilon oec, oec2000;
206 | Nut nut, nut2000, nutv;
207 | TopoData topd;
208 | SidData sidd;
209 | String astelem;
210 | double ast_G, ast_H, ast_diam;
211 | int i_saved_planet_name;
212 | String saved_planet_name;
213 | //double dpsi[36525]; /* works for 100 years after 1962 */
214 | //double deps[36525];
215 | double[] dpsi;
216 | double[] deps;
217 | int astro_models[] = new int[SwephData.SEI_NMODELS];
218 | int timeout;
219 |
220 | /**
221 | * Constructs a new SwissData object.
222 | */
223 | public SwissData() {
224 | int i;
225 | for(i=0;iInfinity, if no date is available.
133 | */
134 | public double getJD() {
135 | return jdet;
136 | }
137 |
138 | /**
139 | * Returns error type.
140 | * @return error type
141 | * @see #UNDEFINED_ERROR
142 | * @see #FILE_ERROR
143 | * @see #UNSPECIFIED_FILE_ERROR
144 | * @see #INVALID_FILE_NAME
145 | * @see #FILE_NOT_FOUND
146 | * @see #FILE_OPEN_FAILED
147 | * @see #FILE_READ_ERROR
148 | * @see #DAMAGED_FILE_ERROR
149 | * @see #INVALID_FILE_ERROR
150 | * @see #PARAM_ERROR
151 | * @see #OUT_OF_TIME_RANGE
152 | * @see #UNSUPPORTED_OBJECT
153 | * @see #INVALID_PARAMETER_COMBINATION
154 | * @see #INVALID_DATE
155 | * @see #USER_ERROR
156 | * @see #BEYOND_USER_TIME_LIMIT
157 | */
158 | public int getType() {
159 | return type;
160 | }
161 |
162 | /**
163 | * Returns the return code from the underlying original
164 | * C-source code, which is SweConst.ERR normally. You should
165 | * not need to know this.
166 | * @return original error code
167 | */
168 | public int getRC() {
169 | return rc;
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/src/main/java/swisseph/TopoData.java:
--------------------------------------------------------------------------------
1 | /*
2 | This is a port of the Swiss Ephemeris Free Edition, Version 2.00.00
3 | of Astrodienst AG, Switzerland from the original C Code to Java. For
4 | copyright see the original copyright notices below and additional
5 | copyright notes in the file named LICENSE, or - if this file is not
6 | available - the copyright notes at http://www.astro.ch/swisseph/ and
7 | following.
8 |
9 | For any questions or comments regarding this port to Java, you should
10 | ONLY contact me and not Astrodienst, as the Astrodienst AG is not involved
11 | in this port in any way.
12 |
13 | Thomas Mack, mack@ifis.cs.tu-bs.de, 23rd of April 2001
14 |
15 | */
16 | /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
17 |
18 | License conditions
19 | ------------------
20 |
21 | This file is part of Swiss Ephemeris.
22 |
23 | Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
24 | or distributor accepts any responsibility for the consequences of using it,
25 | or for whether it serves any particular purpose or works at all, unless he
26 | or she says so in writing.
27 |
28 | Swiss Ephemeris is made available by its authors under a dual licensing
29 | system. The software developer, who uses any part of Swiss Ephemeris
30 | in his or her software, must choose between one of the two license models,
31 | which are
32 | a) GNU public license version 2 or later
33 | b) Swiss Ephemeris Professional License
34 |
35 | The choice must be made before the software developer distributes software
36 | containing parts of Swiss Ephemeris to others, and before any public
37 | service using the developed software is activated.
38 |
39 | If the developer choses the GNU GPL software license, he or she must fulfill
40 | the conditions of that license, which includes the obligation to place his
41 | or her whole software project under the GNU GPL or a compatible license.
42 | See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
43 |
44 | If the developer choses the Swiss Ephemeris Professional license,
45 | he must follow the instructions as found in http://www.astro.com/swisseph/
46 | and purchase the Swiss Ephemeris Professional Edition from Astrodienst
47 | and sign the corresponding license contract.
48 |
49 | The License grants you the right to use, copy, modify and redistribute
50 | Swiss Ephemeris, but only under certain conditions described in the License.
51 | Among other things, the License requires that the copyright notices and
52 | this notice be preserved on all copies.
53 |
54 | Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
55 |
56 | The authors of Swiss Ephemeris have no control or influence over any of
57 | the derived works, i.e. over software or services created by other
58 | programmers which use Swiss Ephemeris functions.
59 |
60 | The names of the authors or of the copyright holder (Astrodienst) must not
61 | be used for promoting any software, product or service which uses or contains
62 | the Swiss Ephemeris. This copyright notice is the ONLY place where the
63 | names of the authors can legally appear, except in cases where they have
64 | given special permission in writing.
65 |
66 | The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
67 | for promoting such software, products or services.
68 | */
69 | package swisseph;
70 |
71 | class TopoData
72 | implements java.io.Serializable
73 | {
74 | double geolon, geolat, geoalt;
75 | double teval;
76 | double tjd_ut;
77 | double xobs[]=new double[6];
78 |
79 |
80 | void clearData() {
81 | geolon = geolat = geoalt = teval = tjd_ut = 0;
82 | xobs = new double[6];
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/java/swisseph/TransitCalculator.java:
--------------------------------------------------------------------------------
1 | package swisseph;
2 |
3 | /**
4 | * Interface for different methods used for transit calculations.
5 | */
6 | public abstract class TransitCalculator
7 | implements java.io.Serializable
8 | {
9 | SwissEph sw;
10 |
11 | // This method changes the offset value for the transit
12 | /**
13 | * @return Returns true, if one position value is identical to another
14 | * position value. E.g., 360 degree is identical to 0 degree in
15 | * circular angles.
16 | * @see #rolloverVal
17 | */
18 | public abstract boolean getRollover();
19 | /**
20 | * @return Returns the value, which is identical to zero on the other
21 | * end of a linear scale.
22 | * @see #rolloverVal
23 | */
24 | public double getRolloverVal() {
25 | return rolloverVal;
26 | }
27 | /**
28 | * This sets the degree or other value for the position or speed of
29 | * the planet to transit. It will be used on the next call to getTransit().
30 | * @param value The desired offset value.
31 | * @see #getOffset()
32 | */
33 | public abstract void setOffset(double value);
34 | /**
35 | * This returns the degree or other value of the position or speed of
36 | * the planet to transit.
37 | * @return The currently set offset value.
38 | * @see #setOffset(double)
39 | */
40 | public abstract double getOffset();
41 | /**
42 | * This returns all the "object identifiers" used in this
43 | * TransitCalculator. It may be the planet number or planet numbers,
44 | * when calculating planets.
45 | * @return An array of identifiers identifying the calculated objects.
46 | */
47 | public Object[] getObjectIdentifiers() {
48 | return null;
49 | }
50 |
51 |
52 |
53 |
54 |
55 | //////////////////////////////////////////////////////////////////////////////
56 |
57 |
58 | // Rollover from 360 degrees to 0 degrees for planetary longitudinal positions
59 | // or similar, or continuous and unlimited values:
60 | protected boolean rollover = false; // We need a rollover of 360 degrees being
61 | // equal to 0 degrees for longitudinal
62 | // position transits only.
63 | protected double rolloverVal = 360.; // if rollover, we roll over from 360 to 0
64 | // as default. Other values than 0.0 for the
65 | // minimum values are not supported for now.
66 |
67 | // These methods have to return the maxima of the first derivative of the
68 | // function, mathematically spoken...
69 | protected abstract double getMaxSpeed();
70 | protected abstract double getMinSpeed();
71 |
72 | // This method returns the precision in x-direction in an x-y-coordinate
73 | // system for the transit calculation routine.
74 | protected abstract double getDegreePrecision(double jdET);
75 |
76 | // This method returns the precision in y-direction in an x-y-coordinate
77 | // system from the x-direction precision.
78 | protected abstract double getTimePrecision(double degPrec);
79 |
80 | // This is the main routine, mathematically speaking: returning f(x):
81 | protected abstract double calc(double jdET);
82 |
83 |
84 | // This routine allows for changing jdET before starting calculations.
85 | double preprocessDate(double jdET, boolean back) {
86 | return jdET;
87 | }
88 | // These routines check the result if it meets the stop condition
89 | protected boolean checkIdenticalResult(double offset, double val) {
90 | return val == offset;
91 | }
92 | protected boolean checkResult(double offset, double lastVal, double val, boolean above, boolean pxway) {
93 | return (// transits from higher deg. to lower deg.:
94 | ( above && val<=offset && !pxway) ||
95 | // transits from lower deg. to higher deg.:
96 | (!above && val>=offset && pxway)) ||
97 | (rollover && (
98 | // transits from above the transit degree via rollover over
99 | // 0 degrees to a higher degree:
100 | (offset.9*rolloverVal && lastVal<20. && !pxway) ||
101 | // transits from below the transit degree via rollover over
102 | // 360 degrees to a lower degree:
103 | (offset>lastVal && val<20. && lastVal>.9*rolloverVal && pxway) ||
104 | // transits from below the transit degree via rollover over
105 | // 0 degrees to a higher degree:
106 | (offset>val && val>.9*rolloverVal && lastVal<20. && !pxway) ||
107 | // transits from above the transit degree via rollover over
108 | // 360 degrees to a lower degree:
109 | (offset.9*rolloverVal && pxway))
110 | );
111 | }
112 |
113 | // Find next reasonable point to probe.
114 | protected double getNextJD(double jdET, double val, double offset, double min, double max, boolean back) {
115 | double jdPlus = 0;
116 | double jdMinus = 0;
117 | if (rollover) {
118 | // In most cases here we cannot find out for sure if the distance
119 | // is decreasing or increasing. We take the smaller one of these:
120 | jdPlus = SMath.min(val-offset,rolloverVal-val+offset)/SMath.abs(max);
121 | jdMinus = SMath.min(val-offset,rolloverVal-val+offset)/SMath.abs(min);
122 | if (back) {
123 | jdET -= SMath.min(jdPlus,jdMinus);
124 | } else {
125 | jdET += SMath.min(jdPlus,jdMinus);
126 | }
127 | } else { // Latitude, distance and speed calculations...
128 | //jdPlus = (back?(val-offset):(offset-val))/max;
129 | //jdMinus = (back?(val-offset):(offset-val))/min;
130 | jdPlus = (offset-val)/max;
131 | jdMinus = (offset-val)/min;
132 | if (back) {
133 | if (jdPlus >= 0 && jdMinus >= 0) {
134 | throw new SwissephException(jdET, SwissephException.OUT_OF_TIME_RANGE,
135 | -1, "No transit in ephemeris time range."); // I mean: No transits possible...
136 | } else if (jdPlus >= 0) {
137 | jdET += jdMinus;
138 | } else { // if (jdMinus >= 0)
139 | jdET += jdPlus;
140 | }
141 | } else {
142 | if (jdPlus <= 0 && jdMinus <= 0) {
143 | throw new SwissephException(jdET, SwissephException.OUT_OF_TIME_RANGE,
144 | -1, "No transit in ephemeris time range."); // I mean: No transits possible...
145 | } else if (jdPlus <= 0) {
146 | jdET += jdMinus;
147 | } else { // if (jdMinus <= 0)
148 | jdET += jdPlus;
149 | }
150 | }
151 | }
152 | return jdET;
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/src/main/resources/settings.properties:
--------------------------------------------------------------------------------
1 | ephemeris.path=/data/ephemeris
--------------------------------------------------------------------------------
/src/test/java/cz/kibo/api/astrology/builder/BuilderTestSuite.java:
--------------------------------------------------------------------------------
1 | package cz.kibo.api.astrology.builder;
2 |
3 | import org.junit.runner.RunWith;
4 | import org.junit.runners.Suite;
5 |
6 | @RunWith(Suite.class)
7 | @Suite.SuiteClasses({
8 | PlanetBuilderTest.class,
9 | CuspBuilderTest.class,
10 | TransitBuilderTest.class,
11 | })
12 |
13 | public class BuilderTestSuite {}
14 |
--------------------------------------------------------------------------------
/src/test/java/cz/kibo/api/astrology/builder/CuspBuilderTest.java:
--------------------------------------------------------------------------------
1 | package cz.kibo.api.astrology.builder;
2 |
3 | import static org.junit.Assert.*;
4 |
5 | import java.time.LocalDateTime;
6 |
7 | import org.junit.Test;
8 |
9 | import cz.kibo.api.astrology.domain.Cusp;
10 |
11 | public class CuspBuilderTest {
12 |
13 | final double LONGITUDE = 16.0542676;
14 | final double LATITUDE = 48.8559107;
15 | final double GEOALT = 286;
16 |
17 | @Test
18 | public void placidusTest() {
19 | LocalDateTime event = LocalDateTime.of( 2018, 3, 20, 5, 6);
20 | Cusp ephemeris = new CuspBuilder(event)
21 | .houses("Placidus")
22 | .topo(LONGITUDE, LATITUDE, GEOALT)
23 | .build();
24 |
25 | assertEquals(12, ephemeris.getCusps().size());
26 | assertEquals(0, ephemeris.getCusps().get(0).intValue());
27 | }
28 |
29 | @Test
30 | public void siderealTest() {
31 | LocalDateTime event = LocalDateTime.of( 2018, 3, 20, 5, 6);
32 | Cusp ephemeris = new CuspBuilder(event)
33 | .houses("Placidus")
34 | .topo(LONGITUDE, LATITUDE, GEOALT)
35 | .zodiac("Babyl Huber")
36 | .build();
37 |
38 | assertEquals(12, ephemeris.getCusps().size());
39 | assertEquals(335, ephemeris.getCusps().get(0).intValue());
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/cz/kibo/api/astrology/builder/PlanetBuilderTest.java:
--------------------------------------------------------------------------------
1 | package cz.kibo.api.astrology.builder;
2 |
3 | import static org.junit.Assert.*;
4 |
5 | import java.time.LocalDateTime;
6 |
7 | import org.junit.Test;
8 |
9 | import cz.kibo.api.astrology.domain.Coordinates;
10 | import cz.kibo.api.astrology.domain.Planet;
11 |
12 | public class PlanetBuilderTest {
13 |
14 | final double LONGITUDE = 16.0542676;
15 | final double LATITUDE = 48.8559107;
16 | final double GEOALT = 286;
17 |
18 | @Test
19 | public void allPlanetTest() {
20 | LocalDateTime event = LocalDateTime.of( 2018, 3, 20, 16, 20);
21 | Planet ephemeris = new PlanetBuilder( event )
22 | .planets()
23 | .build();
24 | assertEquals(13, ephemeris.getPlanets().size());
25 | }
26 |
27 | @Test
28 | public void planetTest() {
29 | LocalDateTime event = LocalDateTime.of( 2018, 3, 20, 16, 20);
30 | Planet ephemeris = new PlanetBuilder( event )
31 | .planet("Sun, Moon")
32 | .build();
33 | assertEquals(2, ephemeris.getPlanets().size());
34 | }
35 |
36 | @Test
37 | public void topoTest() {
38 | LocalDateTime event = LocalDateTime.of( 2018, 3, 20, 16, 20);
39 |
40 | Planet ephemeris = new PlanetBuilder( event )
41 | .planet("Sun, Jupiter, Chiron")
42 | .topo(LONGITUDE, LATITUDE, GEOALT)
43 | .build();
44 | assertEquals(3, ephemeris.getPlanets().size());
45 | assertEquals(0, ephemeris.getPlanets().get("Sun").get(0).intValue());
46 | }
47 |
48 | @Test
49 | public void zidiacTest() {
50 | LocalDateTime event = LocalDateTime.of( 2018, 4, 18, 4, 00);
51 |
52 | Planet ephemeris = new PlanetBuilder( event )
53 | .planet("Sun, Jupiter, Chiron, NNode, Lilith")
54 | .zodiac("Sassanian")
55 | .build();
56 |
57 | assertEquals(5, ephemeris.getPlanets().size());
58 | assertEquals(7, ephemeris.getPlanets().get("Sun").get(0).intValue());
59 | assertEquals(210, ephemeris.getPlanets().get("Jupiter").get(0).intValue());
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/test/java/cz/kibo/api/astrology/builder/TransitBuilderTest.java:
--------------------------------------------------------------------------------
1 | package cz.kibo.api.astrology.builder;
2 |
3 | import static org.junit.Assert.*;
4 |
5 | import java.time.LocalDateTime;
6 |
7 | import org.junit.Test;
8 |
9 | import cz.kibo.api.astrology.domain.Transit;
10 | import swisseph.SweConst;
11 |
12 | public class TransitBuilderTest {
13 |
14 | final double LONGITUDE = 16.0542676;
15 | final double LATITUDE = 48.8559107;
16 | final double GEOALT = 286;
17 |
18 | @Test
19 | public void planetToPointGeocentricTest() {
20 |
21 | LocalDateTime event = LocalDateTime.of( 2017, 6, 18, 0, 0);
22 | Transit transit = new TransitBuilder( event)
23 | .planet("Sun")
24 | .toPoint(90.0)
25 | .build();
26 |
27 | LocalDateTime date = transit.getDate();
28 |
29 | assertEquals( LocalDateTime.of( 2017, 6, 21, 4, 24), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
30 | }
31 |
32 | @Test
33 | public void planeToPointAspectTest() {
34 |
35 | LocalDateTime event = LocalDateTime.of( 2017, 6, 18, 0, 0);
36 | Transit transit = new TransitBuilder( event)
37 | .planet("Moon")
38 | .toPoint(270.0)
39 | .aspect(180.0)
40 | .build();
41 |
42 | LocalDateTime date = transit.getDate();
43 |
44 | assertEquals( LocalDateTime.of( 2017, 6, 23, 22, 06), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
45 | }
46 |
47 | @Test
48 | public void planeToPointAspect2Test() {
49 |
50 | LocalDateTime event = LocalDateTime.of( 2018, 1, 1, 0, 0);
51 | Transit transit = new TransitBuilder( event)
52 | .planet("Pluto")
53 | .toPoint(20.0)
54 | .aspect(-90.0)
55 | .build();
56 |
57 | LocalDateTime date = transit.getDate();
58 |
59 | assertEquals( LocalDateTime.of( 2018, 2, 6, 17, 27), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
60 | }
61 |
62 | @Test
63 | public void planeToPointAspect3Test() {
64 |
65 | LocalDateTime event = LocalDateTime.of( 2017, 6, 17, 0, 0);
66 | Transit transit = new TransitBuilder( event)
67 | .planet("Moon")
68 | .toPoint(90.0)
69 | .aspect(-90.0)
70 | .build();
71 |
72 | LocalDateTime date = transit.getDate();
73 |
74 | assertEquals( LocalDateTime.of( 2017, 6, 17, 17, 54), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
75 | }
76 |
77 | @Test
78 | public void planeToPointBackwardsTest() {
79 |
80 | LocalDateTime event = LocalDateTime.of( 2017, 6, 20, 0, 0);
81 | Transit transit = new TransitBuilder( event)
82 | .planet("Moon")
83 | .toPoint(0.0)
84 | .backwards(true)
85 | .build();
86 |
87 | LocalDateTime date = transit.getDate();
88 |
89 | assertEquals( LocalDateTime.of( 2017, 6, 17, 17, 54), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
90 | }
91 |
92 |
93 | @Test
94 | public void planetToPlanetGeocentricTest() {
95 |
96 | LocalDateTime event = LocalDateTime.of( 2017, 6, 18, 0, 0);
97 | Transit transit = new TransitBuilder( event)
98 | .planet("Moon")
99 | .toPlanet("Sun")
100 | .aspect(90.0)
101 | .build();
102 |
103 | LocalDateTime date = transit.getDate();
104 |
105 | assertEquals( LocalDateTime.of( 2017, 7, 1, 00, 51), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/src/test/java/cz/kibo/api/astrology/domain/CuspTest.java:
--------------------------------------------------------------------------------
1 | package cz.kibo.api.astrology.domain;
2 |
3 | import static org.junit.Assert.*;
4 |
5 | import java.time.LocalDateTime;
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | import org.junit.Test;
10 |
11 | import swisseph.SweConst;
12 |
13 | public class CuspTest {
14 |
15 | final double LONGITUDE = 16.0542676;
16 | final double LATITUDE = 48.8559107;
17 | final double GEOALT = 286;
18 |
19 | private static final double DELTA = 1e-15;
20 |
21 | @Test
22 | public void cuspsPlacidusTropicalWithIflagTest() {
23 |
24 | final int PLACIDUS_HOUSE_SYSTEM = 'P';
25 |
26 | LocalDateTime event = LocalDateTime.of( 2018, 3, 20, 5, 6);
27 | Coordinates coords = new Coordinates(LONGITUDE, LATITUDE, GEOALT);
28 |
29 | int iflag = 0; // tropical - default
30 |
31 | Cusp chart = new Cusp(event, coords, PLACIDUS_HOUSE_SYSTEM, iflag);
32 | List data = chart.getCusps();
33 |
34 | assertEquals(12, data.size());
35 |
36 | assertEquals(0, data.get(0).intValue());
37 |
38 | System.out.println( chart.toString() );
39 | }
40 |
41 | @Test
42 | public void cuspsPlacidusSiderealWithIflagTest() {
43 |
44 | final int PLACIDUS_HOUSE_SYSTEM = 'P';
45 |
46 | LocalDateTime event = LocalDateTime.of( 2018, 3, 20, 5, 6);
47 | Coordinates coords = new Coordinates(LONGITUDE, LATITUDE, GEOALT);
48 |
49 | int iflag = SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_BABYL_HUBER;
50 |
51 | Cusp chart = new Cusp(event, coords, PLACIDUS_HOUSE_SYSTEM, iflag);
52 | List data = chart.getCusps();
53 |
54 | assertEquals(12, data.size());
55 |
56 | assertEquals(335, data.get(0).intValue());
57 |
58 | System.out.println( chart.toString() );
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/test/java/cz/kibo/api/astrology/domain/DomainTestSuite.java:
--------------------------------------------------------------------------------
1 | package cz.kibo.api.astrology.domain;
2 |
3 | import org.junit.runner.RunWith;
4 | import org.junit.runners.Suite;
5 |
6 | @RunWith(Suite.class)
7 | @Suite.SuiteClasses({
8 | PlanetTest.class,
9 | CuspTest.class,
10 | TransitTest.class,
11 | })
12 |
13 | public class DomainTestSuite {}
14 |
--------------------------------------------------------------------------------
/src/test/java/cz/kibo/api/astrology/domain/PlanetTest.java:
--------------------------------------------------------------------------------
1 | package cz.kibo.api.astrology.domain;
2 |
3 | import static org.junit.Assert.*;
4 | import org.junit.Test;
5 |
6 | import java.time.LocalDateTime;
7 | import java.util.ArrayList;
8 | import java.util.List;
9 | import java.util.Map;
10 |
11 | import swisseph.SweConst;
12 |
13 | public class PlanetTest {
14 |
15 | final double LONGITUDE = 16.0542676;
16 | final double LATITUDE = 48.8559107;
17 | final double GEOALT = 286;
18 |
19 | @Test
20 | public void planetsGeocentricTest() {
21 |
22 | LocalDateTime event = LocalDateTime.of( 2018, 3, 20, 16, 20);
23 |
24 | List planets = new ArrayList();
25 | planets.add( SweConst.SE_SUN );
26 | planets.add( SweConst.SE_JUPITER );
27 |
28 | int iflag = 0; // tropical
29 |
30 | Planet chart = new Planet(event, planets, iflag);
31 | Map> data = chart.getPlanets();
32 |
33 | assertEquals(2, data.size());
34 |
35 | assertTrue("Sun",data.containsKey("Sun"));
36 | assertTrue("Jupiter",data.containsKey("Jupiter"));
37 |
38 | assertTrue( data.get("Sun").get(1) > 0 );
39 | assertTrue( data.get("Jupiter").get(1) < 0 ); // Retrograde
40 |
41 | assertEquals(0, data.get("Sun").get(0).intValue()); //Spring is comming
42 | }
43 |
44 | @Test
45 | public void planetTopocentricTest() {
46 |
47 | LocalDateTime event = LocalDateTime.of( 2018, 3, 20, 16, 20);
48 | Coordinates coords = new Coordinates(LONGITUDE, LATITUDE, GEOALT);
49 |
50 | List planets = new ArrayList();
51 | planets.add( SweConst.SE_SUN );
52 | planets.add( SweConst.SE_JUPITER );
53 |
54 | int iflag = 0; // tropical
55 |
56 | Planet chart = new Planet(event, planets, coords, iflag);
57 | Map> data = chart.getPlanets();
58 |
59 | assertEquals(2, data.size());
60 |
61 | assertTrue("Sun",data.containsKey("Sun"));
62 | assertTrue("Jupiter",data.containsKey("Jupiter"));
63 |
64 | assertTrue( data.get("Sun").get(1) > 0 );
65 | assertTrue( data.get("Jupiter").get(1) < 0 ); // Retrograde
66 |
67 | assertEquals(0, data.get("Sun").get(0).intValue()); //Spring is comming
68 | }
69 |
70 | @Test
71 | public void planetsGeocentricSiderealTest() {
72 |
73 | LocalDateTime event = LocalDateTime.of( 2018, 4, 18, 4, 00);
74 |
75 | List planets = new ArrayList();
76 | planets.add( SweConst.SE_SUN );
77 | planets.add( SweConst.SE_JUPITER );
78 |
79 | int iflag = SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_DELUCE;
80 |
81 | Planet chart = new Planet(event, planets, iflag);
82 | Map> data = chart.getPlanets();
83 |
84 | assertEquals(2, data.size());
85 |
86 | assertTrue("Sun",data.containsKey("Sun"));
87 | assertTrue("Jupiter",data.containsKey("Jupiter"));
88 |
89 | assertTrue( data.get("Sun").get(1) > 0 );
90 | assertTrue( data.get("Jupiter").get(1) < 0 ); // Retrograde
91 |
92 | assertEquals(0, data.get("Sun").get(0).intValue());
93 | assertEquals(202, data.get("Jupiter").get(0).intValue());
94 |
95 |
96 | iflag = SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_FAGAN_BRADLEY;
97 |
98 | chart = new Planet(event, planets, iflag);
99 | data = chart.getPlanets();
100 |
101 | assertEquals(2, data.size());
102 |
103 | assertTrue("Sun",data.containsKey("Sun"));
104 | assertTrue("Jupiter",data.containsKey("Jupiter"));
105 |
106 | assertTrue( data.get("Sun").get(1) > 0 );
107 | assertTrue( data.get("Jupiter").get(1) < 0 ); // Retrograde
108 |
109 | assertEquals(3, data.get("Sun").get(0).intValue());
110 | assertEquals(205, data.get("Jupiter").get(0).intValue());
111 |
112 | iflag = SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_BABYL_KUGLER1;
113 |
114 | chart = new Planet(event, planets, iflag);
115 | data = chart.getPlanets();
116 |
117 | assertEquals(2, data.size());
118 |
119 | assertTrue("Sun",data.containsKey("Sun"));
120 | assertTrue("Jupiter",data.containsKey("Jupiter"));
121 |
122 | assertTrue( data.get("Sun").get(1) > 0 );
123 | assertTrue( data.get("Jupiter").get(1) < 0 ); // Retrograde
124 |
125 | assertEquals(1, data.get("Sun").get(0).intValue());
126 | assertEquals(204, data.get("Jupiter").get(0).intValue());
127 |
128 | iflag = SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_SASSANIAN;
129 |
130 | chart = new Planet(event, planets, iflag);
131 | data = chart.getPlanets();
132 |
133 | assertEquals(2, data.size());
134 |
135 | assertTrue("Sun",data.containsKey("Sun"));
136 | assertTrue("Jupiter",data.containsKey("Jupiter"));
137 |
138 | assertTrue( data.get("Sun").get(1) > 0 );
139 | assertTrue( data.get("Jupiter").get(1) < 0 ); // Retrograde
140 |
141 | assertEquals(7, data.get("Sun").get(0).intValue());
142 | assertEquals(210, data.get("Jupiter").get(0).intValue());
143 | }
144 |
145 | @Test
146 | public void planetsTopocentricSiderealTest() {
147 |
148 | LocalDateTime event = LocalDateTime.of( 2018, 4, 18, 4, 00);
149 | Coordinates coords = new Coordinates(LONGITUDE, LATITUDE, GEOALT);
150 |
151 | List planets = new ArrayList();
152 | planets.add( SweConst.SE_SUN );
153 | planets.add( SweConst.SE_JUPITER );
154 |
155 | int iflag = SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_DELUCE;
156 |
157 | Planet chart = new Planet(event, planets, coords, iflag);
158 | Map> data = chart.getPlanets();
159 |
160 | assertEquals(2, data.size());
161 |
162 | assertTrue("Sun",data.containsKey("Sun"));
163 | assertTrue("Jupiter",data.containsKey("Jupiter"));
164 |
165 | assertTrue( data.get("Sun").get(1) > 0 );
166 | assertTrue( data.get("Jupiter").get(1) < 0 ); // Retrograde
167 |
168 | assertEquals(0, data.get("Sun").get(0).intValue());
169 | assertEquals(202, data.get("Jupiter").get(0).intValue());
170 |
171 |
172 | iflag = SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_FAGAN_BRADLEY;
173 |
174 | chart = new Planet(event, planets, coords, iflag);
175 | data = chart.getPlanets();
176 |
177 | assertEquals(2, data.size());
178 |
179 | assertTrue("Sun",data.containsKey("Sun"));
180 | assertTrue("Jupiter",data.containsKey("Jupiter"));
181 |
182 | assertTrue( data.get("Sun").get(1) > 0 );
183 | assertTrue( data.get("Jupiter").get(1) < 0 ); // Retrograde
184 |
185 | assertEquals(3, data.get("Sun").get(0).intValue());
186 | assertEquals(205, data.get("Jupiter").get(0).intValue());
187 |
188 | iflag = SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_BABYL_KUGLER1;
189 |
190 | chart = new Planet(event, planets, coords, iflag);
191 | data = chart.getPlanets();
192 |
193 | assertEquals(2, data.size());
194 |
195 | assertTrue("Sun",data.containsKey("Sun"));
196 | assertTrue("Jupiter",data.containsKey("Jupiter"));
197 |
198 | assertTrue( data.get("Sun").get(1) > 0 );
199 | assertTrue( data.get("Jupiter").get(1) < 0 ); // Retrograde
200 |
201 | assertEquals(1, data.get("Sun").get(0).intValue());
202 | assertEquals(204, data.get("Jupiter").get(0).intValue());
203 |
204 | iflag = SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_SASSANIAN;
205 |
206 | chart = new Planet(event, planets, coords, iflag);
207 | data = chart.getPlanets();
208 |
209 | assertEquals(2, data.size());
210 |
211 | assertTrue("Sun",data.containsKey("Sun"));
212 | assertTrue("Jupiter",data.containsKey("Jupiter"));
213 |
214 | assertTrue( data.get("Sun").get(1) > 0 );
215 | assertTrue( data.get("Jupiter").get(1) < 0 ); // Retrograde
216 |
217 | assertEquals(7, data.get("Sun").get(0).intValue());
218 | assertEquals(210, data.get("Jupiter").get(0).intValue());
219 | }
220 |
221 | @Test
222 | public void planetNameTest() {
223 |
224 | LocalDateTime event = LocalDateTime.now();
225 |
226 | List planets = new ArrayList();
227 | planets.add( SweConst.SE_MOON );
228 | planets.add( SweConst.SE_SUN );
229 | planets.add( SweConst.SE_MERCURY );
230 | planets.add( SweConst.SE_VENUS );
231 | planets.add( SweConst.SE_MARS );
232 | planets.add( SweConst.SE_JUPITER );
233 | planets.add( SweConst.SE_SATURN );
234 | planets.add( SweConst.SE_URANUS );
235 | planets.add( SweConst.SE_NEPTUNE );
236 | planets.add( SweConst.SE_PLUTO );
237 | planets.add( SweConst.SE_CHIRON );
238 | planets.add( SweConst.SE_MEAN_APOG); // Lilith
239 | planets.add(SweConst.SE_MEAN_NODE ); // Nort Node
240 |
241 | Planet chart = new Planet(event, planets, 0);
242 | Map> data = chart.getPlanets();
243 |
244 | assertTrue("Moon", data.containsKey("Moon"));
245 | assertTrue("Sun", data.containsKey("Sun"));
246 | assertTrue("Mercury", data.containsKey("Mercury"));
247 | assertTrue("Venus",data.containsKey("Venus"));
248 | assertTrue("Mars",data.containsKey("Mars"));
249 | assertTrue("Jupiter",data.containsKey("Jupiter"));
250 | assertTrue("Saturn",data.containsKey("Saturn"));
251 | assertTrue("Uranus",data.containsKey("Uranus"));
252 | assertTrue("Neptune",data.containsKey("Neptune"));
253 | assertTrue("Pluto",data.containsKey("Pluto"));
254 | assertTrue("Chiron",data.containsKey("Chiron"));
255 | assertTrue("Lilith",data.containsKey("Lilith"));
256 | assertTrue("NNode",data.containsKey("NNode"));
257 | }
258 | }
259 |
--------------------------------------------------------------------------------
/src/test/java/cz/kibo/api/astrology/domain/TransitTest.java:
--------------------------------------------------------------------------------
1 | package cz.kibo.api.astrology.domain;
2 |
3 | import static org.junit.Assert.*;
4 |
5 | import java.time.LocalDateTime;
6 |
7 | import org.junit.Test;
8 |
9 | import swisseph.SweConst;
10 |
11 | public class TransitTest {
12 |
13 | final double LONGITUDE = 16.0542676;
14 | final double LATITUDE = 48.8559107;
15 | final double GEOALT = 286;
16 |
17 | @Test
18 | public void planetToPointGeocentricTest() {
19 |
20 | int iflag = 0; // tropical
21 |
22 | LocalDateTime event = LocalDateTime.of( 2017, 6, 18, 0, 0);
23 | Transit transit = new Transit( event, SweConst.SE_SUN, 90.0, iflag);
24 | LocalDateTime date = transit.getDate();
25 |
26 | assertEquals( LocalDateTime.of( 2017, 6, 21, 4, 24), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
27 |
28 |
29 | event = LocalDateTime.of( 2017, 6, 18, 0, 0);
30 | transit = new Transit( event, SweConst.SE_MOON, 90.0, iflag);
31 | date = transit.getDate();
32 |
33 | assertEquals( LocalDateTime.of( 2017, 6, 23, 22, 06), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
34 | }
35 |
36 | @Test
37 | public void planetToPointGeocentricBackwardTest() {
38 |
39 | int iflag = 0; // tropical
40 |
41 | LocalDateTime event = LocalDateTime.of( 2017, 6, 25, 0, 0);
42 | Transit transit = new Transit( event, SweConst.SE_SUN, 90.0, iflag, true);
43 | LocalDateTime date = transit.getDate();
44 |
45 | assertEquals( LocalDateTime.of( 2017, 6, 21, 4, 24), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
46 |
47 |
48 | event = LocalDateTime.of( 2017, 6, 18, 0, 0);
49 | transit = new Transit( event, SweConst.SE_MOON, 90.0, iflag, true);
50 | date = transit.getDate();
51 |
52 | assertEquals( LocalDateTime.of( 2017, 5, 27, 11, 24), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
53 | }
54 |
55 | @Test
56 | public void planetToPointTopocentricTest() {
57 |
58 | int iflag = 0; // tropical
59 |
60 | Coordinates coords = new Coordinates(LONGITUDE, LATITUDE, GEOALT);
61 |
62 | LocalDateTime event = LocalDateTime.of( 2017, 6, 18, 0, 0);
63 | Transit transit = new Transit( event, SweConst.SE_SUN, 90.0, coords, iflag);
64 | LocalDateTime date = transit.getDate();
65 |
66 | assertEquals( LocalDateTime.of( 2017, 6, 21, 4, 21), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
67 |
68 |
69 | event = LocalDateTime.of( 2017, 6, 18, 0, 0);
70 | transit = new Transit( event, SweConst.SE_MOON, 90.0, coords, iflag);
71 | date = transit.getDate();
72 |
73 | assertEquals( LocalDateTime.of( 2017, 6, 23, 22, 15), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
74 | }
75 |
76 | @Test
77 | public void planetToPointGeocentricSirerealTest() {
78 |
79 | int iflag = SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_DELUCE;
80 |
81 | LocalDateTime event = LocalDateTime.of( 2017, 6, 18, 0, 0);
82 | Transit transit = new Transit( event, SweConst.SE_SUN, 90.0, iflag);
83 | LocalDateTime date = transit.getDate();
84 |
85 | assertEquals( LocalDateTime.of( 2017, 7, 20, 14, 18), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
86 |
87 | event = LocalDateTime.of( 2017, 6, 18, 0, 0);
88 | transit = new Transit( event, SweConst.SE_MOON, 90.0, iflag);
89 | date = transit.getDate();
90 |
91 | assertEquals( LocalDateTime.of( 2017, 6, 25, 18, 55), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
92 | }
93 |
94 | @Test
95 | public void planetToPointTopocentricSirerealTest() {
96 |
97 | int iflag = SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_BABYL_KUGLER1;
98 |
99 | Coordinates coords = new Coordinates(LONGITUDE, LATITUDE, GEOALT);
100 |
101 | LocalDateTime event = LocalDateTime.of( 2017, 6, 18, 0, 0);
102 | Transit transit = new Transit( event, SweConst.SE_SUN, 90.0, coords, iflag);
103 | LocalDateTime date = transit.getDate();
104 |
105 | assertEquals( LocalDateTime.of( 2017, 7, 18, 12, 38), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
106 |
107 |
108 | iflag = SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_RAMAN;
109 |
110 | event = LocalDateTime.of( 2017, 6, 18, 0, 0);
111 | transit = new Transit( event, SweConst.SE_MOON, 90.0, coords, iflag);
112 | date = transit.getDate();
113 |
114 | assertEquals( LocalDateTime.of( 2017, 6, 25, 9, 16), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
115 | }
116 |
117 | @Test
118 | public void planetToPlanetGeocentricTest() {
119 |
120 | int iflag = 0; // tropical
121 |
122 | LocalDateTime event = LocalDateTime.of( 2017, 6, 18, 0, 0);
123 | Transit transit = new Transit( event, SweConst.SE_SUN, SweConst.SE_MOON, 0.0, iflag);
124 | LocalDateTime date = transit.getDate();
125 |
126 | assertEquals( LocalDateTime.of( 2017, 6, 24, 2, 30), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
127 |
128 |
129 | event = LocalDateTime.of( 2017, 6, 18, 0, 0);
130 | transit = new Transit( event, SweConst.SE_SUN, SweConst.SE_MOON, 180.0, iflag);
131 | date = transit.getDate();
132 |
133 | assertEquals( LocalDateTime.of( 2017, 7, 9, 4, 06), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
134 | }
135 |
136 | @Test
137 | public void planetToPlanetTopocentricTest() {
138 |
139 | int iflag = 0; // tropical
140 |
141 | Coordinates coords = new Coordinates(LONGITUDE, LATITUDE, GEOALT);
142 |
143 | LocalDateTime event = LocalDateTime.of( 2017, 6, 18, 0, 0);
144 | Transit transit = new Transit( event, SweConst.SE_SUN, SweConst.SE_MOON, 0.0, coords, iflag);
145 | LocalDateTime date = transit.getDate();
146 |
147 | assertEquals( LocalDateTime.of( 2017, 6, 24, 1, 43), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
148 |
149 |
150 | event = LocalDateTime.of( 2017, 6, 18, 0, 0);
151 | transit = new Transit( event, SweConst.SE_SUN, SweConst.SE_MOON, 180.0, coords, iflag);
152 | date = transit.getDate();
153 |
154 | assertEquals( LocalDateTime.of( 2017, 7, 9, 5, 33), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
155 | }
156 |
157 | @Test
158 | public void planetToPlanetGeocentricSirerealTest() {
159 |
160 | int iflag = SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_DELUCE;
161 |
162 | LocalDateTime event = LocalDateTime.of( 2017, 6, 18, 0, 0);
163 | Transit transit = new Transit( event, SweConst.SE_SUN, SweConst.SE_MOON, 0.0, iflag);
164 | LocalDateTime date = transit.getDate();
165 |
166 | assertEquals( LocalDateTime.of( 2017, 6, 24, 2, 30), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
167 |
168 | event = LocalDateTime.of( 2017, 6, 18, 0, 0);
169 | transit = new Transit( event, SweConst.SE_SUN, SweConst.SE_MOON, 180.0, iflag);
170 | date = transit.getDate();
171 |
172 | assertEquals( LocalDateTime.of( 2017, 7, 9, 4, 06), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
173 | }
174 |
175 | @Test
176 | public void planetToPlanetTopocentricSirerealTest() {
177 |
178 | int iflag = SweConst.SEFLG_SIDEREAL | SweConst.SE_SIDM_SASSANIAN;
179 |
180 | Coordinates coords = new Coordinates(LONGITUDE, LATITUDE, GEOALT);
181 |
182 | LocalDateTime event = LocalDateTime.of( 2017, 6, 18, 0, 0);
183 | Transit transit = new Transit( event, SweConst.SE_SUN, SweConst.SE_MOON, 0.0, coords, iflag);
184 | LocalDateTime date = transit.getDate();
185 |
186 | assertEquals( LocalDateTime.of( 2017, 6, 24, 1, 43), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
187 |
188 | event = LocalDateTime.of( 2017, 6, 18, 0, 0);
189 | transit = new Transit( event, SweConst.SE_SUN, SweConst.SE_MOON, 180.0, coords, iflag);
190 | date = transit.getDate();
191 |
192 | assertEquals( LocalDateTime.of( 2017, 7, 9, 5, 33), LocalDateTime.of( date.getYear(), date.getMonthValue(), date.getDayOfMonth(), date.getHour(), date.getMinute()));
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/src/test/java/cz/kibo/api/astrology/json/ConvertorTest.java:
--------------------------------------------------------------------------------
1 | package cz.kibo.api.astrology.json;
2 |
3 | import static org.junit.Assert.*;
4 |
5 | import java.util.ArrayList;
6 | import java.util.HashMap;
7 | import java.util.List;
8 | import java.util.Map;
9 |
10 | import org.junit.Test;
11 |
12 | public class ConvertorTest {
13 |
14 | @Test
15 | public void planetsTest() {
16 |
17 | String result = "{\"planets\":{\"Moon\":[4,5,6],\"Sun\":[1,2,3]}}";
18 |
19 | Map> planetsPositions = new HashMap>();
20 | List val1 = new ArrayList(){
21 | {
22 | add(1.0);
23 | add(2.0);
24 | add(3.0);
25 | }
26 | };
27 |
28 | List val2 = new ArrayList(){
29 | {
30 | add(4.0);
31 | add(5.0);
32 | add(6.0);
33 | }
34 | };
35 |
36 | planetsPositions.put("Sun", val1);
37 | planetsPositions.put("Moon", val2);
38 |
39 | Convertor convertor = new Convertor( planetsPositions );
40 |
41 | assertEquals(result, convertor.getJSON().toString());
42 | }
43 |
44 | @Test
45 | public void cuspsTest() {
46 | String result = "{\"cusps\":[1,2,3]}";
47 | List cuspsPosition = new ArrayList() {
48 | {
49 | add(1.0);
50 | add(2.0);
51 | add(3.0);
52 | }
53 | };
54 |
55 | Convertor convertor = new Convertor( cuspsPosition );
56 |
57 | assertEquals(result, convertor.getJSON().toString());
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/test/java/swisseph/TestMultithread.java:
--------------------------------------------------------------------------------
1 | package swisseph;
2 |
3 | import org.testng.annotations.Test;
4 | import static org.junit.Assert.*;
5 |
6 | import java.time.LocalDateTime;
7 | import java.util.ArrayList;
8 | import java.util.HashMap;
9 | import java.util.List;
10 | import java.util.Map;
11 |
12 | import swisseph.SweConst;
13 |
14 | public class TestMultithread {
15 |
16 | final double LONGITUDE = 16.0542676;
17 | final double LATITUDE = 48.8559107;
18 | final double GEOALT = 286;
19 | final String PATH_TO_EPHEMERIS = "/data/ephemeris";
20 |
21 | @Test(threadPoolSize = 10, invocationCount = 1000, timeOut = 1000)
22 | public void testMultiProcessing() {
23 |
24 | Long id = Thread.currentThread().getId();
25 | System.out.println("Test method executing on thread with id: " + id);
26 |
27 |
28 | LocalDateTime event = LocalDateTime.of( 2018, 3, 20, 16, 20);
29 |
30 | List planets = new ArrayList();
31 | planets.add( SweConst.SE_SUN );
32 | planets.add( SweConst.SE_JUPITER );
33 |
34 | int iflag = SweConst.SEFLG_SWIEPH | SweConst.SEFLG_SPEED;
35 |
36 | SwissEph sw = new SwissEph( PATH_TO_EPHEMERIS );
37 |
38 | SweDate sd = new SweDate(event.getYear(), event.getMonthValue(), event.getDayOfMonth(), event.getHour() + event.getMinute()/60.0 + event.getSecond()/360.0, SweDate.SE_GREG_CAL);
39 |
40 | Map> data = new HashMap>();
41 |
42 | for (Integer planet : planets) {
43 |
44 | double[] xp= new double[6];
45 | StringBuffer serr = new StringBuffer();
46 |
47 | int ret = sw.swe_calc_ut(sd.getJulDay(),
48 | planet,
49 | iflag,
50 | xp,
51 | serr);
52 |
53 | if (ret != iflag) {
54 | if (serr.length() > 0) {
55 | System.err.println("Warning: " + serr);
56 | } else {
57 | System.err.println( String.format("Warning, different flags used (0x%x)", ret));
58 | }
59 | }
60 |
61 | // @see swisseph.SwissEph.swe_calc
62 | List values = new ArrayList();
63 | values.add(xp[0]); //longitude
64 | values.add(xp[3]); //speed in longitude
65 |
66 | data.put( sw.swe_get_planet_name(planet), values);
67 | }
68 |
69 | assertEquals(2, data.size());
70 |
71 | assertTrue("Sun",data.containsKey("Sun"));
72 | assertTrue("Jupiter",data.containsKey("Jupiter"));
73 |
74 | assertTrue( data.get("Sun").get(1) > 0 );
75 | assertTrue( data.get("Jupiter").get(1) < 0 ); // Retrograde
76 |
77 | assertEquals(0, data.get("Sun").get(0).intValue()); //Spring is comming
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/test/java/swisseph/Threadtest.java:
--------------------------------------------------------------------------------
1 | package swisseph;
2 |
3 | public class Threadtest {
4 |
5 | public static void main(String[] p) {
6 | int threadcount = 100;
7 | if (p.length == 1 && Integer.parseInt(p[0]) > 0) {
8 | threadcount = Integer.parseInt(p[0]);
9 | }
10 |
11 | for(int t = threadcount; t > 0; t--) {
12 | SEThread se = new SEThread(t);
13 | se.start();
14 | }
15 | }
16 | }
17 |
18 | class SEThread extends Thread {
19 | static final int MAX_COUNT = 100;
20 |
21 | int threadNo;
22 | int[] planets = new int[]{ SweConst.SE_SUN,
23 | SweConst.SE_MOON,
24 | SweConst.SE_MARS,
25 | SweConst.SE_MERCURY,
26 | SweConst.SE_JUPITER,
27 | SweConst.SE_VENUS,
28 | SweConst.SE_SATURN,
29 | SweConst.SE_TRUE_NODE };
30 |
31 |
32 | public SEThread(int n) {
33 | threadNo = n;
34 | }
35 |
36 | public void run() {
37 | System.err.println("Thread " + threadNo + " started");
38 |
39 | SwissEph sw = new SwissEph("/data/ephemeris");
40 | //int iflag = SweConst.SEFLG_SWIEPH;
41 | int iflag = SweConst.SEFLG_SWIEPH | SweConst.SEFLG_SPEED;
42 | double[] xx = new double[6];
43 | StringBuffer serr = new StringBuffer();
44 |
45 | int cnt = 0;
46 | while(cnt < MAX_COUNT) {
47 | cnt++;
48 |
49 | // Random julian day between jan. 1, 1800 and dec. 31, 2399 to restrict
50 | // calculation to the se*_18.se1 data files
51 | double randomJD = Math.random() * (2597640.5 - 2378496.5) + 2378496.5;
52 | int randomPlanet = planets[ new java.util.Random().nextInt(planets.length) ];
53 |
54 | sw.swe_calc(
55 | randomJD,
56 | randomPlanet,
57 | iflag,
58 | xx,
59 | serr
60 | );
61 | System.out.println(xx[0]);
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/test-output/Default suite/testng-failed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/test-output/bullet_point.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kibo/AstroAPI/cfc3d1e5a4c1d8dd5cd9906b15cec855e9e6302e/test-output/bullet_point.png
--------------------------------------------------------------------------------
/test-output/collapseall.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kibo/AstroAPI/cfc3d1e5a4c1d8dd5cd9906b15cec855e9e6302e/test-output/collapseall.gif
--------------------------------------------------------------------------------
/test-output/failed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kibo/AstroAPI/cfc3d1e5a4c1d8dd5cd9906b15cec855e9e6302e/test-output/failed.png
--------------------------------------------------------------------------------
/test-output/navigator-bullet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kibo/AstroAPI/cfc3d1e5a4c1d8dd5cd9906b15cec855e9e6302e/test-output/navigator-bullet.png
--------------------------------------------------------------------------------
/test-output/old/Default suite/Default test.properties:
--------------------------------------------------------------------------------
1 | [SuiteResult context=Default test]
--------------------------------------------------------------------------------
/test-output/old/Default suite/classes.html:
--------------------------------------------------------------------------------
1 |