Class OsmUrlToBounds

java.lang.Object
org.openstreetmap.josm.tools.OsmUrlToBounds

public final class OsmUrlToBounds extends Object
Parses various URL used in OpenStreetMap projects into Bounds.
  • Field Details

  • Constructor Details

  • Method Details

    • parse

      public static Bounds parse(String url)
      Parses an URL into Bounds
      Parameters:
      url - the URL to be parsed
      Returns:
      the parsed Bounds, or null
    • parseHashURLs

      private static Bounds parseHashURLs(String url)
      Openstreetmap.org changed it's URL scheme in August 2013, which breaks the URL parsing. The following function, called by the old parse function if necessary, provides parsing new URLs the new URLs follow the scheme https://www.openstreetmap.org/#map=18/51.71873/8.76164&layers=CN
      Parameters:
      url - string for parsing
      Returns:
      Bounds if hashurl, null otherwise
    • parseDouble

      private static double parseDouble(Map<String,String> map, String key)
    • parseShortLink

      private static Bounds parseShortLink(String url)
      Parse OSM short link
      Parameters:
      url - string for parsing
      Returns:
      Bounds if shortlink, null otherwise
      See Also:
    • setMapSizeSupplier

      public static void setMapSizeSupplier(Supplier<Dimension> mapSizeSupplier)
      Sets the map size supplier.
      Parameters:
      mapSizeSupplier - returns the map size in pixels
      Since:
      12796
    • positionToBounds

      public static Bounds positionToBounds(double lat, double lon, int zoom)
      Compute the bounds for a given lat/lon position and the zoom level
      Parameters:
      lat - The latitude
      lon - The longitude
      zoom - The current zoom level
      Returns:
      The bounds the OSM server would display
    • getZoom

      public static int getZoom(Bounds b)
      Return OSM Zoom level for a given area
      Parameters:
      b - bounds of the area
      Returns:
      matching zoom level for area
    • getURL

      public static String getURL(Bounds b)
      Return OSM URL for given area.
      Parameters:
      b - bounds of the area
      Returns:
      link to display that area in OSM map
    • getURL

      public static String getURL(LatLon pos, int zoom)
      Return OSM URL for given position and zoom.
      Parameters:
      pos - center position of area
      zoom - zoom depth of display
      Returns:
      link to display that area in OSM map
    • getURL

      public static String getURL(double dlat, double dlon, int zoom)
      Return OSM URL for given lat/lon and zoom.
      Parameters:
      dlat - center latitude of area
      dlon - center longitude of area
      zoom - zoom depth of display
      Returns:
      link to display that area in OSM map
      Since:
      6453