Changeset 1910 in josm for trunk/src/org/openstreetmap/josm/gui/layer
- Timestamp:
- 2009-08-05T08:19:02+02:00 (15 years ago)
- 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 710 710 for (GpxTrack trk : data.tracks) { 711 711 for (Collection<WayPoint> segment : trk.trackSegs) { 712 Way w = new Way();712 List<Node> nodes = new ArrayList<Node>(); 713 713 for (WayPoint p : segment) { 714 714 Node n = new Node(p.getCoor()); … … 718 718 } 719 719 ds.nodes.add(n); 720 w.nodes.add(n); 721 } 720 nodes.add(n); 721 } 722 Way w = new Way(); 723 w.setNodes(nodes); 722 724 ds.ways.add(w); 723 725 } … … 741 743 /** 742 744 * Action that issues a series of download requests to the API, following the GPX track. 743 * 745 * 744 746 * @author fred 745 747 */ … … 842 844 * can only download rectangles, so the following is an attempt at finding a number of 843 845 * rectangles to download. 844 * 846 * 845 847 * The idea is simply: Start out with the full bounding box. If it is too large, then 846 848 * split it in half and repeat recursively for each half until you arrive at something … … 1141 1143 * Makes a WayPoint at the projection of point P onto the track providing P is less than 1142 1144 * tolerance away from the track 1143 * 1145 * 1144 1146 * @param P : the point to determine the projection for 1145 1147 * @param tolerance : must be no further than this from the track … … 1151 1153 * assume the coordinates of P are xp,yp, and those of a section of track between two 1152 1154 * trackpoints are R=xr,yr and S=xs,ys. Let N be the projected point. 1153 * 1155 * 1154 1156 * The equation of RS is Ax + By + C = 0 where A = ys - yr B = xr - xs C = - Axr - Byr 1155 * 1157 * 1156 1158 * Also, note that the distance RS^2 is A^2 + B^2 1157 * 1159 * 1158 1160 * If RS^2 == 0.0 ignore the degenerate section of track 1159 * 1161 * 1160 1162 * PN^2 = (Axp + Byp + C)^2 / RS^2 that is the distance from P to the line 1161 * 1163 * 1162 1164 * so if PN^2 is less than PNmin^2 (initialized to tolerance) we can reject the line; 1163 1165 * otherwise... determine if the projected poijnt lies within the bounds of the line: PR^2 - 1164 1166 * PN^2 <= RS^2 and PS^2 - PN^2 <= RS^2 1165 * 1167 * 1166 1168 * where PR^2 = (xp - xr)^2 + (yp-yr)^2 and PS^2 = (xp - xs)^2 + (yp-ys)^2 1167 * 1169 * 1168 1170 * If so, calculate N as xn = xr + (RN/RS) B yn = y1 + (RN/RS) A 1169 * 1171 * 1170 1172 * where RN = sqrt(PR^2 - PN^2) 1171 1173 */ -
trunk/src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java
r1890 r1910 14 14 import java.awt.event.ActionListener; 15 15 import java.io.File; 16 import java.util.ArrayList; 16 17 import java.util.Collection; 18 import java.util.List; 17 19 18 20 import javax.swing.AbstractAction; … … 73 75 DataSet ds = new DataSet(); 74 76 for (Collection<GpsPoint> c : data) { 75 Way w = new Way();77 List<Node> nodes = new ArrayList<Node>(); 76 78 for (GpsPoint p : c) { 77 79 Node n = new Node(p.latlon); 78 80 ds.nodes.add(n); 79 w.nodes.add(n); 80 } 81 nodes.add(n); 82 } 83 Way w = new Way(); 84 w.setNodes(nodes); 81 85 ds.ways.add(w); 82 86 }
Note:
See TracChangeset
for help on using the changeset viewer.