Fix #9532
This commit is contained in:
parent
dedbbb4c26
commit
4a24787da3
5 changed files with 35 additions and 34 deletions
|
@ -32,7 +32,7 @@ public class SearchResult {
|
|||
public double priorityDistance;
|
||||
|
||||
public LatLon location;
|
||||
public int preferredZoom = 15;
|
||||
public double preferredZoom = 15;
|
||||
|
||||
public String localeName;
|
||||
public String alternateName;
|
||||
|
|
|
@ -82,7 +82,7 @@ public class GeoPointParserUtil {
|
|||
// amap.com uses | in their URLs, which is an illegal character for a URL
|
||||
uri = URI.create(uriString.replaceAll("\\s+", "+")
|
||||
.replaceAll("%20", "+")
|
||||
.replaceAll("%2C", ",")
|
||||
.replaceAll("%2F", ",")
|
||||
.replaceAll("\\|", ";")
|
||||
.replaceAll("\\(\\(\\S+\\)\\)", ""));
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -142,7 +142,7 @@ public class GeoPointParserUtil {
|
|||
} else { // data in the query and/or feature strings
|
||||
double lat = 0;
|
||||
double lon = 0;
|
||||
int zoom = GeoParsedPoint.NO_ZOOM;
|
||||
double zoom = GeoParsedPoint.NO_ZOOM;
|
||||
Map<String, String> queryMap = getQueryParameters(uri);
|
||||
if (fragment != null) {
|
||||
if (fragment.startsWith("map=")) {
|
||||
|
@ -187,7 +187,7 @@ public class GeoPointParserUtil {
|
|||
if (vls != null && vls.length >= 2) {
|
||||
double lat = parseSilentInt(vls[0]) / 100000.;
|
||||
double lon = parseSilentInt(vls[1]) / 100000.;
|
||||
int zoom = parseZoom(zm);
|
||||
double zoom = parseZoom(zm);
|
||||
return new GeoParsedPoint(lat, lon, zoom);
|
||||
}
|
||||
} else if (simpleDomains.contains(host)) {
|
||||
|
@ -198,7 +198,7 @@ public class GeoPointParserUtil {
|
|||
if (params.containsKey("lat") && params.containsKey("lon")) {
|
||||
final double lat = parseSilentDouble(params.get("lat"));
|
||||
final double lon = parseSilentDouble(params.get("lon"));
|
||||
int zoom = GeoParsedPoint.NO_ZOOM;
|
||||
double zoom = GeoParsedPoint.NO_ZOOM;
|
||||
if (params.containsKey("z")) {
|
||||
zoom = parseZoom(params.get("z"));
|
||||
} else if (params.containsKey("zoom")) {
|
||||
|
@ -459,7 +459,7 @@ public class GeoPointParserUtil {
|
|||
lon = Double.valueOf(positionMatcher.group(2));
|
||||
}
|
||||
|
||||
int zoom = GeoParsedPoint.NO_ZOOM;
|
||||
double zoom = GeoParsedPoint.NO_ZOOM;
|
||||
String searchRequest = null;
|
||||
for (String param : queryPart.split("&")) {
|
||||
String paramName;
|
||||
|
@ -474,7 +474,8 @@ public class GeoPointParserUtil {
|
|||
}
|
||||
|
||||
if ("z".equals(paramName) && paramValue != null) {
|
||||
zoom = Integer.parseInt(paramValue);
|
||||
// zoom = Double.valueOf(paramValue).intValue();
|
||||
zoom = Double.valueOf(paramValue);
|
||||
} else if ("q".equals(paramName) && paramValue != null) {
|
||||
searchRequest = URLDecoder.decode(paramValue);
|
||||
}
|
||||
|
@ -540,7 +541,7 @@ public class GeoPointParserUtil {
|
|||
if (vls.length >= 2) {
|
||||
double lat = parseSilentDouble(vls[0], Double.NaN);
|
||||
double lon = parseSilentDouble(vls[1], Double.NaN);
|
||||
int zoom = GeoParsedPoint.NO_ZOOM;
|
||||
double zoom = GeoParsedPoint.NO_ZOOM;
|
||||
if (vls.length >= 3 || zmPart.length() > 0) {
|
||||
if (zmPart.length() == 0) {
|
||||
zmPart = vls[2];
|
||||
|
@ -566,10 +567,10 @@ public class GeoPointParserUtil {
|
|||
return vl.split(split);
|
||||
}
|
||||
|
||||
private static int parseZoom(String zoom) {
|
||||
private static double parseZoom(String zoom) {
|
||||
try {
|
||||
if (zoom != null) {
|
||||
return Integer.valueOf(zoom);
|
||||
return Double.valueOf(zoom);
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
@ -601,11 +602,11 @@ public class GeoPointParserUtil {
|
|||
}
|
||||
|
||||
public static class GeoParsedPoint {
|
||||
public static final int NO_ZOOM = -1;
|
||||
public static final double NO_ZOOM = -1;
|
||||
|
||||
private double lat = 0;
|
||||
private double lon = 0;
|
||||
private int zoom = NO_ZOOM;
|
||||
private double zoom = NO_ZOOM;
|
||||
private String label;
|
||||
private String query;
|
||||
private boolean geoPoint;
|
||||
|
@ -624,12 +625,12 @@ public class GeoPointParserUtil {
|
|||
this.label = label.replaceAll("\\+", " ");
|
||||
}
|
||||
|
||||
public GeoParsedPoint(double lat, double lon, int zoom) {
|
||||
public GeoParsedPoint(double lat, double lon, double zoom) {
|
||||
this(lat, lon);
|
||||
this.zoom = zoom;
|
||||
}
|
||||
|
||||
public GeoParsedPoint(double lat, double lon, int zoom, String label) {
|
||||
public GeoParsedPoint(double lat, double lon, double zoom, String label) {
|
||||
this(lat, lon, label);
|
||||
this.zoom = zoom;
|
||||
}
|
||||
|
@ -684,7 +685,7 @@ public class GeoPointParserUtil {
|
|||
return lon;
|
||||
}
|
||||
|
||||
public int getZoom() {
|
||||
public double getZoom() {
|
||||
return zoom;
|
||||
}
|
||||
|
||||
|
@ -755,7 +756,7 @@ public class GeoPointParserUtil {
|
|||
@Override
|
||||
public String toString() {
|
||||
return isGeoPoint() ?
|
||||
String.format("GeoParsedPoint [lat=%.5f, lon=%.5f, zoom=%d, label=%s]", lat, lon, zoom, label) :
|
||||
String.format("GeoParsedPoint [lat=%.5f, lon=%.5f, zoom=%.5f, label=%s]", lat, lon, zoom, label) :
|
||||
String.format("GeoParsedPoint [query=%s]",query);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class GeoPointParserUtilTest {
|
|||
final double dlat = 34.99393, dlon = -106.61568;
|
||||
final double longLat = 34.993933029174805, longLon = -106.615680694580078;
|
||||
final String name = "Treasure Island";
|
||||
int z = GeoParsedPoint.NO_ZOOM;
|
||||
double z = GeoParsedPoint.NO_ZOOM;
|
||||
String url;
|
||||
|
||||
String noQueryParameters[] = {
|
||||
|
@ -63,7 +63,7 @@ public class GeoPointParserUtilTest {
|
|||
"geo:0,0?m",
|
||||
"geo:0,0?m=",
|
||||
"geo:0,0?m=foo",
|
||||
"geo:0,0?q=%D0%9D%D0",
|
||||
"geo:0,0?q=%F0%9D%F0",
|
||||
"http://download.osmand.net/go?lat",
|
||||
"http://download.osmand.net/go?lat=",
|
||||
"http://download.osmand.net/go?lat=34.99393",
|
||||
|
@ -789,7 +789,7 @@ public class GeoPointParserUtilTest {
|
|||
actual.getQuery() + "' != '" + expected.getQuery());
|
||||
} else {
|
||||
double aLat = actual.getLatitude(), eLat = expected.getLatitude(), aLon = actual.getLongitude(), eLon = expected.getLongitude();
|
||||
int aZoom = actual.getZoom(), eZoom = expected.getZoom();
|
||||
double aZoom = actual.getZoom(), eZoom = expected.getZoom();
|
||||
String aLabel = actual.getLabel(), eLabel = expected.getLabel();
|
||||
if (eLabel != null) {
|
||||
if (!aLabel.equals(eLabel)) {
|
||||
|
@ -816,7 +816,7 @@ public class GeoPointParserUtilTest {
|
|||
throw new RuntimeException("Query param not equal");
|
||||
} else {
|
||||
double aLat = actual.getLatitude(), eLat = expected.getLatitude(), aLon = actual.getLongitude(), eLon = expected.getLongitude();
|
||||
int aZoom = actual.getZoom(), eZoom = expected.getZoom();
|
||||
double aZoom = actual.getZoom(), eZoom = expected.getZoom();
|
||||
String aLabel = actual.getLabel(), eLabel = expected.getLabel();
|
||||
if (eLabel != null) {
|
||||
if (!aLabel.equals(eLabel)) {
|
||||
|
|
|
@ -414,7 +414,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_ADDRESS, typeName, name);
|
||||
app.getSettings().setMapLocationToShow(
|
||||
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
|
||||
searchResult.preferredZoom, pointDescription, true, searchResult.object);
|
||||
(int) searchResult.preferredZoom, pointDescription, true, searchResult.object);
|
||||
|
||||
hideToolbar();
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
|
@ -444,7 +444,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
hide();
|
||||
} else if (group.getPoints().size() == 1) {
|
||||
FavouritePoint p = group.getPoints().get(0);
|
||||
app.getSettings().setMapLocationToShow(p.getLatitude(), p.getLongitude(), word.getResult().preferredZoom);
|
||||
app.getSettings().setMapLocationToShow(p.getLatitude(), p.getLongitude(), (int) word.getResult().preferredZoom);
|
||||
hideToolbar();
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
hide();
|
||||
|
|
|
@ -260,7 +260,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
|||
|
||||
showOnMap(getMapActivity(), dialogFragment,
|
||||
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
|
||||
searchResult.preferredZoom, pointDescription, object);
|
||||
(int) searchResult.preferredZoom, pointDescription, object);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue