Changeset 40 in josm for src/org/openstreetmap/josm/data


Ignore:
Timestamp:
2006-01-11T23:39:36+01:00 (18 years ago)
Author:
imi
Message:
  • added world boundaries
  • added bug report exception handler
  • raw gps/real data when open depends now on extension
Location:
src/org/openstreetmap/josm/data
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/data/Bounds.java

    r23 r40  
    11package org.openstreetmap.josm.data;
     2
     3import org.openstreetmap.josm.Main;
     4import org.openstreetmap.josm.data.projection.Projection;
    25
    36/**
     
    4548                this.max = max;
    4649        }
    47        
     50
     51        /**
     52         * Construct bounds that span the whole world.
     53         */
     54        public Bounds() {
     55                min = new GeoPoint(-Projection.MAX_LAT, -Projection.MAX_LON);
     56                Main.pref.getProjection().latlon2xy(min);
     57                max = new GeoPoint(Projection.MAX_LAT, Projection.MAX_LON);
     58                Main.pref.getProjection().latlon2xy(max);
     59        }
     60
    4861        /**
    4962         * @return The bounding rectangle that covers <code>this</code> and
     
    5972                return new Bounds(nmin, nmax);
    6073        }
    61        
     74
    6275        /**
    6376         * @return The bounding rectangle that covers <code>this</code> and
  • src/org/openstreetmap/josm/data/GeoPoint.java

    r18 r40  
    11package org.openstreetmap.josm.data;
     2
     3import org.openstreetmap.josm.data.projection.Projection;
    24
    35
     
    6668                                !Double.isNaN(lat) && !Double.isNaN(lon);
    6769        }
     70
     71        /**
     72         * @return <code>true</code>, if the coordinate is outside the world, compared
     73         * by using lat/lon.
     74         */
     75        public boolean isOutSideWorld() {
     76                return lat < -Projection.MAX_LAT || lat > Projection.MAX_LAT ||
     77                        lon < -Projection.MAX_LON || lon > Projection.MAX_LON;
     78        }
    6879}
  • src/org/openstreetmap/josm/data/osm/DataSet.java

    r35 r40  
    5050                o.addAll(lineSegments);
    5151                o.addAll(tracks);
     52                return o;
     53        }
     54
     55        /**
     56         * @return A collection containing all not-deleted primitives (except keys).
     57         */
     58        public Collection<OsmPrimitive> allNonDeletedPrimitives() {
     59                Collection<OsmPrimitive> o = new LinkedList<OsmPrimitive>();
     60                for (OsmPrimitive osm : allPrimitives())
     61                        if (!osm.isDeleted())
     62                                o.add(osm);
    5263                return o;
    5364        }
  • src/org/openstreetmap/josm/data/osm/visitor/AddVisitor.java

    r35 r40  
    2626        public void visit(Node n) {
    2727                ds.nodes.add(n);
    28                 n.setDeleted(false);
    2928        }
    3029        public void visit(LineSegment ls) {
    3130                ds.lineSegments.add(ls);
    32                 ls.setDeleted(false);
    3331        }
    3432        public void visit(Track t) {
    3533                ds.tracks.add(t);
    36                 t.setDeleted(false);
    3734        }
    3835        public void visit(Key k) {}
  • src/org/openstreetmap/josm/data/osm/visitor/CollectBackReferencesVisitor.java

    r31 r40  
    1414 * Helper that collect all line segments a node is part of, all tracks
    1515 * a node or line segment is part of and all areas a node is part of.
     16 *
     17 * Deleted objects are not collected.
     18 *
    1619 * @author imi
    1720 */
     
    2528        public final Collection<OsmPrimitive> data = new HashSet<OsmPrimitive>();
    2629
     30
     31        /**
     32         * Construct a back reference counter.
     33         * @param ds The dataset to operate on.
     34         */
    2735        public CollectBackReferencesVisitor(DataSet ds) {
    2836                this.ds = ds;
     
    3139        public void visit(Node n) {
    3240                for (Track t : ds.tracks) {
     41                        if (t.isDeleted())
     42                                continue;
    3343                        for (LineSegment ls : t.segments) {
    3444                                if (ls.start == n || ls.end == n) {
     
    3848                        }
    3949                }
    40                 for (LineSegment ls : ds.lineSegments)
     50                for (LineSegment ls : ds.lineSegments) {
     51                        if (ls.isDeleted())
     52                                continue;
    4153                        if (ls.start == n || ls.end == n)
    4254                                data.add(ls);
     55                }
    4356        }
    4457        public void visit(LineSegment ls) {
    45                 for (Track t : ds.tracks)
     58                for (Track t : ds.tracks) {
     59                        if (t.isDeleted())
     60                                continue;
    4661                        if (t.segments.contains(ls))
    4762                                data.add(t);
     63                }
    4864        }
    4965        public void visit(Track t) {}
  • src/org/openstreetmap/josm/data/projection/Projection.java

    r23 r40  
    1818 */
    1919abstract public class Projection implements Cloneable {
     20
     21        public static double MAX_LAT = 85; // yep - JOSM cannot cartograph the poles.
     22        public static double MAX_LON = 179.99999;
    2023
    2124        /**
  • src/org/openstreetmap/josm/data/projection/UTM.java

    r35 r40  
    195195        ZoneData autoDetect(Bounds b) {
    196196                ZoneData zd = new ZoneData();
    197                 if (b == null)
    198                         return zd;
    199197                GeoPoint center = b.centerLatLon();
    200198                double lat = center.lat;
Note: See TracChangeset for help on using the changeset viewer.