Changeset 28887 in osm


Ignore:
Timestamp:
2012-11-02T23:44:09+01:00 (12 years ago)
Author:
bastik
Message:

update to latest josm (projection)

Location:
applications/editors/josm/plugins/cadastre-fr
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/build.xml

    r27981 r28887  
    3232    <property name="ant.build.javac.target" value="1.5"/>
    3333    <property name="commit.message" value="Changed constructor for Plugin"/>
    34     <property name="plugin.main.version" value="5035"/>
     34    <property name="plugin.main.version" value="5553"/>
    3535    <target name="init">
    3636        <mkdir dir="${plugin.build.dir}"/>
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java

    r26835 r28887  
    2121import javax.swing.JOptionPane;
    2222import org.openstreetmap.josm.Main;
    23 import org.openstreetmap.josm.data.projection.LambertCC9Zones;
    24 import org.openstreetmap.josm.data.projection.UTM_France_DOM;
    2523
    2624public class CacheControl implements Runnable {
     
    217215    private String WMSFileExtension() {
    218216        String ext = String.valueOf((wmsLayer.getLambertZone() + 1));
    219         if (Main.getProjection() instanceof LambertCC9Zones)
     217        if (CadastrePlugin.isLambert_cc9())
    220218            ext = cLambertCC9Z + ext;
    221         else if (Main.getProjection() instanceof UTM_France_DOM)
     219        else if (CadastrePlugin.isUtm_france_dom())
    222220            ext = cUTM20N + ext;
    223221        return ext;
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java

    r27881 r28887  
    1010import java.awt.event.KeyEvent;
    1111import java.io.File;
     12import java.util.Arrays;
     13import java.util.HashMap;
     14import java.util.Map;
    1215
    1316import javax.swing.JCheckBoxMenuItem;
     
    2124import org.openstreetmap.josm.actions.JosmAction;
    2225import org.openstreetmap.josm.actions.UploadAction;
     26import org.openstreetmap.josm.data.projection.AbstractProjection;
     27import org.openstreetmap.josm.data.projection.Projection;
    2328import org.openstreetmap.josm.gui.MainMenu;
    2429import org.openstreetmap.josm.gui.MapFrame;
     
    2631import org.openstreetmap.josm.gui.layer.Layer;
    2732import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
     33import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference;
    2834import org.openstreetmap.josm.plugins.Plugin;
    2935import org.openstreetmap.josm.plugins.PluginInformation;
    30 import org.openstreetmap.josm.data.projection.*;
    3136
    3237/**
     
    370375    }
    371376
     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
    372392    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;
    376420    }
    377421
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java

    r27906 r28887  
    1212import org.openstreetmap.josm.Main;
    1313import 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;
    1714import org.openstreetmap.josm.gui.layer.Layer;
    1815
     
    3229
    3330        File[] files = fc.getSelectedFiles();
    34         int layoutZone = getCurrentProjZone();
     31        int layoutZone = CadastrePlugin.getCadastreProjectionLayoutZone();
    3532        nextFile:
    3633        for (File file : files) {
     
    3936                String ext = (filename.lastIndexOf(".")==-1)?"":filename.substring(filename.lastIndexOf(".")+1,filename.length());
    4037                if ((ext.length() == 3 && ext.substring(0, CacheControl.cLambertCC9Z.length()).equals(CacheControl.cLambertCC9Z) &&
    41                     !(Main.getProjection() instanceof LambertCC9Zones))
     38                    !(CadastrePlugin.isLambert_cc9()))
    4239                    || (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())) {
    4542                        JOptionPane.showMessageDialog(Main.parent, tr("{0} not allowed with the current projection", filename), tr("Error"), JOptionPane.ERROR_MESSAGE);
    4643                        continue;
     
    8885        JFileChooser fc = new JFileChooser(new File(CadastrePlugin.cacheDir));
    8986        fc.setMultiSelectionEnabled(true);
    90         int layoutZone = new MenuActionLoadFromCache().getCurrentProjZone();
     87        int layoutZone = CadastrePlugin.getCadastreProjectionLayoutZone();
    9188        if (layoutZone != -1) {
    92             if (Main.getProjection() instanceof Lambert)
     89            if (CadastrePlugin.isLambert())
    9390                fc.addChoosableFileFilter(CacheFileLambert4ZoneFilter.filters[layoutZone]);
    94             else if (Main.getProjection() instanceof LambertCC9Zones)
     91            else if (CadastrePlugin.isLambert_cc9())
    9592                fc.addChoosableFileFilter(CacheFileLambert9ZoneFilter.filters[layoutZone]);
    96             else if (Main.getProjection() instanceof UTM_France_DOM)
     93            else if (CadastrePlugin.isUtm_france_dom())
    9794                fc.addChoosableFileFilter(CacheFileUTM20NFilter.filters[layoutZone]);
    9895        }
     
    106103    }
    107104
    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     }
    118105}
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java

    r27906 r28887  
    1616import org.openstreetmap.josm.Main;
    1717import 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;
    2118import org.openstreetmap.josm.gui.layer.Layer;
    2219import org.openstreetmap.josm.tools.GBC;
     
    115112            }
    116113            // 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();
    124115            wmsLayer = new WMSLayer(location, codeCommune, zone);
    125116            wmsLayer.setDepartement(codeDepartement);
Note: See TracChangeset for help on using the changeset viewer.