Ignore:
Timestamp:
2014-04-25T17:51:41+02:00 (10 years ago)
Author:
malcolmh
Message:

render update control & tilegen

Location:
applications/editors/josm/plugins/smed2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed2/jsearch/src/jsearch/Extract.java

    r30408 r30412  
    1010package jsearch;
    1111
    12 import java.io.BufferedReader;
    13 import java.io.FileReader;
    14 import java.io.IOException;
    15 import java.util.ArrayList;
    16 import java.util.HashMap;
     12import java.io.*;
     13import java.util.*;
    1714
    1815import jsearch.Jsearch.MapBB;
  • applications/editors/josm/plugins/smed2/jsearch/src/jsearch/Jsearch.java

    r30408 r30412  
    1010package jsearch;
    1111
    12 import java.io.BufferedReader;
    13 import java.io.File;
    14 import java.io.FileReader;
    15 import java.io.PrintStream;
    16 import java.util.ArrayList;
    17 import java.util.HashMap;
     12import java.io.*;
     13import java.util.*;
    1814
    1915public class Jsearch {
     
    223219                        int y = (t % 512) * 8;
    224220                        MapBB bb = new MapBB();
    225                         bb.minlon = tile2lon((x + 4095) % 4096, 12);
    226                         bb.maxlon = tile2lon((x + 9) % 4095, 12);
    227                         bb.minlat = tile2lat(Math.min((y + 9), 4095), 12);
    228                         bb.maxlat = tile2lat(Math.max((y - 1), 0), 12);
     221                        bb.minlon = tile2lon((x + 4094) % 4096, 12);
     222                        bb.maxlon = tile2lon((x + 10) % 4095, 12);
     223                        bb.minlat = tile2lat(Math.min((y + 10), 4095), 12);
     224                        bb.maxlat = tile2lat(Math.max((y - 2), 0), 12);
    229225                        ArrayList<String> ext = Extract.extractData(dir + "next.osm", bb);
    230226                        PrintStream out = new PrintStream(dir + "tmp/" + (t / 512) + "-" + (t % 512) + "-9.osm");
     
    238234                        int y = (t % 1024) * 4;
    239235                        MapBB bb = new MapBB();
    240                         bb.minlon = tile2lon((x + 4095) % 4096, 12);
    241                         bb.maxlon = tile2lon((x + 5) % 4095, 12);
    242                         bb.minlat = tile2lat(Math.min((y + 5), 4095), 12);
    243                         bb.maxlat = tile2lat(Math.max((y - 1), 0), 12);
     236                        bb.minlon = tile2lon((x + 4094) % 4096, 12);
     237                        bb.maxlon = tile2lon((x + 6) % 4095, 12);
     238                        bb.minlat = tile2lat(Math.min((y + 6), 4095), 12);
     239                        bb.maxlat = tile2lat(Math.max((y - 2), 0), 12);
    244240                        ArrayList<String> ext = Extract.extractData(dir + "tmp/" + ((t / 1024) / 2) + "-" + ((t % 1024) / 2) + "-9.osm", bb);
    245241                        PrintStream out = new PrintStream(dir + "tmp/" + (t / 1024) + "-" + (t % 1024) + "-10.osm");
     
    253249                        int y = (t % 2048) * 2;
    254250                        MapBB bb = new MapBB();
    255                         bb.minlon = tile2lon((x + 4095) % 4096, 12);
    256                         bb.maxlon = tile2lon((x + 3) % 4095, 12);
    257                         bb.minlat = tile2lat(Math.min((y + 3), 4095), 12);
    258                         bb.maxlat = tile2lat(Math.max((y - 1), 0), 12);
     251                        bb.minlon = tile2lon((x + 4094) % 4096, 12);
     252                        bb.maxlon = tile2lon((x + 4) % 4095, 12);
     253                        bb.minlat = tile2lat(Math.min((y + 4), 4095), 12);
     254                        bb.maxlat = tile2lat(Math.max((y - 2), 0), 12);
    259255                        ArrayList<String> ext = Extract.extractData(dir + "tmp/" + ((t / 2048) / 2) + "-" + ((t % 2048) / 2) + "-10.osm", bb);
    260                         PrintStream out = new PrintStream(dir + "tmp/" + (t / 2048) + "-" + (t % 2048) + "-11.osm");
     256                        String z11nam = dir + "tmp/" + (t / 2048) + "-" + (t % 2048) + "-11.osm";
     257                        PrintStream out = new PrintStream(z11nam);
    261258                        for (String line : ext) {
    262259                                out.println(line);
    263260                        }
    264261                        out.close();
     262                        for (int i = (x+4095)%4096; i < x+3; i = (i+1)%4096) {
     263                                for (int j = Math.max(y-1, 0); j < y+3; j = Math.min(j+1, 4095)) {
     264                                        if (z12s.containsKey(i*4096+j)) {
     265                                                z12s.remove(i*4096+j);
     266                                                bb = new MapBB();
     267                                                bb.minlon = tile2lon((i + 4095) % 4096, 12);
     268                                                bb.maxlon = tile2lon((i + 2) % 4095, 12);
     269                                                bb.minlat = tile2lat(Math.min((j + 2), 4095), 12);
     270                                                bb.maxlat = tile2lat(Math.max((j - 1), 0), 12);
     271                                                ext = Extract.extractData(z11nam, bb);
     272                                                out = new PrintStream(dir + "tmp/" + i + "-" + j + "-12.osm");
     273                                                for (String line : ext) {
     274                                                        out.println(line);
     275                                                }
     276                                                out.close();
     277                                        }
     278                                }
     279                        }
    265280                }
    266281               
  • applications/editors/josm/plugins/smed2/jtile/src/jtile/Jtile.java

    r30407 r30412  
    3030        static int xtile;
    3131        static int ytile;
     32        static int zoom;
    3233        static ArrayList<String> send;
    3334        static HashMap<String, Boolean> deletes;
    3435
    35         static void tile(int zoom, int dxy, int xn, int yn) throws Exception {
     36        static void tile(int z, int dxy, int xn, int yn) throws Exception {
    3637
    3738                trans = new PNGTranscoder();
     
    4041                trans.addTranscodingHint(PNGTranscoder.KEY_AOI, new Rectangle(256+(xn*dxy), 256+(yn*dxy), dxy, dxy));
    4142
    42                 String svgURI = new File(srcdir + xtile + "-" + ytile + "-" + zoom + ".svg").toURI().toURL().toString();
     43                String svgURI = new File(srcdir + xtile + "-" + ytile + "-" + z + ".svg").toURI().toURL().toString();
    4344                TranscoderInput input = new TranscoderInput(svgURI);
    4445                ByteArrayOutputStream bos = new ByteArrayOutputStream();
     
    4647                trans.transcode(input, output);
    4748                if (bos.size() > 446) {
    48                         int scale = (int) Math.pow(2, zoom - 12);
     49                        int scale = (int) Math.pow(2, z - 12);
    4950                        int xdir = (scale * xtile) + xn;
    5051                        int ynam = (scale * ytile) + yn;
    51                         String dstnam = dstdir + zoom + "/" + xdir + "/" + ynam + ".png";
     52                        String dstnam = dstdir + z + "/" + xdir + "/" + ynam + ".png";
    5253                        deletes.remove(dstnam);
    53                         send.add("put " + dstnam + " cache/tiles-" + zoom + "-" + xdir + "-" + ynam + ".png");
    54                         File ofile = new File(dstdir + "/" + zoom + "/" + xdir + "/");
     54                        send.add("put " + dstnam + " cache/tiles-" + z + "-" + xdir + "-" + ynam + ".png");
     55                        File ofile = new File(dstdir + "/" + z + "/" + xdir + "/");
    5556                        ofile.mkdirs();
    56                         OutputStream ostream = new FileOutputStream(dstdir + "/" + zoom + "/" + xdir + "/" + ynam + ".png");
     57                        OutputStream ostream = new FileOutputStream(dstdir + "/" + z + "/" + xdir + "/" + ynam + ".png");
    5758                        bos.writeTo(ostream);
    5859                        ostream.flush();
    5960                        ostream.close();
    6061                        if (send.size() > 10) {
    61                                 PrintWriter writer = new PrintWriter(srcdir + zoom  + "-" + xdir + "-" + ynam + ".send", "UTF-8");
     62                                PrintWriter writer = new PrintWriter(srcdir + z  + "-" + xdir + "-" + ynam + ".send", "UTF-8");
    6263                                for (String str : send) {
    6364                                        writer.println(str);
     
    6768                        }
    6869                }
    69                 if ((zoom < 18) && ((zoom < 16) || (bos.size() > 446))) {
     70                if ((z < 18) && ((z < 16) || (bos.size() > 446))) {
    7071                        for (int x = 0; x < 2; x++) {
    7172                                for (int y = 0; y < 2; y++) {
    72                                         tile((zoom + 1), (dxy / 2), (xn * 2 + x), (yn * 2 + y));
     73                                        tile((z + 1), (dxy / 2), (xn * 2 + x), (yn * 2 + y));
    7374                                }
    7475                        }
     
    7677        }
    7778
    78         static void clean(int zoom, int xn, int yn) throws Exception {
     79        static void tile91011() throws Exception {
     80
     81                trans = new PNGTranscoder();
     82                trans.addTranscodingHint(PNGTranscoder.KEY_WIDTH, new Float(256));
     83                trans.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, new Float(256));
     84                trans.addTranscodingHint(PNGTranscoder.KEY_AOI, new Rectangle(512, 512, 256*(int)(Math.pow(2, 12-zoom)), 256*(int)(Math.pow(2, 12-zoom))));
     85
     86                String svgURI = new File(srcdir + xtile + "-" + ytile + "-" + zoom + ".svg").toURI().toURL().toString();
     87                TranscoderInput input = new TranscoderInput(svgURI);
     88                ByteArrayOutputStream bos = new ByteArrayOutputStream();
     89                TranscoderOutput output = new TranscoderOutput(bos);
     90                trans.transcode(input, output);
     91                String dstnam = dstdir + zoom + "/" + xtile + "/" + ytile + ".png";
     92                if (bos.size() > 446) {
     93                        send.add("put " + dstnam + " cache/tiles-" + zoom + "-" + xtile + "-" + ytile + ".png");
     94                        File ofile = new File(dstdir + "/" + zoom + "/" + xtile + "/");
     95                        ofile.mkdirs();
     96                        OutputStream ostream = new FileOutputStream(dstdir + "/" + zoom + "/" + xtile + "/" + ytile + ".png");
     97                        bos.writeTo(ostream);
     98                        ostream.flush();
     99                        ostream.close();
     100                } else {
     101                        File old = new File(dstnam);
     102                        if (old.exists()) {
     103                                old.delete();
     104                                deletes.put(dstnam, true);
     105                        }
     106                }
     107        }
     108
     109        static void clean(int z, int xn, int yn) throws Exception {
    79110               
    80                 int scale = (int) Math.pow(2, zoom - 12);
     111                int scale = (int) Math.pow(2, z - 12);
    81112                int xdir = (scale * xtile) + xn;
    82113                int ynam = (scale * ytile) + yn;
    83                 String delnam = dstdir + zoom + "/" + xdir + "/" + ynam + ".png";
     114                String delnam = dstdir + z + "/" + xdir + "/" + ynam + ".png";
    84115                File delfile = new File(delnam);
    85116                if (delfile.exists()) {
     
    87118                        delfile.delete();
    88119                }
    89                 if ((zoom < 18)) {
     120                if ((z < 18)) {
    90121                        for (int x = 0; x < 2; x++) {
    91122                                for (int y = 0; y < 2; y++) {
    92                                         clean((zoom + 1), (xn * 2 + x), (yn * 2 + y));
     123                                        clean((z + 1), (xn * 2 + x), (yn * 2 + y));
    93124                                }
    94125                        }
     
    99130                srcdir = args[0];
    100131                dstdir = args[1];
    101                 xtile = Integer.parseInt(args[2]);
    102                 ytile = Integer.parseInt(args[3]);
     132                zoom = Integer.parseInt(args[2]);
     133                xtile = Integer.parseInt(args[3]);
     134                ytile = Integer.parseInt(args[4]);
    103135                send = new ArrayList<String>();
    104136                deletes = new HashMap<String, Boolean>();
    105                 clean(12, 0, 0);
    106                 tile(12, 256, 0, 0);
    107                 if (send.size() > 0) {
    108                         PrintWriter writer = new PrintWriter(srcdir + "12-" + xtile + "-" + ytile + ".send", "UTF-8");
     137                if (zoom == 12) {
     138                        clean(12, 0, 0);
     139                        tile(12, 256, 0, 0);
     140                } else {
     141                        tile91011();
     142                }
     143                if ((send.size() + deletes.size()) > 0) {
     144                        PrintWriter writer = new PrintWriter(srcdir + zoom + "-" + xtile + "-" + ytile + ".send", "UTF-8");
    109145                        for (String str : send) {
    110146                                writer.println(str);
     
    115151                        writer.close();
    116152                }
    117                 for (int z = 12; z <= 18; z++) {
    118                         (new File(srcdir + xtile + "-" + ytile + "-" + z + ".svg")).delete();
     153                if (zoom == 12) {
     154                        for (int zz = 12; zz <= 18; zz++) {
     155                                (new File(srcdir + xtile + "-" + ytile + "-" + zz + ".svg")).delete();
     156                        }
     157                } else {
     158                        (new File(srcdir + xtile + "-" + ytile + "-" + zoom + ".svg")).delete();
    119159                }
    120160                System.exit(0);
  • applications/editors/josm/plugins/smed2/src/render/Renderer.java

    r30396 r30412  
    2525public class Renderer {
    2626
    27         public static final double symbolScale[] = { 256.0, 128.0, 64.0, 32.0, 16.0, 8.0, 4.0, 2.0, 1.0, 0.61, 0.372, 0.227, 0.138, 0.0843, 0.0514, 0.0313, 0.0191, 0.0117, 0.007, 0.138 };
     27        public static final double symbolScale[] = { 256.0, 128.0, 64.0, 32.0, 16.0, 8.0, 4.0, 2.0, 1.0, 0.61, 0.372, 0.227, 0.138, 0.0843, 0.0514, 0.0313, 0.0191, 0.0117, 0.007 };
    2828
    2929        public enum LabelStyle { NONE, RRCT, RECT, ELPS, CIRC, VCLR, PCLR, HCLR }
Note: See TracChangeset for help on using the changeset viewer.