Casting to an int implicitly
This commit is contained in:
parent
274760e9d2
commit
9dbcf312df
6 changed files with 67 additions and 69 deletions
|
@ -1527,7 +1527,7 @@ public class SearchCoreFactory {
|
||||||
sp.location = new LatLon(pnt.getLatitude(), pnt.getLongitude());
|
sp.location = new LatLon(pnt.getLatitude(), pnt.getLongitude());
|
||||||
sp.localeName = ((float)pnt.getLatitude()) +", " + ((float) pnt.getLongitude());
|
sp.localeName = ((float)pnt.getLatitude()) +", " + ((float) pnt.getLongitude());
|
||||||
if (pnt.getZoom() > 0) {
|
if (pnt.getZoom() > 0) {
|
||||||
sp.preferredZoom = (int) pnt.getZoom();
|
sp.preferredZoom = pnt.getZoom();
|
||||||
}
|
}
|
||||||
sp.objectType = ObjectType.LOCATION;
|
sp.objectType = ObjectType.LOCATION;
|
||||||
resultMatcher.publish(sp);
|
resultMatcher.publish(sp);
|
||||||
|
|
|
@ -32,8 +32,7 @@ public class SearchResult {
|
||||||
public double priorityDistance;
|
public double priorityDistance;
|
||||||
|
|
||||||
public LatLon location;
|
public LatLon location;
|
||||||
public float pZ = 15;
|
public int preferredZoom = 15;
|
||||||
public int preferredZoom = Math.round(pZ);
|
|
||||||
|
|
||||||
public String localeName;
|
public String localeName;
|
||||||
public String alternateName;
|
public String alternateName;
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class GeoPointParserUtil {
|
||||||
// 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
|
||||||
uri = URI.create(uriString.replaceAll("\\s+", "+")
|
uri = URI.create(uriString.replaceAll("\\s+", "+")
|
||||||
.replaceAll("%20", "+")
|
.replaceAll("%20", "+")
|
||||||
.replaceAll("%2F", ",")
|
.replaceAll("%2C", ",")
|
||||||
.replaceAll("\\|", ";")
|
.replaceAll("\\|", ";")
|
||||||
.replaceAll("\\(\\(\\S+\\)\\)", ""));
|
.replaceAll("\\(\\(\\S+\\)\\)", ""));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
@ -142,7 +142,7 @@ public class GeoPointParserUtil {
|
||||||
} else { // data in the query and/or feature strings
|
} else { // data in the query and/or feature strings
|
||||||
double lat = 0;
|
double lat = 0;
|
||||||
double lon = 0;
|
double lon = 0;
|
||||||
float zoom = GeoParsedPoint.NO_ZOOM;
|
int zoom = GeoParsedPoint.NO_ZOOM;
|
||||||
Map<String, String> queryMap = getQueryParameters(uri);
|
Map<String, String> queryMap = getQueryParameters(uri);
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
if (fragment.startsWith("map=")) {
|
if (fragment.startsWith("map=")) {
|
||||||
|
@ -187,7 +187,7 @@ public class GeoPointParserUtil {
|
||||||
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.;
|
||||||
float zoom = parseZoom(zm);
|
int zoom = parseZoom(zm);
|
||||||
return new GeoParsedPoint(lat, lon, zoom);
|
return new GeoParsedPoint(lat, lon, zoom);
|
||||||
}
|
}
|
||||||
} else if (simpleDomains.contains(host)) {
|
} else if (simpleDomains.contains(host)) {
|
||||||
|
@ -198,11 +198,11 @@ public class GeoPointParserUtil {
|
||||||
if (params.containsKey("lat") && params.containsKey("lon")) {
|
if (params.containsKey("lat") && params.containsKey("lon")) {
|
||||||
final double lat = parseSilentDouble(params.get("lat"));
|
final double lat = parseSilentDouble(params.get("lat"));
|
||||||
final double lon = parseSilentDouble(params.get("lon"));
|
final double lon = parseSilentDouble(params.get("lon"));
|
||||||
float zoom = GeoParsedPoint.NO_ZOOM;
|
int zoom = GeoParsedPoint.NO_ZOOM;
|
||||||
if (params.containsKey("z")) {
|
if (params.containsKey("z")) {
|
||||||
zoom = (float) parseZoom(params.get("z"));
|
zoom = parseZoom(params.get("z"));
|
||||||
} else if (params.containsKey("zoom")) {
|
} else if (params.containsKey("zoom")) {
|
||||||
zoom = (float) parseZoom(params.get("zoom"));
|
zoom = parseZoom(params.get("zoom"));
|
||||||
}
|
}
|
||||||
return new GeoParsedPoint(lat, lon, zoom);
|
return new GeoParsedPoint(lat, lon, zoom);
|
||||||
}
|
}
|
||||||
|
@ -459,7 +459,7 @@ public class GeoPointParserUtil {
|
||||||
lon = Double.valueOf(positionMatcher.group(2));
|
lon = Double.valueOf(positionMatcher.group(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
float zoom = GeoParsedPoint.NO_ZOOM;
|
int zoom = GeoParsedPoint.NO_ZOOM;
|
||||||
String searchRequest = null;
|
String searchRequest = null;
|
||||||
for (String param : queryPart.split("&")) {
|
for (String param : queryPart.split("&")) {
|
||||||
String paramName;
|
String paramName;
|
||||||
|
@ -474,8 +474,7 @@ public class GeoPointParserUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("z".equals(paramName) && paramValue != null) {
|
if ("z".equals(paramName) && paramValue != null) {
|
||||||
// zoom = Double.valueOf(paramValue).intValue();
|
zoom = (int) Float.parseFloat(paramValue);
|
||||||
zoom = Float.valueOf(paramValue);
|
|
||||||
} else if ("q".equals(paramName) && paramValue != null) {
|
} else if ("q".equals(paramName) && paramValue != null) {
|
||||||
searchRequest = URLDecoder.decode(paramValue);
|
searchRequest = URLDecoder.decode(paramValue);
|
||||||
}
|
}
|
||||||
|
@ -541,7 +540,7 @@ public class GeoPointParserUtil {
|
||||||
if (vls.length >= 2) {
|
if (vls.length >= 2) {
|
||||||
double lat = parseSilentDouble(vls[0], Double.NaN);
|
double lat = parseSilentDouble(vls[0], Double.NaN);
|
||||||
double lon = parseSilentDouble(vls[1], Double.NaN);
|
double lon = parseSilentDouble(vls[1], Double.NaN);
|
||||||
float 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];
|
||||||
|
@ -567,10 +566,10 @@ public class GeoPointParserUtil {
|
||||||
return vl.split(split);
|
return vl.split(split);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float parseZoom(String zoom) {
|
private static int parseZoom(String zoom) {
|
||||||
try {
|
try {
|
||||||
if (zoom != null) {
|
if (zoom != null) {
|
||||||
return Float.valueOf(zoom);
|
return (int) Float.parseFloat(zoom);
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
|
@ -584,7 +583,7 @@ public class GeoPointParserUtil {
|
||||||
private static double parseSilentDouble(String zoom, double vl) {
|
private static double parseSilentDouble(String zoom, double vl) {
|
||||||
try {
|
try {
|
||||||
if (zoom != null) {
|
if (zoom != null) {
|
||||||
return Float.valueOf(zoom);
|
return Double.valueOf(zoom);
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
|
@ -602,11 +601,11 @@ public class GeoPointParserUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class GeoParsedPoint {
|
public static class GeoParsedPoint {
|
||||||
public static final float NO_ZOOM = -1;
|
public static final int NO_ZOOM = -1;
|
||||||
|
|
||||||
private double lat = 0;
|
private double lat = 0;
|
||||||
private double lon = 0;
|
private double lon = 0;
|
||||||
private float zoom = NO_ZOOM;
|
private int zoom = NO_ZOOM;
|
||||||
private String label;
|
private String label;
|
||||||
private String query;
|
private String query;
|
||||||
private boolean geoPoint;
|
private boolean geoPoint;
|
||||||
|
@ -625,12 +624,12 @@ public class GeoPointParserUtil {
|
||||||
this.label = label.replaceAll("\\+", " ");
|
this.label = label.replaceAll("\\+", " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeoParsedPoint(double lat, double lon, float zoom) {
|
public GeoParsedPoint(double lat, double lon, int zoom) {
|
||||||
this(lat, lon);
|
this(lat, lon);
|
||||||
this.zoom = zoom;
|
this.zoom = zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeoParsedPoint(double lat, double lon, float zoom, String label) {
|
public GeoParsedPoint(double lat, double lon, int zoom, String label) {
|
||||||
this(lat, lon, label);
|
this(lat, lon, label);
|
||||||
this.zoom = zoom;
|
this.zoom = zoom;
|
||||||
}
|
}
|
||||||
|
@ -685,7 +684,7 @@ public class GeoPointParserUtil {
|
||||||
return lon;
|
return lon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getZoom() {
|
public int getZoom() {
|
||||||
return zoom;
|
return zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -756,7 +755,7 @@ public class GeoPointParserUtil {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return isGeoPoint() ?
|
return isGeoPoint() ?
|
||||||
String.format("GeoParsedPoint [lat=%.5f, lon=%.5f, zoom=%.5f, label=%s]", lat, lon, zoom, label) :
|
String.format("GeoParsedPoint [lat=%.5f, lon=%.5f, zoom=%d, label=%s]", lat, lon, zoom, label) :
|
||||||
String.format("GeoParsedPoint [query=%s]",query);
|
String.format("GeoParsedPoint [query=%s]",query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class GeoPointParserUtilTest {
|
||||||
final double dlat = 34.99393, dlon = -106.61568;
|
final double dlat = 34.99393, dlon = -106.61568;
|
||||||
final double longLat = 34.993933029174805, longLon = -106.615680694580078;
|
final double longLat = 34.993933029174805, longLon = -106.615680694580078;
|
||||||
final String name = "Treasure Island";
|
final String name = "Treasure Island";
|
||||||
float z = GeoParsedPoint.NO_ZOOM;
|
int z = GeoParsedPoint.NO_ZOOM;
|
||||||
String url;
|
String url;
|
||||||
|
|
||||||
String noQueryParameters[] = {
|
String noQueryParameters[] = {
|
||||||
|
@ -63,7 +63,7 @@ public class GeoPointParserUtilTest {
|
||||||
"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=%F0%9D%F0",
|
"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",
|
||||||
|
@ -789,7 +789,7 @@ public class GeoPointParserUtilTest {
|
||||||
actual.getQuery() + "' != '" + expected.getQuery());
|
actual.getQuery() + "' != '" + expected.getQuery());
|
||||||
} else {
|
} else {
|
||||||
double aLat = actual.getLatitude(), eLat = expected.getLatitude(), aLon = actual.getLongitude(), eLon = expected.getLongitude();
|
double aLat = actual.getLatitude(), eLat = expected.getLatitude(), aLon = actual.getLongitude(), eLon = expected.getLongitude();
|
||||||
double aZoom = actual.getZoom(), eZoom = expected.getZoom();
|
int aZoom = actual.getZoom(), eZoom = expected.getZoom();
|
||||||
String aLabel = actual.getLabel(), eLabel = expected.getLabel();
|
String aLabel = actual.getLabel(), eLabel = expected.getLabel();
|
||||||
if (eLabel != null) {
|
if (eLabel != null) {
|
||||||
if (!aLabel.equals(eLabel)) {
|
if (!aLabel.equals(eLabel)) {
|
||||||
|
@ -816,7 +816,7 @@ public class GeoPointParserUtilTest {
|
||||||
throw new RuntimeException("Query param not equal");
|
throw new RuntimeException("Query param not equal");
|
||||||
} else {
|
} else {
|
||||||
double aLat = actual.getLatitude(), eLat = expected.getLatitude(), aLon = actual.getLongitude(), eLon = expected.getLongitude();
|
double aLat = actual.getLatitude(), eLat = expected.getLatitude(), aLon = actual.getLongitude(), eLon = expected.getLongitude();
|
||||||
double aZoom = actual.getZoom(), eZoom = expected.getZoom();
|
int aZoom = actual.getZoom(), eZoom = expected.getZoom();
|
||||||
String aLabel = actual.getLabel(), eLabel = expected.getLabel();
|
String aLabel = actual.getLabel(), eLabel = expected.getLabel();
|
||||||
if (eLabel != null) {
|
if (eLabel != null) {
|
||||||
if (!aLabel.equals(eLabel)) {
|
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);
|
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_ADDRESS, typeName, name);
|
||||||
app.getSettings().setMapLocationToShow(
|
app.getSettings().setMapLocationToShow(
|
||||||
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
|
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
|
||||||
(int) searchResult.preferredZoom, pointDescription, true, searchResult.object);
|
searchResult.preferredZoom, pointDescription, true, searchResult.object);
|
||||||
|
|
||||||
hideToolbar();
|
hideToolbar();
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||||
|
@ -444,7 +444,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
hide();
|
hide();
|
||||||
} else if (group.getPoints().size() == 1) {
|
} else if (group.getPoints().size() == 1) {
|
||||||
FavouritePoint p = group.getPoints().get(0);
|
FavouritePoint p = group.getPoints().get(0);
|
||||||
app.getSettings().setMapLocationToShow(p.getLatitude(), p.getLongitude(), (int) word.getResult().preferredZoom);
|
app.getSettings().setMapLocationToShow(p.getLatitude(), p.getLongitude(), word.getResult().preferredZoom);
|
||||||
hideToolbar();
|
hideToolbar();
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||||
hide();
|
hide();
|
||||||
|
|
|
@ -260,7 +260,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
||||||
|
|
||||||
showOnMap(getMapActivity(), dialogFragment,
|
showOnMap(getMapActivity(), dialogFragment,
|
||||||
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
|
searchResult.location.getLatitude(), searchResult.location.getLongitude(),
|
||||||
(int) searchResult.preferredZoom, pointDescription, object);
|
searchResult.preferredZoom, pointDescription, object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue