Changeset 18207 in osm for applications
- Timestamp:
- 2009-10-18T18:11:09+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
r17719 r18207 21 21 import javax.swing.JOptionPane; 22 22 import org.openstreetmap.josm.Main; 23 import org.openstreetmap.josm.data.projection.LambertCC9Zones; 23 24 24 25 public class CacheControl implements Runnable { 26 27 public static final String cLambertCC9Z = "CC"; 25 28 26 29 public class ObjectOutputStreamAppend extends ObjectOutputStream { … … 81 84 public boolean loadCacheIfExist() { 82 85 try { 83 File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + String.valueOf(wmsLayer.lambertZone+1)); 86 String extension = String.valueOf((wmsLayer.getLambertZone() + 1)); 87 if (Main.proj instanceof LambertCC9Zones) 88 extension = cLambertCC9Z + extension; 89 File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + extension); 84 90 if (file.exists()) { 85 91 JOptionPane pane = new JOptionPane( … … 96 102 97 103 if (reply == JOptionPane.OK_OPTION) { 98 return loadCache(file, wmsLayer. lambertZone);104 return loadCache(file, wmsLayer.getLambertZone()); 99 105 } else 100 106 file.delete(); … … 108 114 public void deleteCacheFile() { 109 115 try { 110 File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + String.valueOf(wmsLayer.lambertZone+1)); 116 String extension = String.valueOf((wmsLayer.getLambertZone() + 1)); 117 if (Main.proj instanceof LambertCC9Zones) 118 extension = cLambertCC9Z + extension; 119 File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + extension); 111 120 if (file.exists()) 112 121 file.delete(); … … 155 164 imagesLock.unlock(); 156 165 if (images != null && !images.isEmpty()) { 157 File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + String.valueOf((wmsLayer.lambertZone + 1))); 166 String extension = String.valueOf((wmsLayer.getLambertZone() + 1)); 167 if (Main.proj instanceof LambertCC9Zones) 168 extension = cLambertCC9Z + extension; 169 File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + extension); 158 170 try { 159 171 if (file.exists()) { -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java
r17089 r18207 74 74 //str += "&width=800&height=600"; // maximum allowed by wms server 75 75 str += "&width=1000&height=800"; // maximum allowed by wms server 76 //str += "&exception=application/vnd.ogc.se_inimage"; // used by normal client but not required 76 77 str += "&styles=LS3_90,LS2_90,LS1_90,PARCELLE_90,NUMERO_90,PT3_90,PT2_90,PT1_90,LIEUDIT_90"; 77 78 str += ",SUBSECTION_90"; -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
r17710 r18207 7 7 import java.awt.event.ActionListener; 8 8 import java.awt.event.KeyEvent; 9 import java.util.LinkedList;10 9 11 10 import javax.swing.JCheckBoxMenuItem; … … 75 74 * 1.3 23-Aug-2009 - improve georeferencing action cancellation 76 75 * - fixed bug of raster image loaded from cache not working on Java1.6 77 * - improve mouse click bounce detection during georeferencing process 76 * - improve mouse click bounce detection during georeferencing process 77 * 1.4 17-Oct-2009 - add support for new Lambert CC 9 Zones projection 78 78 */ 79 79 public class CadastrePlugin extends Plugin { 80 static String VERSION = "1. 3";80 static String VERSION = "1.4"; 81 81 82 82 static JMenu cadastreJMenu; … … 121 121 122 122 refreshConfiguration(); 123 refreshMenu();124 123 125 124 UploadAction.registerUploadHook(new CheckSourceUploadHook()); 126 125 } 127 126 128 public void refreshMenu() throws Exception{127 public static void refreshMenu() { 129 128 MainMenu menu = Main.main.menu; 130 129 … … 207 206 } else 208 207 System.out.println("shortcut F11 already redefined; do not change"); 208 209 refreshMenu(); 209 210 } 210 211 … … 214 215 } 215 216 216 private void setEnabledAll(boolean isEnabled) { 217 private static void setEnabledAll(boolean isEnabled) { 218 boolean isLambertCC9Zones = Main.proj instanceof LambertCC9Zones; 217 219 for (int i = 0; i < cadastreJMenu.getItemCount(); i++) { 218 220 JMenuItem item = cadastreJMenu.getItem(i); 219 221 if (item != null) 220 if (item.getText().equals(MenuActionGrab .name)||221 item.getText().equals(MenuActionGrab PlanImage.name) /*||222 if (item.getText().equals(MenuActionGrabPlanImage.name) /*|| 223 item.getText().equals(MenuActionGrab.name) || 222 224 item.getText().equals(MenuActionBoundaries.name) || 223 225 item.getText().equals(MenuActionBuildings.name)*/) { … … 239 241 setEnabledAll(false); 240 242 Lambert.layoutZone = -1; 243 LambertCC9Zones.layoutZone = -1; 241 244 } 242 245 } … … 248 251 || Main.proj.toString().equals(new UTM_20N_Guadeloupe_Ste_Anne().toString()) 249 252 || Main.proj.toString().equals(new UTM_20N_Martinique_Fort_Desaix().toString()) 250 || Main.proj.toString().equals(new GaussLaborde_Reunion().toString()); 253 || Main.proj.toString().equals(new GaussLaborde_Reunion().toString()) 254 || Main.proj.toString().equals(new LambertCC9Zones().toString()); 251 255 } 252 256 -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java
r17215 r18207 240 240 CacheControl.cacheEnabled = enableCache.isSelected(); 241 241 CadastrePlugin.refreshConfiguration(); 242 CadastrePlugin.refreshMenu(); 242 243 243 244 return false; -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSVectorImage.java
r17089 r18207 7 7 import org.openstreetmap.josm.Main; 8 8 import org.openstreetmap.josm.data.Bounds; 9 import org.openstreetmap.josm.data.projection.LambertCC9Zones; 9 10 import org.openstreetmap.josm.gui.MapView; 10 11 import org.openstreetmap.josm.gui.PleaseWaitRunnable; … … 38 39 } 39 40 } 40 if (wmsLayer.isRaster()) 41 if (wmsLayer.isRaster()) { 41 42 // set raster image commune bounding box based on current view (before adjustment) 42 43 wmsLayer.setRasterBounds(bounds); 43 else44 } else { 44 45 // set vectorized commune bounding box by opening the standard web window 45 46 wmsLayer.setCommuneBBox( grabber.getWmsInterface().retrieveCommuneBBox()); 47 // if it is the first layer, use the communeBBox as grab bbox 48 if (Main.proj instanceof LambertCC9Zones && Main.map.mapView.getAllLayers().size() == 1 ) { 49 bounds = wmsLayer.getCommuneBBox().toBounds(); 50 Main.map.mapView.zoomTo(bounds); 51 } 52 } 46 53 } 47 54 // grab new images from wms server into active layer -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/EastNorthBound.java
r15961 r18207 3 3 import java.io.Serializable; 4 4 5 import org.openstreetmap.josm.Main; 6 import org.openstreetmap.josm.data.Bounds; 5 7 import org.openstreetmap.josm.data.coor.EastNorth; 6 8 … … 28 30 return enb; 29 31 } 32 33 public Bounds toBounds() { 34 return new Bounds(Main.proj.eastNorth2latlon(min), Main.proj.eastNorth2latlon(max)); 35 } 30 36 31 37 @Override public String toString() { -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrab.java
r17181 r18207 10 10 import org.openstreetmap.josm.Main; 11 11 import org.openstreetmap.josm.actions.JosmAction; 12 import org.openstreetmap.josm.data.projection.LambertCC9Zones; 12 13 import org.openstreetmap.josm.tools.Shortcut; 13 14 … … 28 29 29 30 public void actionPerformed(ActionEvent e) { 30 if (Main.map != null) { 31 // with the new projection LambertCC9Zones, we are able to determin the zone and thus lat/lon of 32 // downloaded commune bounding box 33 if (Main.map != null || Main.proj instanceof LambertCC9Zones) { 31 34 if (CadastrePlugin.isCadastreProjection()) { 32 35 WMSLayer wmsLayer = WMSDownloadAction.getLayer(); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLambertZone.java
r13611 r18207 14 14 import org.openstreetmap.josm.actions.JosmAction; 15 15 import org.openstreetmap.josm.data.projection.Lambert; 16 import org.openstreetmap.josm.data.projection.LambertCC9Zones; 16 17 import org.openstreetmap.josm.tools.GBC; 17 18 … … 22 23 public static String name = "Change Lambert zone"; 23 24 25 public static String[] lambert4zones = { "", "1 (51.30 to 48.15 degrees)", "2 (48.15 to 45.45 degrees)", "3 (45.45 to 42.76 degrees)", "4 (Corsica)" }; 26 public static String[] lambert9zones = { "", "1 (41 to 43 degrees)", "2 (42 to 44 degrees)", 27 "3 (43 to 45 degrees)", "4 (44 to 46 degrees)", "5 (45 to 47 degrees)", 28 "6 (46 to 48 degrees)", "7 (47 to 49 degrees)", "8 (48 to 50 degrees)", 29 "9 (49 to 51 degrees)" }; 30 24 31 public MenuActionLambertZone() { 25 super(tr(name), "cadastre_small", tr("Set manually the Lambert zone (e.g. for locations between two zones)"),32 super(tr(name), "cadastre_small", tr("Set manually the Lambert zone"), 26 33 null, false); 27 34 } … … 29 36 public void actionPerformed(ActionEvent e) { 30 37 JPanel p = new JPanel(new GridBagLayout()); 31 String[] zones = { "", "1 (51.30 to 48.15 degrees)", "2 (48.15 to 45.45 degrees)", "3 (45.45 to 42.76 degrees)", "4 (Corsica)" }; 32 final JComboBox inputLambertZone = new JComboBox(zones); 38 final JComboBox inputLambertZone; 39 if (Main.proj instanceof LambertCC9Zones) 40 inputLambertZone = new JComboBox(lambert9zones); 41 else 42 inputLambertZone = new JComboBox(lambert4zones); 33 43 JLabel newLambertZone = new JLabel(tr("Zone")); 34 44 p.add(newLambertZone, GBC.std()); … … 47 57 if (inputLambertZone.getSelectedIndex() > 0) { 48 58 Lambert.layoutZone = inputLambertZone.getSelectedIndex() - 1; 59 LambertCC9Zones.layoutZone = Lambert.layoutZone; 49 60 } 50 61 } -
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 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java
r17089 r18207 16 16 import org.openstreetmap.josm.actions.JosmAction; 17 17 import org.openstreetmap.josm.data.projection.Lambert; 18 import org.openstreetmap.josm.data.projection.LambertCC9Zones; 18 19 import org.openstreetmap.josm.gui.layer.Layer; 19 20 import org.openstreetmap.josm.tools.GBC; … … 34 35 35 36 public WMSLayer addNewLayer(ArrayList<WMSLayer> existingLayers) { 36 if (Main.map == null) {37 /*if (Main.map == null) { 37 38 JOptionPane.showMessageDialog(Main.parent, 38 39 tr("Open a layer first (GPX, OSM, cache)")); 39 40 return null; 40 /* 41 } else if (existingLayers != null && existingLayers.size() > 0) { 42 JOptionPane.showMessageDialog(Main.parent, 43 tr("Select one cadastre layer first")); 44 return null;*/ 45 } else { 41 } else {*/ 46 42 String location = ""; 47 43 String codeDepartement = ""; … … 78 74 Main.pref.put("cadastrewms.location", location); 79 75 Main.pref.put("cadastrewms.codeCommune", codeCommune); 80 for (Layer l : Main.map.mapView.getAllLayers()) { 81 if (l instanceof WMSLayer && l.getName().equalsIgnoreCase(location + codeDepartement)) { 82 return null; 76 if (Main.map != null) { 77 for (Layer l : Main.map.mapView.getAllLayers()) { 78 if (l instanceof WMSLayer && l.getName().equalsIgnoreCase(location + codeDepartement)) { 79 return null; 80 } 83 81 } 84 82 } 85 83 // add the layer if it doesn't exist 86 wmsLayer = new WMSLayer(location, codeCommune, Lambert.layoutZone); 84 if (Main.proj instanceof LambertCC9Zones) 85 wmsLayer = new WMSLayer(location, codeCommune, LambertCC9Zones.layoutZone); 86 else 87 wmsLayer = new WMSLayer(location, codeCommune, Lambert.layoutZone); 87 88 Main.main.addLayer(wmsLayer); 88 89 System.out.println("Add new layer with Location:" + inputTown.getText()); … … 95 96 CadastrePlugin.cadastreGrabber.getWmsInterface().resetCookieIfNewLayer(wmsLayer.getName()); 96 97 return wmsLayer; 97 }98 //} 98 99 } 99 100 -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSDownloadAction.java
r17089 r18207 26 26 public static WMSLayer getLayer() { 27 27 // check if we already have a layer created. if not, create; if yes, reuse. 28 ArrayList<WMSLayer> existingWMSlayers = new ArrayList<WMSLayer>(); 28 29 if (Main.map != null) { 29 30 Layer activeLayer = Main.map.mapView.getActiveLayer(); 30 31 if (activeLayer instanceof WMSLayer) 31 32 return (WMSLayer) activeLayer; 32 ArrayList<WMSLayer> existingWMSlayers = new ArrayList<WMSLayer>();33 33 for (Layer l : Main.map.mapView.getAllLayers()) { 34 34 if (l instanceof WMSLayer) { … … 42 42 JOptionPane.showMessageDialog(Main.parent, 43 43 tr("More than one WMS layer present\nSelect one of them first, then retry")); 44 } else { 45 return new MenuActionNewLocation().addNewLayer(existingWMSlayers); 44 46 } 45 47 return null; -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
r17719 r18207 19 19 import javax.swing.Icon; 20 20 import javax.swing.ImageIcon; 21 import javax.swing.JDialog; 21 22 import javax.swing.JMenuItem; 22 23 import javax.swing.JOptionPane; … … 25 26 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 26 27 import org.openstreetmap.josm.data.projection.Lambert; 28 import org.openstreetmap.josm.data.projection.LambertCC9Zones; 27 29 import org.openstreetmap.josm.data.Bounds; 28 30 import org.openstreetmap.josm.gui.MapView; … … 42 44 Component[] component = null; 43 45 44 p ublicint lambertZone = -1;46 private int lambertZone = -1; 45 47 46 48 protected static final Icon icon = new ImageIcon(Toolkit.getDefaultToolkit().createImage( … … 77 79 this.location = location; 78 80 this.codeCommune = codeCommune; 79 this.lambertZone = Lambert.layoutZone;81 this.lambertZone = lambertZone; 80 82 // enable auto-sourcing option 81 83 CadastrePlugin.pluginUsed = true; … … 380 382 } 381 383 this.communeBBox = (EastNorthBound) ois.readObject(); 382 if (this.lambertZone != currentLambertZone ) {384 if (this.lambertZone != currentLambertZone && currentLambertZone != -1) { 383 385 JOptionPane.showMessageDialog(Main.parent, tr("Lambert zone {0} in cache "+ 384 386 "incompatible with current Lambert zone {1}", … … 484 486 public void setCommuneBBox(EastNorthBound entireCommune) { 485 487 this.communeBBox = entireCommune; 488 if (Main.proj instanceof LambertCC9Zones) 489 setLambertCC9Zone(communeBBox.min.north()); 486 490 } 487 491 … … 493 497 } 494 498 499 public int getLambertZone() { 500 return lambertZone; 501 } 502 503 public void setLambertCC9Zone(double north) { 504 int lambertZone = LambertCC9Zones.north2ZoneNumber(north); 505 this.lambertZone = lambertZone; 506 if (LambertCC9Zones.layoutZone != lambertZone) { 507 String currentZone = MenuActionLambertZone.lambert9zones[LambertCC9Zones.layoutZone+1]; 508 String destZone = MenuActionLambertZone.lambert9zones[lambertZone+1]; 509 if (Main.map.mapView.getAllLayers().size() == 1) { 510 /* Enable this code below when JOSM will have a proper support of dynamic projection change 511 * 512 System.out.println("close all layers and change current Lambert zone from "+LambertCC9Zones.layoutZone+" to "+lambertZone); 513 Bounds b = null; 514 if (Main.map != null && Main.map.mapView != null) 515 b = Main.map.mapView.getRealBounds(); 516 LambertCC9Zones.layoutZone = lambertZone; 517 Main.map.mapView.zoomTo(b); 518 */ 519 } else { 520 JOptionPane.showMessageDialog(Main.parent, tr("Current layer is in Lambert CC9 Zone \"{0}\"\n"+ 521 "where the commune is in Lambert CC9 Zone \"{1}\".\n"+ 522 "Upload your changes, close all layers and change\n"+ 523 "manually the Lambert zone from the Cadastre menu" 524 , currentZone, destZone)); 525 } 526 } 527 } 528 495 529 }
Note:
See TracChangeset
for help on using the changeset viewer.