- Timestamp:
- 2012-05-12T23:27:39+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/Lambert.java
r5235 r5236 96 96 97 97 public Lambert(final int layoutZone) { 98 if (layoutZone < 0 || layoutZone >= 4) 99 throw new IllegalArgumentException(); 98 100 this.layoutZone = layoutZone; 99 101 ellps = Ellipsoid.clarkeIGN; -
trunk/src/org/openstreetmap/josm/data/projection/ProjectionInfo.java
r5234 r5236 4 4 import java.util.Collection; 5 5 import java.util.HashMap; 6 import java.util.Map; 6 7 7 8 import org.openstreetmap.josm.gui.preferences.projection.ProjectionChoice; … … 9 10 10 11 public class ProjectionInfo { 11 private static HashMap<String, ProjectionChoice> allCodesPC;12 private static HashMap<String, Projection> allCodes;12 private static Map<String, ProjectionChoice> allCodesPC = new HashMap<String, ProjectionChoice>(); 13 private static Map<String, Projection> allCodes = new HashMap<String, Projection>(); 13 14 14 15 static { 15 allCodes = new HashMap<String, Projection>();16 16 for (ProjectionChoice pc : ProjectionPreference.getProjectionChoices()) { 17 17 for (String code : pc.allCodes()) { -
trunk/src/org/openstreetmap/josm/data/projection/Puwg.java
r5235 r5236 22 22 private final int zone; 23 23 24 static public PuwgData[] Zones = new PuwgData[] {24 static public PuwgData[] zones = new PuwgData[] { 25 25 new Epsg2180(), 26 26 new Epsg2176(), … … 35 35 36 36 public Puwg(int zone) { 37 if (zone < 0 || zone >= zones.length) 38 throw new IllegalArgumentException(); 37 39 ellps = Ellipsoid.GRS80; 38 40 proj = new org.openstreetmap.josm.data.projection.proj.TransverseMercator(); … … 44 46 datum = GRS80Datum.INSTANCE; 45 47 this.zone = zone; 46 PuwgData z = Zones[zone];48 PuwgData z = zones[zone]; 47 49 x_0 = z.getPuwgFalseEasting(); 48 50 y_0 = z.getPuwgFalseNorthing(); … … 58 60 @Override 59 61 public Integer getEpsgCode() { 60 return Zones[zone].getEpsgCode();62 return zones[zone].getEpsgCode(); 61 63 } 62 64 … … 68 70 @Override 69 71 public String getCacheDirectoryName() { 70 return Zones[zone].getCacheDirectoryName();72 return zones[zone].getCacheDirectoryName(); 71 73 } 72 74 73 75 @Override 74 76 public Bounds getWorldBoundsLatLon() { 75 return Zones[zone].getWorldBoundsLatLon();77 return zones[zone].getWorldBoundsLatLon(); 76 78 } 77 79 -
trunk/src/org/openstreetmap/josm/data/projection/UTM.java
r5235 r5236 24 24 private Hemisphere hemisphere; 25 25 26 /**27 * Applies an additional false easting of 3000000 m if true.28 */29 private boolean offset;30 31 26 public UTM() { 32 this(DEFAULT_ZONE, DEFAULT_HEMISPHERE , false);27 this(DEFAULT_ZONE, DEFAULT_HEMISPHERE); 33 28 } 34 29 35 public UTM(int zone, Hemisphere hemisphere, boolean offset) { 30 public UTM(int zone, Hemisphere hemisphere) { 31 if (zone < 1 || zone > 60) 32 throw new IllegalArgumentException(); 36 33 ellps = Ellipsoid.WGS84; 37 34 proj = new org.openstreetmap.josm.data.projection.proj.TransverseMercator(); … … 44 41 this.zone = zone; 45 42 this.hemisphere = hemisphere; 46 this.offset = offset; 47 x_0 = 500000 + (offset ? 3000000 : 0); 43 x_0 = 500000; 48 44 y_0 = hemisphere == Hemisphere.North ? 0 : 10000000; 49 45 lon_0 = getUtmCentralMeridianDeg(zone); … … 81 77 @Override 82 78 public Integer getEpsgCode() { 83 return ( (offset?325800:32600)+ getzone() + (hemisphere == Hemisphere.South?100:0));79 return (32600 + getzone() + (hemisphere == Hemisphere.South?100:0)); 84 80 } 85 81 -
trunk/src/org/openstreetmap/josm/data/projection/UTM_France_DOM.java
r5235 r5236 61 61 62 62 public UTM_France_DOM(int currentGeodesic) { 63 if (currentGeodesic < 0 || currentGeodesic >= 5) 64 throw new IllegalArgumentException(); 63 65 this.currentGeodesic = currentGeodesic; 64 66 datum = utmDatums[currentGeodesic]; -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/GaussKruegerProjectionChoice.java
r5234 r5236 20 20 @Override 21 21 public Projection getProjection() { 22 return new GaussKrueger(index ToZone(index));22 return new GaussKrueger(index + 2); 23 23 } 24 24 25 25 @Override 26 protected intindexToZone(int index) {27 return index + 2;26 protected String indexToZone(int index) { 27 return Integer.toString(index + 2); 28 28 } 29 29 30 30 @Override 31 protected int zoneToIndex(int zone) { 32 return zone - 2; 31 protected int zoneToIndex(String zone) { 32 try { 33 return Integer.parseInt(zone) - 2; 34 } catch(NumberFormatException e) {} 35 return defaultIndex; 33 36 } 34 37 -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/LambertCC9ZonesProjectionChoice.java
r5234 r5236 76 76 77 77 @Override 78 protected intindexToZone(int index) {79 return index + 1;78 protected String indexToZone(int index) { 79 return Integer.toString(index + 1); 80 80 } 81 81 82 82 @Override 83 protected int zoneToIndex(int zone) { 84 return zone - 1; 83 protected int zoneToIndex(String zone) { 84 try { 85 return Integer.parseInt(zone) - 1; 86 } catch(NumberFormatException e) {} 87 return defaultIndex; 85 88 } 86 89 -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/LambertProjectionChoice.java
r5234 r5236 70 70 71 71 @Override 72 protected intindexToZone(int index) {73 return index + 1;72 protected String indexToZone(int index) { 73 return Integer.toString(index + 1); 74 74 } 75 75 76 76 @Override 77 protected int zoneToIndex(int zone) { 78 return zone - 1; 77 protected int zoneToIndex(String zone) { 78 try { 79 return Integer.parseInt(zone) - 1; 80 } catch(NumberFormatException e) {} 81 return defaultIndex; 79 82 } 80 83 -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/ListProjectionChoice.java
r5234 r5236 46 46 * Convert 0-based index to preference value. 47 47 */ 48 abstract protected intindexToZone(int index);48 abstract protected String indexToZone(int index); 49 49 50 50 /** 51 51 * Convert preference value to 0-based index. 52 52 */ 53 abstract protected int zoneToIndex( intzone);53 abstract protected int zoneToIndex(String zone); 54 54 55 55 @Override 56 56 public void setPreferences(Collection<String> args) { 57 Integerzone = null;57 String zone = null; 58 58 if (args != null && args.size() >= 1) { 59 try { 60 zone = Integer.parseInt(args.iterator().next()); 61 } catch(NumberFormatException e) {} 59 zone = args.iterator().next(); 62 60 } 63 61 int index; … … 101 99 CBPanel p = (CBPanel) panel; 102 100 int index = p.prefcb.getSelectedIndex(); 103 return Collections.singleton( Integer.toString(indexToZone(index)));101 return Collections.singleton(indexToZone(index)); 104 102 } 105 103 -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/PuwgProjectionChoice.java
r5234 r5236 13 13 14 14 public PuwgProjectionChoice() { 15 super("core:puwg", tr("PUWG (Poland)"), Puwg. Zones, tr("PUWG Zone"));15 super("core:puwg", tr("PUWG (Poland)"), Puwg.zones, tr("PUWG Zone")); 16 16 } 17 17 … … 23 23 @Override 24 24 public String[] allCodes() { 25 String[] zones = new String[Puwg. Zones.length];26 for (int zone = 0; zone < Puwg.Zones.length; zone++) {27 zones[ zone] = Puwg.Zones[zone].toCode();25 String[] zones = new String[Puwg.zones.length]; 26 for (int index = 0; index < Puwg.zones.length; index++) { 27 zones[index] = Puwg.zones[index].toCode(); 28 28 } 29 29 return zones; … … 32 32 @Override 33 33 public Collection<String> getPreferencesFromCode(String code) { 34 for (Puwg.PuwgData p : Puwg. Zones) {34 for (Puwg.PuwgData p : Puwg.zones) { 35 35 if (code.equals(p.toCode())) 36 36 return Collections.singleton(code); … … 45 45 46 46 @Override 47 protected intindexToZone(int index) {48 return index;47 protected String indexToZone(int index) { 48 return Puwg.zones[index].toCode(); 49 49 } 50 50 51 51 @Override 52 protected int zoneToIndex(int zone) { 53 return zone; 52 protected int zoneToIndex(String zone) { 53 for (int i=0; i<Puwg.zones.length; i++) { 54 if (zone.equals(Puwg.zones[i].toCode())) { 55 return i; 56 } 57 } 58 return defaultIndex; 54 59 } 55 60 -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/UTMProjectionChoice.java
r5234 r5236 12 12 13 13 import javax.swing.ButtonGroup; 14 import javax.swing.JCheckBox;15 14 import javax.swing.JLabel; 16 15 import javax.swing.JPanel; … … 27 26 private UTM.Hemisphere hemisphere; 28 27 29 /**30 * Applies an additional false easting of 3000000 m if true.31 */32 private boolean offset;33 34 28 private final static List<String> cbEntries = new ArrayList<String>(); 35 29 static { … … 46 40 47 41 public JRadioButton north, south; 48 public JCheckBox offsetBox;49 42 50 43 public UTMPanel(Object[] entries, int initialIndex, String label, ActionListener listener) { … … 76 69 this.add(GBC.glue(1, 1), GBC.eol().fill(GBC.BOTH)); 77 70 78 //Offset79 offsetBox = new JCheckBox();80 offsetBox.setSelected(offset);81 82 this.add(new JLabel(tr("Offset 3.000.000m east")), GBC.std().insets(5,5,0,5));83 this.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL));84 this.add(offsetBox, GBC.eop().fill(GBC.HORIZONTAL));85 this.add(GBC.glue(1, 1), GBC.eol().fill(GBC.BOTH));86 87 71 if (listener != null) { 88 72 north.addActionListener(listener); 89 73 south.addActionListener(listener); 90 offsetBox.addActionListener(listener);91 74 } 92 75 } … … 100 83 @Override 101 84 public Projection getProjection() { 102 return new UTM(index ToZone(index), hemisphere, offset);85 return new UTM(index + 1, hemisphere); 103 86 } 104 87 … … 108 91 int index = p.prefcb.getSelectedIndex(); 109 92 UTM.Hemisphere hemisphere = p.south.isSelected()?UTM.Hemisphere.South:UTM.Hemisphere.North; 110 boolean offset = p.offsetBox.isSelected(); 111 return Arrays.asList(Integer.toString(indexToZone(index)), hemisphere.toString(), (offset?"offset":"standard")); 93 return Arrays.asList(indexToZone(index), hemisphere.toString()); 112 94 } 113 95 … … 116 98 ArrayList<String> projections = new ArrayList<String>(60*4); 117 99 for (int zone = 1;zone <= 60; zone++) { 118 for (boolean offset : new boolean[] { false, true }) { 119 for (UTM.Hemisphere hemisphere : UTM.Hemisphere.values()) { 120 projections.add("EPSG:" + ((offset?325800:32600) + zone + (hemisphere == UTM.Hemisphere.South?100:0))); 121 } 100 for (UTM.Hemisphere hemisphere : UTM.Hemisphere.values()) { 101 projections.add("EPSG:" + (32600 + zone + (hemisphere == UTM.Hemisphere.South?100:0))); 122 102 } 123 103 } … … 127 107 @Override 128 108 public Collection<String> getPreferencesFromCode(String code) { 129 boolean offset = code.startsWith("EPSG:3258") || code.startsWith("EPSG:3259");130 109 131 if (code.startsWith("EPSG:326") || code.startsWith("EPSG:327") || offset) {110 if (code.startsWith("EPSG:326") || code.startsWith("EPSG:327")) { 132 111 try { 133 UTM.Hemisphere hemisphere; 134 String zonestring; 135 if (offset) { 136 hemisphere = code.charAt(8)=='8'?UTM.Hemisphere.North:UTM.Hemisphere.South; 137 zonestring = code.substring(9); 138 } else { 139 hemisphere = code.charAt(7)=='6'?UTM.Hemisphere.North:UTM.Hemisphere.South; 140 zonestring = code.substring(8); 141 } 142 112 UTM.Hemisphere hemisphere = code.charAt(7)=='6'?UTM.Hemisphere.North:UTM.Hemisphere.South; 113 String zonestring = code.substring(8); 143 114 int zoneval = Integer.parseInt(zonestring); 144 115 if(zoneval > 0 && zoneval <= 60) 145 return Arrays.asList(zonestring, hemisphere.toString() , (offset?"offset":"standard"));116 return Arrays.asList(zonestring, hemisphere.toString()); 146 117 } catch(NumberFormatException e) {} 147 118 } … … 153 124 super.setPreferences(args); 154 125 UTM.Hemisphere hemisphere = DEFAULT_HEMISPHERE; 155 boolean offset = false;156 126 157 127 if(args != null) { … … 161 131 hemisphere = UTM.Hemisphere.valueOf(array[1]); 162 132 } 163 164 if (array.length > 2) {165 offset = array[2].equals("offset");166 }167 133 } 168 134 this.hemisphere = hemisphere; 169 this.offset = offset;170 135 } 171 136 172 137 @Override 173 protected intindexToZone(int index) {174 return index + 1;138 protected String indexToZone(int index) { 139 return Integer.toString(index + 1); 175 140 } 176 141 177 142 @Override 178 protected int zoneToIndex(int zone) { 179 return zone - 1; 143 protected int zoneToIndex(String zone) { 144 try { 145 return Integer.parseInt(zone) - 1; 146 } catch(NumberFormatException e) {} 147 return defaultIndex; 180 148 } 181 149 -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/UTM_France_DOM_ProjectionChoice.java
r5234 r5236 24 24 25 25 @Override 26 protected intindexToZone(int index) {27 return index + 1;26 protected String indexToZone(int index) { 27 return Integer.toString(index + 1); 28 28 } 29 29 30 30 @Override 31 protected int zoneToIndex(int zone) { 32 return zone - 1; 31 protected int zoneToIndex(String zone) { 32 try { 33 return Integer.parseInt(zone) - 1; 34 } catch(NumberFormatException e) {} 35 return defaultIndex; 33 36 } 34 37
Note:
See TracChangeset
for help on using the changeset viewer.