Changeset 29955 in osm for applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap
- Timestamp:
- 2013-09-24T17:11:58+02:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation
- Files:
-
- 13 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationMapMode.java
r29948 r29955 21 21 import org.openstreetmap.josm.actions.mapmode.MapMode; 22 22 import org.openstreetmap.josm.gui.MapFrame; 23 import org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile;24 23 25 24 /** -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/HgtReader.java
r29921 r29955 44 44 for (String location : Main.pref.getAllPossiblePreferenceDirs()) { 45 45 String fullPath = new File(location + File.separator + "elevation", file).getPath(); 46 47 System.out.println(fullPath);48 46 File f = new File(fullPath); 49 47 if (f.exists()) { 50 48 // found something: read HGT file... 51 ShortBuffer data = readHgtFile(fullPath); 52 System.out.println("Read SRTM data from " + fullPath + ", tag is '" + file + "'"); 49 ShortBuffer data = readHgtFile(fullPath); 53 50 // ... and store result in cache 54 51 cache.put(file, data); … … 109 106 110 107 if (sb == null) { 111 System.out.println("readElevation: Buffer is null for tag '" + tag + "'");112 108 return ElevationHelper.NO_ELEVATION; 113 109 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationModel.java
r29954 r29955 1 package org.openstreetmap.josm.plugins.elevation .gpx;1 package org.openstreetmap.josm.plugins.elevation; 2 2 3 3 import java.util.List; 4 4 5 import org.openstreetmap.josm.plugins.elevation.IElevationModelListener;6 5 7 6 public interface IElevationModel { -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationModelListener.java
r29948 r29955 16 16 17 17 import org.openstreetmap.josm.plugins.elevation.gpx.ElevationModel; 18 import org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile;19 18 20 19 /** -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationProfile.java
r29954 r29955 13 13 */ 14 14 15 package org.openstreetmap.josm.plugins.elevation .gpx;15 package org.openstreetmap.josm.plugins.elevation; 16 16 17 17 import java.util.Date; -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationModel.java
r29948 r29955 23 23 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 24 24 import org.openstreetmap.josm.data.gpx.WayPoint; 25 import org.openstreetmap.josm.plugins.elevation.IElevationModel; 25 26 import org.openstreetmap.josm.plugins.elevation.IElevationModelListener; 27 import org.openstreetmap.josm.plugins.elevation.IElevationProfile; 26 28 import org.openstreetmap.josm.tools.CheckParameterUtil; 27 29 … … 37 39 private int trackCounter; 38 40 private GpxData gpxData; 39 41 private String name; 40 42 private WayPointMap children = new WayPointMap(); 41 43 private List<IElevationModelListener> listeners = new ArrayList<IElevationModelListener>(); 42 44 private List<WayPoint> buffer = new ArrayList<WayPoint>(); 43 45 private int currentProfileIndex = 0; 44 46 private ElevationProfileBase curProfile = null; 45 47 46 48 /** … … 59 61 public ElevationModel(String name, GpxData data) { 60 62 gpxData = data; 61 63 this.name = name; 62 64 GpxIterator.visit(data, this); 63 65 } … … 135 137 // we ignore the segment here 136 138 processWayPoint(wp); 139 137 140 } 138 141 … … 146 149 147 150 public void start() { 148 c hildren.clear();151 curProfile = new ElevationProfileBase(name); 149 152 } 150 153 151 154 public void end() { 152 String trackName = "Track#" + trackCounter; 153 addTrackOrRoute(trackName); 154 } 155 155 String trackName = name; //gpxData.getString(GpxData.META_NAME);// "Track#" + trackCounter; 156 157 if (trackCounter > 0) { 158 trackName += "." + trackCounter; 159 } 160 addTrackOrRoute(trackName); 161 trackCounter++; 162 } 163 164 165 @Override 166 public void start(GpxTrack track) { 167 curProfile = new ElevationProfileBase(name); 168 } 169 170 @Override 171 public void end(GpxTrack track) { 172 if (curProfile == null) throw new RuntimeException("Internal error: No elevation profile"); 173 174 curProfile.setDistance(track.length()); 175 addTrackOrRoute(name); 176 } 177 178 @Override 179 public void start(GpxTrack track, GpxTrackSegment segment) { 180 // Nothing to do here for now 181 } 182 183 @Override 184 public void end(GpxTrack track, GpxTrackSegment segment) { 185 // Nothing to do here for now 186 } 187 188 189 /** 190 * Adds a track or route to the internal track list. 191 * 192 * @param trackName the track name 193 */ 156 194 private void addTrackOrRoute(String trackName) { 157 if (buffer.size() > 0) { 158 159 System.out.println("Add track " + trackName + ", n = " + buffer.size()); // TODO: Remove 160 161 ElevationProfileBase ep = new ElevationProfileBase(trackName); 162 ep.setWayPoints(buffer); 163 ep.setName(trackName); 164 children.add(ep); 165 buffer.clear(); 195 if (buffer.size() > 0) { 196 curProfile.setWayPoints(buffer); 197 curProfile.setName(trackName); 198 children.add(curProfile); 166 199 } 167 200 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationProfileBase.java
r29948 r29955 21 21 import org.openstreetmap.josm.data.gpx.WayPoint; 22 22 import org.openstreetmap.josm.plugins.elevation.ElevationHelper; 23 import org.openstreetmap.josm.plugins.elevation.IElevationProfile; 23 24 24 25 /** -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/GpxIterator.java
r29907 r29955 45 45 if (data == null) return; 46 46 if (visitor == null) return; 47 48 if (data.isEmpty()) return; 47 49 48 50 visitor.start(); … … 94 96 95 97 Collection<GpxTrackSegment> segments = trk.getSegments(); 96 visitor.start(); 97 98 98 99 if (segments != null) { 100 visitor.start(trk); 101 // visit all segments 99 102 for (GpxTrackSegment segment : segments) { 100 101 // no visitor here...103 Collection<WayPoint> waypts = segment.getWayPoints(); 104 // no visitor here... 102 105 if (waypts == null) 103 106 continue; 104 107 108 visitor.start(trk, segment); 109 105 110 for (WayPoint wayPoint : waypts) { 106 111 visitor.visit(wayPoint); 107 112 } 113 114 visitor.end(trk, segment); 108 115 } 109 } 110 visitor.end(); 116 visitor.end(trk); 117 } 118 111 119 } 112 120 -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/IGpxVisitor.java
r29907 r29955 15 15 package org.openstreetmap.josm.plugins.elevation.gpx; 16 16 17 import org.openstreetmap.josm.data.gpx.GpxTrack; 18 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 17 19 import org.openstreetmap.josm.data.gpx.WayPoint; 18 20 … … 23 25 public interface IGpxVisitor extends IGpxWaypointVisitor { 24 26 /** 25 * Starts a GPX route , trackor way point collection.27 * Starts a GPX route or way point collection. 26 28 */ 27 29 void start(); 28 30 29 31 /** 30 * Ends a GPX route , trackor way point collection.32 * Ends a GPX route or way point collection. 31 33 */ 32 34 void end(); 35 36 /** 37 * Starts a GPX track. 38 */ 39 void start(GpxTrack track); 40 41 /** 42 * Ends a GPX track. 43 */ 44 void end(GpxTrack track); 45 46 47 /** 48 * Starts a segment within a GPX track. 49 */ 50 void start(GpxTrack track, GpxTrackSegment segment); 51 52 /** 53 * Ends a segment within a GPX track. 54 */ 55 void end(GpxTrack track, GpxTrackSegment segment); 33 56 34 57 /** -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/WayPointMap.java
r29948 r29955 2 2 3 3 import java.util.ArrayList; 4 5 import org.openstreetmap.josm.plugins.elevation.IElevationProfile; 4 6 5 7 public class WayPointMap extends ArrayList<IElevationProfile> { -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/DefaultElevationProfileRenderer.java
r29950 r29955 35 35 import org.openstreetmap.josm.gui.MapView; 36 36 import org.openstreetmap.josm.plugins.elevation.ElevationHelper; 37 import org.openstreetmap.josm.plugins.elevation.IElevationProfile; 37 38 import org.openstreetmap.josm.plugins.elevation.gpx.ElevationWayPointKind; 38 import org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile;39 39 import org.openstreetmap.josm.tools.CheckParameterUtil; 40 40 … … 62 62 private static final Color START_COLOR = Color.GREEN; 63 63 private static final Color END_POINT = Color.RED; 64 private static final Color LEVEL_GAIN_COLOR = Color.GREEN; 65 private static final Color LEVEL_LOSS_COLOR = Color.RED; 64 66 private static final Color MARKER_POINT = Color.YELLOW; 65 67 // Predefined radians … … 93 95 switch (kind) { 94 96 case Plain: 95 return Color.LIGHT_GRAY;97 return Color.LIGHT_GRAY; 96 98 case ElevationLevelLoss: 99 return LEVEL_LOSS_COLOR; 97 100 case ElevationLevelGain: 98 if (z > profile.getAverageHeight()) { 99 return HIGH_COLOR; 100 } else { 101 return LOW_COLOR; 102 } 101 return LEVEL_GAIN_COLOR; 103 102 case Highlighted: 104 103 return Color.ORANGE; … … 108 107 return Color.getHSBColor(0, 1.0f, 1.0f); // red 109 108 case ElevationGainLow: 110 return Color.getHSBColor(0.3f, 0. 7f, 1.0f); // green with low sat109 return Color.getHSBColor(0.3f, 0.5f, 1.0f); // green with low sat 111 110 case ElevationLossLow: 112 return Color.getHSBColor(0, 0. 7f, 1.0f); // red with low sat111 return Color.getHSBColor(0, 0.5f, 1.0f); // red with low sat 113 112 case FullHour: 114 113 return MARKER_POINT; … … 238 237 int ele = ((int) Math.rint(ElevationHelper.getElevation(wpt) / 100.0)) * 100; 239 238 drawLabelWithTriangle(ElevationHelper.getElevationText(ele), pnt.x, pnt.y 240 + g.getFontMetrics().getHeight(), g, c, 8,239 + g.getFontMetrics().getHeight(), g, Color.darkGray, 8, 241 240 getColorForWaypoint(profile, wpt, kind), 242 TriangleDir.Up);241 kind == ElevationWayPointKind.ElevationLevelGain ? TriangleDir.Up : TriangleDir.Down); 243 242 } 244 243 -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java
r29950 r29955 40 40 import org.openstreetmap.josm.gui.layer.Layer; 41 41 import org.openstreetmap.josm.plugins.elevation.ElevationHelper; 42 import org.openstreetmap.josm.plugins.elevation.IElevationModel; 42 43 import org.openstreetmap.josm.plugins.elevation.IElevationModelListener; 44 import org.openstreetmap.josm.plugins.elevation.IElevationProfile; 43 45 import org.openstreetmap.josm.plugins.elevation.gpx.ElevationModel; 44 46 import org.openstreetmap.josm.plugins.elevation.gpx.GeoidCorrectionKind; 45 import org.openstreetmap.josm.plugins.elevation.gpx.IElevationModel;46 import org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile;47 47 import org.openstreetmap.josm.tools.Shortcut; 48 48 /** -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java
r29950 r29955 31 31 import org.openstreetmap.josm.gui.layer.Layer; 32 32 import org.openstreetmap.josm.plugins.elevation.ElevationHelper; 33 import org.openstreetmap.josm.plugins.elevation.IElevationProfile; 33 34 import org.openstreetmap.josm.plugins.elevation.gpx.ElevationWayPointKind; 34 import org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile;35 35 import org.openstreetmap.josm.tools.ImageProvider; 36 36 … … 88 88 @Override 89 89 public Icon getIcon() { 90 return ImageProvider.get("layer", "elevation _small");90 return ImageProvider.get("layer", "elevation"); 91 91 } 92 92 … … 245 245 // TODO: Provide parameters for high/low thresholds 246 246 if (slope > 2) kind =ElevationWayPointKind.ElevationGainLow; 247 if (slope > 1 0) kind =ElevationWayPointKind.ElevationGainHigh;247 if (slope > 15) kind =ElevationWayPointKind.ElevationGainHigh; 248 248 } else { 249 249 if (slope > 2) kind =ElevationWayPointKind.ElevationLossLow; 250 if (slope > 1 0) kind =ElevationWayPointKind.ElevationLossHigh;250 if (slope > 15) kind =ElevationWayPointKind.ElevationLossHigh; 251 251 } 252 252 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfilePanel.java
r29952 r29955 38 38 import org.openstreetmap.josm.data.gpx.WayPoint; 39 39 import org.openstreetmap.josm.plugins.elevation.ElevationHelper; 40 import org.openstreetmap.josm.plugins.elevation.IElevationModel; 41 import org.openstreetmap.josm.plugins.elevation.IElevationProfile; 40 42 import org.openstreetmap.josm.plugins.elevation.gpx.ElevationWayPointKind; 41 import org.openstreetmap.josm.plugins.elevation.gpx.IElevationModel;42 import org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile;43 43 44 44 /** … … 142 142 143 143 int selWp = this.selectedIndex * step; 144 if (profile != null && profile.getWayPoints() != null && profile.getWayPoints().size() > selWp) {144 if (profile != null && profile.getWayPoints() != null && selWp > 0 && profile.getWayPoints().size() > selWp) { 145 145 return profile.getWayPoints().get(selWp); 146 146 } else { -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/IElevationProfileRenderer.java
r29950 r29955 20 20 import org.openstreetmap.josm.data.gpx.WayPoint; 21 21 import org.openstreetmap.josm.gui.MapView; 22 import org.openstreetmap.josm.plugins.elevation.IElevationProfile; 22 23 import org.openstreetmap.josm.plugins.elevation.gpx.ElevationWayPointKind; 23 import org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile;24 24 25 25 /**
Note:
See TracChangeset
for help on using the changeset viewer.