X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Ffunction%2Fsrtm%2FLookupSrtmFunction.java;h=22ee8311a11c91222f58475dfdd2df6e0f750ca2;hb=649c5da6ee1bbc590699e11a92316ece2ea8512d;hp=30183d2d6cd13c0e780a018bc4ca6dd1ba2444b5;hpb=c0387c124840c9407e040600fda88f3c3e8f6aa6;p=GpsPrune.git diff --git a/tim/prune/function/srtm/LookupSrtmFunction.java b/tim/prune/function/srtm/LookupSrtmFunction.java index 30183d2..22ee831 100644 --- a/tim/prune/function/srtm/LookupSrtmFunction.java +++ b/tim/prune/function/srtm/LookupSrtmFunction.java @@ -15,6 +15,7 @@ import java.util.zip.ZipInputStream; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JProgressBar; @@ -48,6 +49,7 @@ public class LookupSrtmFunction extends GenericFunction implements Runnable /** Altitude below which is considered void */ private static final int VOID_VAL = -32768; + /** * Constructor * @param inApp App object @@ -102,6 +104,7 @@ public class LookupSrtmFunction extends GenericFunction implements Runnable cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { _cancelled = true; + _dialog.dispose(); } }); buttonPanel.add(cancelButton); @@ -114,14 +117,40 @@ public class LookupSrtmFunction extends GenericFunction implements Runnable */ public void run() { - _dialog.setVisible(true); // Compile list of tiles to get Track track = _app.getTrackInfo().getTrack(); ArrayList tileList = new ArrayList(); + boolean hasZeroAltitudePoints = false; + boolean hasNonZeroAltitudePoints = false; + // First, loop to see what kind of points we have for (int i=0; i inTileList, boolean inOverwriteZeros) + { + Track track = _app.getTrackInfo().getTrack(); UndoLookupSrtm undo = new UndoLookupSrtm(_app.getTrackInfo()); int numAltitudesFound = 0; // Update progress bar - _progressBar.setMaximum(tileList.size()); - _progressBar.setIndeterminate(tileList.size() <= 1); + _progressBar.setMaximum(inTileList.size()); + _progressBar.setIndeterminate(inTileList.size() <= 1); _progressBar.setValue(0); + String errorMessage = null; // Get urls for each tile - URL[] urls = TileFinder.getUrls(tileList); - for (int t=0; t 0) { // Inform app including undo information @@ -221,8 +263,14 @@ public class LookupSrtmFunction extends GenericFunction implements Runnable _app.completeFunction(undo, I18nManager.getText("confirm.lookupsrtm1") + " " + numAltitudesFound + " " + I18nManager.getText("confirm.lookupsrtm2")); } + else if (errorMessage != null) { + _app.showErrorMessageNoLookup(getNameKey(), errorMessage); + } + else if (inTileList.size() > 0) { + _app.showErrorMessage(getNameKey(), "error.lookupsrtm.nonefound"); + } else { - _app.showErrorMessage(getNameKey(), "error.lookupsrtm.none"); + _app.showErrorMessage(getNameKey(), "error.lookupsrtm.nonerequired"); } }