Changeset 5224 in josm
- Timestamp:
- 2012-05-09T11:35:47+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java
r4869 r5224 13 13 import org.openstreetmap.josm.Main; 14 14 import org.openstreetmap.josm.data.coor.LatLon; 15 import org.openstreetmap.josm.data.projection.Mercator;16 import org.openstreetmap.josm.data.projection.Projection;17 import org.openstreetmap.josm.data.projection.ProjectionInfo;18 import org.openstreetmap.josm.data.projection.Projections;19 15 import org.openstreetmap.josm.gui.layer.ImageryLayer; 20 16 … … 22 18 public static final List<OffsetBookmark> allBookmarks = new ArrayList<OffsetBookmark>(); 23 19 24 public Projectionproj;20 public String projectionCode; 25 21 public String layerName; 26 22 public String name; … … 29 25 30 26 public boolean isUsable(ImageryLayer layer) { 31 if (proj == null) return false; 32 if (!Main.getProjection().toCode().equals(proj .toCode())) return false;27 if (projectionCode == null) return false; 28 if (!Main.getProjection().toCode().equals(projectionCode)) return false; 33 29 return layer.getInfo().getName().equals(layerName); 34 30 } 35 31 36 public OffsetBookmark( Projectionproj, String layerName, String name, double dx, double dy) {37 this(proj, layerName, name, dx, dy, 0, 0); 32 public OffsetBookmark(String projectionCode, String layerName, String name, double dx, double dy) { 33 this(projectionCode, layerName, name, dx, dy, 0, 0); 38 34 } 39 35 40 public OffsetBookmark( Projectionproj, String layerName, String name, double dx, double dy, double centerX, double centerY) {41 this.proj = proj;36 public OffsetBookmark(String projectionCode, String layerName, String name, double dx, double dy, double centerX, double centerY) { 37 this.projectionCode = projectionCode; 42 38 this.layerName = layerName; 43 39 this.name = name; … … 50 46 public OffsetBookmark(Collection<String> list) { 51 47 ArrayList<String> array = new ArrayList<String>(list); 52 String projectionStr = array.get(0); 53 proj = ProjectionInfo.getProjectionByCode(projectionStr); 54 if (proj == null) { 55 for (Projection proj : Projections.getProjections()) { 56 if (proj.getCacheDirectoryName().equals(projectionStr)) { 57 this.proj = proj; 58 break; 59 } 60 } 61 } 48 this.projectionCode = array.get(0); 62 49 this.layerName = array.get(1); 63 50 this.name = array.get(2); … … 68 55 this.centerY = Double.valueOf(array.get(6)); 69 56 } 70 // Mercator scale factor migration 71 if (proj instanceof Mercator && Math.abs(this.dx) < 1E-3 && Math.abs(this.dy) < 1E-3) { 72 this.dx *= 6378137; 73 this.dy *= 6378137; 74 } 75 if (proj == null) { 76 System.err.println(tr("Projection ''{0}'' is not found, bookmark ''{1}'' is not usable", projectionStr, name)); 57 if (projectionCode == null) { 58 System.err.println(tr("Projection ''{0}'' is not found, bookmark ''{1}'' is not usable", projectionCode, name)); 77 59 } 78 60 } … … 80 62 public ArrayList<String> getInfoArray() { 81 63 ArrayList<String> res = new ArrayList<String>(7); 82 if (proj != null) { 83 res.add(proj .toCode());64 if (projectionCode != null) { 65 res.add(projectionCode); 84 66 } else { 85 67 res.add(""); … … 127 109 } 128 110 OffsetBookmark nb = new OffsetBookmark( 129 Main.getProjection(), layer.getInfo().getName(), 111 Main.getProjection().toCode(), layer.getInfo().getName(), 130 112 name, layer.getDx(), layer.getDy(), center.lon(), center.lat()); 131 113 for (ListIterator<OffsetBookmark> it = allBookmarks.listIterator();it.hasNext();) { -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
r4987 r5224 930 930 @Override 931 931 public void actionPerformed(ActionEvent e) { 932 OffsetBookmark b = new OffsetBookmark(Main.getProjection(),"","",0,0); 932 OffsetBookmark b = new OffsetBookmark(Main.getProjection().toCode(),"","",0,0); 933 933 model.addRow(b); 934 934 } … … 988 988 switch (column) { 989 989 case 0: 990 if (info.proj == null) return ""; 991 return info.proj.toString(); 990 if (info.projectionCode == null) return ""; 991 return info.projectionCode.toString(); 992 992 case 1: 993 993 return info.layerName;
Note:
See TracChangeset
for help on using the changeset viewer.