X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fload%2FFieldGuesser.java;h=6b29379eee308fb0b715a7a682fcab4b8477dcaf;hp=7a670968e0e460247ee002c03ce6f48a0be53b4e;hb=1ee49ae3c8ef3aa2e63eadd458531e5f8bd4f92c;hpb=112bb0c9b46894adca9a33ed8c99ea712b253185 diff --git a/tim/prune/load/FieldGuesser.java b/tim/prune/load/FieldGuesser.java index 7a67096..6b29379 100644 --- a/tim/prune/load/FieldGuesser.java +++ b/tim/prune/load/FieldGuesser.java @@ -86,6 +86,12 @@ public abstract class FieldGuesser 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 @@ -115,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; } @@ -298,4 +308,27 @@ public abstract class FieldGuesser 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; + } + } }