Ignore:
Timestamp:
2011-06-07T19:05:14+02:00 (13 years ago)
Author:
bastiK
Message:

memory optimizations for Node & WayPoint (Patch by Gubaer, modified)

The field 'proj' in CachedLatLon is a waste of memory. For the 2 classes where this has the greatest impact, the cache for the projected coordinates is replaced by 2 simple double fields (east & north). On projection change, they have to be invalidated explicitly. This is handled by the DataSet & the GpxLayer.

Location:
trunk/src/org/openstreetmap/josm/data
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/coor/CachedLatLon.java

    r3253 r4126  
    55import org.openstreetmap.josm.data.projection.Projection;
    66
     7/**
     8 * LatLon class that maintains a cache of projected EastNorth coordinates.
     9 *
     10 * This class is convenient to use, but has relatively high memory costs.
     11 * It keeps a pointer to the last known projection in order to detect projection
     12 * changes.
     13 *
     14 * Node and WayPoint have another, optimized, cache for projected coordinates.
     15 */
    716public class CachedLatLon extends LatLon {
    817    private EastNorth eastNorth;
     
    1928
    2029    public CachedLatLon(EastNorth eastNorth) {
    21         super(Main.proj.eastNorth2latlon(eastNorth));
    22         proj = Main.proj;
     30        super(Main.getProjection().eastNorth2latlon(eastNorth));
     31        proj = Main.getProjection();
    2332        this.eastNorth = eastNorth;
    2433    }
     
    3039
    3140    public final void setEastNorth(EastNorth eastNorth) {
    32         proj = Main.proj;
     41        proj = Main.getProjection();
    3342        this.eastNorth = eastNorth;
    3443        LatLon l = proj.eastNorth2latlon(eastNorth);
     
    3645    }
    3746
     47    /**
     48     * Replies the projected east/north coordinates.
     49     *
     50     * @return the internally cached east/north coordinates. null, if the globally defined projection is null
     51     */
    3852    public final EastNorth getEastNorth() {
    39         if(proj != Main.proj)
     53        if(proj != Main.getProjection())
    4054        {
    41             proj = Main.proj;
     55            proj = Main.getProjection();
    4256            eastNorth = proj.latlon2eastNorth(this);
    4357        }
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r3656 r4126  
    106106        case DEGREES_MINUTES_SECONDS: return dms(y) + ((y < 0) ? SOUTH : NORTH);
    107107        case NAUTICAL: return dm(y) + ((y < 0) ? SOUTH : NORTH);
    108         case EAST_NORTH: return cDdFormatter.format(Main.proj.latlon2eastNorth(this).north());
     108        case EAST_NORTH: return cDdFormatter.format(Main.getProjection().latlon2eastNorth(this).north());
    109109        default: return "ERR";
    110110        }
     
    122122        case DEGREES_MINUTES_SECONDS: return dms(x) + ((x < 0) ? WEST : EAST);
    123123        case NAUTICAL: return dm(x) + ((x < 0) ? WEST : EAST);
    124         case EAST_NORTH: return cDdFormatter.format(Main.proj.latlon2eastNorth(this).east());
     124        case EAST_NORTH: return cDdFormatter.format(Main.getProjection().latlon2eastNorth(this).east());
    125125        default: return "ERR";
    126126        }
     
    142142     */
    143143    public boolean isOutSideWorld() {
    144         Bounds b = Main.proj.getWorldBoundsLatLon();
     144        Bounds b = Main.getProjection().getWorldBoundsLatLon();
    145145        return lat() < b.getMin().lat() || lat() > b.getMax().lat() ||
    146146        lon() < b.getMin().lon() || lon() > b.getMax().lon();
  • trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java

    r3321 r4126  
    77import java.util.Date;
    88
    9 import org.openstreetmap.josm.data.coor.CachedLatLon;
     9import org.openstreetmap.josm.Main;
    1010import org.openstreetmap.josm.data.coor.EastNorth;
    1111import org.openstreetmap.josm.data.coor.LatLon;
     12import org.openstreetmap.josm.data.projection.Projections;
    1213import org.openstreetmap.josm.tools.PrimaryDateParser;
    1314
     
    2627
    2728    public WayPoint(LatLon ll) {
    28         coor = new CachedLatLon(ll);
     29        lat = ll.lat();
     30        lon = ll.lon();
    2931    }
    3032
    31     private final CachedLatLon coor;
     33    /*
     34     * We "inline" lat/lon, rather than usinga LatLon internally => reduces memory overhead. Relevant
     35     * because a lot of GPX waypoints are created when GPS tracks are downloaded from the OSM server.
     36     */
     37    private double lat = 0;
     38    private double lon = 0;
     39
     40    /*
     41     * internal cache of projected coordinates
     42     */
     43    private double east = Double.NaN;
     44    private double north = Double.NaN;
     45
     46    /**
     47     * Invalidate the internal cache of east/north coordinates.
     48     */
     49    public void invalidateEastNorthCache() {
     50        this.east = Double.NaN;
     51        this.north = Double.NaN;
     52    }
    3253
    3354    public final LatLon getCoor() {
    34         return coor;
     55        return new LatLon(lat,lon);
    3556    }
    3657
     58    /**
     59     * <p>Replies the projected east/north coordinates.</p>
     60     *
     61     * <p>Uses the {@link Main#getProjection() global projection} to project the lan/lon-coordinates.
     62     * Internally caches the projected coordinates.</p>
     63     *
     64     * <p><strong>Caveat:</strong> doesn't listen to projection changes. Clients must
     65     * {@link #reproject() trigger a reprojection} or {@link #invalidateEastNorthCache() invalidate the internal cache}.</p>
     66     *
     67     * @return the east north coordinates or {@code null}
     68     * @see #invalidateEastNorthCache()
     69     *
     70     */
    3771    public final EastNorth getEastNorth() {
    38         return coor.getEastNorth();
     72        if (Double.isNaN(east) || Double.isNaN(north)) {
     73            // projected coordinates haven't been calculated yet,
     74            // so fill the cache of the projected waypoint coordinates
     75            EastNorth en = Projections.project(new LatLon(lat, lon));
     76            this.east = en.east();
     77            this.north = en.north();
     78        }
     79        return new EastNorth(east, north);
    3980    }
    4081
    4182    @Override
    4283    public String toString() {
    43         return "WayPoint (" + (attr.containsKey("name") ? attr.get("name") + ", " :"") + coor.toString() + ", " + attr + ")";
     84        return "WayPoint (" + (attr.containsKey("name") ? attr.get("name") + ", " :"") + getCoor().toString() + ", " + attr + ")";
    4485    }
    4586
     
    5798    }
    5899
    59     public int compareTo(WayPoint w)
    60     {
     100    public int compareTo(WayPoint w) {
    61101        return Double.compare(time, w.time);
    62102    }
  • trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java

    r3966 r4126  
    3030    public boolean isUsable(ImageryLayer layer) {
    3131        if (proj == null) return false;
    32         if (!Main.proj.toCode().equals(proj.toCode())) return false;
     32        if (!Main.getProjection().toCode().equals(proj.toCode())) return false;
    3333        return layer.getInfo().getName().equals(layerName);
    3434    }
     
    122122        LatLon center;
    123123        if (Main.map != null && Main.map.mapView != null) {
    124             center = Main.proj.eastNorth2latlon(Main.map.mapView.getCenter());
     124            center = Main.getProjection().eastNorth2latlon(Main.map.mapView.getCenter());
    125125        } else {
    126126            center = new LatLon(0,0);
    127127        }
    128128        OffsetBookmark nb = new OffsetBookmark(
    129                 Main.proj, layer.getInfo().getName(),
     129                Main.getProjection(), layer.getInfo().getName(),
    130130                name, layer.getDx(), layer.getDy(), center.lon(), center.lat());
    131131        for (ListIterator<OffsetBookmark> it = allBookmarks.listIterator();it.hasNext();) {
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r4087 r4126  
    2020import java.util.concurrent.locks.ReentrantReadWriteLock;
    2121
     22import org.openstreetmap.josm.Main;
    2223import org.openstreetmap.josm.data.Bounds;
    2324import org.openstreetmap.josm.data.SelectionChangedListener;
     
    3435import org.openstreetmap.josm.data.osm.event.TagsChangedEvent;
    3536import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
     37import org.openstreetmap.josm.data.projection.Projection;
     38import org.openstreetmap.josm.data.projection.ProjectionChangeListener;
    3639import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager;
    3740import org.openstreetmap.josm.tools.FilteredCollection;
    3841import org.openstreetmap.josm.tools.Predicate;
    3942import org.openstreetmap.josm.tools.SubclassFilteredCollection;
     43import org.openstreetmap.josm.tools.Utils;
    4044
    4145/**
     
    8387 * @author imi
    8488 */
    85 public class DataSet implements Cloneable {
     89public class DataSet implements Cloneable, ProjectionChangeListener {
    8690
    8791    /**
     
    120124    private final ReadWriteLock lock = new ReentrantReadWriteLock();
    121125    private final Object selectionLock = new Object();
     126
     127    public DataSet() {
     128        /*
     129         * Transparently register as projection change lister. No need to explicitly remove the
     130         * the listener, projection change listeners are managed as WeakReferences.
     131         */
     132        Main.addProjectionChangeListener(this);
     133    }
    122134
    123135    public Lock getReadLock() {
     
    975987    }
    976988
     989    /**
     990     * Invalidates the internal cache of projected east/north coordinates.
     991     *
     992     * This method can be invoked after the globally configured projection method
     993     * changed. In contrast to {@link DataSet#reproject()} it only invalidates the
     994     * cache and doesn't reproject the coordinates.
     995     */
     996    public void invalidateEastNorthCache() {
     997        if (Main.getProjection() == null) return; // sanity check
     998        try {
     999            beginUpdate();
     1000            for (Node n: Utils.filteredCollection(allPrimitives, Node.class)) {
     1001                n.invalidateEastNorthCache();
     1002            }
     1003        } finally {
     1004            endUpdate();
     1005        }
     1006    }
     1007
    9771008    public void cleanupDeletedPrimitives() {
    9781009        beginUpdate();
     
    10641095        return ret;
    10651096    }
     1097
     1098    /* --------------------------------------------------------------------------------- */
     1099    /* interface ProjectionChangeListner                                                 */
     1100    /* --------------------------------------------------------------------------------- */
     1101    @Override
     1102    public void projectionChanged(Projection oldValue, Projection newValue) {
     1103        invalidateEastNorthCache();
     1104    }
    10661105}
  • trunk/src/org/openstreetmap/josm/data/osm/INode.java

    r4098 r4126  
    66
    77public interface INode extends IPrimitive {
    8    
     8
    99    LatLon getCoor();
    1010    void setCoor(LatLon coor);
    1111    EastNorth getEastNorth();
    1212    void setEastNorth(EastNorth eastNorth);
    13 
    1413}
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r4100 r4126  
    22package org.openstreetmap.josm.data.osm;
    33
    4 import org.openstreetmap.josm.data.coor.CachedLatLon;
     4import org.openstreetmap.josm.Main;
    55import org.openstreetmap.josm.data.coor.EastNorth;
    66import org.openstreetmap.josm.data.coor.LatLon;
    77import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
    88import org.openstreetmap.josm.data.osm.visitor.Visitor;
     9import org.openstreetmap.josm.data.projection.Projections;
    910
    1011/**
     
    1516public final class Node extends OsmPrimitive implements INode {
    1617
    17     private CachedLatLon coor;
     18    /*
     19     * We "inline" lat/lon rather than using a LatLon-object => reduces memory footprint
     20     */
     21    static private final double COORDINATE_NOT_DEFINED = Double.NaN;
     22    private double lat = COORDINATE_NOT_DEFINED;
     23    private double lon = COORDINATE_NOT_DEFINED;
     24
     25    /*
     26     * the cached projected coordinates
     27     */
     28    private double east = Double.NaN;
     29    private double north = Double.NaN;
     30
     31    private boolean isLatLonKnown() {
     32        return lat != COORDINATE_NOT_DEFINED && lon != COORDINATE_NOT_DEFINED;
     33    }
    1834
    1935    @Override
     
    4662    @Override
    4763    public final LatLon getCoor() {
    48         return coor;
    49     }
    50 
     64        if (!isLatLonKnown()) return null;
     65        return new LatLon(lat,lon);
     66    }
     67
     68    /**
     69     * <p>Replies the projected east/north coordinates.</p>
     70     *
     71     * <p>Uses the {@link Main#getProjection() global projection} to project the lan/lon-coordinates.
     72     * Internally caches the projected coordinates.</p>
     73     *
     74     * <p><strong>Caveat:</strong> doesn't listen to projection changes. Clients must
     75     * {@link #invalidateEastNorthCache() invalidate the internal cache}.</p>
     76     *
     77     * <p>Replies {@code null} if this node doesn't know lat/lon-coordinates, i.e. because it is an incomplete node.
     78     *
     79     * @return the east north coordinates or {@code null}
     80     * @see #invalidateEastNorthCache()
     81     *
     82     */
    5183    @Override
    5284    public final EastNorth getEastNorth() {
    53         return coor != null ? coor.getEastNorth() : null;
     85        if (!isLatLonKnown()) return null;
     86       
     87        if (getDataSet() == null)
     88            // there is no dataset that listens for projection changes
     89            // and invalidates the cache, so we don't use the cache at all
     90            return Projections.project(new LatLon(lat, lon));
     91       
     92        if (Double.isNaN(east) || Double.isNaN(north)) {
     93            // projected coordinates haven't been calculated yet,
     94            // so fill the cache of the projected node coordinates
     95            EastNorth en = Projections.project(new LatLon(lat, lon));
     96            this.east = en.east();
     97            this.north = en.north();
     98        }
     99        return new EastNorth(east, north);
    54100    }
    55101
     
    58104     */
    59105    protected void setCoorInternal(LatLon coor, EastNorth eastNorth) {
    60         if(this.coor == null) {
    61             if (eastNorth == null) {
    62                 this.coor = new CachedLatLon(coor);
    63             } else {
    64                 this.coor = new CachedLatLon(eastNorth);
    65             }
    66         } else {
    67             if (eastNorth == null) {
    68                 this.coor.setCoor(coor);
    69             } else {
    70                 this.coor.setEastNorth(eastNorth);
    71             }
    72         }
     106        if (coor != null) {
     107            this.lat = coor.lat();
     108            this.lon = coor.lon();
     109            invalidateEastNorthCache();
     110        } else if (eastNorth != null) {
     111            LatLon ll = Projections.inverseProject(eastNorth);
     112            this.lat = ll.lat();
     113            this.lon = ll.lon();
     114            this.east = eastNorth.east();
     115            this.north = eastNorth.north();
     116        } else
     117            throw new IllegalArgumentException();
    73118    }
    74119
     
    150195        try {
    151196            super.cloneFrom(osm);
    152             setCoor(((Node)osm).coor);
     197            setCoor(((Node)osm).getCoor());
    153198        } finally {
    154199            writeUnlock(locked);
     
    173218            super.mergeFrom(other);
    174219            if (!other.isIncomplete()) {
    175                 setCoor(new LatLon(((Node)other).coor));
     220                setCoor(((Node)other).getCoor());
    176221            }
    177222        } finally {
     
    200245
    201246    @Override public String toString() {
    202         String coorDesc = coor == null?"":"lat="+coor.lat()+",lon="+coor.lon();
     247        String coorDesc = isLatLonKnown() ? "lat="+lat+",lon="+lon : "";
    203248        return "{Node id=" + getUniqueId() + " version=" + getVersion() + " " + getFlagsAsString() + " "  + coorDesc+"}";
    204249    }
     
    211256            return false;
    212257        Node n = (Node)other;
    213         if (coor == null && n.coor == null)
     258        LatLon coor = getCoor();
     259        LatLon otherCoor = n.getCoor();
     260        if (coor == null && otherCoor == null)
    214261            return true;
    215         else if (coor != null && n.coor != null)
    216             return coor.equalsEpsilon(n.coor);
     262        else if (coor != null && otherCoor != null)
     263            return coor.equalsEpsilon(otherCoor);
    217264        else
    218265            return false;
     
    241288    @Override
    242289    public void updatePosition() {
    243         // TODO: replace CachedLatLon with simple doubles and update precalculated EastNorth value here
    244290    }
    245291
     
    253299        builder.append(toString());
    254300        builder.append("\n");
    255         if (coor == null) {
     301        if (isLatLonKnown()) {
    256302            builder.append("Coor is null\n");
    257303        } else {
    258             builder.append(String.format("EastNorth: %s\n", coor.getEastNorth()));
    259             builder.append(coor.getProjection());
     304            builder.append(String.format("EastNorth: %s\n", getEastNorth()));
     305            builder.append(Main.getProjection());
    260306            builder.append("\n");
    261307        }
     
    263309        return builder.toString();
    264310    }
     311
     312    /**
     313     * Invoke to invalidate the internal cache of projected east/north coordinates.
     314     * Coordinates are reprojected on demand when the {@link #getEastNorth()} is invoked
     315     * next time.
     316     */
     317    public void invalidateEastNorthCache() {
     318        this.east = Double.NaN;
     319        this.north = Double.NaN;
     320    }
    265321}
  • trunk/src/org/openstreetmap/josm/data/osm/NodeData.java

    r4100 r4126  
    22package org.openstreetmap.josm.data.osm;
    33
    4 import org.openstreetmap.josm.data.coor.CachedLatLon;
    54import org.openstreetmap.josm.data.coor.EastNorth;
    65import org.openstreetmap.josm.data.coor.LatLon;
    76import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
     7import org.openstreetmap.josm.data.projection.Projections;
    88
    99public class NodeData extends PrimitiveData implements INode {
    1010
    11     private final CachedLatLon coor = new CachedLatLon(0, 0);
     11    /*
     12     * we "inline" lat/lon coordinates instead of using a LatLon => reduces memory footprint
     13     */
     14    private double lat = Double.NaN;
     15    private double lon = Double.NaN;
    1216
    13     public NodeData() {
    14 
    15     }
     17    public NodeData() {}
    1618
    1719    public NodeData(NodeData data) {
     
    2022    }
    2123
     24    private boolean isLatLonKnown() {
     25        return lat != Double.NaN && lon != Double.NaN;
     26    }
     27   
    2228    @Override
    2329    public LatLon getCoor() {
    24         return coor;
     30        return isLatLonKnown() ? new LatLon(lat,lon) : null;
    2531    }
    2632
    2733    @Override
    2834    public void setCoor(LatLon coor) {
    29         this.coor.setCoor(coor);
     35        if (coor == null) {
     36            this.lat = Double.NaN;
     37            this.lon = Double.NaN;
     38        } else {
     39            this.lat = coor.lat();
     40            this.lon = coor.lon();
     41        }
    3042    }
    3143
    3244    @Override
    3345    public EastNorth getEastNorth() {
    34         return this.coor.getEastNorth();
     46        /*
     47         * No internal caching of projected coordinates needed. In contrast to getEastNorth()
     48         * on Node, this method is rarely used. Caching would be overkill.
     49         */
     50        return Projections.project(getCoor());
    3551    }
    3652
    3753    @Override
    3854    public void setEastNorth(EastNorth eastNorth) {
    39         this.coor.setEastNorth(eastNorth);
     55        LatLon ll = Projections.inverseProject(eastNorth);
     56        setCoor(ll);
    4057    }
    4158
     
    4764    @Override
    4865    public String toString() {
    49         return super.toString() + " NODE " + coor;
     66        return super.toString() + " NODE " + getCoor();
    5067    }
    5168
     
    5471        return OsmPrimitiveType.NODE;
    5572    }
    56    
    57     @Override 
     73
     74    @Override
    5875    public void visit(PrimitiveVisitor visitor) {
    5976        visitor.visit(this);
     
    6481        return formatter.format(this);
    6582    }
    66 
    6783}
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java

    r4065 r4126  
    113113        if (bounds == null)
    114114            return;
    115         LatLon minLatlon = Main.proj.eastNorth2latlon(bounds.getMin());
    116         LatLon maxLatlon = Main.proj.eastNorth2latlon(bounds.getMax());
     115        LatLon minLatlon = Main.getProjection().eastNorth2latlon(bounds.getMin());
     116        LatLon maxLatlon = Main.getProjection().eastNorth2latlon(bounds.getMax());
    117117        bounds = new ProjectionBounds(
    118                 Main.proj.latlon2eastNorth(new LatLon(minLatlon.lat() - enlargeDegree, minLatlon.lon() - enlargeDegree)),
    119                 Main.proj.latlon2eastNorth(new LatLon(maxLatlon.lat() + enlargeDegree, maxLatlon.lon() + enlargeDegree)));
     118                Main.getProjection().latlon2eastNorth(new LatLon(minLatlon.lat() - enlargeDegree, minLatlon.lon() - enlargeDegree)),
     119                Main.getProjection().latlon2eastNorth(new LatLon(maxLatlon.lat() + enlargeDegree, maxLatlon.lon() + enlargeDegree)));
    120120    }
    121121
  • trunk/src/org/openstreetmap/josm/data/projection/Projections.java

    r3874 r4126  
    22package org.openstreetmap.josm.data.projection;
    33
     4import java.util.ArrayList;
    45import java.util.Arrays;
    5 import java.util.ArrayList;
     6
     7import org.openstreetmap.josm.Main;
     8import org.openstreetmap.josm.data.coor.EastNorth;
     9import org.openstreetmap.josm.data.coor.LatLon;
    610
    711/**
     
    1418     */
    1519    private static ArrayList<Projection> allProjections =
    16     new ArrayList<Projection>(Arrays.asList(new Projection[] {
    17         // global projections
    18         new Epsg4326(),
    19         new Mercator(),
    20         new UTM(),
    21         // regional - alphabetical order by country name
    22         new LambertEST(), // Still needs proper default zoom
    23         new Lambert(),    // Still needs proper default zoom
    24         new LambertCC9Zones(),    // Still needs proper default zoom
    25         new UTM_France_DOM(),
    26         new TransverseMercatorLV(),
    27         new Puwg(),
    28         new Epsg3008(), // SWEREF99 13 30
    29         new SwissGrid(),
    30     }));
     20        new ArrayList<Projection>(Arrays.asList(new Projection[] {
     21                // global projections
     22                new Epsg4326(),
     23                new Mercator(),
     24                new UTM(),
     25                // regional - alphabetical order by country name
     26                new LambertEST(), // Still needs proper default zoom
     27                new Lambert(),    // Still needs proper default zoom
     28                new LambertCC9Zones(),    // Still needs proper default zoom
     29                new UTM_France_DOM(),
     30                new TransverseMercatorLV(),
     31                new Puwg(),
     32                new Epsg3008(), // SWEREF99 13 30
     33                new SwissGrid(),
     34        }));
    3135
    3236    public static ArrayList<Projection> getProjections() {
     
    4347        allProjections.add(proj);
    4448    }
     49
     50    static public EastNorth project(LatLon ll) {
     51        if (ll == null) return null;
     52        return Main.getProjection().latlon2eastNorth(ll);
     53    }
     54
     55    static public LatLon inverseProject(EastNorth en) {
     56        if (en == null) return null;
     57        return Main.getProjection().eastNorth2latlon(en);
     58    }
    4559}
  • trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java

    r4051 r4126  
    2323import org.openstreetmap.josm.Main;
    2424import org.openstreetmap.josm.actions.ValidateAction;
    25 import org.openstreetmap.josm.actions.upload.ValidateUploadHook;
    2625import org.openstreetmap.josm.data.projection.Epsg4326;
    2726import org.openstreetmap.josm.data.projection.Lambert;
     
    3029import org.openstreetmap.josm.data.validation.tests.CrossingWays;
    3130import org.openstreetmap.josm.data.validation.tests.DuplicateNode;
     31import org.openstreetmap.josm.data.validation.tests.DuplicateRelation;
    3232import org.openstreetmap.josm.data.validation.tests.DuplicateWay;
    33 import org.openstreetmap.josm.data.validation.tests.DuplicateRelation;
    3433import org.openstreetmap.josm.data.validation.tests.DuplicatedWayNodes;
    3534import org.openstreetmap.josm.data.validation.tests.MultipolygonTest;
     
    4847import org.openstreetmap.josm.data.validation.tests.WronglyOrderedWays;
    4948import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    50 import org.openstreetmap.josm.gui.layer.ValidatorLayer;
    5149import org.openstreetmap.josm.gui.layer.Layer;
    5250import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     51import org.openstreetmap.josm.gui.layer.ValidatorLayer;
    5352import org.openstreetmap.josm.gui.preferences.ValidatorPreference;
    5453
     
    7776    @SuppressWarnings("unchecked")
    7877    public static Class<Test>[] allAvailableTests = new Class[] {
    79             DuplicateNode.class, // ID    1 ..   99
    80             OverlappingWays.class, // ID  101 ..  199
    81             UntaggedNode.class, // ID  201 ..  299
    82             UntaggedWay.class, // ID  301 ..  399
    83             SelfIntersectingWay.class, // ID  401 ..  499
    84             DuplicatedWayNodes.class, // ID  501 ..  599
    85             CrossingWays.class, // ID  601 ..  699
    86             SimilarNamedWays.class, // ID  701 ..  799
    87             NodesWithSameName.class, // ID  801 ..  899
    88             Coastlines.class, // ID  901 ..  999
    89             WronglyOrderedWays.class, // ID 1001 .. 1099
    90             UnclosedWays.class, // ID 1101 .. 1199
    91             TagChecker.class, // ID 1201 .. 1299
    92             UnconnectedWays.class, // ID 1301 .. 1399
    93             DuplicateWay.class, // ID 1401 .. 1499
    94             NameMismatch.class, // ID  1501 ..  1599
    95             MultipolygonTest.class, // ID  1601 ..  1699
    96             RelationChecker.class, // ID  1701 ..  1799
    97             TurnrestrictionTest.class, // ID  1801 ..  1899
    98             DuplicateRelation.class, // ID 1901 .. 1999
     78        DuplicateNode.class, // ID    1 ..   99
     79        OverlappingWays.class, // ID  101 ..  199
     80        UntaggedNode.class, // ID  201 ..  299
     81        UntaggedWay.class, // ID  301 ..  399
     82        SelfIntersectingWay.class, // ID  401 ..  499
     83        DuplicatedWayNodes.class, // ID  501 ..  599
     84        CrossingWays.class, // ID  601 ..  699
     85        SimilarNamedWays.class, // ID  701 ..  799
     86        NodesWithSameName.class, // ID  801 ..  899
     87        Coastlines.class, // ID  901 ..  999
     88        WronglyOrderedWays.class, // ID 1001 .. 1099
     89        UnclosedWays.class, // ID 1101 .. 1199
     90        TagChecker.class, // ID 1201 .. 1299
     91        UnconnectedWays.class, // ID 1301 .. 1399
     92        DuplicateWay.class, // ID 1401 .. 1499
     93        NameMismatch.class, // ID  1501 ..  1599
     94        MultipolygonTest.class, // ID  1601 ..  1699
     95        RelationChecker.class, // ID  1701 ..  1799
     96        TurnrestrictionTest.class, // ID  1801 ..  1899
     97        DuplicateRelation.class, // ID 1901 .. 1999
    9998    };
    10099
     
    242241     */
    243242    public void initializeGridDetail() {
    244         if (Main.proj.toString().equals(new Epsg4326().toString())) {
     243        if (Main.getProjection().toString().equals(new Epsg4326().toString())) {
    245244            OsmValidator.griddetail = 10000;
    246         } else if (Main.proj.toString().equals(new Mercator().toString())) {
     245        } else if (Main.getProjection().toString().equals(new Mercator().toString())) {
    247246            OsmValidator.griddetail = 0.01;
    248         } else if (Main.proj.toString().equals(new Lambert().toString())) {
     247        } else if (Main.getProjection().toString().equals(new Lambert().toString())) {
    249248            OsmValidator.griddetail = 0.1;
    250249        }
     
    265264                JOptionPane.showMessageDialog(Main.parent,
    266265                        tr("Error initializing test {0}:\n {1}", test.getClass()
    267                         .getSimpleName(), e),
    268                         tr("Error"),
    269                         JOptionPane.ERROR_MESSAGE);
     266                                .getSimpleName(), e),
     267                                tr("Error"),
     268                                JOptionPane.ERROR_MESSAGE);
    270269            }
    271270        }
Note: See TracChangeset for help on using the changeset viewer.