Changeset 30860 in osm for applications/editors
- Timestamp:
- 2014-12-19T17:28:40+01:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/Lakewalker.java
r30737 r30860 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.io.File;6 5 import java.util.ArrayList; 7 6 import java.util.List; … … 19 18 private String wmslayer; 20 19 21 private File workingdir;22 23 20 private int[] dirslat = new int[] {0,1,1,1,0,-1,-1,-1}; 24 21 private int[] dirslon = new int[] {1,1,0,-1,-1,-1,0,1}; … … 27 24 double start_radius_small = 0.0002; 28 25 29 public Lakewalker(int waylen, int maxnode, int threshold, double epsilon, int resolution, int tilesize, String startdir, String wmslayer , File workingdir){26 public Lakewalker(int waylen, int maxnode, int threshold, double epsilon, int resolution, int tilesize, String startdir, String wmslayer){ 30 27 this.maxnode = maxnode; 31 28 this.threshold = threshold; … … 34 31 this.startdir = startdir; 35 32 this.wmslayer = wmslayer; 36 37 this.workingdir = workingdir;38 33 } 39 34 … … 88 83 try { 89 84 90 LakewalkerWMS wms = new LakewalkerWMS(this.resolution, this.tilesize, this.wmslayer , this.workingdir);85 LakewalkerWMS wms = new LakewalkerWMS(this.resolution, this.tilesize, this.wmslayer); 91 86 LakewalkerBBox bbox = new LakewalkerBBox(tl_lat,tl_lon,br_lat,br_lon); 92 87 -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java
r30737 r30860 76 76 77 77 for (String wmsFolder : LakewalkerPreferences.WMSLAYERS) { 78 String wmsCacheDirName = Main.pref.getPreferencesDir()+"plugins/Lakewalker/"+wmsFolder; 79 File wmsCacheDir = new File(wmsCacheDirName); 78 File wmsCacheDir = new File(LakewalkerPlugin.getLakewalkerCacheDir(), wmsFolder); 80 79 81 80 if (wmsCacheDir.exists() && wmsCacheDir.isDirectory()) { … … 107 106 } 108 107 } 109 110 108 } else { 111 109 // create cache directory 112 110 if (!wmsCacheDir.mkdirs()) { 113 JOptionPane.showMessageDialog(Main.parent, tr("Error creating cache directory: {0}", wmsCacheDirName)); 111 JOptionPane.showMessageDialog(Main.parent, 112 tr("Error creating cache directory: {0}", wmsCacheDir.getPath())); 114 113 } 115 114 } … … 118 117 119 118 protected void lakewalk(Point clickPoint){ 120 /** 121 * Positional data 122 */ 119 // Positional data 123 120 final LatLon pos = Main.map.mapView.getLatLon(clickPoint.x, clickPoint.y); 124 121 final LatLon topLeft = Main.map.mapView.getLatLon(0, 0); 125 122 final LatLon botRight = Main.map.mapView.getLatLon(Main.map.mapView.getWidth(), 126 123 Main.map.mapView.getHeight()); 127 128 /**129 * Cache/working directory location130 */131 final File working_dir = new File(Main.pref.getPreferencesDir(), "plugins/Lakewalker");132 124 133 125 /* … … 149 141 cleanupCache(); 150 142 processnodelist(pos, topLeft, botRight, waylen, maxnode, threshold, 151 epsilon,resolution,tilesize,startdir,wmslayer, working_dir,143 epsilon,resolution,tilesize,startdir,wmslayer, 152 144 progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false)); 153 145 } … … 167 159 } 168 160 169 private void processnodelist(LatLon pos, LatLon topLeft, LatLon botRight, int waylen, int maxnode, int threshold, double epsilon, int resolution, int tilesize, String startdir, String wmslayer, File workingdir, ProgressMonitor progressMonitor){ 161 private void processnodelist(LatLon pos, LatLon topLeft, LatLon botRight, int waylen, int maxnode, int threshold, 162 double epsilon, int resolution, int tilesize, String startdir, String wmslayer, ProgressMonitor progressMonitor){ 170 163 progressMonitor.beginTask(null, 3); 171 164 try { 172 165 ArrayList<double[]> nodelist = new ArrayList<>(); 173 166 174 Lakewalker lw = new Lakewalker(waylen,maxnode,threshold,epsilon,resolution,tilesize,startdir,wmslayer ,workingdir);167 Lakewalker lw = new Lakewalker(waylen,maxnode,threshold,epsilon,resolution,tilesize,startdir,wmslayer); 175 168 try { 176 169 nodelist = lw.trace(pos.lat(),pos.lon(),topLeft.lon(),botRight.lon(),topLeft.lat(),botRight.lat(), -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPlugin.java
r29771 r30860 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 5 import java.io.File; 4 6 5 7 import org.openstreetmap.josm.Main; … … 21 23 22 24 @Override 23 public PreferenceSetting getPreferenceSetting() 24 { 25 public PreferenceSetting getPreferenceSetting() { 25 26 return new LakewalkerPreferences(); 26 27 } 27 28 29 public static File getLakewalkerCacheDir() { 30 return new File(Main.pref.getCacheDirectory(), "lakewalkerwms"); 31 } 28 32 } -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerWMS.java
r30737 r30860 38 38 private String wmslayer; 39 39 40 private File working_dir; 41 42 public LakewalkerWMS(int resolution, int tilesize, String wmslayer, File workdir){ 40 public LakewalkerWMS(int resolution, int tilesize, String wmslayer){ 43 41 this.resolution = resolution; 44 42 this.tilesize = tilesize; 45 this.working_dir = workdir;46 43 this.wmslayer = wmslayer; 47 44 } … … 78 75 "&width="+this.tilesize+"&height="+this.tilesize; 79 76 80 File file = new File( this.working_dir,filename);77 File file = new File(LakewalkerPlugin.getLakewalkerCacheDir(), filename); 81 78 82 79 // Calculate the hashmap key
Note:
See TracChangeset
for help on using the changeset viewer.