Changeset 18801 in josm for trunk/scripts


Ignore:
Timestamp:
2023-08-09T15:30:01+02:00 (18 months ago)
Author:
taylor.smock
Message:

Fix #22832: Code cleanup and some simplification, documentation fixes (patch by gaben)

There should not be any functional changes in this patch; it is intended to do
the following:

  • Simplify and cleanup code (example: Arrays.asList(item) -> Collections.singletonList(item))
  • Fix typos in documentation (which also corrects the documentation to match what actually happens, in some cases)
Location:
trunk/scripts
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/BuildProjectionDefinitions.java

    r16344 r18801  
    9393        if (list.isEmpty())
    9494            throw new AssertionError("EPSG file seems corrupted");
    95         Pattern badDmsPattern = Pattern.compile("(\\d+(?:\\.\\d+)?d\\d+(?:\\.\\d+)?')(N|S|E|W)");
     95        Pattern badDmsPattern = Pattern.compile("(\\d+(?:\\.\\d+)?d\\d+(?:\\.\\d+)?')([NSEW])");
    9696        for (ProjectionDefinition pd : list) {
    9797            // DMS notation without second causes problems with cs2cs, add 0"
     
    145145
    146146        if (printStats) {
    147             System.out.println(String.format("loaded %d entries from %s", epsgJosm.size(), JOSM_EPSG_FILE));
    148             System.out.println(String.format("loaded %d entries from %s", epsgProj4.size(), PROJ4_EPSG_FILE));
    149             System.out.println(String.format("loaded %d entries from %s", esriProj4.size(), PROJ4_ESRI_FILE));
     147            System.out.printf("loaded %d entries from %s%n", epsgJosm.size(), JOSM_EPSG_FILE);
     148            System.out.printf("loaded %d entries from %s%n", epsgProj4.size(), PROJ4_EPSG_FILE);
     149            System.out.printf("loaded %d entries from %s%n", esriProj4.size(), PROJ4_ESRI_FILE);
    150150            System.out.println();
    151151            System.out.println("some entries from proj.4 have not been included:");
    152             System.out.println(String.format(" * already in the maintained JOSM list: %d entries", noInJosm));
     152            System.out.printf(" * already in the maintained JOSM list: %d entries%n", noInJosm);
    153153            if (noInProj4 > 0) {
    154                 System.out.println(String.format(" * ESRI already in the standard EPSG list: %d entries", noInProj4));
    155             }
    156             System.out.println(String.format(" * deprecated: %d entries", noDeprecated));
    157             System.out.println(String.format(" * using +proj=geocent, which is 3D (X,Y,Z) and not useful in JOSM: %d entries", noGeocent));
     154                System.out.printf(" * ESRI already in the standard EPSG list: %d entries%n", noInProj4);
     155            }
     156            System.out.printf(" * deprecated: %d entries%n", noDeprecated);
     157            System.out.printf(" * using +proj=geocent, which is 3D (X,Y,Z) and not useful in JOSM: %d entries%n", noGeocent);
    158158            if (noEllipsoid > 0) {
    159                 System.out.println(String.format(" * unsupported ellipsoids: %d entries", noEllipsoid));
     159                System.out.printf(" * unsupported ellipsoids: %d entries%n", noEllipsoid);
    160160                System.out.println("   in particular: " + ellipsoidMap);
    161161            }
    162162            if (noBaseProjection > 0) {
    163                 System.out.println(String.format(" * unsupported base projection: %d entries", noBaseProjection));
     163                System.out.printf(" * unsupported base projection: %d entries%n", noBaseProjection);
    164164                System.out.println("   in particular: " + baseProjectionMap);
    165165            }
    166166            if (noDatumgrid > 0) {
    167                 System.out.println(String.format(" * requires data file for vertical datum conversion: %d entries", noDatumgrid));
     167                System.out.printf(" * requires data file for vertical datum conversion: %d entries%n", noDatumgrid);
    168168                System.out.println("   in particular: " + datumgridMap);
    169169            }
    170170            if (noNadgrid > 0) {
    171                 System.out.println(String.format(" * requires data file for datum conversion: %d entries", noNadgrid));
     171                System.out.printf(" * requires data file for datum conversion: %d entries%n", noNadgrid);
    172172                System.out.println("   in particular: " + nadgridMap);
    173173            }
    174174            if (noOmercNoBounds > 0) {
    175                 System.out.println(String.format(
    176                         " * projection is Oblique Mercator (requires bounds), but no bounds specified: %d entries", noOmercNoBounds));
     175                System.out.printf(
     176                        " * projection is Oblique Mercator (requires bounds), but no bounds specified: %d entries%n", noOmercNoBounds);
    177177            }
    178178            if (noEquatorStereo > 0) {
    179                 System.out.println(String.format(" * projection is Equatorial Stereographic (see #15970): %d entries", noEquatorStereo));
     179                System.out.printf(" * projection is Equatorial Stereographic (see #15970): %d entries%n", noEquatorStereo);
    180180            }
    181181            System.out.println();
    182             System.out.println(String.format("written %d entries from %s", noJosm, JOSM_EPSG_FILE));
    183             System.out.println(String.format("written %d entries from %s", noProj4, PROJ4_EPSG_FILE));
    184             System.out.println(String.format("written %d entries from %s", noEsri, PROJ4_ESRI_FILE));
     182            System.out.printf("written %d entries from %s%n", noJosm, JOSM_EPSG_FILE);
     183            System.out.printf("written %d entries from %s%n", noProj4, PROJ4_EPSG_FILE);
     184            System.out.printf("written %d entries from %s%n", noEsri, PROJ4_ESRI_FILE);
    185185        }
    186186    }
  • trunk/scripts/SyncEditorLayerIndex.java

    r18723 r18801  
    7070 * Compare and analyse the differences of the editor layer index and the JOSM imagery list.
    7171 * The goal is to keep both lists in sync.
    72  *
    73  * The editor layer index project (https://github.com/osmlab/editor-layer-index)
    74  * provides also a version in the JOSM format, but the GEOJSON is the original source
    75  * format, so we read that.
    76  *
    77  * How to run:
    78  * -----------
    79  *
    80  * Main JOSM binary needs to be in classpath, e.g.
    81  *
    82  * $ java -cp ../dist/josm-custom.jar SyncEditorLayerIndex
    83  *
    84  * Add option "-h" to show the available command line flags.
     72 * <p>
     73 * The <a href="https://github.com/osmlab/editor-layer-index">editor layer index</a> project
     74 * provides also a version in the JOSM format, but the GEOJSON is the original source format, so we read that.
     75 * <p>
     76 * For running, the main JOSM binary needs to be in classpath, e.g.
     77 * <p>
     78 * {@code $ java -cp ../dist/josm-custom.jar SyncEditorLayerIndex}
     79 * <p>
     80 * Add option {@code -h} to show the available command line flags.
    8581 */
    8682@SuppressWarnings("unchecked")
     
    294290    void myprintln(String s) {
    295291        String color;
     292        final String escaped = s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
    296293        if ((color = isSkipString(s)) != null) {
    297294            skip.remove(s);
    298295            if (optionXhtmlBody || optionXhtml) {
    299296                s = "<pre style=\"margin:3px;color:"+color+"\">"
    300                         + s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;")+"</pre>";
     297                        + escaped +"</pre>";
    301298            }
    302299            if (!optionNoSkip) {
     
    310307                                (s.startsWith("!") ? "orange" :
    311308                                    (s.startsWith("~") ? "red" : "brown"))));
    312             s = "<pre style=\"margin:3px;color:"+color+"\">"+s.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;")+"</pre>";
     309            s = "<pre style=\"margin:3px;color:"+color+"\">"+ escaped +"</pre>";
    313310        }
    314311        if ((s.startsWith("+ ") || s.startsWith("+++ ELI") || s.startsWith("#")) && optionNoEli) {
  • trunk/scripts/TagInfoExtract.java

    r18760 r18801  
    9090 * Run from the base directory of a JOSM checkout:
    9191 * <p>
     92 * <pre>
    9293 * java -cp dist/josm-custom.jar TagInfoExtract --type mappaint
    9394 * java -cp dist/josm-custom.jar TagInfoExtract --type presets
    9495 * java -cp dist/josm-custom.jar TagInfoExtract --type external_presets
     96 * </pre>
    9597 */
    9698public class TagInfoExtract {
     
    245247                        .build());
    246248                if (options.outputFile == null) {
    247                     System.out.println(writer.toString());
     249                    System.out.println(writer);
    248250                }
    249251            }
  • trunk/scripts/TaggingPresetSchemeWikiGenerator.java

    r16644 r18801  
    2323
    2424/**
    25  * This script generates the wiki content for https://josm.openstreetmap.de/wiki/TaggingPresets#Attributes
     25 * This script generates the wiki content for <a href="https://josm.openstreetmap.de/wiki/TaggingPresets#Attributes">
     26 * TaggingPresets#Attributes</a>
    2627 */
    2728public final class TaggingPresetSchemeWikiGenerator {
Note: See TracChangeset for help on using the changeset viewer.