- Timestamp:
- 2020-01-12T15:22:16+01:00 (5 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/SyncEditorLayerIndex.java
r15658 r15692 31 31 import java.util.Objects; 32 32 import java.util.Set; 33 import java.util.function.BiConsumer; 33 34 import java.util.function.Function; 34 35 import java.util.regex.Matcher; … … 56 57 import org.openstreetmap.josm.spi.preferences.Config; 57 58 import org.openstreetmap.josm.tools.ImageProvider; 59 import org.openstreetmap.josm.tools.JosmRuntimeException; 58 60 import org.openstreetmap.josm.tools.Logging; 59 61 import org.openstreetmap.josm.tools.OptionParser; … … 257 259 } 258 260 259 void myprintlnfinal(String s) throws IOException{261 void myprintlnfinal(String s) { 260 262 if (outputStream != null) { 261 outputStream.write(s + System.getProperty("line.separator")); 263 try { 264 outputStream.write(s + System.getProperty("line.separator")); 265 } catch (IOException e) { 266 throw new JosmRuntimeException(e); 267 } 262 268 } else { 263 269 System.out.println(s); … … 265 271 } 266 272 267 void myprintln(String s) throws IOException{273 void myprintln(String s) { 268 274 if (skip.containsKey(s)) { 269 275 String color = skip.get(s); … … 290 296 } 291 297 292 void start() throws IOException{298 void start() { 293 299 if (optionXhtml) { 294 300 myprintlnfinal( … … 300 306 } 301 307 302 void end() throws IOException{308 void end() { 303 309 for (String s : skip.keySet()) { 304 310 myprintln("+++ Obsolete skip entry: " + s); … … 504 510 } 505 511 506 void checkInOneButNotTheOther() throws IOException{512 void checkInOneButNotTheOther() { 507 513 List<String> le = new LinkedList<>(eliUrls.keySet()); 508 514 List<String> lj = new LinkedList<>(josmUrls.keySet()); … … 564 570 } 565 571 566 void checkCommonEntries() throws IOException{572 void checkCommonEntries() { 567 573 doSameUrlButDifferentName(); 568 574 doSameUrlButDifferentId(); … … 575 581 doMismatchingShapes(); 576 582 doMismatchingIcons(); 583 doMismatchingCategories(); 577 584 doMiscellaneousChecks(); 578 585 } 579 586 580 void doSameUrlButDifferentName() throws IOException{587 void doSameUrlButDifferentName() { 581 588 myprintln("*** Same URL, but different name: ***"); 582 589 for (String url : eliUrls.keySet()) { … … 592 599 } 593 600 594 void doSameUrlButDifferentId() throws IOException{601 void doSameUrlButDifferentId() { 595 602 myprintln("*** Same URL, but different Id: ***"); 596 603 for (String url : eliUrls.keySet()) { … … 606 613 } 607 614 608 void doSameUrlButDifferentType() throws IOException{615 void doSameUrlButDifferentType() { 609 616 myprintln("*** Same URL, but different type: ***"); 610 617 for (String url : eliUrls.keySet()) { … … 618 625 } 619 626 620 void doSameUrlButDifferentZoomBounds() throws IOException{627 void doSameUrlButDifferentZoomBounds() { 621 628 myprintln("*** Same URL, but different zoom bounds: ***"); 622 629 for (String url : eliUrls.keySet()) { … … 644 651 } 645 652 646 void doSameUrlButDifferentCountryCode() throws IOException{653 void doSameUrlButDifferentCountryCode() { 647 654 myprintln("*** Same URL, but different country code: ***"); 648 655 for (String url : eliUrls.keySet()) { … … 660 667 } 661 668 662 void doSameUrlButDifferentQuality() throws IOException{669 void doSameUrlButDifferentQuality() { 663 670 myprintln("*** Same URL, but different quality: ***"); 664 671 for (String url : eliUrls.keySet()) { … … 678 685 } 679 686 680 void doSameUrlButDifferentDates() throws IOException{687 void doSameUrlButDifferentDates() { 681 688 myprintln("*** Same URL, but different dates: ***"); 682 689 Pattern pattern = Pattern.compile("^(.*;)(\\d\\d\\d\\d)(-(\\d\\d)(-(\\d\\d))?)?$"); … … 720 727 } 721 728 722 void doSameUrlButDifferentInformation() throws IOException{729 void doSameUrlButDifferentInformation() { 723 730 myprintln("*** Same URL, but different information: ***"); 724 731 for (String url : eliUrls.keySet()) { … … 738 745 } 739 746 740 void compareDescriptions(JsonObject e, ImageryInfo j) throws IOException{747 void compareDescriptions(JsonObject e, ImageryInfo j) { 741 748 String et = getDescriptions(e).getOrDefault("en", ""); 742 749 String jt = getDescriptions(j).getOrDefault("en", ""); … … 752 759 } 753 760 754 void comparePermissionReferenceUrls(JsonObject e, ImageryInfo j) throws IOException{761 void comparePermissionReferenceUrls(JsonObject e, ImageryInfo j) { 755 762 String et = getPermissionReferenceUrl(e); 756 763 String jt = getPermissionReferenceUrl(j); … … 780 787 } 781 788 782 void compareAttributionUrls(JsonObject e, ImageryInfo j) throws IOException{789 void compareAttributionUrls(JsonObject e, ImageryInfo j) { 783 790 String et = getAttributionUrl(e); 784 791 String jt = getAttributionUrl(j); … … 799 806 } 800 807 801 void compareAttributionTexts(JsonObject e, ImageryInfo j) throws IOException{808 void compareAttributionTexts(JsonObject e, ImageryInfo j) { 802 809 String et = getAttributionText(e); 803 810 String jt = getAttributionText(j); … … 813 820 } 814 821 815 void compareProjections(JsonObject e, ImageryInfo j) throws IOException{822 void compareProjections(JsonObject e, ImageryInfo j) { 816 823 String et = getProjections(e).stream().sorted().collect(Collectors.joining(" ")); 817 824 String jt = getProjections(j).stream().sorted().collect(Collectors.joining(" ")); … … 836 843 } 837 844 838 void compareDefaults(JsonObject e, ImageryInfo j) throws IOException{845 void compareDefaults(JsonObject e, ImageryInfo j) { 839 846 boolean ed = getDefault(e); 840 847 boolean jd = getDefault(j); … … 848 855 } 849 856 850 void compareOverlays(JsonObject e, ImageryInfo j) throws IOException{857 void compareOverlays(JsonObject e, ImageryInfo j) { 851 858 boolean eo = getOverlay(e); 852 859 boolean jo = getOverlay(j); … … 860 867 } 861 868 862 void compareNoTileHeaders(JsonObject e, ImageryInfo j) throws IOException{869 void compareNoTileHeaders(JsonObject e, ImageryInfo j) { 863 870 Map<String, Set<String>> eh = getNoTileHeader(e); 864 871 Map<String, Set<String>> jh = getNoTileHeader(j); … … 874 881 } 875 882 876 void doMismatchingShapes() throws IOException{883 void doMismatchingShapes() { 877 884 myprintln("*** Mismatching shapes: ***"); 878 885 for (String url : josmUrls.keySet()) { … … 998 1005 } 999 1006 1000 void doMismatchingIcons() throws IOException{1007 void doMismatchingIcons() { 1001 1008 myprintln("*** Mismatching icons: ***"); 1009 doMismatching(this::compareIcons); 1010 } 1011 1012 void doMismatchingCategories() { 1013 myprintln("*** Mismatching categories: ***"); 1014 doMismatching(this::compareCategories); 1015 } 1016 1017 void doMismatching(BiConsumer<ImageryInfo, JsonObject> comparator) { 1002 1018 for (String url : eliUrls.keySet()) { 1003 JsonObject e = eliUrls.get(url); 1004 if (!josmUrls.containsKey(url)) { 1005 continue; 1006 } 1007 ImageryInfo j = josmUrls.get(url); 1008 String ij = getIcon(j); 1009 String ie = getIcon(e); 1010 boolean ijok = isNotBlank(ij); 1011 boolean ieok = isNotBlank(ie); 1012 if (ijok && !ieok) { 1013 if (!optionNoEli) { 1014 myprintln("+ No ELI icon: "+getDescription(j)); 1015 } 1016 } else if (!ijok && ieok) { 1017 myprintln("- No JOSM icon: "+getDescription(j)); 1018 } else if (ijok && ieok && !Objects.equals(ij, ie) && !( 1019 (ie.startsWith("https://osmlab.github.io/editor-layer-index/") 1020 || ie.startsWith("https://raw.githubusercontent.com/osmlab/editor-layer-index/")) && 1021 ij.startsWith("data:"))) { 1022 String iehttps = ie.replace("http:", "https:"); 1023 if (ij.equals(iehttps)) { 1024 myprintln("+ Different icons: "+getDescription(j)); 1025 } else { 1026 myprintln("* Different icons: "+getDescription(j)); 1027 } 1028 } 1029 } 1030 } 1031 1032 void doMiscellaneousChecks() throws IOException { 1019 if (josmUrls.containsKey(url)) { 1020 comparator.accept(josmUrls.get(url), eliUrls.get(url)); 1021 } 1022 } 1023 } 1024 1025 void compareIcons(ImageryInfo j, JsonObject e) { 1026 String ij = getIcon(j); 1027 String ie = getIcon(e); 1028 boolean ijok = isNotBlank(ij); 1029 boolean ieok = isNotBlank(ie); 1030 if (ijok && !ieok) { 1031 if (!optionNoEli) { 1032 myprintln("+ No ELI icon: "+getDescription(j)); 1033 } 1034 } else if (!ijok && ieok) { 1035 myprintln("- No JOSM icon: "+getDescription(j)); 1036 } else if (ijok && ieok && !Objects.equals(ij, ie) && !( 1037 (ie.startsWith("https://osmlab.github.io/editor-layer-index/") 1038 || ie.startsWith("https://raw.githubusercontent.com/osmlab/editor-layer-index/")) && 1039 ij.startsWith("data:"))) { 1040 String iehttps = ie.replace("http:", "https:"); 1041 if (ij.equals(iehttps)) { 1042 myprintln("+ Different icons: "+getDescription(j)); 1043 } else { 1044 myprintln("* Different icons: "+getDescription(j)); 1045 } 1046 } 1047 } 1048 1049 void compareCategories(ImageryInfo j, JsonObject e) { 1050 String cj = getCategory(j); 1051 String ce = getCategory(e); 1052 boolean cjok = isNotBlank(cj); 1053 boolean ceok = isNotBlank(ce); 1054 if (cjok && !ceok) { 1055 if (!optionNoEli) { 1056 myprintln("+ No ELI category: "+getDescription(j)); 1057 } 1058 } else if (!cjok && ceok) { 1059 myprintln("- No JOSM category: "+getDescription(j)); 1060 } else if (cjok && ceok && !Objects.equals(cj, ce)) { 1061 myprintln("+ Different categories: "+getDescription(j)); 1062 } 1063 } 1064 1065 void doMiscellaneousChecks() { 1033 1066 myprintln("*** Miscellaneous checks: ***"); 1034 1067 Map<String, ImageryInfo> josmIds = new HashMap<>(); … … 1376 1409 return ((ImageryInfo) e).getImageryCategoryOriginalString(); 1377 1410 } 1378 return null;1411 return ((Map<String, JsonObject>) e).get("properties").getString("category", null); 1379 1412 } 1380 1413 -
trunk/scripts/TagInfoExtract.java
r15232 r15692 128 128 /** 129 129 * Parse command line arguments. 130 * @param args command line arguments 130 131 */ 131 132 private void parseCommandLineArguments(String[] args) { … … 203 204 * Determine full image url (can refer to JOSM or OSM repository). 204 205 * @param path the image path 206 * @return full image url 205 207 */ 206 208 private String findImageUrl(String path) { … … 323 325 /** 324 326 * Read the style sheet file and parse the MapCSS code. 327 * @throws IOException if any I/O error occurs 328 * @throws ParseException in case of parsing error 325 329 */ 326 330 private void parseStyleSheet() throws IOException, ParseException { … … 335 339 /** 336 340 * Collect all the tag from the style sheet. 341 * @return list of taginfo tags 337 342 */ 338 343 private List<TagInfoTag> convertStyleSheet() { … … 403 408 /** 404 409 * Create image file from StyleElement. 410 * @param element style element 411 * @param type object type 412 * @param nc navigatable component 405 413 * 406 414 * @return the URL … … 428 436 * @param generateImage if true, create or find a suitable image icon and return URL, 429 437 * if false, just check if tag is supported and return true or false 438 * @return URL for image icon if tag is supported 430 439 */ 431 440 abstract Optional<String> findUrl(boolean generateImage); … … 550 559 /** 551 560 * Initialize the script. 561 * @throws IOException if any I/O error occurs 552 562 */ 553 563 private void init() throws IOException { -
trunk/src/org/openstreetmap/josm/data/osm/OsmUtils.java
r15671 r15692 216 216 * @param value the value to separate 217 217 * @return the separated values as Stream 218 * @since xxx218 * @since 15671 219 219 */ 220 220 public static Stream<String> splitMultipleValues(String value) { -
trunk/src/org/openstreetmap/josm/gui/util/AbstractTag2LinkPopupListener.java
r15687 r15692 13 13 * A popup listener which adds web links based on tags of OSM primitives. 14 14 * 15 * @since xxx15 * @since 15673 16 16 */ 17 17 public abstract class AbstractTag2LinkPopupListener implements PopupMenuListener { -
trunk/src/org/openstreetmap/josm/gui/util/OpenBrowserAction.java
r15673 r15692 14 14 * Action to open browser on given URL. 15 15 * @see OpenBrowser 16 * @since xxx16 * @since 15673 17 17 */ 18 18 public class OpenBrowserAction extends AbstractAction {
Note:
See TracChangeset
for help on using the changeset viewer.