Changeset 32775 in osm for applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap
- Timestamp:
- 2016-08-06T00:52:15+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ColorMap.java
r32315 r32775 15 15 * 16 16 */ 17 public class ColorMap {17 public final class ColorMap { 18 18 private List<ColorMapEntry> colorList; 19 19 private String name; … … 67 67 68 68 // interpolate color between both 69 double val = (elevation - e1.getEle()) / (double) (e2.getEle() - e1.getEle());69 double val = (elevation - e1.getEle()) / (double) (e2.getEle() - e1.getEle()); 70 70 return interpolate(e1.getColor(), e2.getColor(), val); 71 71 } … … 165 165 } 166 166 167 168 167 class ColorMapEntry implements Comparable<ColorMapEntry> { 169 168 private final int ele; // limit 170 169 private final Color color; 171 170 172 publicColorMapEntry(Color color, int ele) {171 ColorMapEntry(Color color, int ele) { 173 172 super(); 174 173 this.color = color; -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationHelper.java
r32315 r32775 16 16 * Provides methods to access way point attributes and some utility methods regarding elevation stuff ( 17 17 * e. g. special text formats, unit conversion, geoid calc). 18 * @author Oliver Wieland <oliver.wieland@online.de>18 * @author Oliver Wieland <oliver.wieland@online.de> 19 19 */ 20 public class ElevationHelper { 20 public final class ElevationHelper { 21 22 private ElevationHelper() { 23 // Hide default constructor for utilities classes 24 } 25 21 26 public static double METER_TO_FEET = 3.280948; 22 27 23 28 /* Countries which use the imperial system instead of the metric system. */ 24 private static String IMPERIAL_SYSTEM_COUNTRIES[]= {25 "en_US", /* USA */26 "en_CA", /* Canada */27 "en_AU", /* Australia */28 "en_NZ", /* New Zealand */29 // "de_DE", /* for testing only */30 "en_ZA" /* South Africa */29 private static String[] IMPERIAL_SYSTEM_COUNTRIES = { 30 "en_US", /* USA */ 31 "en_CA", /* Canada */ 32 "en_AU", /* Australia */ 33 "en_NZ", /* New Zealand */ 34 // "de_DE", /* for testing only */ 35 "en_ZA" /* South Africa */ 31 36 }; 32 37 … … 48 53 /** 49 54 * Gets the current mode of GEOID correction. 50 * @return51 55 */ 52 56 public static GeoidCorrectionKind getGeoidKind() { … … 60 64 /** 61 65 * Gets the current unit mode (metric or imperial). 62 * @return63 66 */ 64 67 public static UnitMode getUnitMode() { … … 88 91 /** 89 92 * Gets the unit string for elevation ("m" or "ft"). 90 * @return91 93 */ 92 94 public static String getUnit() { … … 148 150 } 149 151 } 150 151 152 152 153 private static double getElevation(LatLon ll) { … … 211 212 /** 212 213 * Gets the elevation string for a given elevation, e. g "300m" or "800ft". 213 * @param elevation214 * @return215 214 */ 216 215 public static String getElevationText(int elevation) { … … 220 219 /** 221 220 * Gets the elevation string for a given elevation, e. g "300m" or "800ft". 222 * @param elevation223 * @return224 221 */ 225 222 public static String getElevationText(double elevation) { 226 return String.format("%d %s", (int) Math.round(elevation), getUnit());223 return String.format("%d %s", (int) Math.round(elevation), getUnit()); 227 224 } 228 225 … … 236 233 if (wpt == null) return "-"; 237 234 238 int elevation = (int) Math.round(ElevationHelper.getElevation(wpt));235 int elevation = (int) Math.round(ElevationHelper.getElevation(wpt)); 239 236 return String.format("%d %s", elevation, getUnit()); 240 237 } … … 242 239 /** 243 240 * Get the time string for a given way point. 244 * @param wpt245 * @return246 241 */ 247 242 public static String getTimeText(WayPoint wpt) { … … 287 282 LatLon br = bounds.getMax(); 288 283 289 return 284 return isValidElevation(getSrtmElevation(tl)) && 290 285 isValidElevation(getSrtmElevation(br)); 291 286 } … … 343 338 /** 344 339 * Gets the hour value of a way point in 24h format. 345 * @param wpt346 * @return347 340 */ 348 341 public static int getHourOfWayPoint(WayPoint wpt) { … … 356 349 /** 357 350 * Gets the minute value of a way point in 24h format. 358 * @param wpt359 * @return360 351 */ 361 352 public static int getMinuteOfWayPoint(WayPoint wpt) { -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationMapMode.java
r30344 r32775 10 10 11 11 /** 12 * @author Oliver Wieland <oliver.wieland@online.de>12 * @author Oliver Wieland <oliver.wieland@online.de> 13 13 * Provides the map mode and controls visibility of the elevation profile layer/panel. 14 14 */ 15 15 public class ElevationMapMode extends MapMode implements IElevationModelListener { 16 16 /** 17 * 17 * 18 18 */ 19 19 private static final long serialVersionUID = -1011179566962655639L; 20 21 20 22 21 public ElevationMapMode(String name, MapFrame mapFrame) { -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationProfilePlugin.java
r32443 r32775 18 18 /** 19 19 * Plugin class for displaying an elevation profile of the tracks. 20 * @author Oliver Wieland <oliver.wieland@online.de>20 * @author Oliver Wieland <oliver.wieland@online.de> 21 21 * 22 22 */ … … 60 60 * Gets the elevation profile layer which decorates the current layer 61 61 * with some markers. 62 * @return63 62 */ 64 public static ElevationProfileLayer getCurrentLayer() {65 if (currentLayer == null){63 public static ElevationProfileLayer getCurrentLayer() { 64 if (currentLayer == null) { 66 65 currentLayer = new ElevationProfileLayer(tr("Elevation Profile")); 67 66 Main.getLayerManager().addLayer(currentLayer); … … 74 73 ColorMap.create("Physical_US", 75 74 new Color[]{ 76 new Color(18, 129,242),77 new Color(113, 153,89),78 new Color(117, 170,101),79 new Color(149, 190,113),80 new Color(178, 214,117),81 new Color(202, 226,149),82 new Color(222, 238,161),83 new Color(242, 238,161),84 new Color(238, 222,153),85 new Color(242, 206,133),86 new Color(234, 182,129),87 new Color(218, 157,121),88 new Color(194, 141,125),89 new Color(214, 157,145),90 new Color(226, 174,165),91 new Color(222, 186,182),92 new Color(238, 198,210),93 new Color(255, 206,226),94 new Color(250, 218,234),95 new Color(255, 222,230),96 new Color(255, 230,242),97 new Color(255, 242,255)75 new Color(18, 129, 242), 76 new Color(113, 153, 89), 77 new Color(117, 170, 101), 78 new Color(149, 190, 113), 79 new Color(178, 214, 117), 80 new Color(202, 226, 149), 81 new Color(222, 238, 161), 82 new Color(242, 238, 161), 83 new Color(238, 222, 153), 84 new Color(242, 206, 133), 85 new Color(234, 182, 129), 86 new Color(218, 157, 121), 87 new Color(194, 141, 125), 88 new Color(214, 157, 145), 89 new Color(226, 174, 165), 90 new Color(222, 186, 182), 91 new Color(238, 198, 210), 92 new Color(255, 206, 226), 93 new Color(250, 218, 234), 94 new Color(255, 222, 230), 95 new Color(255, 230, 242), 96 new Color(255, 242, 255) 98 97 }, 99 98 // elevation in meters - the page above uses feet, so these values differs slightly -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/HgtReader.java
r32315 r32775 19 19 * 20 20 * SRTM data files are available at the <a href="http://dds.cr.usgs.gov/srtm/version2_1/SRTM3">NASA SRTM site</a> 21 * @author Oliver Wieland <oliver.wieland@online.de>21 * @author Oliver Wieland <oliver.wieland@online.de> 22 22 */ 23 23 public class HgtReader { … … 116 116 117 117 // compute offset within HGT file 118 int row = (int) Math.round(fLat * SECONDS_PER_MINUTE / HGT_RES);119 int col = (int) Math.round(fLon * SECONDS_PER_MINUTE / HGT_RES);118 int row = (int) Math.round(fLat * SECONDS_PER_MINUTE / HGT_RES); 119 int col = (int) Math.round(fLon * SECONDS_PER_MINUTE / HGT_RES); 120 120 121 121 row = HGT_ROW_LENGTH - row; 122 int cell = (HGT_ROW_LENGTH *(row - 1)) + col;122 int cell = (HGT_ROW_LENGTH * (row - 1)) + col; 123 123 124 124 //System.out.println("Read SRTM elevation data from row/col/cell " + row + "," + col + ", " + cell + ", " + sb.limit()); -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IEleRenderingListener.java
r30344 r32775 11 11 * @param vertex the vertex 12 12 */ 13 publicvoid finished(EleVertex vertex);13 void finished(EleVertex vertex); 14 14 15 15 /** 16 16 * Notifies a client that all vertices can be rendered now. 17 17 */ 18 publicvoid finishedAll();18 void finishedAll(); 19 19 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationModel.java
r30344 r32775 8 8 /** 9 9 * Adds a model listener to this instance. 10 * 10 * 11 11 * @param listener 12 12 * The listener to add. 13 13 */ 14 public abstractvoid addModelListener(IElevationModelListener listener);14 void addModelListener(IElevationModelListener listener); 15 15 16 16 /** 17 17 * Removes a model listener from this instance. 18 * 18 * 19 19 * @param listener 20 20 * The listener to remove. 21 21 */ 22 public abstractvoid removeModelListener(IElevationModelListener listener);22 void removeModelListener(IElevationModelListener listener); 23 23 24 24 /** 25 25 * Removes all listeners from this instance. 26 26 */ 27 public abstractvoid removeAllListeners();27 void removeAllListeners(); 28 28 29 29 /** … … 32 32 * @return the profiles 33 33 */ 34 public abstractList<IElevationProfile> getProfiles();34 List<IElevationProfile> getProfiles(); 35 35 36 36 /** … … 39 39 * @return the current profile 40 40 */ 41 public abstractIElevationProfile getCurrentProfile();41 IElevationProfile getCurrentProfile(); 42 42 43 43 /** … … 46 46 * @param newProfile the new current profile 47 47 */ 48 public abstractvoid setCurrentProfile(IElevationProfile newProfile);48 void setCurrentProfile(IElevationProfile newProfile); 49 49 50 50 /** … … 53 53 * @param index the new current profile. Valied numbers are 0 to (profileCount - 1) 54 54 */ 55 public abstractvoid setCurrentProfile(int index);55 void setCurrentProfile(int index); 56 56 57 57 /** … … 60 60 * @return the int 61 61 */ 62 public abstract int profileCount(); 63 62 int profileCount(); 64 63 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationModelListener.java
r30344 r32775 8 8 * repaint UI widgets). 9 9 * {@link ElevationModel} 10 * @author Oliver Wieland <oliver.wieland@online.de>10 * @author Oliver Wieland <oliver.wieland@online.de> 11 11 */ 12 12 public interface IElevationModelListener { -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationProfile.java
r30344 r32775 9 9 10 10 /** 11 * @author Oliver Wieland <oliver.wieland@online.de>11 * @author Oliver Wieland <oliver.wieland@online.de> 12 12 * Interface for an elevation profile providing special properties/values. 13 13 */ … … 15 15 /** 16 16 * Gets the name of the elevation profile. 17 * @return18 17 */ 19 public abstractString getName();18 String getName(); 20 19 21 20 /** 22 21 * Gets the time stamp of first recorded track point. 23 * @return24 22 */ 25 public abstractDate getStart();23 Date getStart(); 26 24 27 25 /** 28 26 * Gets the time stamp of last recorded track point. 29 * @return30 27 */ 31 public abstractDate getEnd();28 Date getEnd(); 32 29 33 30 /** 34 31 * Gets the minimum elevation height of all tracks and routes. 35 * @return36 32 */ 37 public abstractint getMinHeight();33 int getMinHeight(); 38 34 39 35 /** 40 36 * Gets the maximum elevation height of all tracks and routes. 41 * @return42 37 */ 43 public abstractint getMaxHeight();38 int getMaxHeight(); 44 39 45 40 /** 46 41 * Gets the distance of the track in kilometers. 47 42 */ 48 public abstractdouble getDistance();43 double getDistance(); 49 44 50 45 /** 51 46 * Gets the average elevation height of all tracks and routes. 52 * @return53 47 */ 54 public abstractint getAverageHeight();48 int getAverageHeight(); 55 49 56 50 /** 57 51 * Gets the difference between min and max elevation. 58 * @return59 52 */ 60 publicint getHeightDifference();53 int getHeightDifference(); 61 54 62 55 /** 63 56 * Gets the elevation gain. 64 * 65 * @return 57 * 66 58 */ 67 publicint getGain();59 int getGain(); 68 60 69 61 /** 70 62 * Gets the total number of way points (sum of all way points of all tracks and routes). 71 * @return72 63 */ 73 public abstractint getNumberOfWayPoints();64 int getNumberOfWayPoints(); 74 65 75 66 /** 76 67 * Gets the list containing the way points. 77 * @return78 68 */ 79 publicList<WayPoint> getWayPoints();69 List<WayPoint> getWayPoints(); 80 70 81 71 /** 82 72 * Gets the first recorded way point. 83 * @return84 73 */ 85 publicWayPoint getStartWayPoint();74 WayPoint getStartWayPoint(); 86 75 87 76 /** 88 77 * Gets the last recorded way point. 89 * @return90 78 */ 91 publicWayPoint getEndWayPoint();79 WayPoint getEndWayPoint(); 92 80 93 81 /** 94 82 * Gets the way point with the highest elevation value. 95 * @return96 83 */ 97 publicWayPoint getMaxWayPoint();84 WayPoint getMaxWayPoint(); 98 85 99 86 /** 100 87 * Gets the way point with the lowest elevation value. 101 * @return102 88 */ 103 publicWayPoint getMinWayPoint();89 WayPoint getMinWayPoint(); 104 90 105 91 /** … … 107 93 * contained elevation data or not. This is the case if min 108 94 * and max height are equal. 109 * @return110 95 */ 111 publicboolean hasElevationData();96 boolean hasElevationData(); 112 97 113 98 /** 114 99 * Returns the time between start and end of the track. 115 * @return116 100 */ 117 publiclong getTimeDifference();101 long getTimeDifference(); 118 102 119 103 /** 120 104 * Gets the elevation value for at the given data index point. 121 105 */ 122 publicint elevationValueAt(int i);106 int elevationValueAt(int i); 123 107 124 108 /** … … 127 111 * @return the bounds 128 112 */ 129 publicBounds getBounds();113 Bounds getBounds(); 130 114 131 115 /** 132 116 * Gets the children of the segment (maybe null). 133 117 */ 134 publicList<IElevationProfile> getChildren();118 List<IElevationProfile> getChildren(); 135 119 136 120 /** 137 121 * Gets the parent of the elevation profile. 138 122 */ 139 publicIElevationProfile getParent();123 IElevationProfile getParent(); 140 124 141 125 /** 142 126 * Triggers model refresh. 143 127 */ 144 publicvoid updateElevationData();128 void updateElevationData(); 145 129 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IVertexRenderer.java
r30344 r32775 8 8 /** 9 9 * The interface IVertexRenderer. 10 * 10 * 11 11 * Implementors should provide a default color map which cannot be unregistered 12 12 */ … … 19 19 * @return the elevation color 20 20 */ 21 publicColor getElevationColor(EleVertex vertex);21 Color getElevationColor(EleVertex vertex); 22 22 23 23 /** … … 27 27 * @param mapToUse the map to use 28 28 */ 29 public void selectColorMap(String name); 30 29 void selectColorMap(String name); 31 30 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/UnitMode.java
r30344 r32775 3 3 4 4 /** 5 * @author Oliver Wieland <oliver.wieland@online.de>5 * @author Oliver Wieland <oliver.wieland@online.de> 6 6 * Enumeration for different unit types. 7 7 */ -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationModel.java
r32315 r32775 20 20 * breaks done into the tracks/routes of a GPX file. 21 21 * 22 * @author Oliver Wieland <oliver.wieland@online.de> 22 23 * @see IElevationModelTrackListener 23 * @author Oliver Wieland <oliver.wieland@online.de>24 24 */ 25 25 public class ElevationModel implements IGpxVisitor, IElevationModel { … … 55 55 /** 56 56 * Gets the GPX data instance used by this model. 57 *58 * @return59 57 */ 60 58 public GpxData getGpxData() { … … 119 117 @Override 120 118 public void setCurrentProfile(int index) { 121 if (index < 0 || index >= profileCount()) throw new RuntimeException("Invalid arg for setCurrentProfile: " + index + ", value must be 0.." + profileCount()); 119 if (index < 0 || index >= profileCount()) 120 throw new RuntimeException("Invalid arg for setCurrentProfile: " + index + ", value must be 0.." + profileCount()); 122 121 123 122 currentProfileIndex = index; … … 146 145 // we ignore single way points (elevation profile is quite meaningless...) 147 146 } 148 149 147 150 148 @Override -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationProfile.java
r32315 r32775 29 29 * {@link IElevationProfile} {@link IGpxWaypointVisitor} {@link GpxIterator} 30 30 * 31 * @author Oliver Wieland <oliver.wieland@online.de>31 * @author Oliver Wieland <oliver.wieland@online.de> 32 32 * 33 33 */ … … 59 59 /** 60 60 * Creates a name elevation profile without any way points. 61 *62 * @param name63 61 */ 64 62 public ElevationProfile(String name) { … … 187 185 /** 188 186 * Sets the average height. 189 * @param avrgHeight190 187 */ 191 188 protected void setAvrgHeight(int avrgHeight) { … … 195 192 /** 196 193 * Sets the very first way point. 197 * @param wp198 194 */ 199 195 protected void setStart(WayPoint wp) { … … 204 200 /** 205 201 * Sets the very last way point. 206 * @param wp207 202 */ 208 203 protected void setEnd(WayPoint wp) { … … 217 212 /** 218 213 * Sets the way points of this profile. 219 *220 * @param wayPoints221 214 */ 222 215 public void setWayPoints(List<WayPoint> wayPoints) { … … 225 218 numWayPoints = wayPoints != null ? wayPoints.size() : 0; 226 219 updateValues(); 227 228 220 } 229 221 } … … 278 270 /** 279 271 * Gets the difference between min and max elevation. 280 *281 * @return282 272 */ 283 273 @Override … … 288 278 /** 289 279 * Gets the elevation gain. 290 *291 * @return292 280 */ 293 281 @Override … … 303 291 /** 304 292 * Sets the distance of the elevation profile. 305 * @param dist306 293 */ 307 294 protected void setDistance(double dist) { … … 311 298 /** 312 299 * Returns the time between start and end of the track. 313 * @return314 300 */ 315 301 @Override … … 363 349 @Override 364 350 public int getNumberOfWayPoints() { 365 return numWayPoints; // wayPoints != null ? wayPoints.size() : 0;351 return numWayPoints; // wayPoints != null ? wayPoints.size() : 0; 366 352 } 367 353 … … 380 366 * elevation data or not. This is the case if min and max height or both 381 367 * zero. 382 *383 * @return384 368 */ 385 369 @Override -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationWayPointKind.java
r30344 r32775 3 3 4 4 /** 5 * @author Oliver Wieland <oliver.wieland@online.de>5 * @author Oliver Wieland <oliver.wieland@online.de> 6 6 * Enumeration which classifies way points within an elevation profile. 7 7 */ 8 8 public enum ElevationWayPointKind { 9 Plain, 10 Highlighted, 11 StartPoint, 12 EndPoint, 13 MaxElevation, 14 MinElevation, 15 ElevationGainHigh, 16 ElevationLossHigh, 17 ElevationGainLow, 18 ElevationLossLow, 19 ElevationLevelGain, 20 ElevationLevelLoss, 9 Plain, // Simple way point (equal to no or low slope) 10 Highlighted, // Highlighted waypoint 11 StartPoint, // First way point 12 EndPoint, // Last way point 13 MaxElevation, // Highest way point 14 MinElevation, // Lowest way point 15 ElevationGainHigh, // Elevation gain (high slope 15-25%) 16 ElevationLossHigh, // Elevation loss (high downward slope) 17 ElevationGainLow, // Elevation gain (low slope, 5-14.9%) 18 ElevationLossLow, // Elevation loss (low downward slope) 19 ElevationLevelGain, // Elevation level gain (e. g. crossed 300m from lower elevation) 20 ElevationLevelLoss, // Elevation level (e. g. crossed 300m from higher elevation) 21 21 FullHour // Full Hour 22 22 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/GeoidCorrectionKind.java
r30344 r32775 3 3 4 4 /** 5 * @author Oliver Wieland <oliver.wieland@online.de>5 * @author Oliver Wieland <oliver.wieland@online.de> 6 6 * Enumeration for available elevation correction modes. 7 7 */ -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/GpxIterator.java
r30344 r32775 12 12 /** 13 13 * Utility class to apply a visitor on GPX containers (track, route, data). 14 * @author Oliver Wieland <oliver.wieland@online.de>14 * @author Oliver Wieland <oliver.wieland@online.de> 15 15 */ 16 public class GpxIterator {16 public final class GpxIterator { 17 17 /** 18 18 * Static class, no need to instantiate me. … … 23 23 * Runs the given visitor on a GPX data instance. If one or both 24 24 * arguments are null, this method will return immediately. 25 * 25 * 26 26 * @param data 27 27 * The GPX data instance. … … 74 74 // ---------------------- Helper methods ---------------- 75 75 76 /**77 * @param visitor78 * @param trk79 */80 76 private static void visitTrack(IGpxVisitor visitor, GpxTrack trk) { 81 77 if (trk == null) return; … … 103 99 visitor.endTrack(trk); 104 100 } 105 106 101 } 107 102 108 /**109 * @param visitor110 * @param route111 */112 103 private static void visitRoute(IGpxVisitor visitor, GpxRoute route) { 113 104 if (route == null) return; … … 121 112 } 122 113 123 /**124 * @param data125 * @param visitor126 */127 114 private static void visitSingleWaypoints(GpxData data, IGpxVisitor visitor) { 128 115 // isolated way points -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/IGpxVisitor.java
r30344 r32775 9 9 /** 10 10 * Interface for all GPX visitors. 11 * @author Oliver Wieland <oliver.wieland@online.de>11 * @author Oliver Wieland <oliver.wieland@online.de> 12 12 */ 13 13 public interface IGpxVisitor extends IGpxWaypointVisitor { -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/IGpxWaypointVisitor.java
r30344 r32775 5 5 6 6 /** 7 * @author Oliver Wieland <oliver.wieland@online.de>7 * @author Oliver Wieland <oliver.wieland@online.de> 8 8 * Interface for all GPX data visitors. Hopefully this will be part of JOSM some day. 9 9 */ -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/EleVertex.java
r32315 r32775 173 173 } 174 174 175 176 177 178 175 class TriangleEdge implements Comparable<TriangleEdge> { 179 176 private final int i; … … 181 178 private final double dist; 182 179 183 publicTriangleEdge(int i, int j, double dist) {180 TriangleEdge(int i, int j, double dist) { 184 181 super(); 185 182 this.i = i; -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridLayer.java
r32315 r32775 28 28 29 29 /** 30 * @author Oliver Wieland <oliver.wieland@online.de>30 * @author Oliver Wieland <oliver.wieland@online.de> 31 31 * 32 32 */ … … 42 42 private TileSet tileSet; 43 43 44 /**45 * @param info46 */47 44 public ElevationGridLayer(String name) { 48 45 super(name); … … 80 77 } 81 78 82 for (int x = tileSet.x0; x <= tileSet.x1; x++) {83 for (int y = tileSet.y0; y <= tileSet.y1; y++) {79 for (int x = tileSet.x0; x <= tileSet.x1; x++) { 80 for (int y = tileSet.y0; y <= tileSet.y1; y++) { 84 81 Tile t = tileController.getTile(x, y, ELE_ZOOM_LEVEL); 85 82 86 83 if (t != null && t.isLoaded() && t instanceof ElevationGridTile) { 87 ((ElevationGridTile) t).paintTile(g, mv, vertexRenderer);84 ((ElevationGridTile) t).paintTile(g, mv, vertexRenderer); 88 85 } else { 89 86 // give some consolation... … … 119 116 Main.map.repaint(100); 120 117 } 121 } catch (Exception ex) {118 } catch (Exception ex) { 122 119 System.err.println(ex); 123 120 ex.printStackTrace(System.err); … … 153 150 Color oldColor = g.getColor(); 154 151 g.setColor(Color.black); 155 g.drawString(text, x+1,y+1);152 g.drawString(text, x+1, y+1); 156 153 g.setColor(oldColor); 157 g.drawString(text, x,y);154 g.drawString(text, x, y); 158 155 } 159 156 … … 165 162 * Create a TileSet by known LatLon bbox without layer shift correction 166 163 */ 167 publicTileSet(LatLon topLeft, LatLon botRight, int zoom) {164 TileSet(LatLon topLeft, LatLon botRight, int zoom) { 168 165 if (zoom == 0) 169 166 return; … … 186 183 y1 = tmp; 187 184 } 188 tileMax = (int) Math.pow(2.0, zoom);185 tileMax = (int) Math.pow(2.0, zoom); 189 186 if (x0 < 0) { 190 187 x0 = 0; -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridTile.java
r32315 r32775 59 59 60 60 /** 61 * Use {@link ElevationGridTile#paintTile(Graphics2D, MapView, IVertexRenderer)} to render the tile as grid. This method just issues a debug text. 61 * Use {@link ElevationGridTile#paintTile(Graphics2D, MapView, IVertexRenderer)} to render the tile as grid. 62 * This method just issues a debug text. 62 63 */ 63 64 @Override … … 170 171 + ", ytile=" + ytile + "]"; 171 172 } 172 173 174 173 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/ElevationGridTileController.java
r32315 r32775 16 16 public class ElevationGridTileController extends TileController { 17 17 18 /**19 * @param source20 * @param tileCache21 * @param listener22 */23 18 public ElevationGridTileController(TileSource source, TileCache tileCache, 24 19 TileLoaderListener listener, TileLoader loader) { -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/grid/SimpleVertexRenderer.java
r30344 r32775 14 14 private ColorMap cMap = null; 15 15 16 /**17 *18 */19 16 public SimpleVertexRenderer() { 20 17 cMap = ColorMap.getMap(ColorMap.getNames()[0]); … … 26 23 } 27 24 28 29 25 @Override 30 26 public void selectColorMap(String name) { 31 27 // TODO Auto-generated method stub 32 33 28 } 34 35 29 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/DefaultElevationProfileRenderer.java
r32315 r32775 28 28 /** 29 29 * Provides default rendering for elevation profile layer. 30 * @author Oliver Wieland <oliver.wieland@online.de>30 * @author Oliver Wieland <oliver.wieland@online.de> 31 31 */ 32 32 public class DefaultElevationProfileRenderer implements … … 287 287 288 288 // coordinates for upwards directed triangle 289 Point p[]= new Point[3];289 Point[] p = new Point[3]; 290 290 291 291 for (int i = 0; i < p.length; i++) { … … 384 384 Point2D focus = new Point2D.Float(x - (radius * 0.6f), y 385 385 - (radius * 0.6f)); 386 float[] dist = { 0.1f, 0.2f, 1.0f};387 Color[] colors = { firstCol, secondCol, Color.DARK_GRAY};386 float[] dist = {0.1f, 0.2f, 1.0f}; 387 Color[] colors = {firstCol, secondCol, Color.DARK_GRAY}; 388 388 RadialGradientPaint p = new RadialGradientPaint(center, radius, focus, 389 389 dist, colors, CycleMethod.NO_CYCLE); … … 414 414 415 415 /** 416 * Draws a label within a filled rounded rectangle with the specified second gradient color (first color is <tt>Color.WHITE< tt>).416 * Draws a label within a filled rounded rectangle with the specified second gradient color (first color is <tt>Color.WHITE</tt>). 417 417 * 418 418 * @param s … … 539 539 // nothing to do currently 540 540 } 541 542 543 541 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationColors.java
r30344 r32775 8 8 /** 9 9 * Contains some extra predefined colors. 10 * @author Oliver Wieland <oliver.wieland@online.de>10 * @author Oliver Wieland <oliver.wieland@online.de> 11 11 */ 12 public class ElevationColors { 12 public final class ElevationColors { 13 14 private ElevationColors() { 15 // Hide default constructor for utilities classes 16 } 17 13 18 public static Color EPDarkBlue = new Color(21, 59, 99); 14 19 public static Color EPMidBlue = new Color(115, 140, 180); … … 24 29 private final int ele; // limit 25 30 private final Color color; 26 public ColorMapEntry(java.awt.Color color, int ele) { 31 32 ColorMapEntry(Color color, int ele) { 27 33 super(); 28 34 this.color = color; … … 39 45 } 40 46 41 42 43 47 private static ColorMapEntry[] colors = new ColorMapEntry[]{ 44 new ColorMapEntry(new Color(0,128, 0), 0),45 new ColorMapEntry(new Color(156,187, 105), 1),46 new ColorMapEntry(new Color(193,208, 107), 100),47 new ColorMapEntry(new Color(244,224, 100), 200),48 new ColorMapEntry(new Color(242,216, 149), 500),49 new ColorMapEntry(new Color(234,191, 104), 1000),50 new ColorMapEntry(new Color(207,169, 96), 2000),48 new ColorMapEntry(new Color(0, 128, 0), 0), 49 new ColorMapEntry(new Color(156, 187, 105), 1), 50 new ColorMapEntry(new Color(193, 208, 107), 100), 51 new ColorMapEntry(new Color(244, 224, 100), 200), 52 new ColorMapEntry(new Color(242, 216, 149), 500), 53 new ColorMapEntry(new Color(234, 191, 104), 1000), 54 new ColorMapEntry(new Color(207, 169, 96), 2000), 51 55 }; 52 53 56 54 57 public static Color getElevationColor(double ele) { -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java
r32443 r32775 45 45 46 46 /** 47 * @author Oliver Wieland <oliver.wieland@online.de>47 * @author Oliver Wieland <oliver.wieland@online.de> 48 48 * Implements a JOSM ToggleDialog to show the elevation profile. It monitors the 49 49 * connection between layer and elevation profile. … … 216 216 /** 217 217 * Gets the elevation model instance. 218 * @return219 218 */ 220 219 public IElevationModel getModel() { … … 236 235 /** 237 236 * Gets the associated layer instance of the elevation profile. 238 * @return239 237 */ 240 238 public ElevationProfileLayer getProfileLayer() { -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java
r30344 r32775 25 25 * Layer class to show additional information on the elevation map, e. g. show 26 26 * min/max elevation markers. 27 * 28 * @author Oliver Wieland <oliver.wieland@online.de>29 * 27 * 28 * @author Oliver Wieland <oliver.wieland@online.de> 29 * 30 30 */ 31 31 public class ElevationProfileLayer extends Layer implements IElevationProfileSelectionListener { … … 38 38 /** 39 39 * Creates a new elevation profile layer 40 * 40 * 41 41 * @param name 42 42 * The name of the layer. … … 48 48 /** 49 49 * Gets the current elevation profile shown in this layer. 50 *51 * @return52 50 */ 53 51 public IElevationProfile getProfile() { … … 57 55 /** 58 56 * Sets the current elevation profile shown in this layer. 59 * 57 * 60 58 * @param profile 61 59 * The profile to show in the layer … … 81 79 public Action[] getMenuEntries() { 82 80 // TODO: More entries??? 83 return new Action[] { new LayerListPopup.InfoAction(this)};81 return new Action[] {new LayerListPopup.InfoAction(this)}; 84 82 } 85 83 … … 159 157 /** 160 158 * Checks if the given way point requires special decoration (e. g. elevation gain/loss or level crossing). 161 * 159 * 162 160 * Parameters <tt>ele1</tt> and <tt>ele2</tt> point are used for detecting "level crossings", 163 161 * e. g. 1 to 2 indicate that we crossed the 200m elevation in upward direction … … 173 171 174 172 // normalize elevation to levels 175 int actLevel = (int) (actEle / Level_Factor);176 int lastLevel = (int) (lastEle / Level_Factor);173 int actLevel = (int) (actEle / Level_Factor); 174 int lastLevel = (int) (lastEle / Level_Factor); 177 175 double slope = Math.abs(ElevationHelper.computeSlope(lastWpt.getCoor(), actWpt.getCoor())); 178 176 … … 184 182 if (actLevel != lastLevel && Math.abs(actLevel - lastLevel) == 1) { 185 183 if (actLevel > lastLevel) { // we went down? 186 kind = ElevationWayPointKind.ElevationLevelGain;184 kind = ElevationWayPointKind.ElevationLevelGain; 187 185 } else { 188 kind = ElevationWayPointKind.ElevationLevelLoss;186 kind = ElevationWayPointKind.ElevationLevelLoss; 189 187 } 190 188 } else { // check for elevation gain or loss 191 189 if (actEle > lastEle) { // we went uphill? 192 190 // TODO: Provide parameters for high/low thresholds 193 if (slope > 2) kind = ElevationWayPointKind.ElevationGainLow;194 if (slope > 15) kind = ElevationWayPointKind.ElevationGainHigh;191 if (slope > 2) kind = ElevationWayPointKind.ElevationGainLow; 192 if (slope > 15) kind = ElevationWayPointKind.ElevationGainHigh; 195 193 } else { 196 if (slope > 2) kind = ElevationWayPointKind.ElevationLossLow;197 if (slope > 15) kind = ElevationWayPointKind.ElevationLossHigh;194 if (slope > 2) kind = ElevationWayPointKind.ElevationLossLow; 195 if (slope > 15) kind = ElevationWayPointKind.ElevationLossHigh; 198 196 } 199 197 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfilePanel.java
r32315 r32775 32 32 /** 33 33 * Provides the panel showing the elevation profile. 34 * @author Oliver Wieland <oliver.wieland@online.de>34 * @author Oliver Wieland <oliver.wieland@online.de> 35 35 * 36 36 */ … … 69 69 /** 70 70 * Gets the elevation profile instance. 71 * @return72 71 */ 73 72 public IElevationModel getProfile() { … … 77 76 /** 78 77 * Sets the new elevation profile instance. 79 * @param model80 78 */ 81 79 public void setElevationModel(IElevationModel model) { … … 88 86 /** 89 87 * Gets the plot area coordinates. 90 * @return91 88 */ 92 89 public Rectangle getPlotArea() { … … 96 93 /** 97 94 * Sets the plot area coordinates. 98 * @param plotArea99 95 */ 100 96 public void setPlotArea(Rectangle plotArea) { … … 104 100 /** 105 101 * Gets the selected index of the bar. 106 * @return107 102 */ 108 103 public int getSelectedIndex() { … … 112 107 /** 113 108 * Sets the selected index of the bar. 114 * @param selectedIndex115 109 */ 116 110 public void setSelectedIndex(int selectedIndex) { … … 259 253 /** 260 254 * Formats the date in a predefined manner: "21. Oct 2010, 12:10". 261 * @param date262 * @return263 255 */ 264 256 private String formatDate(Date date) { … … 270 262 /** 271 263 * Helper function to draw elevation axes. 272 * @param g273 264 */ 274 265 private void drawElevationLines(Graphics g) { … … 321 312 * Gets the x value of the left border for axes (slightly smaller than the 322 313 * left x). 323 *324 * @return325 314 */ 326 315 private int getPlotLeftAxis() { … … 330 319 /** 331 320 * Gets the x value of the left border. 332 *333 * @return334 321 */ 335 322 private int getPlotLeft() { … … 339 326 /** 340 327 * Gets the horizontal center coordinate (mid between left and right x). 341 *342 * @return343 328 */ 344 329 private int getPlotHCenter() { … … 348 333 /** 349 334 * Gets the vertical center coordinate (mid between top and bottom y). 350 *351 * @return352 335 */ 353 336 private int getPlotVCenter() { … … 357 340 /** 358 341 * Gets the x value of the right border. 359 *360 * @return361 342 */ 362 343 private int getPlotRight() { … … 374 355 /** 375 356 * Gets for an elevation value the according y coordinate in the plot area. 376 *377 * @param elevation378 357 * @return The y coordinate in the plot area. 379 358 */ … … 394 373 /** 395 374 * Draws the elevation profile 396 *397 * @param g398 375 */ 399 376 private void drawProfile(Graphics g) { … … 511 488 WayPoint wpt = getSelectedWayPoint(); 512 489 if (wpt != null) { 513 return 490 return String.format("%s: %s", ElevationHelper.getTimeText(wpt), ElevationHelper.getElevationText(wpt)); 514 491 } 515 492 -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/IElevationProfileRenderer.java
r30344 r32775 15 15 * Second, the layer can simply pass the painting stuff to a renderer without taking care of 16 16 * details. 17 * 18 * @author Oliver Wieland <oliver.wieland@online.de>17 * 18 * @author Oliver Wieland <oliver.wieland@online.de> 19 19 * 20 20 */ -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/IElevationProfileSelectionListener.java
r30344 r32775 7 7 /** 8 8 * Notifies clients about selected index changed. 9 * @param newIndex10 9 */ 11 publicvoid selectedWayPointChanged(WayPoint wpt);10 void selectedWayPointChanged(WayPoint wpt); 12 11 } -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/TextAlignment.java
r30344 r32775 3 3 4 4 /** 5 * @author Oliver Wieland <oliver.wieland@online.de>5 * @author Oliver Wieland <oliver.wieland@online.de> 6 6 * 7 7 */ -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/Triangle.java
r30344 r32775 13 13 14 14 /** 15 * @author Oliver Wieland <oliver.wieland@online.de>15 * @author Oliver Wieland <oliver.wieland@online.de> 16 16 * Class to represent a triangle shape. {@see java.awt.Shape}. 17 17 */ … … 21 21 /** 22 22 * Copy constructor. 23 * @param p24 23 */ 25 24 public Triangle(Polygon p) { … … 31 30 * Creates a triangle from 3 given points. The points are used without any sanity check, so it is up to 32 31 * the user that the points form a triangle. 33 * @param p134 * @param p235 * @param p336 32 */ 37 33 public Triangle(Point p1, Point p2, Point p3) { … … 44 40 /** 45 41 * Draws an outlined triangle. 46 * @param g47 42 */ 48 43 public void draw(Graphics g) { … … 52 47 /** 53 48 * Draws a filled triangle. 54 * @param g55 49 */ 56 50 public void fill(Graphics g) { -
applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/TriangleDir.java
r30344 r32775 3 3 4 4 /** 5 * @author Oliver Wieland <oliver.wieland@online.de>5 * @author Oliver Wieland <oliver.wieland@online.de> 6 6 * 7 7 */
Note:
See TracChangeset
for help on using the changeset viewer.