Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-08-21 17:33:53 +02:00
commit f1ac728c3d
10 changed files with 231 additions and 228 deletions

View file

@ -27,7 +27,7 @@ public class GeoPointParserUtil {
"http://download.osmand.net/go", "http://download.osmand.net/go",
"http://download.osmand.net/go?", "http://download.osmand.net/go?",
}; };
for (String s: noQueryParameters) { for (String s : noQueryParameters) {
URI uri = URI.create(s); URI uri = URI.create(s);
Map<String, String> map = getQueryParameters(uri); Map<String, String> map = getQueryParameters(uri);
System.out.print(s + " map: " + map.size() + "..."); System.out.print(s + " map: " + map.size() + "...");
@ -42,11 +42,12 @@ public class GeoPointParserUtil {
"geo:0,0?m", "geo:0,0?m",
"geo:0,0?m=", "geo:0,0?m=",
"geo:0,0?m=foo", "geo:0,0?m=foo",
"geo:0,0?q=%D0%9D%D0",
"http://download.osmand.net/go?lat", "http://download.osmand.net/go?lat",
"http://download.osmand.net/go?lat=", "http://download.osmand.net/go?lat=",
"http://download.osmand.net/go?lat=34.99393", "http://download.osmand.net/go?lat=34.99393",
}; };
for (String s: oneQueryParameter) { for (String s : oneQueryParameter) {
URI uri = URI.create(s); URI uri = URI.create(s);
Map<String, String> map = getQueryParameters(uri); Map<String, String> map = getQueryParameters(uri);
System.out.print(s + " map: " + map.size() + "..."); System.out.print(s + " map: " + map.size() + "...");
@ -64,7 +65,7 @@ public class GeoPointParserUtil {
"http://download.osmand.net/go?lat=34.99393&lon=-110.12345", "http://download.osmand.net/go?lat=34.99393&lon=-110.12345",
"http://download.osmand.net/go?lat=34.99393&lon=-110.12345#this+should+be+ignored", "http://download.osmand.net/go?lat=34.99393&lon=-110.12345#this+should+be+ignored",
}; };
for (String s: twoQueryParameters) { for (String s : twoQueryParameters) {
URI uri = URI.create(s); URI uri = URI.create(s);
Map<String, String> map = getQueryParameters(uri); Map<String, String> map = getQueryParameters(uri);
System.out.print(s + " map: " + map.size() + "..."); System.out.print(s + " map: " + map.size() + "...");
@ -467,7 +468,7 @@ public class GeoPointParserUtil {
// http://maps.google.com/maps?lci=com.google.latitudepublicupdates&ll=34.99393%2C-106.61568&q=34.99393%2C-106.61568 // http://maps.google.com/maps?lci=com.google.latitudepublicupdates&ll=34.99393%2C-106.61568&q=34.99393%2C-106.61568
z = GeoParsedPoint.NO_ZOOM; z = GeoParsedPoint.NO_ZOOM;
url = "http://maps.google.com/maps?lci=com.google.latitudepublicupdates&ll=" + dlat url = "http://maps.google.com/maps?lci=com.google.latitudepublicupdates&ll=" + dlat
+"%2C" + dlon + "&q=" + dlat + "%2C" + dlon + "((" + dlat + "%2C%20" + dlon + "))"; + "%2C" + dlon + "&q=" + dlat + "%2C" + dlon + "((" + dlat + "%2C%20" + dlon + "))";
System.out.println("url: " + url); System.out.println("url: " + url);
actual = GeoPointParserUtil.parse(url); actual = GeoPointParserUtil.parse(url);
assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z));
@ -523,8 +524,8 @@ public class GeoPointParserUtil {
// http://map.baidu.com/?l=13&tn=B_NORMAL_MAP&c=13748138,4889173&s=gibberish // http://map.baidu.com/?l=13&tn=B_NORMAL_MAP&c=13748138,4889173&s=gibberish
z = 7; z = 7;
int latint = ((int)(dlat * 100000)); int latint = ((int) (dlat * 100000));
int lonint = ((int)(dlon * 100000)); int lonint = ((int) (dlon * 100000));
url = "http://map.baidu.com/?l=" + z + "&tn=B_NORMAL_MAP&c=" + latint + "," + lonint + "&s=gibberish"; url = "http://map.baidu.com/?l=" + z + "&tn=B_NORMAL_MAP&c=" + latint + "," + lonint + "&s=gibberish";
System.out.println("url: " + url); System.out.println("url: " + url);
actual = GeoPointParserUtil.parse(url); actual = GeoPointParserUtil.parse(url);
@ -705,10 +706,10 @@ public class GeoPointParserUtil {
+ aLabel + ", expected=" + eLabel); + aLabel + ", expected=" + eLabel);
} }
} }
if (((int)eLat) != ((int)aLat)) { if (((int) eLat) != ((int) aLat)) {
throw new RuntimeException("Latitude is not equal; actual=" + aLat + ", expected=" + eLat); throw new RuntimeException("Latitude is not equal; actual=" + aLat + ", expected=" + eLat);
} }
if (((int)eLon) != ((int)aLon)) { if (((int) eLon) != ((int) aLon)) {
throw new RuntimeException("Longitude is not equal; actual=" + aLon + ", expected=" + eLon); throw new RuntimeException("Longitude is not equal; actual=" + aLon + ", expected=" + eLon);
} }
if (eZoom != aZoom) { if (eZoom != aZoom) {
@ -786,6 +787,7 @@ public class GeoPointParserUtil {
* @return {@link GeoParsedPoint} * @return {@link GeoParsedPoint}
*/ */
public static GeoParsedPoint parse(final String uriString) { public static GeoParsedPoint parse(final String uriString) {
System.out.println("parse(" + "uriString=" + uriString + ")");
URI uri; URI uri;
try { try {
// amap.com uses | in their URLs, which is an illegal character for a URL // amap.com uses | in their URLs, which is an illegal character for a URL
@ -842,11 +844,11 @@ public class GeoPointParserUtil {
double lon = 0; double lon = 0;
int zoom = GeoParsedPoint.NO_ZOOM; int zoom = GeoParsedPoint.NO_ZOOM;
if (fragment != null) { if (fragment != null) {
if(fragment.startsWith("map=")) { if (fragment.startsWith("map=")) {
fragment = fragment.substring("map=".length()); fragment = fragment.substring("map=".length());
} }
String[] vls = fragment.split("/"); String[] vls = fragment.split("/");
if(vls.length >= 3) { if (vls.length >= 3) {
zoom = parseZoom(vls[0]); zoom = parseZoom(vls[0]);
lat = parseSilentDouble(vls[1]); lat = parseSilentDouble(vls[1]);
lon = parseSilentDouble(vls[2]); lon = parseSilentDouble(vls[2]);
@ -854,11 +856,11 @@ public class GeoPointParserUtil {
} }
// the query string sometimes has higher resolution values // the query string sometimes has higher resolution values
String mlat = getQueryParameter("mlat", uri); String mlat = getQueryParameter("mlat", uri);
if(mlat != null) { if (mlat != null) {
lat = parseSilentDouble(mlat); lat = parseSilentDouble(mlat);
} }
String mlon = getQueryParameter("mlon", uri); String mlon = getQueryParameter("mlon", uri);
if(mlon != null) { if (mlon != null) {
lon = parseSilentDouble(mlon); lon = parseSilentDouble(mlon);
} }
return new GeoParsedPoint(lat, lon, zoom); return new GeoParsedPoint(lat, lon, zoom);
@ -868,8 +870,8 @@ public class GeoPointParserUtil {
* multiplied by 100,000, then rounded to an integer */ * multiplied by 100,000, then rounded to an integer */
Map<String, String> params = getQueryParameters(uri); Map<String, String> params = getQueryParameters(uri);
String zm = params.get("l"); String zm = params.get("l");
String[] vls = silentSplit(params.get("c"),","); String[] vls = silentSplit(params.get("c"), ",");
if ( vls != null && vls.length >= 2) { if (vls != null && vls.length >= 2) {
double lat = parseSilentInt(vls[0]) / 100000.; double lat = parseSilentInt(vls[0]) / 100000.;
double lon = parseSilentInt(vls[1]) / 100000.; double lon = parseSilentInt(vls[1]) / 100000.;
int zoom = parseZoom(zm); int zoom = parseZoom(zm);
@ -877,7 +879,7 @@ public class GeoPointParserUtil {
} }
} else if (simpleDomains.contains(host)) { } else if (simpleDomains.contains(host)) {
Map<String, String> params = getQueryParameters(uri); Map<String, String> params = getQueryParameters(uri);
if(uri.getQuery() == null && params.size() == 0) { if (uri.getQuery() == null && params.size() == 0) {
// DOUBLE check this may be wrong test of openstreetmap.de (looks very weird url and server doesn't respond) // DOUBLE check this may be wrong test of openstreetmap.de (looks very weird url and server doesn't respond)
params = getQueryParameters(path.substring(1)); params = getQueryParameters(path.substring(1));
} }
@ -907,13 +909,13 @@ public class GeoPointParserUtil {
String lonString = null; String lonString = null;
String z = String.valueOf(GeoParsedPoint.NO_ZOOM); String z = String.valueOf(GeoParsedPoint.NO_ZOOM);
Map<String, String> params = getQueryParameters(uri); Map<String, String> params = getQueryParameters(uri);
if(params.containsKey("q")){ if (params.containsKey("q")) {
Matcher matcher = commaSeparatedPairPattern.matcher(params.get("q")); Matcher matcher = commaSeparatedPairPattern.matcher(params.get("q"));
if (matcher.matches()) { if (matcher.matches()) {
latString = matcher.group(1); latString = matcher.group(1);
lonString = matcher.group(2); lonString = matcher.group(2);
} }
} else if(params.containsKey("ll")){ } else if (params.containsKey("ll")) {
Matcher matcher = commaSeparatedPairPattern.matcher(params.get("ll")); Matcher matcher = commaSeparatedPairPattern.matcher(params.get("ll"));
if (matcher.matches()) { if (matcher.matches()) {
latString = matcher.group(1); latString = matcher.group(1);
@ -926,11 +928,11 @@ public class GeoPointParserUtil {
} }
return new GeoParsedPoint(latString, lonString, z); return new GeoParsedPoint(latString, lonString, z);
} }
if(params.containsKey("daddr")){ if (params.containsKey("daddr")) {
return parseGoogleMapsPath(params.get("daddr"), params); return parseGoogleMapsPath(params.get("daddr"), params);
} else if(params.containsKey("saddr")){ } else if (params.containsKey("saddr")) {
return parseGoogleMapsPath(params.get("saddr"), params); return parseGoogleMapsPath(params.get("saddr"), params);
} else if(params.containsKey("q")){ } else if (params.containsKey("q")) {
return parseGoogleMapsPath(params.get("q"), params); return parseGoogleMapsPath(params.get("q"), params);
} }
if (fragment != null) { if (fragment != null) {
@ -941,8 +943,8 @@ public class GeoPointParserUtil {
} }
} }
String[] pathPrefixes = new String[] { "/@", "/ll=", String[] pathPrefixes = new String[]{"/@", "/ll=",
"loc:", "/" }; "loc:", "/"};
for (String pref : pathPrefixes) { for (String pref : pathPrefixes) {
if (path.contains(pref)) { if (path.contains(pref)) {
path = path.substring(path.lastIndexOf(pref) path = path.substring(path.lastIndexOf(pref)
@ -961,7 +963,7 @@ public class GeoPointParserUtil {
/* though this looks like Query String, it is also used as part of the Fragment */ /* though this looks like Query String, it is also used as part of the Fragment */
".*q=([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?).*&radius=(\\d+).*", ".*q=([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?).*&radius=(\\d+).*",
".*q=([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?).*", ".*q=([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?).*",
".*p=(?:[A-Z0-9]+),([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?).*", }; ".*p=(?:[A-Z0-9]+),([+-]?\\d+(?:\\.\\d+)?),([+-]?\\d+(?:\\.\\d+)?).*",};
for (int i = 0; i < patterns.length; i++) { for (int i = 0; i < patterns.length; i++) {
p = Pattern.compile(patterns[i]); p = Pattern.compile(patterns[i]);
matcher = p.matcher(subString); matcher = p.matcher(subString);
@ -969,7 +971,7 @@ public class GeoPointParserUtil {
if (matcher.groupCount() == 3) { if (matcher.groupCount() == 3) {
// amap uses radius in meters, so do rough conversion into zoom level // amap uses radius in meters, so do rough conversion into zoom level
float radius = Float.valueOf(matcher.group(3)); float radius = Float.valueOf(matcher.group(3));
long zoom = Math.round(23. - Math.log(radius)/Math.log(2.0)); long zoom = Math.round(23. - Math.log(radius) / Math.log(2.0));
return new GeoParsedPoint(matcher.group(1), matcher.group(2), String.valueOf(zoom)); return new GeoParsedPoint(matcher.group(1), matcher.group(2), String.valueOf(zoom));
} else if (matcher.groupCount() == 2) { } else if (matcher.groupCount() == 2) {
return new GeoParsedPoint(matcher.group(1), matcher.group(2)); return new GeoParsedPoint(matcher.group(1), matcher.group(2));
@ -1182,12 +1184,12 @@ public class GeoPointParserUtil {
String zmPart = ""; String zmPart = "";
String descr = ""; String descr = "";
String path = opath; String path = opath;
if(path.contains("&")){ if (path.contains("&")) {
String[] vls = path.split("&"); String[] vls = path.split("&");
path = vls[0]; path = vls[0];
for(int i = 1; i < vls.length; i++) { for (int i = 1; i < vls.length; i++) {
int ik = vls[i].indexOf('='); int ik = vls[i].indexOf('=');
if(ik > 0) { if (ik > 0) {
params.put(vls[i].substring(0, ik), vls[i].substring(ik + 1)); params.put(vls[i].substring(0, ik), vls[i].substring(ik + 1));
} }
} }
@ -1200,22 +1202,22 @@ public class GeoPointParserUtil {
} }
} }
if(params.containsKey("z")) { if (params.containsKey("z")) {
zmPart = params.get("z"); zmPart = params.get("z");
} }
String[] vls = silentSplit(path, ","); String[] vls = silentSplit(path, ",");
if(vls.length >= 2) { if (vls.length >= 2) {
double lat = parseSilentDouble(vls[0]); double lat = parseSilentDouble(vls[0]);
double lon = parseSilentDouble(vls[1]) ; double lon = parseSilentDouble(vls[1]);
int zoom = GeoParsedPoint.NO_ZOOM; int zoom = GeoParsedPoint.NO_ZOOM;
if(vls.length >= 3 || zmPart.length() > 0) { if (vls.length >= 3 || zmPart.length() > 0) {
if(zmPart.length() == 0){ if (zmPart.length() == 0) {
zmPart = vls[2]; zmPart = vls[2];
} }
if(zmPart.startsWith("z=")) { if (zmPart.startsWith("z=")) {
zmPart = zmPart.substring(2); zmPart = zmPart.substring(2);
} else if(zmPart.contains("z")) { } else if (zmPart.contains("z")) {
zmPart = zmPart.substring(0, zmPart.indexOf('z')); zmPart = zmPart.substring(0, zmPart.indexOf('z'));
} }
zoom = parseZoom(zmPart); zoom = parseZoom(zmPart);
@ -1226,7 +1228,7 @@ public class GeoPointParserUtil {
} }
private static String[] silentSplit(String vl, String split) { private static String[] silentSplit(String vl, String split) {
if(vl == null) { if (vl == null) {
return null; return null;
} }
return vl.split(split); return vl.split(split);
@ -1307,18 +1309,18 @@ public class GeoPointParserUtil {
} }
private static double parseLon(String lonString) { private static double parseLon(String lonString) {
if(lonString.startsWith("E")) { if (lonString.startsWith("E")) {
return -Double.valueOf(lonString.substring(1)); return -Double.valueOf(lonString.substring(1));
} else if(lonString.startsWith("W")) { } else if (lonString.startsWith("W")) {
return Double.valueOf(lonString.substring(1)); return Double.valueOf(lonString.substring(1));
} }
return Double.valueOf(lonString); return Double.valueOf(lonString);
} }
private static double parseLat(String latString) { private static double parseLat(String latString) {
if(latString.startsWith("S")) { if (latString.startsWith("S")) {
return -Double.valueOf(latString.substring(1)); return -Double.valueOf(latString.substring(1));
} else if(latString.startsWith("N")) { } else if (latString.startsWith("N")) {
return Double.valueOf(latString.substring(1)); return Double.valueOf(latString.substring(1));
} }
return Double.valueOf(latString); return Double.valueOf(latString);
@ -1363,8 +1365,8 @@ public class GeoPointParserUtil {
} }
private String formatDouble(double d) { private String formatDouble(double d) {
if(d == (long) d) if (d == (long) d)
return String.format(Locale.ENGLISH, "%d", (long)d); return String.format(Locale.ENGLISH, "%d", (long) d);
else else
return String.format("%s", d); return String.format("%s", d);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4 KiB

View file

@ -51,6 +51,13 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
public void onAttach(Activity activity) { public void onAttach(Activity activity) {
super.onAttach(activity); super.onAttach(activity);
Intent intent = activity.getIntent(); Intent intent = activity.getIntent();
settings = getApplication().getSettings();
OsmandApplication app = getApplication();
favouritesAdapter = new FavouritesAdapter(activity, app.getFavorites().getFavouritePoints(),
!selectFavoriteMode);
setListAdapter(favouritesAdapter);
setHasOptionsMenu(true);
if (intent != null) { if (intent != null) {
selectFavoriteMode = intent.hasExtra(SELECT_FAVORITE_POINT_INTENT_KEY); selectFavoriteMode = intent.hasExtra(SELECT_FAVORITE_POINT_INTENT_KEY);
if (intent.hasExtra(SearchActivity.SEARCH_LAT) && intent.hasExtra(SearchActivity.SEARCH_LON)) { if (intent.hasExtra(SearchActivity.SEARCH_LAT) && intent.hasExtra(SearchActivity.SEARCH_LON)) {
@ -61,12 +68,6 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
} }
} }
} }
settings = ((OsmandApplication) getApplication()).getSettings();
OsmandApplication app = (OsmandApplication) getApplication();
favouritesAdapter = new FavouritesAdapter(activity, app.getFavorites().getFavouritePoints(),
!selectFavoriteMode);
setListAdapter(favouritesAdapter);
setHasOptionsMenu(true);
} }
private OsmandApplication getApplication() { private OsmandApplication getApplication() {