Changeset 35421 in osm for applications


Ignore:
Timestamp:
2020-04-11T08:43:09+02:00 (5 years ago)
Author:
simon04
Message:

TemplatedTMSTileSource: extract getRandomPart

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSource.java

    r35420 r35421  
    157157                break;
    158158            case "switch:":
    159                 replacement = randomParts[rand.nextInt(randomParts.length)];
     159                replacement = getRandomPart(randomParts);
    160160                break;
    161161            default:
     
    164164                    replacement = Integer.toString((inverse_zoom ? -1 * zoom : zoom) + zoom_offset);
    165165                } else if (PATTERN_SWITCH.matcher("{" + matcher.group(1) + "}").matches()) {
    166                     replacement = randomParts[rand.nextInt(randomParts.length)];
     166                    replacement = getRandomPart(randomParts);
    167167                } else {
    168168                    replacement = '{' + matcher.group(1) + '}';
     
    173173        matcher.appendTail(url);
    174174        return url.toString().replace(" ", "%20");
     175    }
     176
     177    protected String getRandomPart(final String[] parts) {
     178        return parts[rand.nextInt(parts.length)];
    175179    }
    176180
Note: See TracChangeset for help on using the changeset viewer.