Changeset 28887 in osm for applications/editors/josm/plugins/cadastre-fr
- Timestamp:
- 2012-11-02T23:44:09+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/build.xml
r27981 r28887 32 32 <property name="ant.build.javac.target" value="1.5"/> 33 33 <property name="commit.message" value="Changed constructor for Plugin"/> 34 <property name="plugin.main.version" value="5 035"/>34 <property name="plugin.main.version" value="5553"/> 35 35 <target name="init"> 36 36 <mkdir dir="${plugin.build.dir}"/> -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
r26835 r28887 21 21 import javax.swing.JOptionPane; 22 22 import org.openstreetmap.josm.Main; 23 import org.openstreetmap.josm.data.projection.LambertCC9Zones;24 import org.openstreetmap.josm.data.projection.UTM_France_DOM;25 23 26 24 public class CacheControl implements Runnable { … … 217 215 private String WMSFileExtension() { 218 216 String ext = String.valueOf((wmsLayer.getLambertZone() + 1)); 219 if ( Main.getProjection() instanceof LambertCC9Zones)217 if (CadastrePlugin.isLambert_cc9()) 220 218 ext = cLambertCC9Z + ext; 221 else if ( Main.getProjection() instanceof UTM_France_DOM)219 else if (CadastrePlugin.isUtm_france_dom()) 222 220 ext = cUTM20N + ext; 223 221 return ext; -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
r27881 r28887 10 10 import java.awt.event.KeyEvent; 11 11 import java.io.File; 12 import java.util.Arrays; 13 import java.util.HashMap; 14 import java.util.Map; 12 15 13 16 import javax.swing.JCheckBoxMenuItem; … … 21 24 import org.openstreetmap.josm.actions.JosmAction; 22 25 import org.openstreetmap.josm.actions.UploadAction; 26 import org.openstreetmap.josm.data.projection.AbstractProjection; 27 import org.openstreetmap.josm.data.projection.Projection; 23 28 import org.openstreetmap.josm.gui.MainMenu; 24 29 import org.openstreetmap.josm.gui.MapFrame; … … 26 31 import org.openstreetmap.josm.gui.layer.Layer; 27 32 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 33 import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference; 28 34 import org.openstreetmap.josm.plugins.Plugin; 29 35 import org.openstreetmap.josm.plugins.PluginInformation; 30 import org.openstreetmap.josm.data.projection.*;31 36 32 37 /** … … 370 375 } 371 376 377 public static boolean isLambert() { 378 String code = Main.getProjection().toCode(); 379 return Arrays.asList(ProjectionPreference.lambert.allCodes()).contains(code); 380 } 381 382 public static boolean isUtm_france_dom() { 383 String code = Main.getProjection().toCode(); 384 return Arrays.asList(ProjectionPreference.utm_france_dom.allCodes()).contains(code); 385 } 386 387 public static boolean isLambert_cc9() { 388 String code = Main.getProjection().toCode(); 389 return Arrays.asList(ProjectionPreference.lambert_cc9.allCodes()).contains(code); 390 } 391 372 392 public static boolean isCadastreProjection() { 373 return Main.getProjection().toString().equals(new Lambert().toString()) 374 || Main.getProjection().toString().equals(new UTM_France_DOM().toString()) 375 || Main.getProjection().toString().equals(new LambertCC9Zones().toString()); 393 return isLambert() || isUtm_france_dom() || isLambert_cc9(); 394 } 395 396 public static int getCadastreProjectionLayoutZone() { 397 int zone = -1; 398 Projection proj = Main.getProjection(); 399 if (proj instanceof AbstractProjection) { 400 Integer code = ((AbstractProjection) proj).getEpsgCode(); 401 if (code != null) { 402 if (code >= 3942 && code <= 3950) { // LambertCC9Zones 403 zone = code - 3942; 404 } else if (code >= 27561 && 27564 <= code) { // Lambert 405 zone = code - 27561; 406 } else { // UTM_France_DOM 407 Map<Integer, Integer> utmfr = new HashMap<Integer, Integer>(); 408 utmfr.put(2969, 0); 409 utmfr.put(2970, 1); 410 utmfr.put(2973, 2); 411 utmfr.put(2975, 3); 412 utmfr.put(2972, 4); 413 if (utmfr.containsKey(code)) { 414 zone = utmfr.get(code); 415 } 416 } 417 } 418 } 419 return zone; 376 420 } 377 421 -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java
r27906 r28887 12 12 import org.openstreetmap.josm.Main; 13 13 import org.openstreetmap.josm.actions.JosmAction; 14 import org.openstreetmap.josm.data.projection.Lambert;15 import org.openstreetmap.josm.data.projection.LambertCC9Zones;16 import org.openstreetmap.josm.data.projection.UTM_France_DOM;17 14 import org.openstreetmap.josm.gui.layer.Layer; 18 15 … … 32 29 33 30 File[] files = fc.getSelectedFiles(); 34 int layoutZone = getCurrentProjZone();31 int layoutZone = CadastrePlugin.getCadastreProjectionLayoutZone(); 35 32 nextFile: 36 33 for (File file : files) { … … 39 36 String ext = (filename.lastIndexOf(".")==-1)?"":filename.substring(filename.lastIndexOf(".")+1,filename.length()); 40 37 if ((ext.length() == 3 && ext.substring(0, CacheControl.cLambertCC9Z.length()).equals(CacheControl.cLambertCC9Z) && 41 !( Main.getProjection() instanceof LambertCC9Zones))38 !(CadastrePlugin.isLambert_cc9())) 42 39 || (ext.length() == 4 && ext.substring(0, CacheControl.cUTM20N.length()).equals(CacheControl.cUTM20N) && 43 !( Main.getProjection() instanceof UTM_France_DOM))44 || (ext.length() == 1) && !( Main.getProjection() instanceof Lambert)) {40 !(CadastrePlugin.isUtm_france_dom())) 41 || (ext.length() == 1) && !(CadastrePlugin.isLambert())) { 45 42 JOptionPane.showMessageDialog(Main.parent, tr("{0} not allowed with the current projection", filename), tr("Error"), JOptionPane.ERROR_MESSAGE); 46 43 continue; … … 88 85 JFileChooser fc = new JFileChooser(new File(CadastrePlugin.cacheDir)); 89 86 fc.setMultiSelectionEnabled(true); 90 int layoutZone = new MenuActionLoadFromCache().getCurrentProjZone();87 int layoutZone = CadastrePlugin.getCadastreProjectionLayoutZone(); 91 88 if (layoutZone != -1) { 92 if ( Main.getProjection() instanceof Lambert)89 if (CadastrePlugin.isLambert()) 93 90 fc.addChoosableFileFilter(CacheFileLambert4ZoneFilter.filters[layoutZone]); 94 else if ( Main.getProjection() instanceof LambertCC9Zones)91 else if (CadastrePlugin.isLambert_cc9()) 95 92 fc.addChoosableFileFilter(CacheFileLambert9ZoneFilter.filters[layoutZone]); 96 else if ( Main.getProjection() instanceof UTM_France_DOM)93 else if (CadastrePlugin.isUtm_france_dom()) 97 94 fc.addChoosableFileFilter(CacheFileUTM20NFilter.filters[layoutZone]); 98 95 } … … 106 103 } 107 104 108 private int getCurrentProjZone() {109 int zone = -1;110 if (Main.getProjection() instanceof LambertCC9Zones)111 zone = ((LambertCC9Zones)Main.getProjection()).getLayoutZone();112 else if (Main.getProjection() instanceof Lambert)113 zone = ((Lambert)Main.getProjection()).getLayoutZone();114 else if (Main.getProjection() instanceof UTM_France_DOM)115 zone = ((UTM_France_DOM)Main.getProjection()).getCurrentGeodesic();116 return zone;117 }118 105 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java
r27906 r28887 16 16 import org.openstreetmap.josm.Main; 17 17 import org.openstreetmap.josm.actions.JosmAction; 18 import org.openstreetmap.josm.data.projection.Lambert;19 import org.openstreetmap.josm.data.projection.LambertCC9Zones;20 import org.openstreetmap.josm.data.projection.UTM_France_DOM;21 18 import org.openstreetmap.josm.gui.layer.Layer; 22 19 import org.openstreetmap.josm.tools.GBC; … … 115 112 } 116 113 // add the layer if it doesn't exist 117 int zone = -1; 118 if (Main.getProjection() instanceof LambertCC9Zones) 119 zone = ((LambertCC9Zones)Main.getProjection()).getLayoutZone(); 120 else if (Main.getProjection() instanceof Lambert) 121 zone = ((Lambert)Main.getProjection()).getLayoutZone(); 122 else if (Main.getProjection() instanceof UTM_France_DOM) 123 zone = ((UTM_France_DOM)Main.getProjection()).getCurrentGeodesic(); 114 int zone = CadastrePlugin.getCadastreProjectionLayoutZone(); 124 115 wmsLayer = new WMSLayer(location, codeCommune, zone); 125 116 wmsLayer.setDepartement(codeDepartement);
Note:
See TracChangeset
for help on using the changeset viewer.