]> gitweb.fperrin.net Git - GpsPrune.git/commitdiff
Merge remote-tracking branch 'upstream/master' into fp-integration
authorFrédéric Perrin <fred@fperrin.net>
Tue, 20 Oct 2020 19:25:42 +0000 (20:25 +0100)
committerFrédéric Perrin <fred@fperrin.net>
Tue, 20 Oct 2020 19:25:42 +0000 (20:25 +0100)
14 files changed:
1  2 
buildtools/build.sh
pom.xml
src/tim/prune/App.java
src/tim/prune/FunctionLibrary.java
src/tim/prune/GpsPrune.java
src/tim/prune/config/Config.java
src/tim/prune/data/FileInfo.java
src/tim/prune/function/AddTimeOffset.java
src/tim/prune/function/srtm/LookupSrtmFunction.java
src/tim/prune/gui/MenuManager.java
src/tim/prune/gui/Viewport.java
src/tim/prune/gui/map/MapCanvas.java
src/tim/prune/gui/map/MapTileManager.java
src/tim/prune/lang/prune-texts_en.properties

index d2311b590dc5f17e18c85aedd412314a0ac0e4e4,193244bb3319fa81e974dd1d9f09fbbb52c7f70c..ee29ad85452faf1e7f530a91eeb93b791313a5a2
mode 100755,100644..100755
@@@ -1,7 -1,7 +1,8 @@@
 +set -e
  # Build script
+ set -e
  # Version number
- PRUNENAME=gpsprune_19.2
+ PRUNENAME=gpsprune_20
  # remove compile directory
  rm -rf compile
  # remove dist directory
diff --cc pom.xml
Simple merge
index 317064d39984acb566cee90940236c52c32fd58f,94e10e0e2ed873e6bbf7558419de14e393c20f08..f76edb177d2ffb4f8ba09e3feda928022be052d5
@@@ -765,22 -755,24 +773,28 @@@ public class Ap
                        _lastSavePosition = _undoStack.size();
                        _trackInfo.getSelection().clearAll();
                        _track.load(inLoadedTrack);
-                       inSourceInfo.populatePointObjects(_track, _track.getNumPoints());
-                       _trackInfo.getFileInfo().addSource(inSourceInfo);
+                       if (inSourceInfo != null)
+                       {
+                               inSourceInfo.populatePointObjects(_track, _track.getNumPoints());
+                               _trackInfo.getFileInfo().addSource(inSourceInfo);
+                       }
                }
                // Update config before subscribers are told
-               boolean isRegularLoad = (inSourceInfo.getFileType() != FILE_TYPE.GPSBABEL);
-               Config.getRecentFileList().addFile(new RecentFile(inSourceInfo.getFile(), isRegularLoad));
+               if (inSourceInfo != null)
+               {
+                       boolean isRegularLoad = (inSourceInfo.getFileType() != FILE_TYPE.GPSBABEL);
+                       Config.getRecentFileList().addFile(new RecentFile(inSourceInfo.getFile(), isRegularLoad));
+                       // Update status bar
+                       UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.loadfile")
+                               + " '" + inSourceInfo.getName() + "'");
+               }
                UpdateMessageBroker.informSubscribers();
-               // Update status bar
-               UpdateMessageBroker.informSubscribers(I18nManager.getText("confirm.loadfile")
-                       + " '" + inSourceInfo.getName() + "'");
                // update menu
                _menuManager.informFileLoaded();
 +              // recentre viewport on new file data
 +              _viewport.recentreViewport();
 +              // update main window title
 +              updateTitle();
                // Remove busy lock
                _busyLoading = false;
                // load next file if there's a queue
index 4be286e479d036a8b37cabe8223f495872a2f361,68303ed95946466daf23cf1adc5b15aa24f31786..58d049d34d18b24e69b510b944df34f301b16c56
@@@ -110,10 -109,8 +109,9 @@@ public abstract class FunctionLibrar
        public static GenericFunction FUNCTION_DOWNLOAD_OSM = null;
        public static GenericFunction FUNCTION_ADD_TIME_OFFSET  = null;
        public static GenericFunction FUNCTION_ADD_ALTITUDE_OFFSET  = null;
 +      public static GenericFunction FUNCTION_REMOVE_ALTITUDES = null;
        public static GenericFunction FUNCTION_CONVERT_NAMES_TO_TIMES  = null;
        public static GenericFunction FUNCTION_DELETE_FIELD_VALUES  = null;
-       public static GenericFunction FUNCTION_PASTE_COORDINATES = null;
        public static GenericFunction FUNCTION_FIND_WAYPOINT = null;
        public static GenericFunction FUNCTION_DUPLICATE_POINT = null;
        public static GenericFunction FUNCTION_CONNECT_TO_POINT = null;
                FUNCTION_DOWNLOAD_OSM = new DownloadOsmFunction(inApp);
                FUNCTION_ADD_TIME_OFFSET = new AddTimeOffset(inApp);
                FUNCTION_ADD_ALTITUDE_OFFSET = new AddAltitudeOffset(inApp);
 +              FUNCTION_REMOVE_ALTITUDES = new RemoveAltitudes(inApp);
                FUNCTION_CONVERT_NAMES_TO_TIMES = new ConvertNamesToTimes(inApp);
                FUNCTION_DELETE_FIELD_VALUES = new DeleteFieldValues(inApp);
-               FUNCTION_PASTE_COORDINATES = new PasteCoordinates(inApp);
                FUNCTION_FIND_WAYPOINT = new FindWaypoint(inApp);
                FUNCTION_DUPLICATE_POINT = new DuplicatePoint(inApp);
                FUNCTION_CONNECT_TO_POINT = new ConnectToPointFunction(inApp);
Simple merge
Simple merge
Simple merge
index 199ae5056b133aa27f59b3f509cf9806f9e4dca2,115bfa5997102edc0db005074c05fa5a97bb4754..ed75a5ec7104d441770435ee56dbc290000cfb86
@@@ -129,9 -126,8 +129,9 @@@ public class AddTimeOffset extends Gene
                MouseAdapter mouseListener = new MouseAdapter() {
                        public void mouseReleased(java.awt.event.MouseEvent arg0) {
                                _okButton.setEnabled(getOffsetSecs() != 0L);
-                       };
+                       }
                };
 +              _1024weekField.addKeyListener(keyListener);
                _dayField.addKeyListener(keyListener);
                _hourField.addKeyListener(keyListener);
                _minuteField.addKeyListener(keyListener);
index 947cca9294b53c54a529684255cd063fcdd3c296,c48af016b889f0df84a094de2df84db0db0ef272..8f4dc2e01767fb18237dd39380e6943bfb29567d
@@@ -171,81 -170,52 +171,38 @@@ public class LookupSrtmFunction extend
                        _progress.setMaximum(inTileList.size());
                        _progress.setValue(0);
                }
 -              String errorMessage = null;
 -              // Get urls for each tile
 -              URL[] urls = TileFinder.getUrls(inTileList);
 -              for (int t=0; t<inTileList.size() && !_progress.isCancelled() && urls != null; t++)
 +              String errorMessage = "";
 +              for (int t=0; t<inTileList.size() && !_progress.isCancelled(); t++)
                {
 -                      if (urls[t] != null)
 +                      SrtmTile tile = inTileList.get(t);
 +                      SrtmSource srtmSource = tile.findBestCachedSource();
 +
 +                      if (srtmSource == null)
                        {
 -                              SrtmTile tile = inTileList.get(t);
 -                              try
 -                              {
 -                                      // Set progress
 -                                      _progress.setValue(t);
 -                                      final int ARRLENGTH = 1201 * 1201;
 -                                      int[] heights = new int[ARRLENGTH];
 -                                      // Open zipinputstream on url and check size
 -                                      ZipInputStream inStream = getStreamToHgtFile(urls[t]);
 -                                      boolean entryOk = false;
 -                                      if (inStream != null)
 -                                      {
 -                                              ZipEntry entry = inStream.getNextEntry();
 -                                              entryOk = (entry != null && entry.getSize() == HGT_SIZE);
 -                                              if (entryOk)
 -                                              {
 -                                                      // Read entire file contents into one byte array
 -                                                      for (int i = 0; i < ARRLENGTH; i++)
 -                                                      {
 -                                                              heights[i] = inStream.read() * 256 + inStream.read();
 -                                                              if (heights[i] >= 32768) {heights[i] -= 65536;}
 -                                                      }
 -                                              }
 -                                              // else {
 -                                              //      System.out.println("length not ok: " + entry.getSize());
 -                                              // }
 -                                              // Close stream from url
 -                                              inStream.close();
 -                                      }
 +                              errorMessage += "Tile "+tile.getTileName()+" not in cache!\n";
 +                              continue;
 +                      }
  
 -                                      if (entryOk)
 -                                      {
 -                                              numAltitudesFound += applySrtmTileToWholeTrack(tile, heights, inOverwriteZeros);
 -                                      }
 -                              }
 -                              catch (IOException ioe) {
 -                                      errorMessage = ioe.getClass().getName() + " - " + ioe.getMessage();
 -                              }
 +                      // Set progress
 +                      _progress.setValue(t);
 +
 +                      int[] heights;
 +                      try {
 +                              heights = srtmSource.getTileHeights(tile);
 +                      }
 +                      catch (SrtmSourceException e)
 +                      {
 +                              errorMessage += e.getMessage();
 +                              e.printStackTrace();
 +                              continue;
                        }
-                       // Loop over all points in track, try to apply altitude from array
-                       for (int p = 0; p < _track.getNumPoints(); p++)
-                       {
-                               DataPoint point = _track.getPoint(p);
-                               if (needsAltitude(point, inOverwriteZeros))
-                               {
-                                       if (new SrtmTile(point).equals(tile))
-                                       {
-                                               double x = (point.getLongitude().getDouble() - tile.getLongitude()) * (rowSize - 1);
-                                               double y = rowSize - (point.getLatitude().getDouble() - tile.getLatitude()) * (rowSize - 1);
-                                               int idx1 = ((int)y)*rowSize + (int)x;
-                                               try
-                                               {
-                                                       int[] fouralts = {heights[idx1], heights[idx1+1], heights[idx1-rowSize], heights[idx1-rowSize+1]};
-                                                       int numVoids = (fouralts[0]==VOID_VAL?1:0) + (fouralts[1]==VOID_VAL?1:0)
-                                                               + (fouralts[2]==VOID_VAL?1:0) + (fouralts[3]==VOID_VAL?1:0);
-                                                       // if (numVoids > 0) System.out.println(numVoids + " voids found");
-                                                       double altitude = 0.0;
-                                                       switch (numVoids)
-                                                       {
-                                                       case 0: altitude = bilinearInterpolate(fouralts, x, y); break;
-                                                       case 1: altitude = bilinearInterpolate(fixVoid(fouralts), x, y); break;
-                                                       case 2:
-                                                       case 3: altitude = averageNonVoid(fouralts); break;
-                                                       default: altitude = VOID_VAL;
-                                                       }
-                                                       // Special case for terrain tracks, don't interpolate voids yet
-                                                       if (!_normalTrack && numVoids > 0) {
-                                                               altitude = VOID_VAL;
-                                                       }
-                                                       if (altitude != VOID_VAL)
-                                                       {
-                                                               point.setFieldValue(Field.ALTITUDE, ""+altitude, false);
-                                                               // depending on settings, this value may have been added as feet, we need to force metres
-                                                               point.getAltitude().reset(new Altitude((int)altitude, UnitSetLibrary.UNITS_METRES));
-                                                               numAltitudesFound++;
-                                                       }
-                                               }
-                                               catch (ArrayIndexOutOfBoundsException obe) {
-                                                       errorMessage += "Point not in tile? lat=" + point.getLatitude().getDouble() + ", x=" + x + ", y=" + y + ", idx=" + idx1+"\n";
-                                               }
-                                       }
-                               }
-                       }
 +                      int rowSize = srtmSource.getRowSize(tile);
 +                      if (rowSize <= 0)
 +                      {
 +                              errorMessage += "Tile "+tile.getTileName()+" is corrupted";
 +                      }
 +
++                      numAltitudesFound += applySrtmTimeToWholeTrack(tile, heights, rowSize, inOverwriteZeros);
                }
  
                _progress.dispose();
                }
        }
  
 -      /**
 -       * See whether the SRTM file is already available locally first, then try online
 -       * @param inUrl URL for online resource
 -       * @return ZipInputStream either on the local file or on the downloaded zip file
 -       */
 -      private ZipInputStream getStreamToHgtFile(URL inUrl)
 -      throws IOException
 -      {
 -              String diskCachePath = Config.getConfigString(Config.KEY_DISK_CACHE);
 -              if (diskCachePath != null)
 -              {
 -                      File srtmDir = new File(diskCachePath, "srtm");
 -                      if (srtmDir.exists() && srtmDir.isDirectory() && srtmDir.canRead())
 -                      {
 -                              File srtmFile = new File(srtmDir, new File(inUrl.getFile()).getName());
 -                              if (srtmFile.exists() && srtmFile.isFile() && srtmFile.canRead()
 -                                      && srtmFile.length() > 400)
 -                              {
 -                                      // System.out.println("Lookup: Using file " + srtmFile.getAbsolutePath());
 -                                      // File found, use this one
 -                                      return new ZipInputStream(new FileInputStream(srtmFile));
 -                              }
 -                      }
 -              }
 -              // System.out.println("Lookup: Trying online: " + inUrl.toString());
 -              _hadToDownload = true;
 -              // MAYBE: Only download if we're in online mode?
 -              return new ZipInputStream(inUrl.openStream());
 -      }
 -
+       /**
+        * Given the height data read in from file, apply the given tile to all points
+        * in the track with missing altitude
+        * @param inTile tile being applied
+        * @param inHeights height data read in from file
+        * @param inOverwriteZeros true to overwrite zero altitude values
+        * @return number of altitudes found
+        */
 -      private int applySrtmTileToWholeTrack(SrtmTile inTile, int[] inHeights, boolean inOverwriteZeros)
++      private int applySrtmTimeToWholeTrack(SrtmTile inTile, int[] inHeights, int inRowSize, boolean inOverwriteZeros)
+       {
+               int numAltitudesFound = 0;
+               // Loop over all points in track, try to apply altitude from array
+               for (int p = 0; p < _track.getNumPoints(); p++)
+               {
+                       DataPoint point = _track.getPoint(p);
 -                      if (!point.hasAltitude()
 -                              || (inOverwriteZeros && point.getAltitude().getValue() == 0))
++                      if (needsAltitude(point, inOverwriteZeros))
+                       {
+                               if (new SrtmTile(point).equals(inTile))
+                               {
 -                                      double x = (point.getLongitude().getDouble() - inTile.getLongitude()) * 1200;
 -                                      double y = 1201 - (point.getLatitude().getDouble() - inTile.getLatitude()) * 1200;
 -                                      int idx1 = ((int)y)*1201 + (int)x;
++                                      double x = (point.getLongitude().getDouble() - inTile.getLongitude()) * (inRowSize - 1);
++                                      double y = inRowSize - (point.getLatitude().getDouble() - inTile.getLatitude()) * (inRowSize - 1);
++                                      int idx1 = ((int)y)*inRowSize + (int)x;
+                                       try
+                                       {
 -                                              int[] fouralts = {inHeights[idx1], inHeights[idx1+1], inHeights[idx1-1201], inHeights[idx1-1200]};
++                                              int[] fouralts = {inHeights[idx1], inHeights[idx1+1], inHeights[idx1-inRowSize], inHeights[idx1-inRowSize+1]};
+                                               int numVoids = (fouralts[0]==VOID_VAL?1:0) + (fouralts[1]==VOID_VAL?1:0)
+                                                       + (fouralts[2]==VOID_VAL?1:0) + (fouralts[3]==VOID_VAL?1:0);
+                                               // if (numVoids > 0) System.out.println(numVoids + " voids found");
+                                               double altitude = 0.0;
+                                               switch (numVoids)
+                                               {
 -                                                      case 0: altitude = bilinearInterpolate(fouralts, x, y); break;
 -                                                      case 1: altitude = bilinearInterpolate(fixVoid(fouralts), x, y); break;
 -                                                      case 2:
 -                                                      case 3: altitude = averageNonVoid(fouralts); break;
 -                                                      default: altitude = VOID_VAL;
++                                              case 0: altitude = bilinearInterpolate(fouralts, x, y); break;
++                                              case 1: altitude = bilinearInterpolate(fixVoid(fouralts), x, y); break;
++                                              case 2:
++                                              case 3: altitude = averageNonVoid(fouralts); break;
++                                              default: altitude = VOID_VAL;
+                                               }
+                                               // Special case for terrain tracks, don't interpolate voids yet
+                                               if (!_normalTrack && numVoids > 0) {
+                                                       altitude = VOID_VAL;
+                                               }
+                                               if (altitude != VOID_VAL)
+                                               {
+                                                       point.setFieldValue(Field.ALTITUDE, ""+altitude, false);
+                                                       // depending on settings, this value may have been added as feet, we need to force metres
+                                                       point.getAltitude().reset(new Altitude((int)altitude, UnitSetLibrary.UNITS_METRES));
+                                                       numAltitudesFound++;
+                                               }
+                                       }
+                                       catch (ArrayIndexOutOfBoundsException obe) {
 -                                              // System.err.println("lat=" + point.getLatitude().getDouble() + ", x=" + x + ", y=" + y + ", idx=" + idx1);
++                                              System.err.println("Point not in tile? lat=" + point.getLatitude().getDouble() + ", x=" + x + ", y=" + y + ", idx=" + idx1+"\n");
+                                       }
+                               }
+                       }
+               }
+               return numAltitudesFound;
+       }
        /**
         * Perform a bilinear interpolation on the given altitude array
         * @param inAltitudes array of four altitude values on corners of square (bl, br, tl, tr)
index d3386fe9d61acd073f7e3402fdf0976db18bdaee,d289b7828fca0086eacf58a6ce74275b1471c786..ed8474ca9b1d41978e9154e9d057c1f72aa20b44
@@@ -34,10 -37,7 +37,11 @@@ import tim.prune.function.SearchOpenCac
  import tim.prune.function.browser.UrlGenerator;
  import tim.prune.function.browser.WebMapFunction;
  import tim.prune.function.search.SearchMapillaryFunction;
 +import tim.prune.function.srtm.DownloadSrtmFunction;
 +import tim.prune.function.srtm.SrtmGl1Source;
 +import tim.prune.function.srtm.Srtm3Source;
 +import tim.prune.function.srtm.SrtmViewfinderSource;
+ import tim.prune.function.settings.SaveConfig;
  
  /**
   * Class to manage the menu bar and tool bar,
@@@ -95,10 -95,8 +100,8 @@@ public class MenuManager implements Dat
        private JMenu     _browserMapMenu = null;
        private JMenuItem _routingGraphHopperItem = null;
        private JMenuItem _chartItem = null;
-       private JMenuItem _getGpsiesItem = null;
-       private JMenuItem _uploadGpsiesItem = null;
        private JMenuItem _lookupSrtmItem = null;
 -      private JMenuItem _downloadSrtmItem = null;
 +      private JMenu     _downloadSrtmMenu = null;
        private JMenuItem _nearbyWikipediaItem = null;
        private JMenuItem _nearbyOsmPoiItem = null;
        private JMenuItem _showPeakfinderItem = null;
                // SRTM
                _lookupSrtmItem = makeMenuItem(FunctionLibrary.FUNCTION_LOOKUP_SRTM, false);
                onlineMenu.add(_lookupSrtmItem);
 -              _downloadSrtmItem = makeMenuItem(FunctionLibrary.FUNCTION_DOWNLOAD_SRTM, false);
 -              onlineMenu.add(_downloadSrtmItem);
 +              // Download SRTM sub-menu
 +              _downloadSrtmMenu = new JMenu(I18nManager.getText("function.downloadsrtm"));
 +              _downloadSrtmMenu.setEnabled(false);
 +              JMenuItem downloadStrmGl1Item = makeMenuItem(new DownloadSrtmFunction(_app, new SrtmGl1Source()));
 +              _downloadSrtmMenu.add(downloadStrmGl1Item);
 +              JMenuItem downloadStrmViewfinderItem = makeMenuItem(new DownloadSrtmFunction(_app, new SrtmViewfinderSource()));
 +              _downloadSrtmMenu.add(downloadStrmViewfinderItem);
 +              JMenuItem downloadStrm3Item = makeMenuItem(new DownloadSrtmFunction(_app, new Srtm3Source()));
 +              _downloadSrtmMenu.add(downloadStrm3Item);
 +              onlineMenu.add(_downloadSrtmMenu);
  
-               // Get gpsies tracks
-               _getGpsiesItem = makeMenuItem(FunctionLibrary.FUNCTION_GET_GPSIES, false);
-               onlineMenu.add(_getGpsiesItem);
-               // Upload to gpsies
-               _uploadGpsiesItem = makeMenuItem(FunctionLibrary.FUNCTION_UPLOAD_GPSIES, false);
-               onlineMenu.add(_uploadGpsiesItem);
                onlineMenu.addSeparator();
                // browser submenu
                _browserMapMenu = new JMenu(I18nManager.getText("menu.view.browser"));
                _reverseItem.setEnabled(hasRange);
                _addTimeOffsetItem.setEnabled(hasRange);
                _addAltitudeOffsetItem.setEnabled(hasRange);
 +              _removeAltitudesItem.setEnabled(hasRange);
                _convertNamesToTimesItem.setEnabled(hasRange && _track.hasWaypoints());
                _deleteFieldValuesItem.setEnabled(hasRange);
-               _fullRangeDetailsItem.setEnabled(hasRange);
+               _viewFullDetailsItem.setEnabled(hasRange || hasPoint);
                _estimateTimeItem.setEnabled(hasRange);
                _learnEstimationParams.setEnabled(hasData && _track.hasTrackPoints() && _track.hasData(Field.TIMESTAMP)
                        && _track.hasAltitudeData());
Simple merge
Simple merge
index 35ac13bbe9f4feb91555c3f099f84c2b26d567c3,dbc4be4a59d3cff49a9dbea409a07beab1dca1cc..fe5210cfd1c21dd0b41d17d9cf88b8f8448e5780
@@@ -111,14 -112,8 +113,12 @@@ function.selectsegment=Select current s
  function.splitsegments=Split track into segments
  function.sewsegments=Sew track segments together
  function.createmarkerwaypoints=Create marker waypoints
- function.getgpsies=Get Gpsies tracks
- function.uploadgpsies=Upload track to Gpsies
  function.lookupsrtm=Get altitudes from SRTM
  function.downloadsrtm=Download SRTM tiles
 +function.downloadsrtm.SRTMGL1_v003=SRTM 1 arc-second tiles
 +function.downloadsrtm.SRTMGL1_v003.needsetup=An Earthdata account is necessary to download SRTM 1 arc-second tiles
 +function.downloadsrtm.SRTM3_v21=SRTM 3 arc-second tiles
 +function.downloadsrtm.SRTM_Viewfinder=Viewfinderpanoramas.org data
  function.getwikipedia=Get nearby Wikipedia articles
  function.searchwikipedianames=Search Wikipedia by name
  function.searchosmpois=Get nearby OSM points
@@@ -581,12 -550,10 +557,15 @@@ dialog.displaysettings.wpicon.pin=Boar
  dialog.displaysettings.size.small=Small
  dialog.displaysettings.size.medium=Medium
  dialog.displaysettings.size.large=Large
+ dialog.displaysettings.windowstyle=Window style (requires restart)
+ dialog.displaysettings.windowstyle.default=Default
+ dialog.displaysettings.windowstyle.nimbus=Nimbus
  dialog.downloadosm.desc=Confirm to download the raw OSM data for the specified area:
 +dialog.earthdataauth.intro=<p>Configure username and password to access your NASA Earthdata login account.</p><p> Create an account at <tt>https://urs.earthdata.nasa.gov/users/new</tt>.</p>
 +dialog.earthdataauth.user=Username
 +dialog.earthdataauth.password=Password
 +dialog.earthdataauth.authaccepted=Username and password accepted
 +dialog.earthdataauth.authrejected=Username and password rejected
  dialog.searchwikipedianames.search=Search for:
  dialog.weather.location=Location
  dialog.weather.update=Forecast updated