OSDN Git Service

i18n, reformat, Java8
[importpicture/importpicture.git] / importPicture / src / osm / jp / gpx / ElementMapTRKPT.java
index ab25615..538f025 100644 (file)
@@ -8,30 +8,32 @@ import org.w3c.dom.DOMException;
 
 @SuppressWarnings("serial")
 public class ElementMapTRKPT extends TreeMap<Date, TagTrkpt> {
-       public static final long DIFF_MAE_TIME = 3000L; // before 3 secound
+    public static final long DIFF_MAE_TIME = 3000L;    // before 3 secound
 
-       public ElementMapTRKPT() {
-               super(new TimeComparator());
-       }
+    public ElementMapTRKPT() {
+        super(new TimeComparator());
+    }
 
-       /**
-        * 拡張put value:ElementをputするとElement内のtimeを読み取ってkeyとしてthis.put(key,value)する。
-        * <trkpt lat="36.4260153752" lon="138.0117778201">
+    /**
+     * 拡張put value:ElementをputするとElement内のtimeを読み取ってkeyとしてthis.put(key,value)する。
+     * @param tag
+     * @code{
+     * <trkpt lat="36.4260153752" lon="138.0117778201">
      *   <ele>614.90</ele>
      *   <time>2017-05-21T23:02:16Z</time>
      *   <hdop>0.5</hdop>
      * </trkpt>
-        * @param value
-        * @return      keyとして登録したtime:Date
-        * @throws ParseException 
-        * @throws DOMException 
-        */
-       public Date put(TagTrkpt tag) throws DOMException, ParseException {
+     * }
+     * @return keyとして登録したtime:Date
+     * @throws ParseException 
+     * @throws DOMException 
+     */
+    public Date put(TagTrkpt tag) throws DOMException, ParseException {
         this.put(tag.time, tag);
        return tag.time;
-       }
-       
-       /**
+    }
+
+    /**
      * 指定時刻(jptime)のTRKPTエレメントを取り出す。
      * 
      * @param jptime   指定する日時
@@ -41,7 +43,7 @@ public class ElementMapTRKPT extends TreeMap<Date, TagTrkpt> {
     public TagTrkpt getValue(Date jptime) throws ParseException {
        TagTrkpt imaE = getTrkpt(jptime);
         if (imaE != null) {
-               TagTrkpt maeE = getMaeTrkpt(imaE.time);
+            TagTrkpt maeE = getMaeTrkpt(imaE.time);
             if (maeE != null) {
                Complementation comp = new Complementation(imaE, maeE);
 
@@ -49,12 +51,12 @@ public class ElementMapTRKPT extends TreeMap<Date, TagTrkpt> {
                 // 直前の位置と、現在地から進行方向を求める
                // 経度(longitude)と経度から進行方向を求める
                 if (Complementation.param_GpxOverwriteMagvar) {
-                       comp.complementationMagvar();
+                    comp.complementationMagvar();
                 }
 
                 // 緯度・経度と時間差から速度(km/h)を求める
                 if (Complementation.param_GpxOutputSpeed) {
-                       comp.complementationSpeed();
+                    comp.complementationSpeed();
                 }
                 //return (TagTrkpt)(comp.imaTag.trkpt.cloneNode(true));
                 return (TagTrkpt)(comp.imaTag);
@@ -77,26 +79,26 @@ public class ElementMapTRKPT extends TreeMap<Date, TagTrkpt> {
     private TagTrkpt getTrkpt(Date jptime) throws ParseException {
        Date keyTime = null;
        for (Date key : this.keySet()) {
-                       int flag = jptime.compareTo(key);
-                       if (flag < 0) {
-                               if (keyTime != null) {
-                                       return this.get(keyTime);
-                               }
-                               return null;
-                       }
-                       else if (flag == 0) {
-                               return this.get(key);
-                       }
-                       else if (flag > 0) {
-                               keyTime = new Date(key.getTime());
-                       }
-               }
-               if (keyTime != null) {
-                       if (Math.abs(keyTime.getTime() - jptime.getTime()) <= OVER_TIME_LIMIT) {
-                               return this.get(keyTime);
-                       }
-               }
-               return null;
+            int flag = jptime.compareTo(key);
+            if (flag < 0) {
+                if (keyTime != null) {
+                    return this.get(keyTime);
+                }
+                return null;
+            }
+            else if (flag == 0) {
+                return this.get(key);
+            }
+            else if (flag > 0) {
+                keyTime = new Date(key.getTime());
+            }
+        }
+        if (keyTime != null) {
+            if (Math.abs(keyTime.getTime() - jptime.getTime()) <= OVER_TIME_LIMIT) {
+                return this.get(keyTime);
+            }
+        }
+        return null;
     }
     
     /**
@@ -108,40 +110,40 @@ public class ElementMapTRKPT extends TreeMap<Date, TagTrkpt> {
     
     private TagTrkpt getMaeTrkpt(Date time) throws ParseException {
        Date maeTime = null;
-               for (Date key : this.keySet()) {
-                       int flag = time.compareTo(key);
-                       if (flag > 0) {
-                               maeTime = new Date(key.getTime());
-                       }
-                       else if (flag == 0) {
-                               if (maeTime == null) {
-                                       return null;
-                               }
-                               return this.get(maeTime);
-                       }
-                       else {
-                               // time は key より古い
-                               if (maeTime == null) {
-                                       return null;
-                               }
-                               if (Math.abs(maeTime.getTime() - time.getTime()) > OVER_TIME_LIMIT) {
-                                       return null;
-                               }
-                               return this.get(maeTime);
-                       }
-               }
+        for (Date key : this.keySet()) {
+            int flag = time.compareTo(key);
+            if (flag > 0) {
+                maeTime = new Date(key.getTime());
+            }
+            else if (flag == 0) {
+                if (maeTime == null) {
+                    return null;
+                }
+                return this.get(maeTime);
+            }
+            else {
+                // time は key より古い
+                if (maeTime == null) {
+                    return null;
+                }
+                if (Math.abs(maeTime.getTime() - time.getTime()) > OVER_TIME_LIMIT) {
+                    return null;
+                }
+                return this.get(maeTime);
+            }
+        }
         return null;
     }
     
     public void printinfo() {
        Date firstTime = null;
        Date lastTime = null;
-               for (Date key : this.keySet()) {
-                       if (firstTime == null) {
-                               firstTime = new Date(key.getTime());
-                       }
-                       lastTime = new Date(key.getTime());
-               }
-               System.out.println(String.format("|                      <trkseg/> |%20s|%20s|", ImportPicture.toUTCString(firstTime), ImportPicture.toUTCString(lastTime)));
+        for (Date key : this.keySet()) {
+            if (firstTime == null) {
+                firstTime = new Date(key.getTime());
+            }
+            lastTime = new Date(key.getTime());
+        }
+        System.out.println(String.format("|                      <trkseg/> |%20s|%20s|", ImportPicture.toUTCString(firstTime), ImportPicture.toUTCString(lastTime)));
     }
 }