Add horoscope-api, synastry, and backend services
- horoscope-api: Swiss Ephemeris natal charts, timezone/place resolution, POST /v1/natal and POST /v1/synastry - backend: users with roles, email/password and Google login, saved charts, synastries and invites, analyses with credit ledger, public shares, admin - shared crates: astro-engine, db (migrations), horoscope-client, service-kit - docker-compose with postgres, legacy Java project for reference Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package astrochart.shared;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import astrochart.shared.enums.RashimanaGroup;
|
||||
import astrochart.shared.enums.ZodiacSign;
|
||||
|
||||
/**
|
||||
* Lengths of the equinoctial shadow of a Shanku of 12 units at different
|
||||
* latitudes Values from: http://www.vedicastro.com/astronomy6.asp
|
||||
*/
|
||||
public class EquinocticalShaddowLengths {
|
||||
private static final double CHARAKHANDA_MULTIPLICATOR_1 = 10D;
|
||||
private static final double CHARAKHANDA_MULTIPLICATOR_2 = 8D;
|
||||
private static final double CHARAKHANDA_MULTIPLICATOR_3 = 3.3333333333D;
|
||||
private static final int LATITUDES = 60;
|
||||
private final Map<Integer, Double> shaddowLengths = new HashMap<Integer, Double>(LATITUDES);
|
||||
|
||||
private enum ShaddowLength {
|
||||
_01(0.21D), _02(0.42D), _03(0.63D), _04(0.84D), _05(1.05D), _06(1.26D), _07(1.47D), _08(1.69D), _09(1.90D), _10(2.11D),
|
||||
_11(2.33D), _12(2.55D), _13(2.70D), _14(2.99D), _15(3.21D), _16(3.44D), _17(3.66D), _18(3.90D), _19(4.13D), _20(4.37D),
|
||||
_21(4.60D), _22(4.85D), _23(5.09D), _24(5.34D), _25(5.59D), _26(5.85D), _27(6.11D), _28(6.38D), _29(6.65D), _30(6.93D),
|
||||
_31(7.21D), _32(7.50D), _33(7.79D), _34(8.09D), _35(8.40D), _36(8.71D), _37(9.04D), _38(9.37D), _39(9.72D), _40(10.06D),
|
||||
_41(10.43D), _42(10.80D), _43(11.19D), _44(11.58D), _45(12.00D), _46(12.42D), _47(12.87D), _48(13.33D), _49(13.80D), _50(14.30D),
|
||||
_51(14.82D), _52(15.35D), _53(15.92D), _54(16.52D), _55(17.13D), _56(17.79D), _57(18.46D), _58(19.20D), _59(19.97D), _60(20.78D);
|
||||
|
||||
private final double length;
|
||||
|
||||
ShaddowLength(final double length) {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public double getLength() {
|
||||
return length;
|
||||
}
|
||||
}
|
||||
|
||||
public EquinocticalShaddowLengths() {
|
||||
for (final ShaddowLength sl : ShaddowLength.values()) {
|
||||
shaddowLengths.put(Integer.valueOf(sl.name().substring(1, 3)), Double.valueOf(sl.getLength()));
|
||||
}
|
||||
}
|
||||
|
||||
public final double getShaddowLength(final int latitude) {
|
||||
return shaddowLengths.get(Integer.valueOf(latitude)).doubleValue();
|
||||
}
|
||||
|
||||
public final int calculateCharakhandas(final ZodiacSign sign, final int latitude) {
|
||||
return calculatePalas(sign, latitude) * 6; // in asus
|
||||
}
|
||||
|
||||
private int calculatePalas(final ZodiacSign sign, final int latitude) {
|
||||
final double shaddowLenght = getShaddowLength(latitude);
|
||||
if (RashimanaGroup.I.equals(sign.getRashimanaGroup())) {
|
||||
return (int) (shaddowLenght * CHARAKHANDA_MULTIPLICATOR_1);
|
||||
} else if (RashimanaGroup.II.equals(sign.getRashimanaGroup())) {
|
||||
return (int) (shaddowLenght * CHARAKHANDA_MULTIPLICATOR_2);
|
||||
} else if (RashimanaGroup.III.equals(sign.getRashimanaGroup())) {
|
||||
return (int) (shaddowLenght * CHARAKHANDA_MULTIPLICATOR_3);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Sign " + sign + " has illegal rashomana group: " + sign.getRashimanaGroup());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+201
@@ -0,0 +1,201 @@
|
||||
package astrochart.shared.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import javax.jdo.annotations.IdentityType;
|
||||
import javax.jdo.annotations.PersistenceCapable;
|
||||
import javax.jdo.annotations.Persistent;
|
||||
import javax.jdo.annotations.PrimaryKey;
|
||||
import com.google.gwt.i18n.client.NumberFormat;
|
||||
import astrochart.shared.enums.Planet;
|
||||
import astrochart.shared.enums.ZodiacSign;
|
||||
|
||||
@PersistenceCapable(identityType = IdentityType.APPLICATION)
|
||||
public class Epoch implements Serializable {
|
||||
private static final long serialVersionUID = 546722654874032959L;
|
||||
private static final double MINUTES_PER_DEGREE = 60D;
|
||||
private static final double PRECISION = 100D;
|
||||
|
||||
@PrimaryKey
|
||||
@Persistent
|
||||
private Long key; // Timestamp of sidereal Date
|
||||
|
||||
@Persistent
|
||||
private Date sidDate;
|
||||
@Persistent
|
||||
private String day;
|
||||
|
||||
@Persistent
|
||||
private String sun;
|
||||
@Persistent
|
||||
private String moon;
|
||||
@Persistent
|
||||
private String mercury;
|
||||
@Persistent
|
||||
private String venus;
|
||||
@Persistent
|
||||
private String mars;
|
||||
@Persistent
|
||||
private String jupiter;
|
||||
@Persistent
|
||||
private String saturn;
|
||||
@Persistent
|
||||
private String uranus;
|
||||
@Persistent
|
||||
private String neptune;
|
||||
@Persistent
|
||||
private String pluto;
|
||||
@Persistent
|
||||
private String node;
|
||||
|
||||
public Epoch() {
|
||||
}
|
||||
|
||||
public final Long getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public final Date getSidDate() {
|
||||
return sidDate;
|
||||
}
|
||||
|
||||
public final void setSidDate(final Date sidDate) {
|
||||
this.sidDate = sidDate;
|
||||
this.key = sidDate.getTime();
|
||||
}
|
||||
|
||||
public final String getDay() {
|
||||
return day;
|
||||
}
|
||||
|
||||
public final void setDay(final String day) {
|
||||
this.day = day;
|
||||
}
|
||||
|
||||
public final void setPosition(final Planet planet, final String position) {
|
||||
if (planet.equals(Planet.Sun)) {
|
||||
sun = position;
|
||||
} else if (planet.equals(Planet.Moon)) {
|
||||
moon = position;
|
||||
} else if (planet.equals(Planet.Mercury)) {
|
||||
mercury = position;
|
||||
} else if (planet.equals(Planet.Venus)) {
|
||||
venus = position;
|
||||
} else if (planet.equals(Planet.Mars)) {
|
||||
mars = position;
|
||||
} else if (planet.equals(Planet.Jupiter)) {
|
||||
jupiter = position;
|
||||
} else if (planet.equals(Planet.Saturn)) {
|
||||
saturn = position;
|
||||
} else if (planet.equals(Planet.Uranus)) {
|
||||
uranus = position;
|
||||
} else if (planet.equals(Planet.Neptune)) {
|
||||
neptune = position;
|
||||
} else if (planet.equals(Planet.Pluto)) {
|
||||
pluto = position;
|
||||
} else if (planet.equals(Planet.Node)) {
|
||||
node = position;
|
||||
} else if (planet.equals(Planet.SouthNode)) {
|
||||
assert true; // ignore
|
||||
//throw new IllegalArgumentException("Cannot set south node position.");
|
||||
} else {
|
||||
throw new IllegalArgumentException("Planet unknown.");
|
||||
}
|
||||
}
|
||||
|
||||
public final String getPosition(final Planet planet) {
|
||||
if (planet.equals(Planet.Sun)) {
|
||||
return sun;
|
||||
} else if (planet.equals(Planet.Moon)) {
|
||||
return moon;
|
||||
} else if (planet.equals(Planet.Mercury)) {
|
||||
return mercury;
|
||||
} else if (planet.equals(Planet.Venus)) {
|
||||
return venus;
|
||||
} else if (planet.equals(Planet.Mars)) {
|
||||
return mars;
|
||||
} else if (planet.equals(Planet.Jupiter)) {
|
||||
return jupiter;
|
||||
} else if (planet.equals(Planet.Saturn)) {
|
||||
return saturn;
|
||||
} else if (planet.equals(Planet.Uranus)) {
|
||||
return uranus;
|
||||
} else if (planet.equals(Planet.Neptune)) {
|
||||
return neptune;
|
||||
} else if (planet.equals(Planet.Pluto)) {
|
||||
return pluto;
|
||||
} else if (planet.equals(Planet.Node)) {
|
||||
return node;
|
||||
} else if (planet.equals(Planet.SouthNode)) {
|
||||
return determineSouthNodePosition();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Planet unknown");
|
||||
}
|
||||
}
|
||||
|
||||
public final int getDegrees(final Planet planet) {
|
||||
return Integer.parseInt(getPosition(planet).substring(0, 2));
|
||||
}
|
||||
|
||||
public final String getSign(final Planet planet) {
|
||||
return getPosition(planet).substring(2, 4);
|
||||
}
|
||||
|
||||
public final int getMinutes(final Planet planet) {
|
||||
return Integer.parseInt(getPosition(planet).substring(4, 6));
|
||||
}
|
||||
|
||||
public final double getPreciseDegrees(final Planet planet) {
|
||||
return getDegrees(planet) + (((getMinutes(planet) * PRECISION) / MINUTES_PER_DEGREE) / PRECISION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines and returns the position of the south node by evaluating the
|
||||
* north node position.
|
||||
*/
|
||||
private String determineSouthNodePosition() {
|
||||
final String northNode = getPosition(Planet.Node);
|
||||
final String northSign = northNode.substring(2, 4);
|
||||
final String sign = ZodiacSign.valueOfAbbrevistion(northSign).getDescendent();
|
||||
final String southNode = northNode.substring(0, 2) + sign + northNode.substring(4, 6);
|
||||
return southNode;
|
||||
}
|
||||
|
||||
public final String getPositionString(final Planet planet) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
final ZodiacSign sign = ZodiacSign.valueOfAbbrevistion(getSign(planet));
|
||||
builder.append(sign.getUnicode());
|
||||
builder.append(" ");
|
||||
builder.append(sign);
|
||||
builder.append(" ");
|
||||
final double degree = getPreciseDegrees(planet);
|
||||
builder.append(NumberFormat.getFormat("0.000").format(degree));
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public final String getPositionDegreeString(final Planet planet) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
final ZodiacSign sign = ZodiacSign.valueOfAbbrevistion(getSign(planet));
|
||||
builder.append(sign.getUnicode());
|
||||
builder.append(" ");
|
||||
builder.append(sign);
|
||||
builder.append(" ");
|
||||
builder.append(getDegrees(planet));
|
||||
builder.append(String.valueOf('\u00B0'));
|
||||
builder.append(" ");
|
||||
builder.append(getMinutes(planet));
|
||||
builder.append(String.valueOf('\u2032'));
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
for (final Planet planet : Planet.values()) {
|
||||
builder.append(planet.name());
|
||||
builder.append(":");
|
||||
builder.append(getPosition(planet));
|
||||
builder.append(" ");
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package astrochart.shared.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class GeocodeData implements Serializable {
|
||||
private static final long serialVersionUID = 2353838294439322239L;
|
||||
|
||||
private double latitude;
|
||||
private double longitude;
|
||||
private String cityName;
|
||||
|
||||
public GeocodeData() {
|
||||
}
|
||||
|
||||
public final double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public final void setLatitude(final double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public final double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public final void setLongitude(final double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public final String getCityName() {
|
||||
return cityName;
|
||||
}
|
||||
|
||||
public final void setCityName(final String cityName) {
|
||||
this.cityName = cityName;
|
||||
}
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package astrochart.shared.enums;
|
||||
|
||||
public enum AspectType {
|
||||
Conjunction('\u260C', 0D, 7D, new double[]{1D, 2D, 3D, 4D, 5D, 6D, 7D, 8D, 9D, 10D}),
|
||||
Sextile('\u26B9', 60D, 5D, new double[]{1D, 2D, 3D, 4D, 5D, 6D, 7D, 8D, 9D, 10D}), //26B9
|
||||
Quintile('\u0051', 72D, 5D, new double[]{1D, 2D, 3D, 4D, 5D, 6D, 7D, 8D, 9D, 10D}),
|
||||
Square('\u25A1', 90D, 6D, new double[]{1D, 2D, 3D, 4D, 5D, 6D, 7D, 8D, 9D, 10D}),
|
||||
Trine('\u25B3', 120D, 5D, new double[]{1D, 2D, 3D, 4D, 5D, 6D, 7D, 8D, 9D, 10D}),
|
||||
Opposition('\u260D', 180D, 7D, new double[]{1D, 2D, 3D, 4D, 5D, 6D, 7D, 8D, 9D, 10D});
|
||||
|
||||
// <donh> trines are third-order and sextiles sixth-order. sextiles need to be given half the weight
|
||||
// <donh> and about half the orb, and most certainly less orb than quintiles or squares
|
||||
|
||||
private final char unicode;
|
||||
private final double angle;
|
||||
private final double defaultOrb;
|
||||
private final double[] orbs;
|
||||
|
||||
private AspectType(final char unicode, final double angle, final double defaultOrb, final double[] orbs) {
|
||||
this.unicode = unicode;
|
||||
this.angle = angle;
|
||||
this.defaultOrb = defaultOrb;
|
||||
this.orbs = orbs;
|
||||
}
|
||||
|
||||
public final char getUnicode() {
|
||||
return unicode;
|
||||
}
|
||||
|
||||
public final double getAngle() {
|
||||
return angle;
|
||||
}
|
||||
|
||||
public final double[] getOrbs() {
|
||||
return orbs;
|
||||
}
|
||||
|
||||
public final double getDefaultOrb() {
|
||||
return defaultOrb;
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return name();
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package astrochart.shared.enums;
|
||||
|
||||
public enum ChartColor {
|
||||
Black("#000000"),
|
||||
White("#FFFFFF"),
|
||||
Red("#ED1C24"),
|
||||
Blue("#3F48CC"),
|
||||
Yellow("#FFF200"),
|
||||
Green("#22B14C");
|
||||
|
||||
private final String hex;
|
||||
|
||||
private ChartColor(final String hex) {
|
||||
this.hex = hex;
|
||||
}
|
||||
|
||||
public final String getHex() {
|
||||
return hex;
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return name();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package astrochart.shared.enums;
|
||||
|
||||
public enum ChartProportions {
|
||||
Outer(1.00D),
|
||||
HouseNumber(0.98D),
|
||||
OuterEclyptic(0.95D),
|
||||
EclypticCenter(0.85D),
|
||||
InnerEclyptic(0.75D),
|
||||
OuterMark(0.72D),
|
||||
InnerMark(0.70D),
|
||||
PlanetMark(0.66D),
|
||||
PlanetSign(0.62D),
|
||||
Degree(0.55D),
|
||||
Minute(0.48D),
|
||||
InnerLine(0.44D),
|
||||
Inner(0.40D);
|
||||
|
||||
private final double relativeRadius;
|
||||
|
||||
private ChartProportions(final double relativeRadius) {
|
||||
this.relativeRadius = relativeRadius;
|
||||
}
|
||||
|
||||
public final double getRelativeRadius() {
|
||||
return relativeRadius;
|
||||
}
|
||||
|
||||
public static final int getRadius(final int halfChartSize, final ChartProportions prop) {
|
||||
return (int) (halfChartSize * prop.getRelativeRadius());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return this.name();
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package astrochart.shared.enums;
|
||||
|
||||
public enum HouseType {
|
||||
Equal("Equal House"),
|
||||
WholeSigns("Whole Sign");
|
||||
// Placidus("Placidus"), //http://groups.google.com/group/alt.astrology.moderated/browse_thread/thread/5cf05d6fe8eabb52/17e0c6282d8c7dce?lnk=raot
|
||||
// Campanus,
|
||||
// Regiomontanus,
|
||||
// KochHousesSystem;
|
||||
|
||||
private final String name;
|
||||
|
||||
private HouseType(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public final String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public static HouseType getTypeForName(final String name) {
|
||||
for (final HouseType type : HouseType.values()) {
|
||||
if (type.getName().equals(name)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package astrochart.shared.enums;
|
||||
|
||||
public enum Planet {
|
||||
Sun(3, '\u2609', true, false),
|
||||
Moon(4, '\u263e', true, false),
|
||||
Node(13, '\u260A', false, false), //ascending
|
||||
SouthNode(14, '\u260B', false, false), //descending
|
||||
Mercury(5, '\u263f', true, false),
|
||||
Venus(6, '\u2640', true, false),
|
||||
Mars(7, '\u2642', true, false),
|
||||
Jupiter(8, '\u2643', true, false),
|
||||
Saturn(9, '\u2644', true, false),
|
||||
Uranus(10, '\u2645', true, true),
|
||||
Neptune(11, '\u2646', true, true),
|
||||
Pluto(12, '\u2647', true, true);
|
||||
|
||||
private final int token;
|
||||
private final char unicode;
|
||||
private final boolean isBody;
|
||||
private final boolean isOuter;
|
||||
|
||||
private Planet(final int token, final char unicode, final boolean isBody, final boolean isOuter) {
|
||||
this.token = token;
|
||||
this.unicode = unicode;
|
||||
this.isBody = isBody;
|
||||
this.isOuter = isOuter;
|
||||
}
|
||||
|
||||
public final int getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public final char getUnicode() {
|
||||
return unicode;
|
||||
}
|
||||
|
||||
public final boolean isBody() {
|
||||
return isBody;
|
||||
}
|
||||
|
||||
public final boolean isOuter() {
|
||||
return isOuter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return this.name();
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package astrochart.shared.enums;
|
||||
|
||||
/**
|
||||
* compare: http://www.vedicastro.com/astronomy6.asp
|
||||
*/
|
||||
public enum RashimanaGroup {
|
||||
I(1674), II(1795), III(1931);
|
||||
|
||||
private final int equatorialAsus;
|
||||
|
||||
private RashimanaGroup(final int equatorialAsus) {
|
||||
this.equatorialAsus = equatorialAsus;
|
||||
}
|
||||
|
||||
public final int getEquatorialAsus() {
|
||||
return equatorialAsus;
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package astrochart.shared.enums;
|
||||
|
||||
public enum Weekday {
|
||||
Monday("Mo"), Tuesday("Tu"), Wednesday("We"), Thursday("Th"), Friday("Fr"), Saturday("Sa"), Sunday("Su");
|
||||
|
||||
private final String abbreviation;
|
||||
|
||||
private Weekday(final String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
public final String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return this.name();
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
package astrochart.shared.enums;
|
||||
|
||||
|
||||
public enum ZodiacSign {
|
||||
Aries(0, ChartColor.Red, '\u2648', "AR", "LI", RashimanaGroup.I, false),
|
||||
Taurus(30, ChartColor.Green, '\u2649', "TA", "SC", RashimanaGroup.II, false),
|
||||
Gemini(60, ChartColor.Yellow, '\u264A', "GE", "SG", RashimanaGroup.III, false),
|
||||
Cancer(90, ChartColor.Blue, '\u264B', "CN", "CP", RashimanaGroup.III, true),
|
||||
Leo(120, ChartColor.Red, '\u264C', "LE", "AQ", RashimanaGroup.II, true),
|
||||
Virgo(150, ChartColor.Green, '\u264D', "VI", "PI", RashimanaGroup.I, true),
|
||||
Libra(180, ChartColor.Yellow, '\u264E', "LI", "AR", RashimanaGroup.I, true),
|
||||
Scorpio(210, ChartColor.Blue, '\u264F', "SC", "TA", RashimanaGroup.II, true),
|
||||
Sagittaurius(240, ChartColor.Red, '\u2650', "SG", "GE", RashimanaGroup.III, true),
|
||||
Capricorn(270, ChartColor.Green, '\u2651', "CP", "CN", RashimanaGroup.III, false),
|
||||
Aquarius(300, ChartColor.Yellow, '\u2652', "AQ", "LE", RashimanaGroup.II, false),
|
||||
Pisces(330, ChartColor.Blue, '\u2653', "PI", "VI", RashimanaGroup.I, false);
|
||||
|
||||
private static final int DEGREES_PER_SIGN = 30;
|
||||
private final int eclipticLongitude;
|
||||
private final ChartColor color;
|
||||
private final char unicode;
|
||||
private final String abbreviation;
|
||||
private final String descendent;
|
||||
private final RashimanaGroup rashimanaGroup;
|
||||
private final boolean hasLongAscension;
|
||||
|
||||
private ZodiacSign(final int eclipticLongitude, final ChartColor color, final char unicode, final String abbreviation, final String descendent,
|
||||
final RashimanaGroup rashimanaGroup, final boolean hasLongAscension) {
|
||||
this.eclipticLongitude = eclipticLongitude;
|
||||
this.color = color;
|
||||
this.unicode = unicode;
|
||||
this.abbreviation = abbreviation;
|
||||
this.descendent = descendent;
|
||||
this.rashimanaGroup = rashimanaGroup;
|
||||
this.hasLongAscension = hasLongAscension;
|
||||
}
|
||||
|
||||
public static final ZodiacSign getSignAtDegree(final double degree) {
|
||||
for (final ZodiacSign sign : ZodiacSign.values()) {
|
||||
if (degree >= sign.getEclipticLongitude() && degree < sign.getEclipticLongitude() + DEGREES_PER_SIGN) {
|
||||
return sign;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Value out of range: " + degree);
|
||||
}
|
||||
|
||||
public final int getEclipticLongitude() {
|
||||
return eclipticLongitude;
|
||||
}
|
||||
|
||||
public final ChartColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public final char getUnicode() {
|
||||
return unicode;
|
||||
}
|
||||
|
||||
public final String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
public final String getDescendent() {
|
||||
return descendent;
|
||||
}
|
||||
|
||||
public final RashimanaGroup getRashimanaGroup() {
|
||||
return rashimanaGroup;
|
||||
}
|
||||
|
||||
public final boolean hasLongAscension() {
|
||||
return hasLongAscension;
|
||||
}
|
||||
|
||||
public static final ZodiacSign valueOfAbbrevistion(final String abbreviation) {
|
||||
for (final ZodiacSign sign : ZodiacSign.values()) {
|
||||
if (sign.getAbbreviation().equals(abbreviation)) {
|
||||
return sign;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Fail: Abbreviation unknown: " + abbreviation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return this.name();
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package astrochart.shared.enums.time;
|
||||
|
||||
public enum Month {
|
||||
January(1, 31),
|
||||
February(2, 28), // 29 days in leap years
|
||||
March(3, 31),
|
||||
April(4, 30),
|
||||
May(5, 31),
|
||||
June(6, 30),
|
||||
July(7, 31),
|
||||
August(8, 31),
|
||||
September(9, 30),
|
||||
October(10, 31),
|
||||
November(11, 30),
|
||||
December(12, 31);
|
||||
|
||||
private final int number;
|
||||
private final int days;
|
||||
|
||||
private Month(final int number, final int days) {
|
||||
this.number = number;
|
||||
this.days = days;
|
||||
}
|
||||
|
||||
public final int getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public final int getDays() {
|
||||
return days;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return this.name();
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package astrochart.shared.enums.time;
|
||||
|
||||
public enum TimeZone {
|
||||
UTC_12(-720, "UTC-12:00", "-1200"),
|
||||
UTC_11(-660, "UTC-11:00", "-1100"),
|
||||
UTC_10(-600, "UTC-10:00", "-1000"),
|
||||
UTC_930(-570, "UTC-9:30", "-0930"),
|
||||
UTC_9(-540, "UTC-9:00", "-0900"),
|
||||
UTC_8(-480, "UTC-8:00", "-0800"),
|
||||
UTC_7(-420, "UTC-7:00", "-0700"),
|
||||
UTC_6(-360, "UTC-6:00", "-0600"),
|
||||
UTC_5(-300, "UTC-5:00", "-0500"),
|
||||
UTC_430(-270, "UTC-4:30", "-0430"),
|
||||
UTC_4(-240, "UTC-4:00", "-0400"),
|
||||
UTC_330(-210, "UTC-3:30", "-0330"),
|
||||
UTC_3(-180, "UTC-3:00", "-0300"),
|
||||
UTC_2(-120, "UTC-2:00", "-0200"),
|
||||
UTC_1(-60, "UTC-1:00", "-0100"),
|
||||
UTC(0, "UTC", "+0000"),
|
||||
UTC1(60, "UTC+1:00", "+0100"),
|
||||
UTC2(120, "UTC+2:00", "+0200"),
|
||||
UTC3(180, "UTC+3:00", "+0300"),
|
||||
UTC330(210, "UTC+3:30", "+0330"),
|
||||
UTC4(240, "UTC+4:00", "+0400"),
|
||||
UTC430(270, "UTC+4:30", "+0430"),
|
||||
UTC5(300, "UTC+5:00", "+0500"),
|
||||
UTC530(330, "UTC+5:30", "+0530"),
|
||||
UTC545(345, "UTC+5:45", "+0545"),
|
||||
UTC6(360, "UTC+6:00", "+0600"),
|
||||
UTC630(390, "UTC+6:30", "+0630"),
|
||||
UTC7(420, "UTC+7:00", "+0700"),
|
||||
UTC8(480, "UTC+8:00", "+0800"),
|
||||
UTC9(540, "UTC+9:00", "+0900"),
|
||||
UTC930(570, "UTC+9:30", "+0930"),
|
||||
UTC10(600, "UTC+10:00", "+1000"),
|
||||
UTC1030(630, "UTC+10:30", "+1030"),
|
||||
UTC11(660, "UTC+11:00", "+1100"),
|
||||
UTC1130(690, "UTC+11:30", "+1130"),
|
||||
UTC12(720, "UTC+12:00", "+1200"),
|
||||
UTC1245(765, "UTC+12:45", "+1245"),
|
||||
UTC13(780, "UTC+13:00", "+1300"),
|
||||
UTC14(840, "UTC+14:00", "+1400");
|
||||
|
||||
private final int utcOffsetMinutes;
|
||||
private final String name;
|
||||
private final String zone;
|
||||
|
||||
private TimeZone(final int utcOffsetMinutes, final String name, final String zone) {
|
||||
this.utcOffsetMinutes = utcOffsetMinutes;
|
||||
this.name = name;
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
public final int getUtcOffsetMinutes() {
|
||||
return utcOffsetMinutes;
|
||||
}
|
||||
|
||||
public final String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public final String getZone() {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public static final TimeZone getTimeZoneForName(final String name) {
|
||||
for (final TimeZone timeZone : TimeZone.values()) {
|
||||
if (timeZone.getName().equals(name)) {
|
||||
return timeZone;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No timezone for name " + name + " found.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package astrochart.shared.exceptions;
|
||||
|
||||
public class EpochNotFoundException extends Exception {
|
||||
private static final long serialVersionUID = 769463999415154553L;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package astrochart.shared.wrappers;
|
||||
|
||||
import com.google.gwt.i18n.client.NumberFormat;
|
||||
import astrochart.shared.enums.ZodiacSign;
|
||||
|
||||
public class AscendentAndOffset {
|
||||
private final ZodiacSign ascendent;
|
||||
private final double offset;
|
||||
private final double midheaven;
|
||||
|
||||
public AscendentAndOffset(final ZodiacSign ascendent, final double offset, final double midheaven) {
|
||||
this.ascendent = ascendent;
|
||||
this.offset = offset;
|
||||
this.midheaven = midheaven;
|
||||
}
|
||||
|
||||
public final ZodiacSign getAscendent() {
|
||||
return ascendent;
|
||||
}
|
||||
|
||||
public final double getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public final String getFormattedOffset() {
|
||||
return NumberFormat.getFormat("0.00").format(offset) + String.valueOf('\u00B0');
|
||||
}
|
||||
|
||||
public final double getMidheaven() {
|
||||
return midheaven;
|
||||
}
|
||||
|
||||
public final String getFormattedMidheaven() {
|
||||
return NumberFormat.getFormat("0.00").format(midheaven) + String.valueOf('\u00B0');
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return ascendent + " at " + NumberFormat.getFormat("0.000").format(offset);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package astrochart.shared.wrappers;
|
||||
|
||||
import com.google.gwt.i18n.client.NumberFormat;
|
||||
|
||||
public class BodyPosition {
|
||||
private final double azimuth;
|
||||
private final double height;
|
||||
|
||||
public BodyPosition(final double azimuth, final double height) {
|
||||
this.azimuth = azimuth;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public final double getAzimuth() {
|
||||
return azimuth;
|
||||
}
|
||||
|
||||
public final double getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append("Azimuth: ");
|
||||
builder.append(NumberFormat.getFormat("0.000").format(azimuth));
|
||||
builder.append(" Height: ");
|
||||
builder.append(NumberFormat.getFormat("0.000").format(height));
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package astrochart.shared.wrappers;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class RiseAndSet {
|
||||
private final Date rise;
|
||||
private final Date set;
|
||||
|
||||
public RiseAndSet(final Date rise, final Date set) {
|
||||
this.rise = rise;
|
||||
this.set = set;
|
||||
}
|
||||
|
||||
public final Date getRise() {
|
||||
return rise;
|
||||
}
|
||||
|
||||
public final Date getSet() {
|
||||
return set;
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return "rise: " + rise + " set: " + set;
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package astrochart.shared.wrappers;
|
||||
|
||||
public class TextPosition {
|
||||
private final String text;
|
||||
private final double x;
|
||||
private final double y;
|
||||
|
||||
public TextPosition(final String text, final double x, final double y) {
|
||||
this.text = text;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public final String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public final double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public final double getY() {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user