rolled back previous changes;
fix address uri without lat & lon in searchRequest (example: geo:0,0?q=Van+Bleiswijkstraat+66,+2582+LG+The+Hague)
This commit is contained in:
parent
2da563815d
commit
0205628a48
2 changed files with 7 additions and 25 deletions
|
@ -558,6 +558,10 @@ public class GeoPointParserUtil {
|
||||||
if (lat == 0.0 && lon == 0.0 && positionInSearchRequestMatcher.find()) {
|
if (lat == 0.0 && lon == 0.0 && positionInSearchRequestMatcher.find()) {
|
||||||
lat = Double.valueOf(positionInSearchRequestMatcher.group(1));
|
lat = Double.valueOf(positionInSearchRequestMatcher.group(1));
|
||||||
lon = Double.valueOf(positionInSearchRequestMatcher.group(2));
|
lon = Double.valueOf(positionInSearchRequestMatcher.group(2));
|
||||||
|
if (lat < -90 || lat > 90 || lon < -180 || lon > 180) {
|
||||||
|
lat = 0.0;
|
||||||
|
lon = 0.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
package net.osmand.plus.activities.search;
|
package net.osmand.plus.activities.search;
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.DialogInterface.OnCancelListener;
|
import android.content.DialogInterface.OnCancelListener;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.location.Address;
|
|
||||||
import android.location.Geocoder;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -29,9 +26,6 @@ import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.GeoPointParserUtil;
|
import net.osmand.util.GeoPointParserUtil;
|
||||||
import net.osmand.util.GeoPointParserUtil.GeoParsedPoint;
|
import net.osmand.util.GeoPointParserUtil.GeoParsedPoint;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class GeoIntentActivity extends OsmandListActivity {
|
public class GeoIntentActivity extends OsmandListActivity {
|
||||||
|
|
||||||
private ProgressDialog progressDlg;
|
private ProgressDialog progressDlg;
|
||||||
|
@ -59,7 +53,7 @@ public class GeoIntentActivity extends OsmandListActivity {
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
final ProgressDialog progress = ProgressDialog.show(GeoIntentActivity.this, getString(R.string.searching),
|
final ProgressDialog progress = ProgressDialog.show(GeoIntentActivity.this, getString(R.string.searching),
|
||||||
getString(R.string.searching_address));
|
getString(R.string.searching_address));
|
||||||
final GeoIntentTask task = new GeoIntentTask(progress, intent, this);
|
final GeoIntentTask task = new GeoIntentTask(progress, intent);
|
||||||
|
|
||||||
progress.setOnCancelListener(new OnCancelListener() {
|
progress.setOnCancelListener(new OnCancelListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,12 +84,10 @@ public class GeoIntentActivity extends OsmandListActivity {
|
||||||
private class GeoIntentTask extends AsyncTask<Void, Void, GeoParsedPoint> {
|
private class GeoIntentTask extends AsyncTask<Void, Void, GeoParsedPoint> {
|
||||||
private final ProgressDialog progress;
|
private final ProgressDialog progress;
|
||||||
private final Intent intent;
|
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.progress = progress;
|
||||||
this.intent = intent;
|
this.intent = intent;
|
||||||
this.context = context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -121,21 +113,7 @@ public class GeoIntentActivity extends OsmandListActivity {
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
}
|
}
|
||||||
Uri uri = intent.getData();
|
Uri uri = intent.getData();
|
||||||
GeoParsedPoint gpp;
|
return GeoPointParserUtil.parse(uri.toString());
|
||||||
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;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue