Package org.openstreetmap.josm.tools
Class OsmUrlToBounds
- java.lang.Object
-
- org.openstreetmap.josm.tools.OsmUrlToBounds
-
public final class OsmUrlToBounds extends Object
Parses various URL used in OpenStreetMap projects intoBounds
.
-
-
Field Summary
Fields Modifier and Type Field Description private static Supplier<Dimension>
mapSize
private static char[]
SHORTLINK_CHARS
private static String
SHORTLINK_PREFIX
private static int
TILE_SIZE_IN_PIXELS
-
Constructor Summary
Constructors Modifier Constructor Description private
OsmUrlToBounds()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getURL(double dlat, double dlon, int zoom)
Return OSM URL for given lat/lon and zoom.static String
getURL(Bounds b)
Return OSM URL for given area.static String
getURL(LatLon pos, int zoom)
Return OSM URL for given position and zoom.static int
getZoom(Bounds b)
Return OSM Zoom level for a given areastatic Bounds
parse(String url)
Parses an URL intoBounds
private static double
parseDouble(Map<String,String> map, String key)
private static Bounds
parseHashURLs(String url)
Openstreetmap.org changed it's URL scheme in August 2013, which breaks the URL parsing.private static Bounds
parseShortLink(String url)
Parse OSM short linkstatic Bounds
positionToBounds(double lat, double lon, int zoom)
Compute the bounds for a given lat/lon position and the zoom levelstatic void
setMapSizeSupplier(Supplier<Dimension> mapSizeSupplier)
Sets the map size supplier.
-
-
-
Field Detail
-
SHORTLINK_PREFIX
private static final String SHORTLINK_PREFIX
- See Also:
- Constant Field Values
-
SHORTLINK_CHARS
private static final char[] SHORTLINK_CHARS
-
TILE_SIZE_IN_PIXELS
private static final int TILE_SIZE_IN_PIXELS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OsmUrlToBounds
private OsmUrlToBounds()
-
-
Method Detail
-
parse
public static Bounds parse(String url)
Parses an URL intoBounds
- Parameters:
url
- the URL to be parsed- Returns:
- the parsed
Bounds
, ornull
-
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:
- short_link.rb
-
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 latitudelon
- The longitudezoom
- 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 areazoom
- zoom depth of display- Returns:
- link to display that area in OSM map
-
-