X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FCoordinate.java;h=40853ebc62505983b132abb71c85afcc041bc115;hb=649c5da6ee1bbc590699e11a92316ece2ea8512d;hp=44ab779ab6c1a0d66f1254c3df6fb82391a955fb;hpb=c0387c124840c9407e040600fda88f3c3e8f6aa6;p=GpsPrune.git diff --git a/tim/prune/data/Coordinate.java b/tim/prune/data/Coordinate.java index 44ab779..40853eb 100644 --- a/tim/prune/data/Coordinate.java +++ b/tim/prune/data/Coordinate.java @@ -60,7 +60,7 @@ public abstract class Coordinate inString = inString.trim(); strLen = inString.length(); } - if (strLen > 1) + if (strLen > 0) { // Check for cardinal character either at beginning or end boolean hasCardinal = true; @@ -98,8 +98,11 @@ public abstract class Coordinate numFields++; denoms[numFields-1] = 1; } - fields[numFields-1] = fields[numFields-1] * 10 + (currChar - '0'); - denoms[numFields-1] *= 10; + if (denoms[numFields-1] < 1E18) // ignore trailing characters if too big for long + { + fields[numFields-1] = fields[numFields-1] * 10 + (currChar - '0'); + denoms[numFields-1] *= 10; + } } else { @@ -263,11 +266,7 @@ public abstract class Coordinate */ public boolean equals(Coordinate inOther) { - return (inOther != null && _cardinal == inOther._cardinal - && _degrees == inOther._degrees - && _minutes == inOther._minutes - && _seconds == inOther._seconds - && _fracs == inOther._fracs); + return (_asDouble == inOther._asDouble); } @@ -304,8 +303,12 @@ public abstract class Coordinate } case FORMAT_DEG_WHOLE_MIN: { - answer = "" + PRINTABLE_CARDINALS[_cardinal] + threeDigitString(_degrees) + "\u00B0" - + (int) Math.floor(_minutes + _seconds / 60.0 + _fracs / 60.0 / _fracDenom + 0.5) + "'"; + int deg = _degrees; + int min = (int) Math.floor(_minutes + _seconds / 60.0 + _fracs / 60.0 / _fracDenom + 0.5); + if (min == 60) { + min = 0; deg++; + } + answer = "" + PRINTABLE_CARDINALS[_cardinal] + threeDigitString(deg) + "\u00B0" + min + "'"; break; } case FORMAT_DEG: