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

update to latest josm (projection)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.