Changeset 18207 in osm for applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java
- Timestamp:
- 2009-10-18T18:11:09+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java
r17719 r18207 6 6 import java.io.File; 7 7 import javax.swing.JFileChooser; 8 import javax.swing.JOptionPane; 9 8 10 import org.openstreetmap.josm.Main; 9 11 import org.openstreetmap.josm.actions.JosmAction; 10 12 import org.openstreetmap.josm.data.projection.Lambert; 13 import org.openstreetmap.josm.data.projection.LambertCC9Zones; 11 14 import org.openstreetmap.josm.gui.layer.Layer; 12 15 … … 31 34 String filename = file.getName(); 32 35 String ext = (filename.lastIndexOf(".")==-1)?"":filename.substring(filename.lastIndexOf(".")+1,filename.length()); 33 String location = filename.substring(0, filename.lastIndexOf(".")); 34 // check the extension and its Lambert zone consistency 35 try { 36 int cacheZone = Integer.parseInt(ext) - 1; 37 if (cacheZone >=0 && cacheZone <= 3) { 38 if (Lambert.layoutZone == -1) { 39 Lambert.layoutZone = cacheZone; 40 System.out.println("Load cache \"" + filename + "\" in Lambert Zone " + (Lambert.layoutZone+1)); 41 } else if (cacheZone != Lambert.layoutZone) { 42 System.out.println("Cannot load cache \"" + filename + "\" which is not in current Lambert Zone " 43 + Lambert.layoutZone); 44 continue nextFile; 45 } else 46 System.out.println("Load cache " + filename); 36 if ((ext.length() > 2 && ext.substring(0, CacheControl.cLambertCC9Z.length()).equals(CacheControl.cLambertCC9Z) && 37 !(Main.proj instanceof LambertCC9Zones)) 38 || (ext.length() == 1) && !(Main.proj instanceof Lambert)) { 39 JOptionPane.showMessageDialog(Main.parent, tr("{0} not allowed with the current projection", filename), tr("Error"), JOptionPane.ERROR_MESSAGE); 40 continue; 41 } else { 42 String location = filename.substring(0, filename.lastIndexOf(".")); 43 if (ext.length() > 2 && ext.substring(0, CacheControl.cLambertCC9Z.length()).equals(CacheControl.cLambertCC9Z)) 44 ext = ext.substring(2); 45 // check the extension and its Lambert zone consistency 46 try { 47 int cacheZone = Integer.parseInt(ext) - 1; 48 if (cacheZone >=0 && cacheZone <= 3) { 49 if (Lambert.layoutZone == -1) { 50 Lambert.layoutZone = cacheZone; 51 System.out.println("Load cache \"" + filename + "\" in Lambert Zone " + (Lambert.layoutZone+1)); 52 } else if (cacheZone != Lambert.layoutZone) { 53 System.out.println("Cannot load cache \"" + filename + "\" which is not in current Lambert Zone " 54 + Lambert.layoutZone); 55 continue nextFile; 56 } else 57 System.out.println("Load cache " + filename); 58 } 59 } catch (NumberFormatException ex) { 60 System.out.println("Selected file \"" + filename + "\" is not a WMS cache file (invalid extension)"); 61 continue; 47 62 } 48 } catch (NumberFormatException ex) { 49 System.out.println("Selected file \"" + filename + "\" is not a WMS cache file (invalid extension)"); 50 continue; 51 } 52 // check if the selected cache is not already displayed 53 if (Main.map != null) { 54 for (Layer l : Main.map.mapView.getAllLayers()) { 55 if (l instanceof WMSLayer && l.getName().equals(location)) { 56 System.out.println("The location " + filename + " is already on screen. Cache not loaded."); 57 continue nextFile; 63 // check if the selected cache is not already displayed 64 if (Main.map != null) { 65 for (Layer l : Main.map.mapView.getAllLayers()) { 66 if (l instanceof WMSLayer && l.getName().equals(location)) { 67 System.out.println("The location " + filename + " is already on screen. Cache not loaded."); 68 continue nextFile; 69 } 58 70 } 59 71 } 72 // create layer and load cache 73 WMSLayer wmsLayer = new WMSLayer("", "", Integer.parseInt(ext)-1); 74 if (wmsLayer.getCacheControl().loadCache(file, Lambert.layoutZone)) 75 Main.main.addLayer(wmsLayer); 76 60 77 } 61 // create layer and load cache62 WMSLayer wmsLayer = new WMSLayer("", "", Integer.parseInt(ext)-1);63 if (wmsLayer.getCacheControl().loadCache(file, Lambert.layoutZone))64 Main.main.addLayer(wmsLayer);65 78 } 66 79 }
Note:
See TracChangeset
for help on using the changeset viewer.
