Changeset 18720 in osm
- Timestamp:
- 2009-11-21T00:18:50+01:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
r18544 r18720 22 22 import org.openstreetmap.josm.Main; 23 23 import org.openstreetmap.josm.data.projection.LambertCC9Zones; 24 import org.openstreetmap.josm.data.projection.UTM_20N_France_DOM; 24 25 25 26 public class CacheControl implements Runnable { 26 27 27 28 public static final String cLambertCC9Z = "CC"; 29 30 public static final String cUTM20N = "UTM"; 28 31 29 32 public class ObjectOutputStreamAppend extends ObjectOutputStream { … … 87 90 if (Main.proj instanceof LambertCC9Zones) 88 91 extension = cLambertCC9Z + extension; 92 else if (Main.proj instanceof UTM_20N_France_DOM) 93 extension = cUTM20N + extension; 89 94 File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + extension); 90 95 if (file.exists()) { … … 167 172 if (Main.proj instanceof LambertCC9Zones) 168 173 extension = cLambertCC9Z + extension; 174 else if (Main.proj instanceof UTM_20N_France_DOM) 175 extension = cUTM20N + extension; 169 176 File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + extension); 170 177 try { -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
r18547 r18720 25 25 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 26 26 import org.openstreetmap.josm.plugins.Plugin; 27 import org.openstreetmap.josm.data.coor.EastNorth; 28 import org.openstreetmap.josm.data.coor.LatLon; 27 29 import org.openstreetmap.josm.data.projection.*; 28 30 … … 129 131 130 132 UploadAction.registerUploadHook(new CheckSourceUploadHook()); 133 134 Lambert proj = new Lambert(); 135 LatLon ll = new LatLon(48.559902360278954, 7.75309953770033); 136 EastNorth ea = proj.latlon2eastNorth(ll); 137 System.out.println(ea); 131 138 } 132 139 … … 154 161 155 162 JMenuItem menuResetCookie = new JMenuItem(new MenuActionResetCookie()); 156 JMenuItem menuLambertZone = new JMenuItem(new MenuActionLambertZone());163 //JMenuItem menuLambertZone = new JMenuItem(new MenuActionLambertZone()); 157 164 JMenuItem menuLoadFromCache = new JMenuItem(new MenuActionLoadFromCache()); 165 // temporary disabled: 158 166 //JMenuItem menuActionBoundaries = new JMenuItem(new MenuActionBoundaries()); 159 167 //JMenuItem menuActionBuildings = new JMenuItem(new MenuActionBuildings()); … … 164 172 cadastreJMenu.add(menuSource); 165 173 cadastreJMenu.add(menuResetCookie); 166 cadastreJMenu.add(menuLambertZone);174 //cadastreJMenu.add(menuLambertZone); 167 175 cadastreJMenu.add(menuLoadFromCache); 168 176 // all SVG features disabled until official WMS is released … … 229 237 item.getText().equals(MenuActionBuildings.name)*/) { 230 238 item.setEnabled(isEnabled); 231 } else if (item.getText().equals(MenuActionLambertZone.name)) {232 item.setEnabled(!isEnabled);233 239 } 234 240 } … … 244 250 } else if (oldFrame != null && newFrame == null) { 245 251 setEnabledAll(false); 246 Lambert.layoutZone = -1;247 LambertCC9Zones.layoutZone = -1;252 //Lambert.layoutZone = -1; 253 //LambertCC9Zones.layoutZone = -1; 248 254 } 249 255 } … … 251 257 252 258 public static boolean isCadastreProjection() { 253 return Main.proj.toString().equals(new Lambert().toString()) 254 || Main.proj.toString().equals(new UTM_20N_Guadeloupe_Fort_Marigot().toString()) 255 || Main.proj.toString().equals(new UTM_20N_Guadeloupe_Ste_Anne().toString()) 256 || Main.proj.toString().equals(new UTM_20N_Martinique_Fort_Desaix().toString()) 259 return Main.proj.toString().equals(new Lambert().toString()) 260 || Main.proj.toString().equals(new UTM_20N_France_DOM().toString()) 257 261 || Main.proj.toString().equals(new GaussLaborde_Reunion().toString()) 258 262 || Main.proj.toString().equals(new LambertCC9Zones().toString()); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java
r18544 r18720 13 13 import org.openstreetmap.josm.data.projection.Lambert; 14 14 import org.openstreetmap.josm.data.projection.LambertCC9Zones; 15 import org.openstreetmap.josm.data.projection.UTM_20N_France_DOM; 15 16 import org.openstreetmap.josm.gui.layer.Layer; 16 17 … … 30 31 31 32 File[] files = fc.getSelectedFiles(); 33 int layoutZone = getCurrentProjZone(); 32 34 nextFile: 33 35 for (File file : files) { … … 35 37 String filename = file.getName(); 36 38 String ext = (filename.lastIndexOf(".")==-1)?"":filename.substring(filename.lastIndexOf(".")+1,filename.length()); 37 if ((ext.length() > 2&& ext.substring(0, CacheControl.cLambertCC9Z.length()).equals(CacheControl.cLambertCC9Z) &&39 if ((ext.length() == 3 && ext.substring(0, CacheControl.cLambertCC9Z.length()).equals(CacheControl.cLambertCC9Z) && 38 40 !(Main.proj instanceof LambertCC9Zones)) 41 || (ext.length() == 4 && ext.substring(0, CacheControl.cUTM20N.length()).equals(CacheControl.cUTM20N) && 42 !(Main.proj instanceof UTM_20N_France_DOM)) 39 43 || (ext.length() == 1) && !(Main.proj instanceof Lambert)) { 40 44 JOptionPane.showMessageDialog(Main.parent, tr("{0} not allowed with the current projection", filename), tr("Error"), JOptionPane.ERROR_MESSAGE); … … 42 46 } else { 43 47 String location = filename.substring(0, filename.lastIndexOf(".")); 44 if (ext.length() > 2&& ext.substring(0, CacheControl.cLambertCC9Z.length()).equals(CacheControl.cLambertCC9Z))48 if (ext.length() == 3 && ext.substring(0, CacheControl.cLambertCC9Z.length()).equals(CacheControl.cLambertCC9Z)) 45 49 ext = ext.substring(2); 46 // check the extension and its Lambert zone consistency 50 else if (ext.length() == 4 && ext.substring(0, CacheControl.cUTM20N.length()).equals(CacheControl.cUTM20N)) 51 ext = ext.substring(3); 52 // check the extension and its compatibility with current projection 47 53 try { 48 54 int cacheZone = Integer.parseInt(ext) - 1; 49 if (cacheZone >=0 && cacheZone <= 3) { 50 if (Lambert.layoutZone == -1) { 51 Lambert.layoutZone = cacheZone; 52 System.out.println("Load cache \"" + filename + "\" in Lambert Zone " + (Lambert.layoutZone+1)); 53 } else if (cacheZone != Lambert.layoutZone) { 54 System.out.println("Cannot load cache \"" + filename + "\" which is not in current Lambert Zone " 55 + Lambert.layoutZone); 55 if (cacheZone >=0 && cacheZone <= 9) { 56 if (cacheZone != layoutZone) { 57 JOptionPane.showMessageDialog(Main.parent, tr("Cannot load cache {0} which is not compatible with current projection zone", filename), tr("Error"), JOptionPane.ERROR_MESSAGE); 56 58 continue nextFile; 57 59 } else … … 59 61 } 60 62 } catch (NumberFormatException ex) { 61 System.out.println("Selected file \"" + filename + "\" is not a WMS cache file (invalid extension)");62 continue ;63 JOptionPane.showMessageDialog(Main.parent, tr("Selected file {0} is not a cache file from this plugin (invalid extension)", filename), tr("Error"), JOptionPane.ERROR_MESSAGE); 64 continue nextFile; 63 65 } 64 66 // check if the selected cache is not already displayed … … 66 68 for (Layer l : Main.map.mapView.getAllLayers()) { 67 69 if (l instanceof WMSLayer && l.getName().equals(location)) { 68 System.out.println("The location " + filename + " is already on screen. Cache not loaded.");70 JOptionPane.showMessageDialog(Main.parent, tr("The location {0} is already on screen. Cache not loaded.", filename), tr("Error"), JOptionPane.ERROR_MESSAGE); 69 71 continue nextFile; 70 72 } … … 73 75 // create layer and load cache 74 76 WMSLayer wmsLayer = new WMSLayer("", "", Integer.parseInt(ext)-1); 75 if (wmsLayer.getCacheControl().loadCache(file, Lambert.layoutZone))77 if (wmsLayer.getCacheControl().loadCache(file, layoutZone)) 76 78 Main.main.addLayer(wmsLayer); 77 79 … … 85 87 JFileChooser fc = new JFileChooser(new File(CadastrePlugin.cacheDir)); 86 88 fc.setMultiSelectionEnabled(true); 87 if (Lambert.layoutZone != -1) 88 fc.addChoosableFileFilter(CacheFileFilter.filters[Lambert.layoutZone]); 89 int layoutZone = new MenuActionLoadFromCache().getCurrentProjZone(); 90 if (layoutZone != -1) { 91 if (Main.proj instanceof Lambert) 92 fc.addChoosableFileFilter(CacheFileLambert4ZoneFilter.filters[layoutZone]); 93 else if (Main.proj instanceof LambertCC9Zones) 94 fc.addChoosableFileFilter(CacheFileLambert9ZoneFilter.filters[layoutZone]); 95 else if (Main.proj instanceof UTM_20N_France_DOM) 96 fc.addChoosableFileFilter(CacheFileUTM20NFilter.filters[layoutZone]); 97 } 89 98 fc.setAcceptAllFileFilterUsed(false); 90 99 … … 96 105 } 97 106 107 private int getCurrentProjZone() { 108 int zone = -1; 109 if (Main.proj instanceof LambertCC9Zones) 110 zone = ((LambertCC9Zones)Main.proj).getLayoutZone(); 111 else if (Main.proj instanceof Lambert) 112 zone = ((Lambert)Main.proj).getLayoutZone(); 113 else if (Main.proj instanceof UTM_20N_France_DOM) 114 zone = ((UTM_20N_France_DOM)Main.proj).getCurrentGeodesic(); 115 return zone; 116 } 98 117 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java
r18544 r18720 17 17 import org.openstreetmap.josm.data.projection.Lambert; 18 18 import org.openstreetmap.josm.data.projection.LambertCC9Zones; 19 import org.openstreetmap.josm.data.projection.UTM_20N_France_DOM; 19 20 import org.openstreetmap.josm.gui.layer.Layer; 20 21 import org.openstreetmap.josm.tools.GBC; … … 81 82 } 82 83 // add the layer if it doesn't exist 84 int zone = -1; 83 85 if (Main.proj instanceof LambertCC9Zones) 84 wmsLayer = new WMSLayer(location, codeCommune, LambertCC9Zones.layoutZone); 85 else 86 wmsLayer = new WMSLayer(location, codeCommune, Lambert.layoutZone); 86 zone = ((LambertCC9Zones)Main.proj).getLayoutZone(); 87 else if (Main.proj instanceof Lambert) 88 zone = ((Lambert)Main.proj).getLayoutZone(); 89 else if (Main.proj instanceof UTM_20N_France_DOM) 90 zone = ((UTM_20N_France_DOM)Main.proj).getCurrentGeodesic(); 91 wmsLayer = new WMSLayer(location, codeCommune, zone); 87 92 Main.main.addLayer(wmsLayer); 88 93 System.out.println("Add new layer with Location:" + inputTown.getText()); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
r18595 r18720 29 29 import org.openstreetmap.josm.data.coor.EastNorth; 30 30 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 31 import org.openstreetmap.josm.data.projection.LambertCC9Zones;32 31 import org.openstreetmap.josm.gui.MapView; 33 32 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; … … 517 516 public void setCommuneBBox(EastNorthBound entireCommune) { 518 517 this.communeBBox = entireCommune; 519 if (Main.proj instanceof LambertCC9Zones)520 setLambertCC9Zone(communeBBox.min.north());518 // if (Main.proj instanceof LambertCC9Zones) 519 // setLambertCC9Zone(communeBBox.min.north()); 521 520 } 522 521 … … 532 531 } 533 532 534 public void setLambertCC9Zone(double north) {535 int lambertZone = LambertCC9Zones.north2ZoneNumber(north);536 this.lambertZone = lambertZone;537 if (LambertCC9Zones.layoutZone!= lambertZone) {538 String currentZone = MenuActionLambertZone.lambert9zones[LambertCC9Zones.layoutZone+1];539 String destZone = MenuActionLambertZone.lambert9zones[lambertZone+1];540 if (Main.map.mapView.getAllLayers().size() == 1) {541 /* Enable this code below when JOSM will have a proper support of dynamic projection change542 *543 System.out.println("close all layers and change current Lambert zone from "+LambertCC9Zones.layoutZone+" to "+lambertZone);544 Bounds b = null;545 if (Main.map != null && Main.map.mapView != null)546 b = Main.map.mapView.getRealBounds();547 LambertCC9Zones.layoutZone = lambertZone;548 Main.map.mapView.zoomTo(b);549 */550 } else {551 JOptionPane.showMessageDialog(Main.parent, tr("Current layer is in Lambert CC9 Zone \"{0}\"\n"+552 "where the commune is in Lambert CC9 Zone \"{1}\".\n"+553 "Upload your changes, close all layers and change\n"+554 "manually the Lambert zone from the Cadastre menu"555 , currentZone, destZone));556 }557 }558 }533 // public void setLambertCC9Zone(double north) { 534 // int lambertZone = LambertCC9Zones.north2ZoneNumber(north); 535 // this.lambertZone = lambertZone; 536 // if (((LambertCC9Zones)Main.proj).getLayoutZone() != lambertZone) { 537 // String currentZone = MenuActionLambertZone.lambert9zones[((LambertCC9Zones)Main.proj).getLayoutZone()+1]; 538 // String destZone = MenuActionLambertZone.lambert9zones[lambertZone+1]; 539 // if (Main.map.mapView.getAllLayers().size() == 1) { 540 // /* Enable this code below when JOSM will have a proper support of dynamic projection change 541 // * 542 // System.out.println("close all layers and change current Lambert zone from "+LambertCC9Zones.layoutZone+" to "+lambertZone); 543 // Bounds b = null; 544 // if (Main.map != null && Main.map.mapView != null) 545 // b = Main.map.mapView.getRealBounds(); 546 // LambertCC9Zones.layoutZone = lambertZone; 547 // Main.map.mapView.zoomTo(b); 548 // */ 549 // } else { 550 // JOptionPane.showMessageDialog(Main.parent, tr("Current layer is in Lambert CC9 Zone \"{0}\"\n"+ 551 // "where the commune is in Lambert CC9 Zone \"{1}\".\n"+ 552 // "Upload your changes, close all layers and change\n"+ 553 // "manually the Lambert zone from the Cadastre menu" 554 // , currentZone, destZone)); 555 // } 556 // } 557 // } 559 558 560 559 public EastNorth getRasterCenter() {
Note:
See TracChangeset
for help on using the changeset viewer.