X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FCoordinate.java;h=e30fa4ac357d89a68041fa07eee2f76bf5e8ee22;hb=1ea5817da5381ceebee75ea7294ea78dffff5671;hp=085c502b363a5c81dfe18d45ebd583a92a3360c2;hpb=7f5ed2be62905bd37717376dc22d09e5ea7edb4d;p=GpsPrune.git diff --git a/tim/prune/data/Coordinate.java b/tim/prune/data/Coordinate.java index 085c502..e30fa4a 100644 --- a/tim/prune/data/Coordinate.java +++ b/tim/prune/data/Coordinate.java @@ -126,7 +126,7 @@ public abstract class Coordinate // parse fields according to number found _degrees = (int) fields[0]; _asDouble = _degrees; - _originalFormat = hasCardinal?FORMAT_DEG:FORMAT_DEG_WITHOUT_CARDINAL; + _originalFormat = hasCardinal ? FORMAT_DEG : FORMAT_DEG_WITHOUT_CARDINAL; _fracDenom = 10; if (numFields == 2) { @@ -150,6 +150,19 @@ public abstract class Coordinate _asDouble = 1.0 * _degrees + (_minutes / 60.0); } } + // Check for exponential degrees like 1.3E-6 + else if (numFields == 3 && !otherDelims[1] && otherDelims[2] && isJustNumber(inString)) + { + _originalFormat = FORMAT_DEG; + _asDouble = Math.abs(Double.parseDouble(inString)); // must succeed if isJustNumber has given true + // now we can ignore the fields and just use this double + _degrees = (int) _asDouble; + double numMins = (_asDouble - _degrees) * 60.0; + _minutes = (int) numMins; + double numSecs = (numMins - _minutes) * 60.0; + _seconds = (int) numSecs; + _fracs = (int) ((numSecs - _seconds) * 10); + } // Differentiate between d-m.f and d-m-s using . or , else if (numFields == 3 && !otherDelims[2]) { @@ -184,10 +197,10 @@ public abstract class Coordinate /** * Get the cardinal from the given character - * @param inFirstChar first character from file - * @param inLastChar last character from file + * @param inFirstChar first character from string + * @param inLastChar last character from string */ - protected int getCardinal(char inFirstChar, char inLastChar) + private int getCardinal(char inFirstChar, char inLastChar) { // Try leading character first int cardinal = getCardinal(inFirstChar); @@ -424,7 +437,7 @@ public abstract class Coordinate double startValue = inStart.getDouble(); double endValue = inEnd.getDouble(); double newValue = startValue + (endValue - startValue) * inFraction; - Coordinate answer = inStart.makeNew(newValue, inStart._originalFormat); + Coordinate answer = inStart.makeNew(newValue, Coordinate.FORMAT_DECIMAL_FORCE_POINT); return answer; }