Changeset 30407 in osm for applications/editors


Ignore:
Timestamp:
2014-04-18T22:30:21+02:00 (10 years ago)
Author:
malcolmh
Message:

new tiler

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed2/jtile/src/jtile/Jtile.java

    r30405 r30407  
    1717import java.io.PrintWriter;
    1818import java.util.ArrayList;
     19import java.util.HashMap;
    1920
    2021import org.apache.batik.transcoder.TranscoderInput;
     
    3031        static int ytile;
    3132        static ArrayList<String> send;
     33        static HashMap<String, Boolean> deletes;
    3234
    33         public static void tile(int zoom, int dxy, int xn, int yn) throws Exception {
     35        static void tile(int zoom, int dxy, int xn, int yn) throws Exception {
    3436
    3537                trans = new PNGTranscoder();
     
    4749                        int xdir = (scale * xtile) + xn;
    4850                        int ynam = (scale * ytile) + yn;
    49                         send.add("put " + dstdir + zoom + "/" + xdir + "/" + ynam + ".png" + " cache/tiles-" + zoom + "-" + xdir + "-" + ynam + ".png");
     51                        String dstnam = dstdir + zoom + "/" + xdir + "/" + ynam + ".png";
     52                        deletes.remove(dstnam);
     53                        send.add("put " + dstnam + " cache/tiles-" + zoom + "-" + xdir + "-" + ynam + ".png");
    5054                        File ofile = new File(dstdir + "/" + zoom + "/" + xdir + "/");
    5155                        ofile.mkdirs();
     
    7276        }
    7377
     78        static void clean(int zoom, int xn, int yn) throws Exception {
     79               
     80                int scale = (int) Math.pow(2, zoom - 12);
     81                int xdir = (scale * xtile) + xn;
     82                int ynam = (scale * ytile) + yn;
     83                String delnam = dstdir + zoom + "/" + xdir + "/" + ynam + ".png";
     84                File delfile = new File(delnam);
     85                if (delfile.exists()) {
     86                        deletes.put(delnam, true);
     87                        delfile.delete();
     88                }
     89                if ((zoom < 18)) {
     90                        for (int x = 0; x < 2; x++) {
     91                                for (int y = 0; y < 2; y++) {
     92                                        clean((zoom + 1), (xn * 2 + x), (yn * 2 + y));
     93                                }
     94                        }
     95                }
     96        }
     97       
    7498        public static void main(String[] args) throws Exception {
    7599                srcdir = args[0];
     
    78102                ytile = Integer.parseInt(args[3]);
    79103                send = new ArrayList<String>();
     104                deletes = new HashMap<String, Boolean>();
     105                clean(12, 0, 0);
    80106                tile(12, 256, 0, 0);
    81107                if (send.size() > 0) {
     
    83109                        for (String str : send) {
    84110                                writer.println(str);
     111                        }
     112                        for (String del : deletes.keySet()) {
     113                                writer.println("rm " + del);
    85114                        }
    86115                        writer.close();
Note: See TracChangeset for help on using the changeset viewer.