Changeset 6119 in josm for trunk/src/org


Ignore:
Timestamp:
2013-08-08T19:49:02+02:00 (11 years ago)
Author:
framm
Message:

fix hash url parsing, npe introduced in r6118

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java

    r6118 r6119  
    8585    private static Bounds parseHashURLs(String url) {
    8686        int startIndex = url.indexOf("=");
     87        if (startIndex == -1) return null;
    8788        int endIndex = url.indexOf("&");
    88         String coordPart = url.substring(startIndex+1, endIndex);
    89         System.out.println(coordPart);
    90 
    91         String[] parts = coordPart.split("/");
    92         Bounds b = positionToBounds(Double.parseDouble(parts[1]),
    93                 Double.parseDouble(parts[2]),
    94                 Integer.parseInt(parts[0]));
    95         return b;
     89        if (endIndex == -1) endIndex = url.length();
     90        try
     91        {
     92            String coordPart = url.substring(startIndex+1, endIndex);
     93            String[] parts = coordPart.split("/");
     94            Bounds b = positionToBounds(Double.parseDouble(parts[1]),
     95                    Double.parseDouble(parts[2]),
     96                    Integer.parseInt(parts[0]));
     97            return b;
     98        }
     99        catch(Exception ex)
     100        {
     101            return null;
     102        }
    96103    }
    97104
Note: See TracChangeset for help on using the changeset viewer.