Ignore:
Timestamp:
2009-08-05T08:19:02+02:00 (15 years ago)
Author:
jttt
Message:

Way refactoring - finish replacing Way.nodes with the new api

Location:
trunk/src/org/openstreetmap/josm/gui/layer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r1890 r1910  
    710710            for (GpxTrack trk : data.tracks) {
    711711                for (Collection<WayPoint> segment : trk.trackSegs) {
    712                     Way w = new Way();
     712                    List<Node> nodes = new ArrayList<Node>();
    713713                    for (WayPoint p : segment) {
    714714                        Node n = new Node(p.getCoor());
     
    718718                        }
    719719                        ds.nodes.add(n);
    720                         w.nodes.add(n);
    721                     }
     720                        nodes.add(n);
     721                    }
     722                    Way w = new Way();
     723                    w.setNodes(nodes);
    722724                    ds.ways.add(w);
    723725                }
     
    741743    /**
    742744     * Action that issues a series of download requests to the API, following the GPX track.
    743      * 
     745     *
    744746     * @author fred
    745747     */
     
    842844             * can only download rectangles, so the following is an attempt at finding a number of
    843845             * rectangles to download.
    844              * 
     846             *
    845847             * The idea is simply: Start out with the full bounding box. If it is too large, then
    846848             * split it in half and repeat recursively for each half until you arrive at something
     
    11411143     * Makes a WayPoint at the projection of point P onto the track providing P is less than
    11421144     * tolerance away from the track
    1143      * 
     1145     *
    11441146     * @param P : the point to determine the projection for
    11451147     * @param tolerance : must be no further than this from the track
     
    11511153         * assume the coordinates of P are xp,yp, and those of a section of track between two
    11521154         * trackpoints are R=xr,yr and S=xs,ys. Let N be the projected point.
    1153          * 
     1155         *
    11541156         * The equation of RS is Ax + By + C = 0 where A = ys - yr B = xr - xs C = - Axr - Byr
    1155          * 
     1157         *
    11561158         * Also, note that the distance RS^2 is A^2 + B^2
    1157          * 
     1159         *
    11581160         * If RS^2 == 0.0 ignore the degenerate section of track
    1159          * 
     1161         *
    11601162         * PN^2 = (Axp + Byp + C)^2 / RS^2 that is the distance from P to the line
    1161          * 
     1163         *
    11621164         * so if PN^2 is less than PNmin^2 (initialized to tolerance) we can reject the line;
    11631165         * otherwise... determine if the projected poijnt lies within the bounds of the line: PR^2 -
    11641166         * PN^2 <= RS^2 and PS^2 - PN^2 <= RS^2
    1165          * 
     1167         *
    11661168         * where PR^2 = (xp - xr)^2 + (yp-yr)^2 and PS^2 = (xp - xs)^2 + (yp-ys)^2
    1167          * 
     1169         *
    11681170         * If so, calculate N as xn = xr + (RN/RS) B yn = y1 + (RN/RS) A
    1169          * 
     1171         *
    11701172         * where RN = sqrt(PR^2 - PN^2)
    11711173         */
  • trunk/src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java

    r1890 r1910  
    1414import java.awt.event.ActionListener;
    1515import java.io.File;
     16import java.util.ArrayList;
    1617import java.util.Collection;
     18import java.util.List;
    1719
    1820import javax.swing.AbstractAction;
     
    7375            DataSet ds = new DataSet();
    7476            for (Collection<GpsPoint> c : data) {
    75                 Way w = new Way();
     77                List<Node> nodes = new ArrayList<Node>();
    7678                for (GpsPoint p : c) {
    7779                    Node n = new Node(p.latlon);
    7880                    ds.nodes.add(n);
    79                     w.nodes.add(n);
    80                 }
     81                    nodes.add(n);
     82                }
     83                Way w = new Way();
     84                w.setNodes(nodes);
    8185                ds.ways.add(w);
    8286            }
Note: See TracChangeset for help on using the changeset viewer.