Changeset 14399 in josm for trunk/src


Ignore:
Timestamp:
2018-11-02T00:07:28+01:00 (13 months ago)
Author:
wiktorn
Message:

GetTileUrl performance improvements for WMS

See: #16769

Location:
trunk/src/org/openstreetmap/josm/data/imagery
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/AbstractWMSTileSource.java

    r13733 r14399  
    226226        double e = se.getX();
    227227
    228         return (
    229                 switchLatLon ?
    230                         String.format("%s,%s,%s,%s",
    231                                 LATLON_FORMAT.format(s), LATLON_FORMAT.format(w), LATLON_FORMAT.format(n), LATLON_FORMAT.format(e))
    232                         :
    233                         String.format("%s,%s,%s,%s",
    234                                 LATLON_FORMAT.format(w), LATLON_FORMAT.format(s), LATLON_FORMAT.format(e), LATLON_FORMAT.format(n))
    235 
    236                 );
     228        return switchLatLon ?
     229                getBboxstr(s, w, n, e)
     230                : getBboxstr(w, s, e, n);
     231    }
     232
     233    private final String getBboxstr(double x1, double x2, double x3, double x4) {
     234        return new StringBuilder(64)
     235                .append(LATLON_FORMAT.format(x1))
     236                .append(',')
     237                .append(LATLON_FORMAT.format(x2))
     238                .append(',')
     239                .append(LATLON_FORMAT.format(x3))
     240                .append(',')
     241                .append(LATLON_FORMAT.format(x4))
     242                .toString();
    237243    }
    238244}
  • trunk/src/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSource.java

    r14120 r14399  
    5151    };
    5252
     53    private final boolean switchLatLon;
    5354    /**
    5455     * Creates a tile source based on imagery info
     
    6263        handleTemplate();
    6364        initProjection();
     65        // Bounding box coordinates have to be switched for WMS 1.3.0 EPSG:4326.
     66        //
     67        // Background:
     68        //
     69        // bbox=x_min,y_min,x_max,y_max
     70        //
     71        //      SRS=... is WMS 1.1.1
     72        //      CRS=... is WMS 1.3.0
     73        //
     74        // The difference:
     75        //      For SRS x is east-west and y is north-south
     76        //      For CRS x and y are as specified by the EPSG
     77        //          E.g. [1] lists lat as first coordinate axis and lot as second, so it is switched for EPSG:4326.
     78        //          For most other EPSG code there seems to be no difference.
     79        // CHECKSTYLE.OFF: LineLength
     80        // [1] https://www.epsg-registry.org/report.htm?type=selection&entity=urn:ogc:def:crs:EPSG::4326&reportDetail=short&style=urn:uuid:report-style:default-with-code&style_name=OGP%20Default%20With%20Code&title=EPSG:4326
     81        // CHECKSTYLE.ON: LineLength
     82        if (baseUrl.toLowerCase(Locale.US).contains("crs=epsg:4326")) {
     83            switchLatLon = true;
     84        } else if (baseUrl.toLowerCase(Locale.US).contains("crs=")) {
     85            // assume WMS 1.3.0
     86            switchLatLon = ProjectionRegistry.getProjection().switchXY();
     87        } else {
     88            switchLatLon = false;
     89        }
    6490    }
    6591
     
    86112        }
    87113
    88         // Bounding box coordinates have to be switched for WMS 1.3.0 EPSG:4326.
    89         //
    90         // Background:
    91         //
    92         // bbox=x_min,y_min,x_max,y_max
    93         //
    94         //      SRS=... is WMS 1.1.1
    95         //      CRS=... is WMS 1.3.0
    96         //
    97         // The difference:
    98         //      For SRS x is east-west and y is north-south
    99         //      For CRS x and y are as specified by the EPSG
    100         //          E.g. [1] lists lat as first coordinate axis and lot as second, so it is switched for EPSG:4326.
    101         //          For most other EPSG code there seems to be no difference.
    102         // CHECKSTYLE.OFF: LineLength
    103         // [1] https://www.epsg-registry.org/report.htm?type=selection&entity=urn:ogc:def:crs:EPSG::4326&reportDetail=short&style=urn:uuid:report-style:default-with-code&style_name=OGP%20Default%20With%20Code&title=EPSG:4326
    104         // CHECKSTYLE.ON: LineLength
    105         boolean switchLatLon = false;
    106         if (baseUrl.toLowerCase(Locale.US).contains("crs=epsg:4326")) {
    107             switchLatLon = true;
    108         } else if (baseUrl.toLowerCase(Locale.US).contains("crs=")) {
    109             // assume WMS 1.3.0
    110             switchLatLon = ProjectionRegistry.getProjection().switchXY();
    111         }
    112         String bbox = getBbox(zoom, tilex, tiley, switchLatLon);
    113 
    114114        // Using StringBuffer and generic PATTERN_PARAM matcher gives 2x performance improvement over replaceAll
    115115        StringBuffer url = new StringBuffer(baseUrl.length());
     
    125125                break;
    126126            case "bbox":
    127                 replacement = bbox;
     127                replacement = getBbox(zoom, tilex, tiley, switchLatLon);
    128128                break;
    129129            case "w":
  • trunk/src/org/openstreetmap/josm/data/imagery/WMSEndpointTileSource.java

    r14214 r14399  
    6060    @Override
    6161    public String getTileUrl(int zoom, int tilex, int tiley) {
    62         String bbox = getBbox(zoom, tilex, tiley, !wmsi.belowWMS130() && getTileProjection().switchXY());
    63 
    6462        // Using StringBuffer and generic PATTERN_PARAM matcher gives 2x performance improvement over replaceAll
    6563        StringBuffer url = new StringBuffer(urlPattern.length());
     
    7270                break;
    7371            case "bbox":
    74                 replacement = bbox;
     72                replacement = getBbox(zoom, tilex, tiley, !wmsi.belowWMS130() && getTileProjection().switchXY());
    7573                break;
    7674            case "width":
Note: See TracChangeset for help on using the changeset viewer.