Ignore:
Timestamp:
2012-05-09T11:35:47+02:00 (12 years ago)
Author:
bastiK
Message:

remove unnecessary projection lookup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java

    r4869 r5224  
    1313import org.openstreetmap.josm.Main;
    1414import 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;
    1915import org.openstreetmap.josm.gui.layer.ImageryLayer;
    2016
     
    2218    public static final List<OffsetBookmark> allBookmarks = new ArrayList<OffsetBookmark>();
    2319
    24     public Projection proj;
     20    public String projectionCode;
    2521    public String layerName;
    2622    public String name;
     
    2925
    3026    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;
    3329        return layer.getInfo().getName().equals(layerName);
    3430    }
    3531
    36     public OffsetBookmark(Projection proj, 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);
    3834    }
    3935
    40     public OffsetBookmark(Projection proj, 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;
    4238        this.layerName = layerName;
    4339        this.name = name;
     
    5046    public OffsetBookmark(Collection<String> list) {
    5147        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);
    6249        this.layerName = array.get(1);
    6350        this.name = array.get(2);
     
    6855            this.centerY = Double.valueOf(array.get(6));
    6956        }
    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));
    7759        }
    7860    }
     
    8062    public ArrayList<String> getInfoArray() {
    8163        ArrayList<String> res = new ArrayList<String>(7);
    82         if (proj != null) {
    83             res.add(proj.toCode());
     64        if (projectionCode != null) {
     65            res.add(projectionCode);
    8466        } else {
    8567            res.add("");
     
    127109        }
    128110        OffsetBookmark nb = new OffsetBookmark(
    129                 Main.getProjection(), layer.getInfo().getName(),
     111                Main.getProjection().toCode(), layer.getInfo().getName(),
    130112                name, layer.getDx(), layer.getDy(), center.lon(), center.lat());
    131113        for (ListIterator<OffsetBookmark> it = allBookmarks.listIterator();it.hasNext();) {
Note: See TracChangeset for help on using the changeset viewer.