Package org.openstreetmap.josm.tools
Class OsmUrlToBounds
java.lang.Object
org.openstreetmap.josm.tools.OsmUrlToBounds
Parses various URL used in OpenStreetMap projects into
Bounds.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final char[]private static final Stringprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetURL(double dlat, double dlon, int zoom) Return OSM URL for given lat/lon and zoom.static StringReturn OSM URL for given area.static StringReturn OSM URL for given position and zoom.static intReturn OSM Zoom level for a given areastatic BoundsParses an URL intoBoundsprivate static doubleparseDouble(Map<String, String> map, String key) private static BoundsparseHashURLs(String url) Openstreetmap.org changed it's URL scheme in August 2013, which breaks the URL parsing.private static BoundsparseShortLink(String url) Parse OSM short linkstatic BoundspositionToBounds(double lat, double lon, int zoom) Compute the bounds for a given lat/lon position and the zoom levelstatic voidsetMapSizeSupplier(Supplier<Dimension> mapSizeSupplier) Sets the map size supplier.
-
Field Details
-
SHORTLINK_PREFIX
- See Also:
-
mapSize
-
SHORTLINK_CHARS
-
TILE_SIZE_IN_PIXELS
- See Also:
-
-
Constructor Details
-
OsmUrlToBounds
private OsmUrlToBounds()
-
-
Method Details
-
parse
Parses an URL intoBounds- Parameters:
url- the URL to be parsed- Returns:
- the parsed
Bounds, ornull
-
parseHashURLs
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,
nullotherwise
-
parseDouble
-
parseShortLink
Parse OSM short link- Parameters:
url- string for parsing- Returns:
- Bounds if shortlink, null otherwise
- See Also:
-
setMapSizeSupplier
Sets the map size supplier.- Parameters:
mapSizeSupplier- returns the map size in pixels- Since:
- 12796
-
positionToBounds
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
Return OSM Zoom level for a given area- Parameters:
b- bounds of the area- Returns:
- matching zoom level for area
-
getURL
Return OSM URL for given area.- Parameters:
b- bounds of the area- Returns:
- link to display that area in OSM map
-
getURL
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
-
getURL
Return OSM URL for given lat/lon and zoom.- Parameters:
dlat- center latitude of areadlon- center longitude of areazoom- zoom depth of display- Returns:
- link to display that area in OSM map
- Since:
- 6453
-