url = URLDecoder.decode(url, "UTF-8");
}
} catch (UnsupportedEncodingException | IllegalArgumentException x) {
Main.error(x);
}
Bounds b = parseShortLink(url);
if (b != null)
return b;
int i = url.indexOf("#map");
if (i >= 0) {
// probably it's a URL following the new scheme?
return parseHashURLs(url);
}
i = url.indexOf('?');
if (i == -1) {
return null;
}
String[] args = url.substring(i+1).split("&");
HashMap<String, String> map = new HashMap<>();
for (String arg : args) {
int eq = arg.indexOf('=');
if (eq != -1) {
map.put(arg.substring(0, eq), arg.substring(eq + 1));
}
}
try {
if (map.containsKey("bbox")) {
String[] bbox = map.get("bbox").split(",");
b = new Bounds(
Double.parseDouble(bbox[1]), Double.parseDouble(bbox[0]),
Double.parseDouble(bbox[3]), Double.parseDouble(bbox[2]));
} else if (map.containsKey("minlat")) {
double minlat = Double.parseDouble(map.get("minlat"));
double minlon = Double.parseDouble(map.get("minlon"));
double maxlat = Double.parseDouble(map.get("maxlat"));
double maxlon = Double.parseDouble(map.get("maxlon"));
b = new Bounds(minlat, minlon, maxlat, maxlon);
} else {
String z = map.get("zoom");
b = positionToBounds(parseDouble(map, "lat"),
parseDouble(map, "lon"),
z == null ? 18 : Integer.parseInt(z));