Changeset 3779 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2011-01-08T01:04:23+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java
r3775 r3779 14 14 import org.openstreetmap.josm.data.coor.LatLon; 15 15 import org.openstreetmap.josm.data.projection.Projection; 16 import org.openstreetmap.josm.data.projection.ProjectionInfo; 16 17 import org.openstreetmap.josm.gui.layer.ImageryLayer; 17 18 … … 26 27 27 28 public boolean isUsable(ImageryLayer layer) { 28 return Main.proj.getClass() == proj.getClass() && 29 layer.getInfo().getName().equals(layerName); 29 if (proj == null) return false; 30 if (!Main.proj.toCode().equals(proj.toCode())) return false; 31 return layer.getInfo().getName().equals(layerName); 30 32 } 31 33 … … 46 48 public OffsetBookmark(Collection<String> list) { 47 49 ArrayList<String> array = new ArrayList<String>(list); 48 String projectionName = array.get(0); 49 for (Projection proj : Projection.allProjections) { 50 if (proj.getCacheDirectoryName().equals(projectionName)) { 51 this.proj = proj; 52 break; 50 String projectionStr = array.get(0); 51 proj = ProjectionInfo.getProjectionByCode(projectionStr); 52 if (proj == null) { 53 for (Projection proj : Projection.allProjections) { 54 if (proj.getCacheDirectoryName().equals(projectionStr)) { 55 this.proj = proj; 56 break; 57 } 53 58 } 54 59 } 55 if (this.proj == null)56 throw new IllegalStateException(tr("Projection ''{0}'' not found", projectionName));57 60 this.layerName = array.get(1); 58 61 this.name = array.get(2); … … 63 66 this.centerY = Double.valueOf(array.get(6)); 64 67 } 68 if (proj == null) { 69 System.err.println(tr("Projection ''{0}'' is not found, bookmark ''{1}'' is not usable", projectionStr, name)); 70 } 65 71 } 66 72 67 73 public ArrayList<String> getInfoArray() { 68 ArrayList<String> res = new ArrayList<String>(5); 69 res.add(proj.getCacheDirectoryName()); // we should use non-localized projection name 74 ArrayList<String> res = new ArrayList<String>(7); 75 if (proj != null) { 76 res.add(proj.toCode()); 77 } else { 78 res.add(""); 79 } 70 80 res.add(layerName); 71 81 res.add(name); -
trunk/src/org/openstreetmap/josm/data/projection/Lambert.java
r3480 r3779 5 5 6 6 import java.awt.GridBagLayout; 7 import java.awt.event.ActionListener; 7 8 import java.io.IOException; 8 9 import java.io.InputStream; … … 254 255 }; 255 256 256 public void setupPreferencePanel(JPanel p) { 257 @Override 258 public void setupPreferencePanel(JPanel p, ActionListener listener) { 257 259 JComboBox prefcb = new JComboBox(lambert4zones); 258 260 … … 265 267 p.add(new JLabel(ImageProvider.get("data/projection", "Departements_Lambert4Zones.png")), GBC.eol().fill(GBC.HORIZONTAL)); 266 268 p.add(GBC.glue(1, 1), GBC.eol().fill(GBC.BOTH)); 269 270 if (listener != null) { 271 prefcb.addActionListener(listener); 272 } 267 273 } 268 274 … … 291 297 } 292 298 299 @Override 300 public String[] allCodes() { 301 String[] zones = new String[4]; 302 for (int zone = 0; zone < 4; zone++) { 303 zones[zone] = "EPSG:"+(27561+zone); 304 } 305 return zones; 306 } 307 293 308 public Collection<String> getPreferencesFromCode(String code) { 294 if (code.startsWith("EPSG:2756") && code.length() == 9) {309 if (code.startsWith("EPSG:2756") && code.length() == 10) { 295 310 try { 296 311 String zonestring = code.substring(9); -
trunk/src/org/openstreetmap/josm/data/projection/LambertCC9Zones.java
r3480 r3779 5 5 6 6 import java.awt.GridBagLayout; 7 import java.awt.event.ActionListener; 7 8 import java.util.Collection; 8 9 import java.util.Collections; … … 15 16 import org.openstreetmap.josm.data.coor.EastNorth; 16 17 import org.openstreetmap.josm.data.coor.LatLon; 17 import org.openstreetmap.josm.data.projection.Projection;18 import org.openstreetmap.josm.data.projection.Ellipsoid;19 18 import org.openstreetmap.josm.tools.GBC; 20 19 import org.openstreetmap.josm.tools.ImageProvider; … … 186 185 }; 187 186 188 public void setupPreferencePanel(JPanel p) { 187 @Override 188 public void setupPreferencePanel(JPanel p, ActionListener listener) { 189 189 JComboBox prefcb = new JComboBox(lambert9zones); 190 190 … … 197 197 p.add(new JLabel(ImageProvider.get("data/projection", "LambertCC9Zones.png")), GBC.eol().fill(GBC.HORIZONTAL)); 198 198 p.add(GBC.glue(1, 1), GBC.eol().fill(GBC.BOTH)); 199 200 if (listener != null) { 201 prefcb.addActionListener(listener); 202 } 199 203 } 200 204 … … 224 228 } 225 229 230 @Override 231 public String[] allCodes() { 232 String[] zones = new String[9]; 233 for (int zone = 0; zone < 9; zone++) { 234 zones[zone] = "EPSG:" + (3942 + zone); 235 } 236 return zones; 237 } 238 226 239 public Collection<String> getPreferencesFromCode(String code) 227 240 { … … 229 242 if (code.startsWith("EPSG:39") && code.length() == 9) { 230 243 try { 231 String zonestring = code.substring(5, 4);244 String zonestring = code.substring(5,9); 232 245 int zoneval = Integer.parseInt(zonestring)-3942; 233 246 if(zoneval >= 0 && zoneval <= 8) 234 return Collections.singleton( zonestring);247 return Collections.singleton(String.valueOf(zoneval+1)); 235 248 } catch(NumberFormatException e) {} 236 249 } -
trunk/src/org/openstreetmap/josm/data/projection/ProjectionSubPrefs.java
r3083 r3779 2 2 package org.openstreetmap.josm.data.projection; 3 3 4 import java.awt.event.ActionListener; 4 5 import java.util.Collection; 5 6 6 7 import javax.swing.JPanel; 7 8 8 public interface ProjectionSubPrefs { 9 public interface ProjectionSubPrefs extends Projection { 9 10 /** 10 11 * Generates the GUI for the given preference and packs them in a JPanel 11 12 * so they may be displayed if the projection is selected. 13 * 14 * @param listener listener for any change of preferences 12 15 */ 13 public void setupPreferencePanel(JPanel p); 16 public void setupPreferencePanel(JPanel p, ActionListener listener); 14 17 15 18 /** … … 17 20 */ 18 21 public Collection<String> getPreferences(JPanel p); 22 23 /** 24 * Return all projection codes supported by this projection class. 25 */ 26 public String[] allCodes(); 19 27 20 28 /** -
trunk/src/org/openstreetmap/josm/data/projection/Puwg.java
r3480 r3779 6 6 7 7 import java.awt.GridBagLayout; 8 import java.awt.event.ActionListener; 8 9 import java.text.DecimalFormat; 9 10 import java.util.Collection; … … 99 100 100 101 @Override 101 public void setupPreferencePanel(JPanel p) { 102 public void setupPreferencePanel(JPanel p, ActionListener listener) { 102 103 JComboBox prefcb = new JComboBox(Puwg.Zones); 103 104 … … 109 110 p.add(prefcb, GBC.eop().fill(GBC.HORIZONTAL)); 110 111 p.add(GBC.glue(1, 1), GBC.eol().fill(GBC.BOTH)); 112 113 if (listener != null) { 114 prefcb.addActionListener(listener); 115 } 111 116 } 112 117 … … 118 123 int zone = ((JComboBox)prefcb).getSelectedIndex(); 119 124 return Collections.singleton((Puwg.Zones[zone]).toCode()); 125 } 126 127 @Override 128 public String[] allCodes() { 129 String[] zones = new String[Zones.length]; 130 for (int zone = 0; zone < Zones.length; zone++) { 131 zones[zone] = Zones[zone].toCode(); 132 } 133 return zones; 120 134 } 121 135 -
trunk/src/org/openstreetmap/josm/data/projection/SwissGrid.java
r3473 r3779 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.event.ActionListener; 6 7 import java.util.Collection; 7 8 import java.util.Collections; 9 8 10 import javax.swing.Box; 9 11 import javax.swing.JPanel; … … 36 38 private static final double b0 = Math.asin(Math.sin(phi0) / alpha); 37 39 private static final double K = Math.log(Math.tan(Math.PI / 4 + b0 / 2)) - alpha 38 39 40 * Math.log(Math.tan(Math.PI / 4 + phi0 / 2)) + alpha * Ellipsoid.Bessel1841.e / 2 41 * Math.log((1 + Ellipsoid.Bessel1841.e * Math.sin(phi0)) / (1 - Ellipsoid.Bessel1841.e * Math.sin(phi0))); 40 42 41 43 private static final double xTrans = 200000; … … 71 73 72 74 double S = alpha * Math.log(Math.tan(Math.PI / 4 + phi / 2)) - alpha * Ellipsoid.Bessel1841.e / 2 73 75 * Math.log((1 + Ellipsoid.Bessel1841.e * Math.sin(phi)) / (1 - Ellipsoid.Bessel1841.e * Math.sin(phi))) + K; 74 76 double b = 2 * (Math.atan(Math.exp(S)) - Math.PI / 4); 75 77 double l = alpha * (lambda - lambda0); … … 107 109 // iteration to finds S and phi 108 110 while (Math.abs(phi - prevPhi) > DELTA_PHI) { 109 if (++iteration > 30) {111 if (++iteration > 30) 110 112 throw new RuntimeException("Two many iterations"); 111 }112 113 prevPhi = phi; 113 114 S = 1 / alpha * (Math.log(Math.tan(Math.PI / 4 + b / 2)) - K) + Ellipsoid.Bessel1841.e 114 115 * Math.log(Math.tan(Math.PI / 4 + Math.asin(Ellipsoid.Bessel1841.e * Math.sin(phi)) / 2)); 115 116 phi = 2 * Math.atan(Math.exp(S)) - Math.PI / 2; 116 117 } … … 152 153 153 154 @Override 154 public void setupPreferencePanel(JPanel p) { 155 public void setupPreferencePanel(JPanel p, ActionListener listener) { 155 156 p.add(new HtmlPanel("<i>CH1903 / LV03 (without local corrections)</i>"), GBC.eol().fill(GBC.HORIZONTAL)); 156 157 p.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH)); … … 167 168 168 169 @Override 170 public String[] allCodes() { 171 return new String[] { "EPSG:21781" }; 172 } 173 174 @Override 169 175 public Collection<String> getPreferencesFromCode(String code) { 170 176 if ("EPSG:21781".equals(code)) -
trunk/src/org/openstreetmap/josm/data/projection/UTM.java
r3635 r3779 5 5 6 6 import java.awt.GridBagLayout; 7 import java.awt.event.ActionListener; 8 import java.util.ArrayList; 7 9 import java.util.Arrays; 8 10 import java.util.Collection; … … 112 114 } 113 115 114 public void setupPreferencePanel(JPanel p) { 116 @Override 117 public void setupPreferencePanel(JPanel p, ActionListener listener) { 115 118 //Zone 116 119 JComboBox zonecb = new JComboBox(); … … 161 164 p.add(offsetBox, GBC.eop().fill(GBC.HORIZONTAL)); 162 165 p.add(GBC.glue(1, 1), GBC.eol().fill(GBC.BOTH)); 166 167 if (listener != null) { 168 north.addActionListener(listener); 169 south.addActionListener(listener); 170 zonecb.addActionListener(listener); 171 offsetBox.addActionListener(listener); 172 } 163 173 } 164 174 … … 214 224 } 215 225 updateParameters(); 226 } 227 228 public String[] allCodes() { 229 ArrayList<String> projections = new ArrayList<String>(60*4); 230 for (int zone = 1;zone <= 60; zone++) { 231 for (boolean offset : new boolean[] { false, true }) { 232 for (Hemisphere hemisphere : Hemisphere.values()) { 233 projections.add("EPSG:" + ((offset?325800:32600) + zone + (hemisphere == Hemisphere.South?100:0))); 234 } 235 } 236 } 237 return projections.toArray(new String[0]); 238 216 239 } 217 240 -
trunk/src/org/openstreetmap/josm/data/projection/UTM_France_DOM.java
r3473 r3779 9 9 10 10 import java.awt.GridBagLayout; 11 import java.awt.event.ActionListener; 11 12 import java.util.Collection; 12 13 import java.util.Collections; … … 410 411 } 411 412 412 public void setupPreferencePanel(JPanel p) { 413 @Override 414 public void setupPreferencePanel(JPanel p, ActionListener listener) { 413 415 JComboBox prefcb = new JComboBox(utmGeodesicsNames); 414 416 … … 419 421 p.add(prefcb, GBC.eop().fill(GBC.HORIZONTAL)); 420 422 p.add(GBC.glue(1, 1), GBC.eol().fill(GBC.BOTH)); 423 if (listener != null) { 424 prefcb.addActionListener(listener); 425 } 421 426 } 422 427 … … 430 435 } 431 436 437 @Override 438 public String[] allCodes() { 439 return utmEPSGs; 440 } 441 432 442 public Collection<String> getPreferencesFromCode(String code) { 433 443 for (int i=0; i < utmEPSGs.length; i++ ) 434 444 if (utmEPSGs[i].endsWith(code)) 435 return Collections.singleton(Integer.toString(i)); 445 return Collections.singleton(Integer.toString(i+1)); 436 446 return null; 437 447 } … … 444 454 { 445 455 currentGeodesic = Integer.parseInt(s)-1; 446 if(currentGeodesic < 0 || currentGeodesic > 4) {456 if(currentGeodesic < 0 || currentGeodesic >= utmEPSGs.length) { 447 457 currentGeodesic = DEFAULT_GEODESIC; 448 458 }
Note:
See TracChangeset
for help on using the changeset viewer.