Changeset 30412 in osm for applications
- Timestamp:
- 2014-04-25T17:51:41+02:00 (11 years ago)
- 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 10 10 package jsearch; 11 11 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; 12 import java.io.*; 13 import java.util.*; 17 14 18 15 import jsearch.Jsearch.MapBB; -
applications/editors/josm/plugins/smed2/jsearch/src/jsearch/Jsearch.java
r30408 r30412 10 10 package jsearch; 11 11 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; 12 import java.io.*; 13 import java.util.*; 18 14 19 15 public class Jsearch { … … 223 219 int y = (t % 512) * 8; 224 220 MapBB bb = new MapBB(); 225 bb.minlon = tile2lon((x + 409 5) % 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); 229 225 ArrayList<String> ext = Extract.extractData(dir + "next.osm", bb); 230 226 PrintStream out = new PrintStream(dir + "tmp/" + (t / 512) + "-" + (t % 512) + "-9.osm"); … … 238 234 int y = (t % 1024) * 4; 239 235 MapBB bb = new MapBB(); 240 bb.minlon = tile2lon((x + 409 5) % 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); 244 240 ArrayList<String> ext = Extract.extractData(dir + "tmp/" + ((t / 1024) / 2) + "-" + ((t % 1024) / 2) + "-9.osm", bb); 245 241 PrintStream out = new PrintStream(dir + "tmp/" + (t / 1024) + "-" + (t % 1024) + "-10.osm"); … … 253 249 int y = (t % 2048) * 2; 254 250 MapBB bb = new MapBB(); 255 bb.minlon = tile2lon((x + 409 5) % 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); 259 255 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); 261 258 for (String line : ext) { 262 259 out.println(line); 263 260 } 264 261 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 } 265 280 } 266 281 -
applications/editors/josm/plugins/smed2/jtile/src/jtile/Jtile.java
r30407 r30412 30 30 static int xtile; 31 31 static int ytile; 32 static int zoom; 32 33 static ArrayList<String> send; 33 34 static HashMap<String, Boolean> deletes; 34 35 35 static void tile(int z oom, int dxy, int xn, int yn) throws Exception {36 static void tile(int z, int dxy, int xn, int yn) throws Exception { 36 37 37 38 trans = new PNGTranscoder(); … … 40 41 trans.addTranscodingHint(PNGTranscoder.KEY_AOI, new Rectangle(256+(xn*dxy), 256+(yn*dxy), dxy, dxy)); 41 42 42 String svgURI = new File(srcdir + xtile + "-" + ytile + "-" + z oom+ ".svg").toURI().toURL().toString();43 String svgURI = new File(srcdir + xtile + "-" + ytile + "-" + z + ".svg").toURI().toURL().toString(); 43 44 TranscoderInput input = new TranscoderInput(svgURI); 44 45 ByteArrayOutputStream bos = new ByteArrayOutputStream(); … … 46 47 trans.transcode(input, output); 47 48 if (bos.size() > 446) { 48 int scale = (int) Math.pow(2, z oom- 12);49 int scale = (int) Math.pow(2, z - 12); 49 50 int xdir = (scale * xtile) + xn; 50 51 int ynam = (scale * ytile) + yn; 51 String dstnam = dstdir + z oom+ "/" + xdir + "/" + ynam + ".png";52 String dstnam = dstdir + z + "/" + xdir + "/" + ynam + ".png"; 52 53 deletes.remove(dstnam); 53 send.add("put " + dstnam + " cache/tiles-" + z oom+ "-" + xdir + "-" + ynam + ".png");54 File ofile = new File(dstdir + "/" + z oom+ "/" + xdir + "/");54 send.add("put " + dstnam + " cache/tiles-" + z + "-" + xdir + "-" + ynam + ".png"); 55 File ofile = new File(dstdir + "/" + z + "/" + xdir + "/"); 55 56 ofile.mkdirs(); 56 OutputStream ostream = new FileOutputStream(dstdir + "/" + z oom+ "/" + xdir + "/" + ynam + ".png");57 OutputStream ostream = new FileOutputStream(dstdir + "/" + z + "/" + xdir + "/" + ynam + ".png"); 57 58 bos.writeTo(ostream); 58 59 ostream.flush(); 59 60 ostream.close(); 60 61 if (send.size() > 10) { 61 PrintWriter writer = new PrintWriter(srcdir + z oom+ "-" + xdir + "-" + ynam + ".send", "UTF-8");62 PrintWriter writer = new PrintWriter(srcdir + z + "-" + xdir + "-" + ynam + ".send", "UTF-8"); 62 63 for (String str : send) { 63 64 writer.println(str); … … 67 68 } 68 69 } 69 if ((z oom < 18) && ((zoom< 16) || (bos.size() > 446))) {70 if ((z < 18) && ((z < 16) || (bos.size() > 446))) { 70 71 for (int x = 0; x < 2; x++) { 71 72 for (int y = 0; y < 2; y++) { 72 tile((z oom+ 1), (dxy / 2), (xn * 2 + x), (yn * 2 + y));73 tile((z + 1), (dxy / 2), (xn * 2 + x), (yn * 2 + y)); 73 74 } 74 75 } … … 76 77 } 77 78 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 { 79 110 80 int scale = (int) Math.pow(2, z oom- 12);111 int scale = (int) Math.pow(2, z - 12); 81 112 int xdir = (scale * xtile) + xn; 82 113 int ynam = (scale * ytile) + yn; 83 String delnam = dstdir + z oom+ "/" + xdir + "/" + ynam + ".png";114 String delnam = dstdir + z + "/" + xdir + "/" + ynam + ".png"; 84 115 File delfile = new File(delnam); 85 116 if (delfile.exists()) { … … 87 118 delfile.delete(); 88 119 } 89 if ((z oom< 18)) {120 if ((z < 18)) { 90 121 for (int x = 0; x < 2; x++) { 91 122 for (int y = 0; y < 2; y++) { 92 clean((z oom+ 1), (xn * 2 + x), (yn * 2 + y));123 clean((z + 1), (xn * 2 + x), (yn * 2 + y)); 93 124 } 94 125 } … … 99 130 srcdir = args[0]; 100 131 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]); 103 135 send = new ArrayList<String>(); 104 136 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"); 109 145 for (String str : send) { 110 146 writer.println(str); … … 115 151 writer.close(); 116 152 } 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(); 119 159 } 120 160 System.exit(0); -
applications/editors/josm/plugins/smed2/src/render/Renderer.java
r30396 r30412 25 25 public class Renderer { 26 26 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 }; 28 28 29 29 public enum LabelStyle { NONE, RRCT, RECT, ELPS, CIRC, VCLR, PCLR, HCLR }
Note:
See TracChangeset
for help on using the changeset viewer.