]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/load/FieldGuesser.java
Version 5, May 2008
[GpsPrune.git] / tim / prune / load / FieldGuesser.java
index 032874af74da8ac9dafa5ad7e36f43dbfd71bbb2..7a670968e0e460247ee002c03ce6f48a0be53b4e 100644 (file)
@@ -80,6 +80,12 @@ 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;
+                               }
                        }
                }
                // Fill in the rest of the fields using just custom fields
@@ -270,4 +276,26 @@ 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");
+               }
+               else
+               {
+                       // can't reliably identify it just using the value
+                       return false;
+               }
+       }
 }