Changeset 31988 in osm for applications/editors/josm/plugins/mapillary
- Timestamp:
- 2016-01-16T15:52:12+01:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/README.md
r31971 r31988 4 4 [![code coverage](https://img.shields.io/codecov/c/github/floscher/josm-mapillary-plugin/master.svg?style=flat-square)](https://codecov.io/github/floscher/josm-mapillary-plugin?branch=master) 5 5 [![technical debt](https://img.shields.io/sonar/https/josm.openstreetmap.de/sonar/josm-plugins:mapillary/sqale_debt_ratio.svg?style=flat-square)](https://josm.openstreetmap.de/sonar/drilldown/measures/3325?metric=sqale_index) 6 [![code quality](https://img.shields.io/codacy/49bb5717d8a64575b0b4ce771c62f1d7.svg?style=flat-square)](https://www.codacy.com/app/floscher/josm-mapillary-plugin) 6 7 [![latest release](https://img.shields.io/github/release/floscher/josm-mapillary-plugin.svg?style=flat-square)](https://github.com/floscher/josm-mapillary-plugin/releases/latest) 7 8 ![license: GPLv2 or later](https://img.shields.io/badge/license-GPLv2 or later-blue.svg?style=flat-square) -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoSign.java
r31799 r31988 3 3 4 4 import java.awt.Color; 5 import java.io.IOException; 5 6 import java.io.InputStream; 6 7 import java.util.ArrayList; … … 14 15 import javax.json.JsonObject; 15 16 17 import org.openstreetmap.josm.Main; 18 16 19 public final class TrafficoSign { 17 20 private static Map<String, Map<String, TrafficoSignElement[]>> signs = new HashMap<>(); … … 23 26 public static TrafficoSignElement[] getSign(String country, String signName) { 24 27 if (signs.get(country) == null) { 25 System.out.println("Read signs for " + country); 26 InputStream countryStream = TrafficoSign.class 27 .getResourceAsStream("/data/fonts/traffico/signs/" + country + ".json"); 28 if (countryStream == null) { 29 return null; 28 Main.info("Reading signs for country ''{0}''.", country); 29 try ( 30 InputStream countryStream = TrafficoSign.class 31 .getResourceAsStream("/data/fonts/traffico/signs/" + country + ".json")) { 32 if (countryStream == null) { 33 return null; 34 } 35 JsonObject countrySigns = Json.createReader(countryStream).readObject(); 36 Set<String> countrySignNames = countrySigns.keySet(); 37 Main.info( 38 countrySignNames.size() + " different signs are supported for ''{0}'' by the Mapillary-plugin .", 39 country 40 ); 41 Map<String, TrafficoSignElement[]> countryMap = new HashMap<>(); 42 for (String name : countrySignNames) { 43 JsonArray elements = countrySigns.getJsonObject(name).getJsonArray("elements"); 44 45 // TODO: Replace by an array when all types of sign elements (text!) are 46 // supported 47 List<TrafficoSignElement> layers = new ArrayList<>(); 48 49 for (int i = 0; i < elements.size(); i++) { 50 Character glyph = TrafficoGlyph.getGlyph(elements.getJsonObject(i) 51 .getString("type")); 52 if (glyph != null) { 53 Color c; 54 switch (elements.getJsonObject(i).getString("color").toLowerCase()) { 55 case "black": 56 c = Color.BLACK; 57 break; 58 case "red": 59 c = Color.RED; 60 break; 61 case "blue": 62 c = Color.BLUE; 63 break; 64 case "white": 65 c = Color.WHITE; 66 break; 67 case "green": 68 c = Color.GREEN; 69 break; 70 case "yellow": 71 c = Color.YELLOW; 72 break; 73 default: 74 c = Color.MAGENTA; 75 } 76 layers.add(new TrafficoSignElement(glyph, c)); 77 } 78 } 79 countryMap.put(name, layers.toArray(new TrafficoSignElement[layers.size()])); 80 } 81 signs.put(country, countryMap); 82 } catch (IOException e) { 83 Main.error(e); 30 84 } 31 JsonObject countrySigns = Json.createReader(countryStream).readObject();32 Set<String> countrySignNames = countrySigns.keySet();33 System.out.println(countrySignNames.size() + " signs found");34 Map<String, TrafficoSignElement[]> countryMap = new HashMap<>();35 for (String name : countrySignNames) {36 System.out.println(" * sign " + name);37 JsonArray elements = countrySigns.getJsonObject(name).getJsonArray(38 "elements");39 40 // TODO: Replace by an array when all types of sign elements (text!) are41 // supported42 List<TrafficoSignElement> layers = new ArrayList<>();43 44 for (int i = 0; i < elements.size(); i++) {45 System.out.println(" - "46 + elements.getJsonObject(i).getString("color") + " layer "47 + elements.getJsonObject(i).getString("type"));48 Character glyph = TrafficoGlyph.getGlyph(elements.getJsonObject(i)49 .getString("type"));50 if (glyph != null) {51 Color c;52 switch (elements.getJsonObject(i).getString("color").toLowerCase()) {53 case "black":54 c = Color.BLACK;55 break;56 case "red":57 c = Color.RED;58 break;59 case "blue":60 c = Color.BLUE;61 break;62 case "white":63 c = Color.WHITE;64 break;65 case "green":66 c = Color.GREEN;67 break;68 case "yellow":69 c = Color.YELLOW;70 break;71 default:72 c = Color.MAGENTA;73 }74 layers.add(new TrafficoSignElement(glyph, c));75 }76 }77 countryMap.put(name, layers.toArray(new TrafficoSignElement[0]));78 }79 signs.put(country, countryMap);80 85 } 81 86 if (signs.get(country).get(signName) != null) {
Note:
See TracChangeset
for help on using the changeset viewer.