Changeset 2491 in josm


Ignore:
Timestamp:
Nov 21, 2009 3:48:35 PM (4 years ago)
Author:
stoecker
Message:

fix for subprojections

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/projection/ProjectionSubPrefs.java

    r2272 r2491  
    3737    /** 
    3838     * Will be called if the preference dialog is dismissed. 
     39     * argument may be null to reset everything 
    3940     */ 
    4041    public void setPreferences(Collection<String> args); 
  • trunk/src/org/openstreetmap/josm/data/projection/UTM.java

    r2272 r2491  
    2626public class UTM implements Projection, ProjectionSubPrefs { 
    2727 
    28     private int zone = 33; 
     28    public static final int DEFAULT_ZONE = 30; 
     29    private int zone = DEFAULT_ZONE; 
    2930 
    3031    final private double UTMScaleFactor = 0.9996; 
     
    410411    public void setPreferences(Collection<String> args) 
    411412    { 
    412         /* TODO: parse args instead of fixed value */ 
    413         zone = 33; 
     413        zone = DEFAULT_ZONE; 
     414        try { 
     415            for(String s : args) 
     416            { 
     417                zone = Integer.parseInt(s); 
     418                if(zone <= 0 || zone > 60) 
     419                    zone = DEFAULT_ZONE; 
     420                break; 
     421            } 
     422        } catch(NumberFormatException e) {} 
    414423    } 
    415424 
    416425    public Collection<String> getPreferencesFromCode(String code) 
    417426    { 
    418         /* TODO: implement */ 
     427        if(code.startsWith("EPSG:3258")) 
     428        { 
     429            try { 
     430                String zonestring = code.substring(9); 
     431                int zoneval = Integer.parseInt(zonestring); 
     432                if(zoneval > 0 && zone <= 60) 
     433                { 
     434                    return Collections.singleton(zonestring); 
     435                } 
     436            } catch(NumberFormatException e) {} 
     437        } 
    419438        return null; 
    420439    } 
  • trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java

    r2327 r2491  
    164164            coll = null; 
    165165            Main.proj = new Mercator(); 
     166            name = Main.proj.getClass().getName(); 
    166167        } 
    167168        if(!Main.proj.equals(oldProj) && b != null) 
     
    171172        } 
    172173        Main.pref.putCollection("projection.sub", coll); 
    173         if(coll != null && projHasPrefs(Main.proj)) 
     174        String sname = name.substring(name.lastIndexOf(".")+1); 
     175        Main.pref.putCollection("projection.sub."+sname, coll); 
     176        if(projHasPrefs(Main.proj)) 
    174177            ((ProjectionSubPrefs) Main.proj).setPreferences(coll); 
    175178    } 
     
    205208        for (int i = 0; i < projectionCombo.getItemCount(); ++i) { 
    206209            Projection proj = (Projection)projectionCombo.getItemAt(i); 
    207             if (proj.getClass().getName().equals(Main.pref.get("projection", Mercator.class.getName()))) { 
     210            String name = proj.getClass().getName(); 
     211            String sname = name.substring(name.lastIndexOf(".")+1); 
     212            if(projHasPrefs(proj)) 
     213                ((ProjectionSubPrefs) proj).setPreferences(Main.pref.getCollection("projection.sub."+sname, null)); 
     214            if (name.equals(Main.pref.get("projection", Mercator.class.getName()))) { 
    208215                projectionCombo.setSelectedIndex(i); 
    209216                selectedProjectionChanged(proj); 
Note: See TracChangeset for help on using the changeset viewer.