X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fload%2FFieldGuesser.java;h=9b2bdc787a9c9a0833d7d5efd08380535b5dcc21;hb=f1b92378a792131ac8fb33a869405851d5b2d1f7;hp=032874af74da8ac9dafa5ad7e36f43dbfd71bbb2;hpb=da0b1f449260a0b4a94318006382a9039726ef3e;p=GpsPrune.git diff --git a/tim/prune/load/FieldGuesser.java b/tim/prune/load/FieldGuesser.java index 032874a..9b2bdc7 100644 --- a/tim/prune/load/FieldGuesser.java +++ b/tim/prune/load/FieldGuesser.java @@ -80,6 +80,18 @@ public abstract class FieldGuesser fields[f] = Field.TIMESTAMP; continue; } + // check for tracksegment + if (!checkArrayHasField(fields, Field.NEW_SEGMENT) && fieldLooksLikeSegment(value, isHeader)) + { + fields[f] = Field.NEW_SEGMENT; + continue; + } + // check for waypoint type + if (!checkArrayHasField(fields, Field.WAYPT_TYPE) && fieldLooksLikeWaypointType(value, isHeader)) + { + fields[f] = Field.WAYPT_TYPE; + continue; + } } } // Fill in the rest of the fields using just custom fields @@ -109,6 +121,10 @@ public abstract class FieldGuesser else if (!checkArrayHasField(fields, Field.LONGITUDE)) { fields[1] = Field.LONGITUDE; } + // Longitude _could_ have overwritten latitude in position 1 + if (!checkArrayHasField(fields, Field.LATITUDE)) { + fields[0] = Field.LATITUDE; + } return fields; } @@ -195,6 +211,7 @@ public abstract class FieldGuesser String upperValue = inValue.toUpperCase(); return (upperValue.equals("ALTITUDE") || upperValue.equals("ALT") + || upperValue.equals("HMSL") // height above mean sea level || upperValue.equals(I18nManager.getText("fieldname.altitude").toUpperCase())); } else @@ -270,4 +287,50 @@ public abstract class FieldGuesser return stamp.isValid(); } } + + /** + * Check whether the given String looks like a track segment field + * @param inValue value from file + * @param inIsHeader true if this is a header line, false for data + * @return true if it could be a track segment + */ + private static boolean fieldLooksLikeSegment(String inValue, boolean inIsHeader) + { + if (inValue == null || inValue.equals("")) {return false;} + if (inIsHeader) + { + String upperValue = inValue.toUpperCase(); + // This is a header line so look for english or local text + return upperValue.equals("SEGMENT") + || upperValue.equals(I18nManager.getText("fieldname.newsegment").toUpperCase()); + } + else + { + // can't reliably identify it just using the value + return false; + } + } + + /** + * Check whether the given String looks like a waypoint type + * @param inValue value from file + * @param inIsHeader true if this is a header line, false for data + * @return true if it could be a waypoint type + */ + private static boolean fieldLooksLikeWaypointType(String inValue, boolean inIsHeader) + { + if (inValue == null || inValue.equals("")) {return false;} + if (inIsHeader) + { + String upperValue = inValue.toUpperCase(); + // This is a header line so look for english or local text + return (upperValue.equals("TYPE") + || upperValue.equals(I18nManager.getText("fieldname.waypointtype").toUpperCase())); + } + else + { + // can't reliably identify it just using the value + return false; + } + } }