Ticket #494: gpx_draw.patch
| File gpx_draw.patch, 2.7 KB (added by , 19 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/layer/GpxLayer.java
old new 43 43 import org.openstreetmap.josm.actions.SaveAction; 44 44 import org.openstreetmap.josm.actions.SaveAsAction; 45 45 import org.openstreetmap.josm.actions.RenameLayerAction; 46 import org.openstreetmap.josm.data.coor.LatLon; 46 47 import org.openstreetmap.josm.data.gpx.GpxData; 47 48 import org.openstreetmap.josm.data.gpx.GpxTrack; 48 49 import org.openstreetmap.josm.data.gpx.GpxRoute; … … 229 230 boolean large = Main.pref.getBoolean("draw.rawgps.large"); 230 231 231 232 Point old = null; 233 LatLon oldlatlon = null; 232 234 for (GpxTrack trk : data.tracks) { 233 235 if (!forceLines) { 234 236 old = null; … … 237 239 for (WayPoint trkPnt : segment) { 238 240 Point screen = mv.getPoint(trkPnt.eastNorth); 239 241 if (lines && old != null) { 240 g.drawLine(old.x, old.y, screen.x, screen.y); 242 /* Calculate approximate line distance in meters */ 243 double d; 244 d = Math.pow(trkPnt.latlon.lat()-oldlatlon.lat(),2) + 245 Math.pow(Math.cos(Math.toRadians(trkPnt.latlon.lat())),2) * 246 Math.pow(trkPnt.latlon.lon()-oldlatlon.lon(),2); 247 d = Math.pow(d,0.5) * 111111.1; 248 if(d<100.0) 249 g.drawLine(old.x, old.y, screen.x, screen.y); 241 250 } else if (!large) { 242 251 g.drawRect(screen.x, screen.y, 0, 0); 243 252 } 244 253 if (large) 245 254 g.fillRect(screen.x-1, screen.y-1, 3, 3); 246 255 old = screen; 256 oldlatlon = trkPnt.latlon; 247 257 } 248 258 } 249 259 } -
src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java
old new 244 244 else 245 245 g.setColor(Color.GRAY); 246 246 Point old = null; 247 LatLon oldlatlon = null; 247 248 248 249 boolean force = Main.pref.getBoolean("draw.rawgps.lines.force"); 249 250 boolean lines = Main.pref.getBoolean("draw.rawgps.lines"); … … 256 257 old = null; 257 258 for (GpsPoint p : c) { 258 259 Point screen = mv.getPoint(p.eastNorth); 259 if (lines && old != null) 260 g.drawLine(old.x, old.y, screen.x, screen.y); 260 if (lines && old != null) { 261 /* Calculate approximate line distance in meters */ 262 double d; 263 d = Math.pow(p.latlon.lat()-oldlatlon.lat(),2) + 264 Math.pow(Math.cos(Math.toRadians(p.latlon.lat())),2) * 265 Math.pow(p.latlon.lon()-oldlatlon.lon(),2); 266 d = Math.pow(d,0.5) * 111111.1; 267 if(d<100.0) 268 g.drawLine(old.x, old.y, screen.x, screen.y); 269 } 261 270 else if (!large) 262 271 g.drawRect(screen.x, screen.y, 0, 0); 263 272 if (large) 264 273 g.fillRect(screen.x-1, screen.y-1, 3, 3); 265 274 old = screen; 275 oldlatlon = p.latlon; 266 276 } 267 277 } 268 278 }
