From 0205628a486fabb96b2dae5d637909d8292fcb2f Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 31 Dec 2020 15:15:17 +0200 Subject: [PATCH] rolled back previous changes; fix address uri without lat & lon in searchRequest (example: geo:0,0?q=Van+Bleiswijkstraat+66,+2582+LG+The+Hague) --- .../net/osmand/util/GeoPointParserUtil.java | 4 +++ .../activities/search/GeoIntentActivity.java | 28 ++----------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/util/GeoPointParserUtil.java b/OsmAnd-java/src/main/java/net/osmand/util/GeoPointParserUtil.java index 951ae870e2..f46f4f6f70 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/GeoPointParserUtil.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/GeoPointParserUtil.java @@ -558,6 +558,10 @@ public class GeoPointParserUtil { if (lat == 0.0 && lon == 0.0 && positionInSearchRequestMatcher.find()) { lat = Double.valueOf(positionInSearchRequestMatcher.group(1)); lon = Double.valueOf(positionInSearchRequestMatcher.group(2)); + if (lat < -90 || lat > 90 || lon < -180 || lon > 180) { + lat = 0.0; + lon = 0.0; + } } } diff --git a/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java index 951ba74b16..1e8ff552b4 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java @@ -1,12 +1,9 @@ package net.osmand.plus.activities.search; import android.app.ProgressDialog; -import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnCancelListener; import android.content.Intent; -import android.location.Address; -import android.location.Geocoder; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; @@ -29,9 +26,6 @@ import net.osmand.util.Algorithms; import net.osmand.util.GeoPointParserUtil; import net.osmand.util.GeoPointParserUtil.GeoParsedPoint; -import java.io.IOException; -import java.util.Locale; - public class GeoIntentActivity extends OsmandListActivity { private ProgressDialog progressDlg; @@ -59,7 +53,7 @@ public class GeoIntentActivity extends OsmandListActivity { if (intent != null) { final ProgressDialog progress = ProgressDialog.show(GeoIntentActivity.this, getString(R.string.searching), getString(R.string.searching_address)); - final GeoIntentTask task = new GeoIntentTask(progress, intent, this); + final GeoIntentTask task = new GeoIntentTask(progress, intent); progress.setOnCancelListener(new OnCancelListener() { @Override @@ -90,12 +84,10 @@ public class GeoIntentActivity extends OsmandListActivity { private class GeoIntentTask extends AsyncTask { private final ProgressDialog progress; private final Intent intent; - private Context context; - private GeoIntentTask(final ProgressDialog progress, final Intent intent, Context context) { + private GeoIntentTask(final ProgressDialog progress, final Intent intent) { this.progress = progress; this.intent = intent; - this.context = context; } @Override @@ -121,21 +113,7 @@ public class GeoIntentActivity extends OsmandListActivity { Thread.sleep(200); } Uri uri = intent.getData(); - GeoParsedPoint gpp; - Address address = null; - try { - address = new Geocoder(context, Locale.getDefault()) - .getFromLocationName(uri.toString(), 1) - .get(0); - } catch (IndexOutOfBoundsException | IOException e) { - e.printStackTrace(); - } - if (address != null) { - gpp = new GeoParsedPoint(address.getLatitude(), address.getLongitude(), GeoParsedPoint.NO_ZOOM); - } else { - gpp = GeoPointParserUtil.parse(uri.toString()); - } - return gpp; + return GeoPointParserUtil.parse(uri.toString()); } catch (Exception e) { return null; }