Changeset 7625 in josm
- Timestamp:
- 2014-10-16T21:10:23+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/taginfoextract.groovy
r7554 r7625 7 7 * groovy -cp dist/josm-custom.jar taginfoextract.groovy 8 8 */ 9 10 import java.io.BufferedReader11 9 import java.awt.image.BufferedImage 10 12 11 import javax.imageio.ImageIO 13 12 14 13 import org.openstreetmap.josm.Main 14 import org.openstreetmap.josm.data.Version 15 15 import org.openstreetmap.josm.data.coor.LatLon 16 16 import org.openstreetmap.josm.data.osm.Node 17 17 import org.openstreetmap.josm.data.osm.Way 18 import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings 19 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer 18 20 import org.openstreetmap.josm.data.projection.Projections 19 import org.openstreetmap.josm. data.Version21 import org.openstreetmap.josm.gui.NavigatableComponent 20 22 import org.openstreetmap.josm.gui.mappaint.AreaElemStyle 21 import org.openstreetmap.josm.gui.mappaint.Cascade22 23 import org.openstreetmap.josm.gui.mappaint.Environment 23 24 import org.openstreetmap.josm.gui.mappaint.LineElemStyle 25 import org.openstreetmap.josm.gui.mappaint.MultiCascade 26 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference 27 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource 24 28 import org.openstreetmap.josm.gui.mappaint.mapcss.Condition.SimpleKeyValueCondition 25 import org.openstreetmap.josm.gui.mappaint.mapcss. MapCSSStyleSource29 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.GeneralSelector 26 30 import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.MapCSSParser 27 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.GeneralSelector28 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference29 import org.openstreetmap.josm.gui.mappaint.MultiCascade30 31 import org.openstreetmap.josm.io.CachedFile 31 32 32 import org.openstreetmap.josm.gui.NavigatableComponent33 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer34 import org.openstreetmap.josm.data.Bounds35 //import org.openstreetmap.josm.data.osm.DataSet36 import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings37 38 33 class taginfoextract { 39 34 40 35 static def options 41 36 static String image_dir … … 46 41 def base_dir = "." 47 42 def tags = [] as Set 48 43 49 44 private def cached_svnrev 50 45 … … 53 48 */ 54 49 abstract class Checker { 55 50 56 51 def tag 57 52 def osm 58 53 59 54 Checker(tag) { 60 55 this.tag = tag 61 56 } 62 57 63 58 def apply_stylesheet(osm) { 64 59 osm.put(tag[0], tag[1]) 65 60 def mc = new MultiCascade() 66 61 67 62 def env = new Environment(osm, mc, null, style_source) 68 63 for (def r in style_source.rules) { … … 80 75 return env 81 76 } 82 77 83 78 /** 84 79 * Determine full image url (can refer to JOSM or OSM repository). … … 100 95 * Create image file from ElemStyle. 101 96 * @return the URL 102 */ 97 */ 103 98 def create_image(elem_style, type, nc) { 104 99 def img = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB) … … 107 102 def renderer = new StyledMapRenderer(g, nc, false) 108 103 renderer.getSettings(false) 109 elem_style.paintPrimitive(osm, MapPaintSettings.INSTANCE, renderer, false, false )104 elem_style.paintPrimitive(osm, MapPaintSettings.INSTANCE, renderer, false, false, false) 110 105 def base_url = options.imgurlprefix ? options.imgurlprefix : image_dir 111 106 def image_name = "${type}_${tag[0]}=${tag[1]}.png" … … 234 229 } 235 230 } 236 231 237 232 void run() { 238 233 init() … … 280 275 } 281 276 } 282 277 283 278 output """${sep} { 284 279 | "key": "${tag[0]}", … … 294 289 } 295 290 sep = ",\n" 296 } 291 } 297 292 output """ 298 293 | ] … … 343 338 xml = "svn info --xml ${base_dir}/images/styles/standard/".execute().text 344 339 } 345 340 346 341 def svninfo = new XmlParser().parseText(xml) 347 342 def rev = svninfo.entry.'@revision'[0] … … 350 345 return cached_svnrev 351 346 } 352 347 353 348 /** 354 349 * Read the style sheet file and parse the MapCSS code. … … 362 357 parser.sheet(style_source) 363 358 } 364 359 365 360 /** 366 361 * Collect all the tag from the style sheet. … … 382 377 /** 383 378 * Write the JSON output (either to file or to command line). 384 */ 379 */ 385 380 def output(x) { 386 381 if (output_file != null) { … … 398 393 System.err.print(s); 399 394 } 400 395 401 396 } 402 397
Note:
See TracChangeset
for help on using the changeset viewer.