]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/function/search/SearchResult.java
Version 19, May 2018
[GpsPrune.git] / tim / prune / function / search / SearchResult.java
index 2a05a8cf22e7c818e12250fba37ec7b5fb98b065..d757b017a2d6456e9e43475418116c84e6144ec3 100644 (file)
@@ -1,12 +1,14 @@
 package tim.prune.function.search;
 
 /**
- * Class to hold a search result from wikipedia / gpsies / panoramio etc
+ * Class to hold a search result from wikipedia / gpsies etc
  */
-public class SearchResult
+public class SearchResult implements Comparable<SearchResult>
 {
        /** Track name or title */
        private String _trackName = null;
+       /** Point type (for POIs) */
+       private String _pointType = null;
        /** Description */
        private String _description = null;
        /** Web page for more details */
@@ -35,6 +37,22 @@ public class SearchResult
                return _trackName;
        }
 
+       /**
+        * @param inType type of point (for POIs)
+        */
+       public void setPointType(String inType)
+       {
+               _pointType = inType;
+       }
+
+       /**
+        * @return type of point (for POIs)
+        */
+       public String getPointType()
+       {
+               return _pointType;
+       }
+
        /**
         * @param inDesc description
         */
@@ -126,4 +144,21 @@ public class SearchResult
        public String getLongitude() {
                return _longitude;
        }
+
+       /**
+        * Compare two search results for sorting (nearest first, then alphabetic)
+        */
+       public int compareTo(SearchResult inOther)
+       {
+               double distDiff = getLength() - inOther.getLength();
+               if (distDiff < 0.0)
+               {
+                       return -1;
+               }
+               if (distDiff > 0.0)
+               {
+                       return 1;
+               }
+               return getTrackName().compareTo(inOther.getTrackName());
+       }
 }