Changeset 30860 in osm


Ignore:
Timestamp:
2014-12-19T17:28:40+01:00 (10 years ago)
Author:
donvip
Message:

[josm_lakewalker] use correct JOSM cache directory

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  
    33import static org.openstreetmap.josm.tools.I18n.tr;
    44
    5 import java.io.File;
    65import java.util.ArrayList;
    76import java.util.List;
     
    1918    private String wmslayer;
    2019
    21     private File workingdir;
    22 
    2320    private int[] dirslat = new int[] {0,1,1,1,0,-1,-1,-1};
    2421    private int[] dirslon = new int[] {1,1,0,-1,-1,-1,0,1};
     
    2724    double start_radius_small = 0.0002;
    2825
    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){
    3027        this.maxnode = maxnode;
    3128        this.threshold = threshold;
     
    3431        this.startdir = startdir;
    3532        this.wmslayer = wmslayer;
    36 
    37         this.workingdir = workingdir;
    3833    }
    3934
     
    8883        try {
    8984
    90             LakewalkerWMS wms = new LakewalkerWMS(this.resolution, this.tilesize, this.wmslayer, this.workingdir);
     85            LakewalkerWMS wms = new LakewalkerWMS(this.resolution, this.tilesize, this.wmslayer);
    9186            LakewalkerBBox bbox = new LakewalkerBBox(tl_lat,tl_lon,br_lat,br_lon);
    9287
  • applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java

    r30737 r30860  
    7676
    7777        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);
    8079
    8180            if (wmsCacheDir.exists() && wmsCacheDir.isDirectory()) {
     
    107106                    }
    108107                }
    109 
    110108            } else {
    111109                // create cache directory
    112110                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()));
    114113                }
    115114            }
     
    118117
    119118    protected void lakewalk(Point clickPoint){
    120         /**
    121         * Positional data
    122         */
     119        // Positional data
    123120        final LatLon pos = Main.map.mapView.getLatLon(clickPoint.x, clickPoint.y);
    124121        final LatLon topLeft = Main.map.mapView.getLatLon(0, 0);
    125122        final LatLon botRight = Main.map.mapView.getLatLon(Main.map.mapView.getWidth(),
    126123            Main.map.mapView.getHeight());
    127 
    128         /**
    129         * Cache/working directory location
    130         */
    131         final File working_dir = new File(Main.pref.getPreferencesDir(), "plugins/Lakewalker");
    132124
    133125        /*
     
    149141                    cleanupCache();
    150142                    processnodelist(pos, topLeft, botRight, waylen, maxnode, threshold,
    151                             epsilon,resolution,tilesize,startdir,wmslayer, working_dir,
     143                            epsilon,resolution,tilesize,startdir,wmslayer,
    152144                            progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
    153145                }
     
    167159    }
    168160
    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){
    170163        progressMonitor.beginTask(null, 3);
    171164        try {
    172165            ArrayList<double[]> nodelist = new ArrayList<>();
    173166
    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);
    175168            try {
    176169                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  
    22
    33import static org.openstreetmap.josm.tools.I18n.tr;
     4
     5import java.io.File;
    46
    57import org.openstreetmap.josm.Main;
     
    2123
    2224    @Override
    23     public PreferenceSetting getPreferenceSetting()
    24     {
     25    public PreferenceSetting getPreferenceSetting() {
    2526        return new LakewalkerPreferences();
    2627    }
    2728
     29    public static File getLakewalkerCacheDir() {
     30        return new File(Main.pref.getCacheDirectory(), "lakewalkerwms");
     31    }
    2832}
  • applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerWMS.java

    r30737 r30860  
    3838    private String wmslayer;
    3939
    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){
    4341        this.resolution = resolution;
    4442        this.tilesize = tilesize;
    45         this.working_dir = workdir;
    4643        this.wmslayer = wmslayer;
    4744    }
     
    7875            "&width="+this.tilesize+"&height="+this.tilesize;
    7976
    80             File file = new File(this.working_dir,filename);
     77            File file = new File(LakewalkerPlugin.getLakewalkerCacheDir(), filename);
    8178
    8279            // Calculate the hashmap key
Note: See TracChangeset for help on using the changeset viewer.