Changeset 15034 in josm
- Timestamp:
- 2019-05-02T04:33:57+02:00 (6 years ago)
- Location:
- trunk
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.checkstyle
r14417 r15034 18 18 <filter-data value="src/org/openstreetmap/gui"/> 19 19 <filter-data value="src/org/openstreetmap/josm/gui/mappaint/mapcss/parsergen"/> 20 <filter-data value="src/org/tukaani"/> 21 <filter-data value=".externalToolBuilders"/> 22 <filter-data value=".settings"/> 20 23 <filter-data value=".svn"/> 24 <filter-data value="bin"/> 25 <filter-data value="bintest"/> 26 <filter-data value="build"/> 27 <filter-data value="build2"/> 21 28 <filter-data value="data"/> 29 <filter-data value="data_nodist"/> 30 <filter-data value="dist"/> 31 <filter-data value="eclipse"/> 22 32 <filter-data value="images"/> 33 <filter-data value="images_nodist"/> 23 34 <filter-data value="javadoc"/> 35 <filter-data value="linux"/> 36 <filter-data value="macosx"/> 37 <filter-data value="netbeans"/> 38 <filter-data value="patches"/> 24 39 <filter-data value="resources"/> 25 40 <filter-data value="styles"/> 26 <filter-data value="scripts"/> 41 <filter-data value="styles_nodist"/> 42 <filter-data value="test/build"/> 43 <filter-data value="test/config"/> 44 <filter-data value="test/data"/> 45 <filter-data value="test/lib"/> 46 <filter-data value="test/report"/> 47 <filter-data value="tools"/> 48 <filter-data value="windows"/> 27 49 </filter> 28 50 </fileset-config> -
trunk/build.xml
r15033 r15034 47 47 <property name="failureaccess.jar" location="${tools.dir}/failureaccess.jar"/> 48 48 <property name="guava.jar" location="${tools.dir}/guava.jar"/> 49 49 <property name="commons-lang3.jar" location="${pmd.dir}/commons-lang3-3.8.1.jar"/> 50 50 <property name="jformatstring.jar" location="${spotbugs.dir}/jFormatString-3.0.0.jar"/> 51 51 <property name="dist.jar" location="${dist.dir}/josm-custom.jar"/> -
trunk/scripts/SyncEditorLayerIndex.java
r15033 r15034 1 1 // License: GPL. For details, see LICENSE file. 2 import static java.nio.charset.StandardCharsets.UTF_8; 2 3 import static org.apache.commons.lang3.StringUtils.isBlank; 3 4 import static org.apache.commons.lang3.StringUtils.isNotBlank; 4 5 5 6 import java.io.BufferedReader; 6 import java.io.FileInputStream;7 import java.io.FileNotFoundException;8 import java.io.FileOutputStream;9 7 import java.io.IOException; 10 8 import java.io.InputStreamReader; 9 import java.io.OutputStream; 11 10 import java.io.OutputStreamWriter; 12 import java.io.UnsupportedEncodingException;13 11 import java.lang.reflect.Field; 12 import java.nio.file.Files; 13 import java.nio.file.Paths; 14 14 import java.text.DecimalFormat; 15 15 import java.text.ParseException; … … 50 50 import org.openstreetmap.josm.io.imagery.ImageryReader; 51 51 import org.openstreetmap.josm.spi.preferences.Config; 52 import org.openstreetmap.josm.tools.Logging; 52 53 import org.openstreetmap.josm.tools.OptionParser; 53 54 import org.openstreetmap.josm.tools.OptionParser.OptionCount; … … 74 75 public class SyncEditorLayerIndex { 75 76 77 private static final int MAXLEN = 140; 78 76 79 private List<ImageryInfo> josmEntries; 77 80 private JsonArray eliEntries; 78 81 79 private Map<String, JsonObject> eliUrls = new HashMap<>(); 80 private Map<String, ImageryInfo> josmUrls = new HashMap<>(); 81 private Map<String, ImageryInfo> josmMirrors = new HashMap<>(); 82 private static Map<String, String> oldproj = new HashMap<>(); 83 private static List<String> ignoreproj = new LinkedList<>(); 82 private final Map<String, JsonObject> eliUrls = new HashMap<>(); 83 private final Map<String, ImageryInfo> josmUrls = new HashMap<>(); 84 private final Map<String, ImageryInfo> josmMirrors = new HashMap<>(); 85 private static final Map<String, String> oldproj = new HashMap<>(); 86 private static final List<String> ignoreproj = new LinkedList<>(); 84 87 85 88 private static String eliInputFile = "imagery_eli.geojson"; 86 89 private static String josmInputFile = "imagery_josm.imagery.xml"; 87 90 private static String ignoreInputFile = "imagery_josm.ignores.txt"; 88 private static FileOutputStream outputFile= null;89 private static OutputStreamWriter outputStream = null;91 private static OutputStream outputFile; 92 private static OutputStreamWriter outputStream; 90 93 private static String optionOutput; 91 94 private static boolean optionShorten; … … 108 111 public static void main(String[] args) throws IOException, SAXException, ReflectiveOperationException { 109 112 Locale.setDefault(Locale.ROOT); 110 parse _command_line_arguments(args);113 parseCommandLineArguments(args); 111 114 Preferences pref = new Preferences(JosmBaseDirectories.getInstance()); 112 115 Config.setPreferencesInstance(pref); … … 118 121 script.loadJosmEntries(); 119 122 if (optionJosmXml != null) { 120 FileOutputStream file = new FileOutputStream(optionJosmXml); 121 OutputStreamWriter stream = new OutputStreamWriter(file, "UTF-8"); 122 script.printentries(script.josmEntries, stream); 123 stream.close(); 124 file.close(); 123 try (OutputStreamWriter stream = new OutputStreamWriter(Files.newOutputStream(Paths.get(optionJosmXml)), UTF_8)) { 124 script.printentries(script.josmEntries, stream); 125 } 125 126 } 126 127 script.loadELIEntries(); 127 128 if (optionEliXml != null) { 128 FileOutputStream file = new FileOutputStream(optionEliXml); 129 OutputStreamWriter stream = new OutputStreamWriter(file, "UTF-8"); 130 script.printentries(script.eliEntries, stream); 131 stream.close(); 132 file.close(); 129 try (OutputStreamWriter stream = new OutputStreamWriter(Files.newOutputStream(Paths.get(optionEliXml)), UTF_8)) { 130 script.printentries(script.eliEntries, stream); 131 } 133 132 } 134 133 script.checkInOneButNotTheOther(); … … 154 153 return "usage: java -cp build SyncEditorLayerIndex\n" + 155 154 "-c,--encoding <encoding> output encoding (defaults to UTF-8 or cp850 on Windows)\n" + 156 "-e,--eli_input <eli_input> Input file for the editor layer index (geojson). Default is imagery_eli.geojson (current directory).\n" + 155 "-e,--eli_input <eli_input> Input file for the editor layer index (geojson). " + 156 "Default is imagery_eli.geojson (current directory).\n" + 157 157 "-h,--help show this help\n" + 158 158 "-i,--ignore_input <ignore_input> Input file for the ignore list. Default is imagery_josm.ignores.txt (current directory).\n" + 159 "-j,--josm_input <josm_input> Input file for the JOSM imagery list (xml). Default is imagery_josm.imagery.xml (current directory).\n" + 159 "-j,--josm_input <josm_input> Input file for the JOSM imagery list (xml). " + 160 "Default is imagery_josm.imagery.xml (current directory).\n" + 160 161 "-m,--noeli don't show output for ELI problems\n" + 161 162 "-n,--noskip don't skip known entries\n" + … … 171 172 * Parse command line arguments. 172 173 * @param args program arguments 173 * @throws FileNotFoundException if a file can't be found 174 * @throws UnsupportedEncodingException if the given encoding can't be found 174 * @throws IOException in case of I/O error 175 175 */ 176 static void parse _command_line_arguments(String[] args) throwsFileNotFoundException, UnsupportedEncodingException {176 static void parseCommandLineArguments(String[] args) throws IOException { 177 177 new OptionParser("JOSM/ELI synchronization script") 178 178 .addFlagParameter("help", SyncEditorLayerIndex::showHelp) … … 204 204 .parseOptionsOrExit(Arrays.asList(args)); 205 205 206 if (optionOutput != null && optionOutput != "-") {207 outputFile = new FileOutputStream(optionOutput);206 if (optionOutput != null && !"-".equals(optionOutput)) { 207 outputFile = Files.newOutputStream(Paths.get(optionOutput)); 208 208 outputStream = new OutputStreamWriter(outputFile, optionEncoding != null ? optionEncoding : "UTF-8"); 209 209 } else if (optionEncoding != null) { … … 233 233 void loadSkip() throws IOException { 234 234 final Pattern pattern = Pattern.compile("^\\|\\| *(ELI|Ignore) *\\|\\| *\\{\\{\\{(.+)\\}\\}\\} *\\|\\|"); 235 try (BufferedReader fr = new BufferedReader(new InputStreamReader( new FileInputStream(ignoreInputFile), "UTF-8"))) {235 try (BufferedReader fr = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get(ignoreInputFile)), UTF_8))) { 236 236 String line; 237 237 … … 262 262 skip.remove(s); 263 263 if (optionXhtmlBody || optionXhtml) { 264 s = "<pre style=\"margin:3px;color:"+color+"\">"+s.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")+"</pre>"; 264 s = "<pre style=\"margin:3px;color:"+color+"\">" 265 + s.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">")+"</pre>"; 265 266 } 266 267 if (!optionNoSkip) { 267 268 return; 268 269 } 269 } else if(optionXhtmlBody || optionXhtml) { 270 } else if (optionXhtmlBody || optionXhtml) { 270 271 String color = 271 272 s.startsWith("***") ? "black" : … … 273 274 (s.startsWith("#") ? "indigo" : 274 275 (s.startsWith("!") ? "orange" : "red"))); 275 s = "<pre style=\"margin:3px;color:"+color+"\">"+s.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")+"</pre>"; 276 s = "<pre style=\"margin:3px;color:"+color+"\">"+s.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">")+"</pre>"; 276 277 } 277 278 if ((s.startsWith("+ ") || s.startsWith("+++ ELI") || s.startsWith("#")) && optionNoEli) { … … 283 284 void start() throws IOException { 284 285 if (optionXhtml) { 285 myprintlnfinal("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"); 286 myprintlnfinal("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/><title>JOSM - ELI differences</title></head><body>\n"); 286 myprintlnfinal( 287 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"); 288 myprintlnfinal( 289 "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>"+ 290 "<title>JOSM - ELI differences</title></head><body>\n"); 287 291 } 288 292 } … … 298 302 299 303 void loadELIEntries() throws IOException { 300 try (JsonReader jr = Json.createReader(new InputStreamReader( new FileInputStream(eliInputFile), "UTF-8"))) {304 try (JsonReader jr = Json.createReader(new InputStreamReader(Files.newInputStream(Paths.get(eliInputFile)), UTF_8))) { 301 305 eliEntries = jr.readObject().getJsonArray("features"); 302 306 } … … 306 310 if (url.contains("{z}")) { 307 311 myprintln("+++ ELI-URL uses {z} instead of {zoom}: "+url); 308 url = url.replace("{z}","{zoom}"); 312 url = url.replace("{z}", "{zoom}"); 309 313 } 310 314 if (eliUrls.containsKey(url)) { … … 355 359 if (p != null) { 356 360 res += offset + "<projections>\n"; 357 for (String c : p) 361 for (String c : p) { 358 362 res += offset + " <code>"+c+"</code>\n"; 363 } 359 364 res += offset + "</projections>\n"; 360 365 } … … 370 375 for (Object e : entries) { 371 376 stream.write(" <entry" 372 + ("eli-best".equals(getQuality(e)) ? " eli-best=\"true\"" : "" 373 + (getOverlay(e) ? " overlay=\"true\"" : "" 377 + ("eli-best".equals(getQuality(e)) ? " eli-best=\"true\"" : "") 378 + (getOverlay(e) ? " overlay=\"true\"" : "") 374 379 + ">\n"); 375 380 String t; … … 428 433 if (lat < minlat) minlat = lat; 429 434 if (lon < minlon) minlon = lon; 430 if ((i++ %3) == 0) {435 if ((i++ % 3) == 0) { 431 436 shapes += sep + " "; 432 437 } … … 435 440 shapes += sep + "</shape>\n"; 436 441 } 437 } catch(IllegalArgumentException ignored) { 442 } catch (IllegalArgumentException ignored) { 443 Logging.trace(ignored); 438 444 } 439 445 if (!shapes.isEmpty()) { 440 stream.write(" <bounds min-lat='"+df.format(minlat)+"' min-lon='"+df.format(minlon)+"' max-lat='"+df.format(maxlat)+"' max-lon='"+df.format(maxlon)+"'>\n"); 446 stream.write(" <bounds min-lat='"+df.format(minlat) 447 +"' min-lon='"+df.format(minlon) 448 +"' max-lat='"+df.format(maxlat) 449 +"' max-lon='"+df.format(maxlon)+"'>\n"); 441 450 stream.write(shapes + " </bounds>\n"); 442 451 } … … 464 473 if (url.contains("{z}")) { 465 474 myprintln("+++ JOSM-URL uses {z} instead of {zoom}: "+url); 466 url = url.replace("{z}","{zoom}"); 475 url = url.replace("{z}", "{zoom}"); 467 476 } 468 477 if (josmUrls.containsKey(url)) { … … 475 484 Field origNameField = ImageryInfo.class.getDeclaredField("origName"); 476 485 ReflectionUtils.setObjectsAccessible(origNameField); 477 origNameField.set(m, m.getOriginalName().replaceAll(" mirror server( \\d+)?","")); 486 origNameField.set(m, m.getOriginalName().replaceAll(" mirror server( \\d+)?", "")); 478 487 if (josmUrls.containsKey(url)) { 479 488 myprintln("+++ JOSM-Mirror-URL is not unique: "+url); … … 504 513 JsonObject e = eliUrls.get(urle); 505 514 String ide = getId(e); 506 String urlhttps = urle.replace("http:","https:"); 515 String urlhttps = urle.replace("http:", "https:"); 507 516 if (lj.contains(urlhttps)) { 508 517 myprintln("+ Missing https: "+getDescription(e)); … … 523 532 // replace key for this entry with JOSM URL 524 533 eliUrls.remove(urle); 525 eliUrls.put(urlj,e); 534 eliUrls.put(urlj, e); 526 535 break; 527 536 } … … 548 557 549 558 void checkCommonEntries() throws IOException { 559 doSameUrlButDifferentName(); 560 doSameUrlButDifferentId(); 561 doSameUrlButDifferentType(); 562 doSameUrlButDifferentZoomBounds(); 563 doSameUrlButDifferentCountryCode(); 564 doSameUrlButDifferentQuality(); 565 doSameUrlButDifferentDates(); 566 doSameUrlButDifferentInformation(); 567 doMismatchingShapes(); 568 doMismatchingIcons(); 569 doMiscellaneousChecks(); 570 } 571 572 void doSameUrlButDifferentName() throws IOException { 550 573 myprintln("*** Same URL, but different name: ***"); 551 574 for (String url : eliUrls.keySet()) { … … 553 576 if (!josmUrls.containsKey(url)) continue; 554 577 ImageryInfo j = josmUrls.get(url); 555 String ename = getName(e).replace("'","\u2019"); 556 String jname = getName(j).replace("'","\u2019"); 578 String ename = getName(e).replace("'", "\u2019"); 579 String jname = getName(j).replace("'", "\u2019"); 557 580 if (!ename.equals(jname)) { 558 581 myprintln("* Name differs ('"+getName(e)+"' != '"+getName(j)+"'): "+getUrl(j)); 559 582 } 560 583 } 561 584 } 585 586 void doSameUrlButDifferentId() throws IOException { 562 587 myprintln("*** Same URL, but different Id: ***"); 563 588 for (String url : eliUrls.keySet()) { … … 571 596 } 572 597 } 573 598 } 599 600 void doSameUrlButDifferentType() throws IOException { 574 601 myprintln("*** Same URL, but different type: ***"); 575 602 for (String url : eliUrls.keySet()) { … … 581 608 } 582 609 } 583 610 } 611 612 void doSameUrlButDifferentZoomBounds() throws IOException { 584 613 myprintln("*** Same URL, but different zoom bounds: ***"); 585 614 for (String url : eliUrls.keySet()) { … … 605 634 } 606 635 } 607 636 } 637 638 void doSameUrlButDifferentCountryCode() throws IOException { 608 639 myprintln("*** Same URL, but different country code: ***"); 609 640 for (String url : eliUrls.keySet()) { … … 619 650 } 620 651 } 652 } 653 654 void doSameUrlButDifferentQuality() throws IOException { 621 655 myprintln("*** Same URL, but different quality: ***"); 622 656 for (String url : eliUrls.keySet()) { … … 634 668 } 635 669 } 670 } 671 672 void doSameUrlButDifferentDates() throws IOException { 636 673 myprintln("*** Same URL, but different dates: ***"); 637 674 Pattern pattern = Pattern.compile("^(.*;)(\\d\\d\\d\\d)(-(\\d\\d)(-(\\d\\d))?)?$"); … … 642 679 String jd = getDate(j); 643 680 // The forms 2015;- or -;2015 or 2015;2015 are handled equal to 2015 644 String ef = ed.replaceAll("\\A-;","").replaceAll(";-\\z","").replaceAll("\\A([0-9-]+);\\1\\z", "$1"); 681 String ef = ed.replaceAll("\\A-;", "").replaceAll(";-\\z", "").replaceAll("\\A([0-9-]+);\\1\\z", "$1"); 645 682 // ELI has a strange and inconsistent used end_date definition, so we try again with subtraction by one 646 683 String ed2 = ed; … … 658 695 ed2 += "-" + String.format("%02d", cal.get(Calendar.DAY_OF_MONTH)); 659 696 } 660 String ef2 = ed2.replaceAll("\\A-;","").replaceAll(";-\\z","").replaceAll("\\A([0-9-]+);\\1\\z", "$1"); 697 String ef2 = ed2.replaceAll("\\A-;", "").replaceAll(";-\\z", "").replaceAll("\\A([0-9-]+);\\1\\z", "$1"); 661 698 if (!ed.equals(jd) && !ef.equals(jd) && !ed2.equals(jd) && !ef2.equals(jd)) { 662 699 String t = "'"+ed+"'"; … … 673 710 } 674 711 } 712 } 713 714 void doSameUrlButDifferentInformation() throws IOException { 675 715 myprintln("*** Same URL, but different information: ***"); 676 716 for (String url : eliUrls.keySet()) { … … 723 763 myprintln("- Missing JOSM attribution URL ("+et+"): "+getDescription(j)); 724 764 } else if (isNotBlank(et)) { 725 String ethttps = et.replace("http:","https:"); 765 String ethttps = et.replace("http:", "https:"); 726 766 if (jt.equals(ethttps) || jt.equals(et+"/") || jt.equals(ethttps+"/")) { 727 767 myprintln("+ Attribution URL differs ('"+et+"' != '"+jt+"'): "+getDescription(j)); … … 786 826 } 787 827 } 828 } 829 830 void doMismatchingShapes() throws IOException { 788 831 myprintln("*** Mismatching shapes: ***"); 789 832 for (String url : josmUrls.keySet()) { … … 792 835 for (Shape shape : getShapes(j)) { 793 836 List<Coordinate> p = shape.getPoints(); 794 if(!p.get(0).equals(p.get(p.size()-1))) { 837 if (!p.get(0).equals(p.get(p.size()-1))) { 795 838 myprintln("+++ JOSM shape "+num+" unclosed: "+getDescription(j)); 796 839 } … … 811 854 for (Shape shape : s) { 812 855 List<Coordinate> p = shape.getPoints(); 813 if(!p.get(0).equals(p.get(p.size()-1)) && !optionNoEli) { 856 if (!p.get(0).equals(p.get(p.size()-1)) && !optionNoEli) { 814 857 myprintln("+++ ELI shape "+num+" unclosed: "+getDescription(e)); 815 858 } … … 834 877 myprintln("+ No ELI shape: "+getDescription(j)); 835 878 } 836 } else if(js.isEmpty() && !s.isEmpty()) { 879 } else if (js.isEmpty() && !s.isEmpty()) { 837 880 // don't report boundary like 5 point shapes as difference 838 881 if (s.size() != 1 || s.get(0).getPoints().size() != 5) { 839 882 myprintln("- No JOSM shape: "+getDescription(j)); 840 883 } 841 } else if(s.size() != js.size()) { 884 } else if (s.size() != js.size()) { 842 885 myprintln("* Different number of shapes ("+s.size()+" != "+js.size()+"): "+getDescription(j)); 843 886 } else { … … 850 893 if (ep.size() == jp.size() && !jdone[jnums]) { 851 894 boolean err = false; 852 for(int nump = 0; nump < ep.size() && !err; ++nump) { 895 for (int nump = 0; nump < ep.size() && !err; ++nump) { 853 896 Coordinate ept = ep.get(nump); 854 897 Coordinate jpt = jp.get(nump); 855 if(Math.abs(ept.getLat()-jpt.getLat()) > 0.00001 || Math.abs(ept.getLon()-jpt.getLon()) > 0.00001) 898 if (Math.abs(ept.getLat()-jpt.getLat()) > 0.00001 || Math.abs(ept.getLon()-jpt.getLon()) > 0.00001) 856 899 err = true; 857 900 } 858 if(!err) { 901 if (!err) { 859 902 edone[enums] = true; 860 903 jdone[jnums] = true; … … 897 940 numtxt += '/' + Integer.toString(jnums+1); 898 941 } 899 myprintln("* Different number of points for shape "+numtxt+" ("+ep.size()+" ! = "+jp.size()+")): "+getDescription(j)); 942 myprintln("* Different number of points for shape "+numtxt+" ("+ep.size()+" ! = "+jp.size()+")): " 943 + getDescription(j)); 900 944 edone[enums] = true; 901 945 jdone[jnums] = true; … … 906 950 } 907 951 } 952 } 953 954 void doMismatchingIcons() throws IOException { 908 955 myprintln("*** Mismatching icons: ***"); 909 956 for (String url : eliUrls.keySet()) { … … 927 974 || ie.startsWith("https://raw.githubusercontent.com/osmlab/editor-layer-index/")) && 928 975 ij.startsWith("data:"))) { 929 String iehttps = ie.replace("http:","https:"); 976 String iehttps = ie.replace("http:", "https:"); 930 977 if (ij.equals(iehttps)) { 931 978 myprintln("+ Different icons: "+getDescription(j)); … … 935 982 } 936 983 } 984 } 985 986 void doMiscellaneousChecks() throws IOException { 937 987 myprintln("*** Miscellaneous checks: ***"); 938 988 Map<String, ImageryInfo> josmIds = new HashMap<>(); … … 964 1014 } 965 1015 for (String o : old) { 966 myprintln("* Projection "+o+" is an old unsupported code and has been replaced by "+oldproj.get(o)+": "+getDescription(j)); 1016 myprintln("* Projection "+o+" is an old unsupported code and has been replaced by "+oldproj.get(o)+": " 1017 + getDescription(j)); 967 1018 } 968 1019 } … … 995 1046 myprintln("* Strange URL '"+u+"': "+getDescription(j)); 996 1047 } else { 997 String domain = m.group(1).replaceAll("\\{switch:.*\\}","x"); 1048 String domain = m.group(1).replaceAll("\\{switch:.*\\}", "x"); 998 1049 String port = m.group(2); 999 1050 if (!(domain.matches("^\\d+\\.\\d+\\.\\d+\\.\\d+$")) && !dv.isValid(domain)) … … 1028 1079 myprintln("* JOSM-Date '"+d+"' is strange (second earlier than first): "+getDescription(j)); 1029 1080 } 1030 } 1031 catch (Exception e) { 1081 } catch (Exception e) { 1032 1082 myprintln("* JOSM-Date '"+d+"' is strange ("+e.getMessage()+"): "+getDescription(j)); 1033 1083 } … … 1053 1103 double lat = p.getLat(); 1054 1104 double lon = p.getLon(); 1055 if(lat > maxlat) maxlat = lat; 1056 if(lon > maxlon) maxlon = lon; 1057 if(lat < minlat) minlat = lat; 1058 if(lon < minlon) minlon = lon; 1105 if (lat > maxlat) maxlat = lat; 1106 if (lon > maxlon) maxlon = lon; 1107 if (lat < minlat) minlat = lat; 1108 if (lon < minlon) minlon = lon; 1059 1109 } 1060 1110 } … … 1062 1112 if (b.getMinLat() != minlat || b.getMinLon() != minlon || b.getMaxLat() != maxlat || b.getMaxLon() != maxlon) { 1063 1113 myprintln("* Bounds do not match shape (is "+b.getMinLat()+","+b.getMinLon()+","+b.getMaxLat()+","+b.getMaxLon() 1064 + ", calculated <bounds min-lat='"+minlat+"' min-lon='"+minlon+"' max-lat='"+maxlat+"' max-lon='"+maxlon+"'>): "+getDescription(j)); 1114 + ", calculated <bounds min-lat='"+minlat+"' min-lon='"+minlon+"' max-lat='"+maxlat+"' max-lon='"+maxlon+"'>): " 1115 + getDescription(j)); 1065 1116 } 1066 1117 } … … 1085 1136 1086 1137 static String getUrlStripped(Object e) { 1087 return getUrl(e).replaceAll("\\?(apikey|access_token)=.*",""); 1138 return getUrl(e).replaceAll("\\?(apikey|access_token)=.*", ""); 1088 1139 } 1089 1140 … … 1093 1144 String start = p.containsKey("start_date") ? p.getString("start_date") : ""; 1094 1145 String end = p.containsKey("end_date") ? p.getString("end_date") : ""; 1095 if(!start.isEmpty() && !end.isEmpty()) 1146 if (!start.isEmpty() && !end.isEmpty()) 1096 1147 return start+";"+end; 1097 else if(!start.isEmpty()) 1148 else if (!start.isEmpty()) 1098 1149 return start+";-"; 1099 else if(!end.isEmpty()) 1150 else if (!end.isEmpty()) 1100 1151 return "-;"+end; 1101 1152 return ""; … … 1104 1155 static Date verifyDate(String year, String month, String day) throws ParseException { 1105 1156 String date; 1106 if(year == null) { 1157 if (year == null) { 1107 1158 date = "3000-01-01"; 1108 1159 } else { … … 1161 1212 if (e instanceof ImageryInfo) { 1162 1213 ImageryBounds bounds = ((ImageryInfo) e).getBounds(); 1163 if(bounds != null) { 1214 if (bounds != null) { 1164 1215 return bounds.getShapes(); 1165 1216 } … … 1283 1334 } 1284 1335 1285 static Map<String,String> getDescriptions(Object e) { 1286 Map<String,String> res = new HashMap<String, String>(); 1336 static Map<String, String> getDescriptions(Object e) { 1337 Map<String, String> res = new HashMap<String, String>(); 1287 1338 if (e instanceof ImageryInfo) { 1288 1339 String a = ((ImageryInfo) e).getDescription(); … … 1290 1341 } else { 1291 1342 String a = ((Map<String, JsonObject>) e).get("properties").getString("description", null); 1292 if (a != null) res.put("en", a.replaceAll("''","'")); 1343 if (a != null) res.put("en", a.replaceAll("''", "'")); 1293 1344 } 1294 1345 return res; … … 1323 1374 String d = cc + getName(o) + " - " + getUrl(o); 1324 1375 if (optionShorten) { 1325 final int MAXLEN = 140;1326 1376 if (d.length() > MAXLEN) d = d.substring(0, MAXLEN-1) + "..."; 1327 1377 } -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r15015 r15034 595 595 } 596 596 597 private static String l c(String s) {597 private static String lower(String s) { 598 598 return s.toLowerCase(Locale.ENGLISH); 599 599 } 600 600 601 601 static String validateUploadTag(String uploadValue, String preferencePrefix, List<String> defMandatory, List<String> defForbidden) { 602 String uploadValueLc = l c(uploadValue);602 String uploadValueLc = lower(uploadValue); 603 603 // Check mandatory terms 604 604 List<String> missingTerms = Config.getPref().getList(preferencePrefix+".mandatory-terms", defMandatory) 605 .stream().map(UploadAction::l c).filter(x -> !uploadValueLc.contains(x)).collect(Collectors.toList());605 .stream().map(UploadAction::lower).filter(x -> !uploadValueLc.contains(x)).collect(Collectors.toList()); 606 606 if (!missingTerms.isEmpty()) { 607 607 return tr("The following required terms are missing: {0}", missingTerms); … … 609 609 // Check forbidden terms 610 610 List<String> forbiddenTerms = Config.getPref().getList(preferencePrefix+".forbidden-terms", defForbidden) 611 .stream().map(UploadAction::l c).filter(uploadValueLc::contains).collect(Collectors.toList());611 .stream().map(UploadAction::lower).filter(uploadValueLc::contains).collect(Collectors.toList()); 612 612 if (!forbiddenTerms.isEmpty()) { 613 613 return tr("The following forbidden terms have been found: {0}", forbiddenTerms); -
trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java
r14120 r15034 10 10 import java.awt.image.BufferedImage; 11 11 import java.io.File; 12 import java.io.FileInputStream;13 import java.io.FileNotFoundException;14 12 import java.io.IOException; 13 import java.nio.file.Files; 14 import java.nio.file.Paths; 15 15 import java.text.MessageFormat; 16 16 import java.util.ArrayList; … … 345 345 } 346 346 347 public DataSet getOsmDataSet() throws FileNotFoundException, IllegalDataException {347 public DataSet getOsmDataSet() throws IllegalDataException, IOException { 348 348 if (ds == null) { 349 ds = OsmReader.parseDataSet( new FileInputStream(getTestDirectory()+ "/data.osm"), null);349 ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(getTestDirectory(), "data.osm")), null); 350 350 } 351 351 return ds; 352 352 } 353 353 354 public Bounds getTestArea() throws FileNotFoundException, IllegalDataException {354 public Bounds getTestArea() throws IllegalDataException, IOException { 355 355 if (testArea == null) { 356 356 testArea = getOsmDataSet().getDataSourceBounds().get(0); -
trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRendererPerformanceTestParent.java
r14582 r15034 7 7 import java.awt.image.BufferedImage; 8 8 import java.io.File; 9 import java.io.FileInputStream;10 9 import java.io.IOException; 11 10 import java.io.InputStream; 11 import java.nio.file.Files; 12 import java.nio.file.Paths; 12 13 13 14 import javax.imageio.ImageIO; … … 80 81 StyledMapRenderer.PREFERENCE_TEXT_ANTIALIASING.put("gasp"); 81 82 82 try (InputStream fisR = new FileInputStream("data_nodist/restriction.osm");83 new FileInputStream("data_nodist/multipolygon.osm");84 85 83 try (InputStream fisR = Files.newInputStream(Paths.get("data_nodist/restriction.osm")); 84 InputStream fisM = Files.newInputStream(Paths.get("data_nodist/multipolygon.osm")); 85 InputStream fisC = Compression.getUncompressedFileInputStream(new File("data_nodist/neubrandenburg.osm.bz2")); 86 InputStream fisO = Compression.getUncompressedFileInputStream(new File("data_nodist/overpass-download.osm.bz2"));) { 86 87 dsRestriction = OsmReader.parseDataSet(fisR, NullProgressMonitor.INSTANCE); 87 88 dsMultipolygon = OsmReader.parseDataSet(fisM, NullProgressMonitor.INSTANCE); -
trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java
r12740 r15034 4 4 import static org.junit.Assert.assertEquals; 5 5 6 import java.io.FileInputStream; 6 import java.nio.file.Files; 7 import java.nio.file.Paths; 7 8 import java.util.Collection; 8 9 import java.util.Map; … … 74 75 @Test 75 76 public void testCreate1() throws Exception { 76 DataSet ds = OsmReader.parseDataSet( new FileInputStream(TestUtils.getTestDataRoot()+"create_multipolygon.osm"), null);77 DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null); 77 78 Pair<SequenceCommand, Relation> mp = CreateMultipolygonAction.createMultipolygonCommand(ds.getWays(), null); 78 79 assertEquals("Sequence: Create multipolygon", mp.a.getDescriptionText()); … … 82 83 @Test 83 84 public void testCreate2() throws Exception { 84 DataSet ds = OsmReader.parseDataSet( new FileInputStream(TestUtils.getTestDataRoot()+"create_multipolygon.osm"), null);85 DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null); 85 86 Relation mp = createMultipolygon(ds.getWays(), "ref=1 OR ref:1.1.", null, true); 86 87 assertEquals("{1=outer, 1.1.1=inner, 1.1.2=inner}", getRefToRoleMap(mp).toString()); … … 89 90 @Test 90 91 public void testUpdate1() throws Exception { 91 DataSet ds = OsmReader.parseDataSet( new FileInputStream(TestUtils.getTestDataRoot()+"create_multipolygon.osm"), null);92 DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null); 92 93 Relation mp = createMultipolygon(ds.getWays(), "ref=\".*1$\"", null, true); 93 94 assertEquals(3, mp.getMembersCount()); … … 100 101 @Test 101 102 public void testUpdate2() throws Exception { 102 DataSet ds = OsmReader.parseDataSet( new FileInputStream(TestUtils.getTestDataRoot()+"create_multipolygon.osm"), null);103 DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null); 103 104 Relation mp = createMultipolygon(ds.getWays(), "ref=1 OR ref:1.1.1", null, true); 104 105 assertEquals("{1=outer, 1.1.1=inner}", getRefToRoleMap(mp).toString()); -
trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java
r14138 r15034 5 5 import static org.junit.Assert.assertTrue; 6 6 7 import java.io.FileInputStream;8 7 import java.io.IOException; 9 8 import java.io.InputStream; 9 import java.nio.file.Files; 10 import java.nio.file.Paths; 10 11 import java.util.Arrays; 11 12 import java.util.Collection; … … 106 107 public void testExamples() throws Exception { 107 108 DataSet dsToJoin, dsExpected; 108 try (InputStream is = new FileInputStream("data_nodist/Join_Areas_Tests.osm")) {109 try (InputStream is = Files.newInputStream(Paths.get("data_nodist/Join_Areas_Tests.osm"))) { 109 110 dsToJoin = OsmReader.parseDataSet(is, NullProgressMonitor.INSTANCE); 110 111 } 111 try (InputStream is = new FileInputStream("data_nodist/Join_Areas_Tests_joined.osm")) {112 try (InputStream is = Files.newInputStream(Paths.get("data_nodist/Join_Areas_Tests_joined.osm"))) { 112 113 dsExpected = OsmReader.parseDataSet(is, NullProgressMonitor.INSTANCE); 113 114 } -
trunk/test/unit/org/openstreetmap/josm/actions/OrthogonalizeActionTest.java
r12656 r15034 4 4 import static org.junit.Assert.assertEquals; 5 5 6 import java.io.FileInputStream; 6 import java.io.InputStream; 7 import java.nio.file.Files; 8 import java.nio.file.Paths; 7 9 import java.util.ArrayList; 8 10 import java.util.List; … … 97 99 98 100 DataSet performTest(String... search) throws Exception { 99 try ( FileInputStream in =new FileInputStream(TestUtils.getTestDataRoot()+"orthogonalize.osm")) {101 try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "orthogonalize.osm"))) { 100 102 final DataSet ds = OsmReader.parseDataSet(in, null); 101 103 // TODO: Executing commands depends on active edit layer -
trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java
r13079 r15034 6 6 import static org.junit.Assert.assertTrue; 7 7 8 import java.io.FileInputStream;9 8 import java.io.InputStream; 9 import java.nio.file.Files; 10 import java.nio.file.Paths; 10 11 import java.util.Arrays; 11 12 import java.util.Collection; … … 73 74 for (int i : new int[] {1, 2, 3, 11, 12, 13, 14, 15}) { 74 75 DataSet ds; 75 try (InputStream is = new FileInputStream("data_nodist/filterTests.osm")) {76 try (InputStream is = Files.newInputStream(Paths.get("data_nodist/filterTests.osm"))) { 76 77 ds = OsmReader.parseDataSet(is, NullProgressMonitor.INSTANCE); 77 78 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java
r14120 r15034 4 4 import static org.openstreetmap.josm.TestUtils.getPrivateField; 5 5 6 import java.io.FileInputStream;7 6 import java.io.InputStream; 7 import java.nio.file.Files; 8 import java.nio.file.Paths; 8 9 import java.security.SecureRandom; 9 10 import java.util.ArrayList; … … 84 85 public void testRemove() throws Exception { 85 86 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 86 try (InputStream fis = new FileInputStream("data_nodist/restriction.osm")) {87 try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/restriction.osm"))) { 87 88 DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 88 89 removeAllTest(ds); … … 97 98 public void testMove() throws Exception { 98 99 ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 99 try (InputStream fis = new FileInputStream("data_nodist/restriction.osm")) {100 try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/restriction.osm"))) { 100 101 DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 101 102 -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java
r14273 r15034 5 5 import java.io.BufferedWriter; 6 6 import java.io.File; 7 import java.io.FileInputStream;8 import java.io.FileOutputStream;9 7 import java.io.IOException; 10 8 import java.io.InputStream; … … 15 13 import java.lang.reflect.Method; 16 14 import java.nio.charset.StandardCharsets; 15 import java.nio.file.Files; 16 import java.nio.file.Paths; 17 17 import java.security.SecureRandom; 18 18 import java.util.ArrayList; … … 121 121 } 122 122 try (BufferedReader in = new BufferedReader(new InputStreamReader( 123 new FileInputStream(REFERENCE_DATA_FILE), StandardCharsets.UTF_8))) {123 Files.newInputStream(Paths.get(REFERENCE_DATA_FILE)), StandardCharsets.UTF_8))) { 124 124 String line; 125 125 Pattern projPattern = Pattern.compile("<(.+?)>(.*)<>"); … … 357 357 } 358 358 try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter( 359 new FileOutputStream(REFERENCE_DATA_FILE), StandardCharsets.UTF_8))) {359 Files.newOutputStream(Paths.get(REFERENCE_DATA_FILE)), StandardCharsets.UTF_8))) { 360 360 for (Map.Entry<String, RefEntry> e : refsMap.entrySet()) { 361 361 RefEntry ref = e.getValue(); -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
r13702 r15034 5 5 import java.io.BufferedWriter; 6 6 import java.io.File; 7 import java.io.FileInputStream;8 7 import java.io.FileNotFoundException; 9 import java.io.FileOutputStream;10 8 import java.io.IOException; 11 9 import java.io.InputStreamReader; 12 10 import java.io.OutputStreamWriter; 13 11 import java.nio.charset.StandardCharsets; 12 import java.nio.file.Files; 13 import java.nio.file.Paths; 14 14 import java.security.SecureRandom; 15 15 import java.util.ArrayList; … … 89 89 Random rand = new SecureRandom(); 90 90 try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter( 91 new FileOutputStream(PROJECTION_DATA_FILE), StandardCharsets.UTF_8))) {91 Files.newOutputStream(Paths.get(PROJECTION_DATA_FILE)), StandardCharsets.UTF_8))) { 92 92 out.write("# Data for test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java\n"); 93 93 out.write("# Format: 1. Projection code; 2. lat/lon; 3. lat/lon projected -> east/north; 4. east/north (3.) inverse projected\n"); … … 114 114 115 115 private static List<TestData> readData() throws IOException, FileNotFoundException { 116 try (BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream(PROJECTION_DATA_FILE),116 try (BufferedReader in = new BufferedReader(new InputStreamReader(Files.newInputStream(Paths.get(PROJECTION_DATA_FILE)), 117 117 StandardCharsets.UTF_8))) { 118 118 List<TestData> result = new ArrayList<>(); -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/UnconnectedWaysTest.java
r8926 r15034 5 5 import static org.junit.Assert.assertThat; 6 6 7 import java.io.FileInputStream;8 7 import java.io.FileNotFoundException; 9 8 import java.io.IOException; 10 9 import java.io.InputStream; 10 import java.nio.file.Files; 11 import java.nio.file.Paths; 11 12 12 13 import org.junit.Before; … … 45 46 @Test 46 47 public void testTicket6313() throws IOException, IllegalDataException, FileNotFoundException { 47 try (InputStream fis = new FileInputStream("data_nodist/UnconnectedWaysTest.osm")) {48 try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/UnconnectedWaysTest.osm"))) { 48 49 final DataSet ds = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 49 50 bib.visit(ds.allPrimitives()); -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/ValidatorTestUtils.java
r14966 r15034 6 6 import static org.junit.Assert.fail; 7 7 8 import java.io.FileInputStream;9 8 import java.io.InputStream; 9 import java.nio.file.Files; 10 import java.nio.file.Paths; 10 11 import java.util.ArrayList; 11 12 import java.util.Collections; … … 35 36 Function<DataSet, Iterable<T>> provider, Predicate<String> namePredicate, 36 37 Test... tests) throws Exception { 37 try (InputStream is = new FileInputStream(sampleFile)) {38 try (InputStream is = Files.newInputStream(Paths.get(sampleFile))) { 38 39 for (T t: provider.apply(OsmReader.parseDataSet(is, null))) { 39 40 String name = DefaultNameFormatter.getInstance().format(t); -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java
r10876 r15034 2 2 package org.openstreetmap.josm.gui.dialogs.relation.sort; 3 3 4 import java.io.FileInputStream;5 4 import java.io.IOException; 6 5 import java.io.InputStream; 6 import java.nio.file.Files; 7 import java.nio.file.Paths; 7 8 import java.util.List; 8 9 … … 44 45 public void loadData() throws IllegalDataException, IOException { 45 46 if (testDataset == null) { 46 try (InputStream fis = new FileInputStream("data_nodist/relation_sort.osm")) {47 try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/relation_sort.osm"))) { 47 48 testDataset = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 48 49 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java
r11886 r15034 2 2 package org.openstreetmap.josm.gui.dialogs.relation.sort; 3 3 4 import java.io.FileInputStream;5 4 import java.io.IOException; 6 5 import java.io.InputStream; 6 import java.nio.file.Files; 7 import java.nio.file.Paths; 7 8 import java.util.ArrayList; 8 9 import java.util.Arrays; … … 46 47 public void loadData() throws IllegalDataException, IOException { 47 48 if (testDataset == null) { 48 try (InputStream fis = new FileInputStream("data_nodist/relation_sort.osm")) {49 try (InputStream fis = Files.newInputStream(Paths.get("data_nodist/relation_sort.osm"))) { 49 50 testDataset = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 50 51 } -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ChildOrParentSelectorTest.java
r14064 r15034 6 6 import static org.junit.Assert.assertTrue; 7 7 8 import java.io.FileInputStream; 8 import java.nio.file.Files; 9 import java.nio.file.Paths; 9 10 import java.util.Arrays; 10 11 … … 188 189 @Test 189 190 public void testContains() throws Exception { 190 ds = OsmReader.parseDataSet( new FileInputStream("data_nodist/amenity-in-amenity.osm"), null);191 ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get("data_nodist/amenity-in-amenity.osm")), null); 191 192 ChildOrParentSelector css = parse("node[tag(\"amenity\") = parent_tag(\"amenity\")] ∈ *[amenity] {}"); 192 193 assertTrue(css.matches(new Environment(ds.getPrimitiveById(123, OsmPrimitiveType.WAY)))); -
trunk/test/unit/org/openstreetmap/josm/io/GeoJSONWriterTest.java
r13232 r15034 5 5 import static org.junit.Assert.assertTrue; 6 6 7 import java.io.FileInputStream; 7 import java.io.InputStream; 8 import java.nio.file.Files; 9 import java.nio.file.Paths; 8 10 import java.util.Arrays; 9 11 … … 113 115 @Test 114 116 public void testMultipolygon() throws Exception { 115 try ( FileInputStream in =new FileInputStream(TestUtils.getTestDataRoot()+"multipolygon.osm")) {117 try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "multipolygon.osm"))) { 116 118 DataSet ds = OsmReader.parseDataSet(in, null); 117 119 final GeoJSONWriter writer = new GeoJSONWriter(ds); … … 126 128 @Test 127 129 public void testMultipolygonRobustness() throws Exception { 128 try ( FileInputStream in =new FileInputStream("data_nodist/multipolygon.osm")) {130 try (InputStream in = Files.newInputStream(Paths.get("data_nodist/multipolygon.osm"))) { 129 131 DataSet ds = OsmReader.parseDataSet(in, null); 130 132 final GeoJSONWriter writer = new GeoJSONWriter(ds); -
trunk/test/unit/org/openstreetmap/josm/io/OsmReaderTest.java
r14219 r15034 9 9 10 10 import java.io.ByteArrayInputStream; 11 import java.io.FileInputStream;12 11 import java.io.InputStream; 13 12 import java.nio.charset.StandardCharsets; 13 import java.nio.file.Files; 14 import java.nio.file.Paths; 14 15 15 16 import org.junit.Rule; … … 59 60 OsmReader.deregisterPostprocessor(unregistered); 60 61 61 try (InputStream in = new FileInputStream(TestUtils.getTestDataRoot()+"empty.osm")) {62 try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "empty.osm"))) { 62 63 OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE); 63 64 assertTrue(registered.called); -
trunk/test/unit/org/openstreetmap/josm/io/nmea/NmeaReaderTest.java
r14456 r15034 7 7 8 8 import java.io.ByteArrayInputStream; 9 import java.io.FileInputStream;10 9 import java.io.IOException; 11 10 import java.nio.charset.StandardCharsets; 11 import java.nio.file.Files; 12 import java.nio.file.Paths; 12 13 import java.text.SimpleDateFormat; 13 14 import java.util.ArrayList; … … 61 62 public void testReader() throws Exception { 62 63 TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin")); 63 final NmeaReader in = new NmeaReader( new FileInputStream("data_nodist/btnmeatrack_2016-01-25.nmea"));64 final NmeaReader in = new NmeaReader(Files.newInputStream(Paths.get("data_nodist/btnmeatrack_2016-01-25.nmea"))); 64 65 in.parse(true); 65 66 assertEquals(30, in.getNumberOfCoordinates()); … … 87 88 private static void compareWithReference(int ticket, String filename, int numCoor) throws IOException, SAXException { 88 89 GpxData gpx = GpxReaderTest.parseGpxData(TestUtils.getRegressionDataFile(ticket, filename+".gpx")); 89 NmeaReader in = new NmeaReader( new FileInputStream(TestUtils.getRegressionDataFile(ticket, filename+".nmea")));90 NmeaReader in = new NmeaReader(Files.newInputStream(Paths.get(TestUtils.getRegressionDataFile(ticket, filename+".nmea")))); 90 91 in.parse(true); 91 92 assertEquals(numCoor, in.getNumberOfCoordinates()); -
trunk/test/unit/org/openstreetmap/josm/tools/GeometryTest.java
r15022 r15034 7 7 import static org.junit.Assert.assertTrue; 8 8 9 import java.io.FileInputStream; 9 import java.io.InputStream; 10 import java.nio.file.Files; 11 import java.nio.file.Paths; 10 12 import java.util.Arrays; 11 13 import java.util.List; … … 78 80 @Test 79 81 public void testClosedWayArea() throws Exception { 80 try ( FileInputStream in =new FileInputStream(TestUtils.getTestDataRoot()+"create_multipolygon.osm")) {82 try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm"))) { 81 83 DataSet ds = OsmReader.parseDataSet(in, null); 82 84 Way closedWay = (Way) SubclassFilteredCollection.filter(ds.allPrimitives(), … … 94 96 @Test 95 97 public void testMultipolygonArea() throws Exception { 96 try ( FileInputStream in =new FileInputStream(TestUtils.getTestDataRoot()+"multipolygon.osm")) {98 try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "multipolygon.osm"))) { 97 99 DataSet ds = OsmReader.parseDataSet(in, null); 98 100 final Relation r = ds.getRelations().iterator().next(); … … 109 111 @Test 110 112 public void testAreaAndPerimeter() throws Exception { 111 try ( FileInputStream in =new FileInputStream(TestUtils.getTestDataRoot()+"create_multipolygon.osm")) {113 try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm"))) { 112 114 DataSet ds = OsmReader.parseDataSet(in, null); 113 115 Way closedWay = (Way) SubclassFilteredCollection.filter(ds.allPrimitives(),
Note:
See TracChangeset
for help on using the changeset viewer.