aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/geopoint/direction/Direction.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/geopoint/direction/Direction.java')
-rw-r--r--main/src/cgeo/geocaching/geopoint/direction/Direction.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/geopoint/direction/Direction.java b/main/src/cgeo/geocaching/geopoint/direction/Direction.java
new file mode 100644
index 0000000..ad91516
--- /dev/null
+++ b/main/src/cgeo/geocaching/geopoint/direction/Direction.java
@@ -0,0 +1,29 @@
+package cgeo.geocaching.geopoint.direction;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.math.BigDecimal;
+
+public class Direction {
+ /* Constant values needed for calculation */
+ static final double D60 = 60.0d;
+ private static final double D1000 = 1000.0d;
+ static final double D3600 = 3600.0d;
+ static final BigDecimal BD_SIXTY = BigDecimal.valueOf(D60);
+ static final BigDecimal BD_THOUSAND = BigDecimal.valueOf(D1000);
+ static final BigDecimal BD_ONEHOUNDREDTHOUSAND = BigDecimal.valueOf(100000.0d);
+
+ /** latitude direction, 'N' or 'S' */
+ public final char latDir;
+ /** longitude direction, 'E' or 'W' */
+ public final char lonDir;
+
+ public Direction(final double latSigned, final double lonSigned) {
+ latDir = latSigned < 0 ? 'S' : 'N';
+ lonDir = lonSigned < 0 ? 'W' : 'E';
+ }
+
+ protected static String addZeros(final int value, final int len) {
+ return StringUtils.leftPad(Integer.toString(value), len, '0');
+ }
+} \ No newline at end of file