From 11ab262987df6f8e4c5d9fdf8565e83d4b36bf0a Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 27 Apr 2013 14:22:50 +0200 Subject: [PATCH] Fix geo --- .../activities/search/GeoIntentActivity.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java index ea27bee085..c91a2ccd64 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java @@ -212,7 +212,25 @@ public class GeoIntentActivity extends OsmandListActivity { // it is 0,0? that means a search return new GeoAddressSearch(data.getQuery()); } else { - showErrorMessage(data.getSchemeSpecificPart()); + String geo = data.getSchemeSpecificPart(); + if(geo == null) { + showErrorMessage(""); + } else { + int latIndex = geo.indexOf(','); + int lonIndex = geo.indexOf('?'); + lonIndex = lonIndex > 0 ? lonIndex : geo.length(); + if (latIndex > 0) { + try { + double lat = Double.parseDouble(geo.substring(0, latIndex).trim()); + double lon = Double.parseDouble(geo.substring(latIndex + 1, lonIndex).trim()); + return new GeoPointSearch(lat, lon); + } catch (NumberFormatException e) { + showErrorMessage(geo); + } + } else { + showErrorMessage(geo); + } + } } return new Empty(); }