Fixing issue #1486. Incorrect parsing of double parentheses. Now double parentheses are simply removed.

This commit is contained in:
GaidamakUA 2015-07-27 20:58:10 +03:00
parent aa036c0ed6
commit 50845c74db
3 changed files with 47 additions and 34 deletions

View file

@ -1,4 +1,6 @@
apply plugin: 'java' apply plugin: 'java'
apply plugin:'application'
mainClassName = "net.osmand.util.GeoPointParserUtil"
sourceSets { sourceSets {
main { main {

View file

@ -3,7 +3,6 @@ package net.osmand.util;
import java.net.URI; import java.net.URI;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Locale; import java.util.Locale;
@ -465,6 +464,13 @@ public class GeoPointParserUtil {
actual = GeoPointParserUtil.parse(url); actual = GeoPointParserUtil.parse(url);
assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z)); assertGeoPoint(actual, new GeoParsedPoint(dlat, dlon, z));
// http://maps.google.com/maps?lci=com.google.latitudepublicupdates&ll=34.99393%2C-106.61568&q=34.99393%2C-106.61568
z = GeoParsedPoint.NO_ZOOM;
url = "http://maps.google.com/maps?lci=com.google.latitudepublicupdates&ll=55.8063697%2C25.3749485&q=55.8063697%2C25.3749485((55.8063670%2C%2025.3749488))";
System.out.println("url: " + url);
actual = GeoPointParserUtil.parse(url);
assertGeoPoint(actual, new GeoParsedPoint(55.8063697, 25.3749485, z));
// https://www.google.com/maps/place/34%C2%B059'38.1%22N+106%C2%B036'56.5%22W/@34.99393,-106.61568,17z/data=!3m1!4b1!4m2!3m1!1s0x0:0x0 // https://www.google.com/maps/place/34%C2%B059'38.1%22N+106%C2%B036'56.5%22W/@34.99393,-106.61568,17z/data=!3m1!4b1!4m2!3m1!1s0x0:0x0
z = 17; z = 17;
url = "https://www.google.com/maps/place/34%C2%B059'38.1%22N+106%C2%B036'56.5%22W/@" + dlat + "," + dlon + "," + z + "z/data=!3m1!4b1!4m2!3m1!1s0x0:0x0"; url = "https://www.google.com/maps/place/34%C2%B059'38.1%22N+106%C2%B036'56.5%22W/@" + dlat + "," + dlon + "," + z + "z/data=!3m1!4b1!4m2!3m1!1s0x0:0x0";
@ -785,7 +791,8 @@ public class GeoPointParserUtil {
uri = URI.create(uriString.replaceAll("\\s+", "+") uri = URI.create(uriString.replaceAll("\\s+", "+")
.replaceAll("%20", "+") .replaceAll("%20", "+")
.replaceAll("%2C", ",") .replaceAll("%2C", ",")
.replaceAll("\\|", ";")); .replaceAll("\\|", ";")
.replaceAll("\\(\\(\\S+\\)\\)", ""));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return null; return null;
} }

View file

@ -1,36 +1,5 @@
package net.osmand.plus.activities.search; package net.osmand.plus.activities.search;
import android.widget.*;
import gnu.trove.map.hash.TLongObjectHashMap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import net.osmand.ResultMatcher;
import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
import net.osmand.data.City;
import net.osmand.data.LatLon;
import net.osmand.data.MapObject;
import net.osmand.data.PointDescription;
import net.osmand.data.Street;
import net.osmand.plus.AppInitializer;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.AppInitializer.InitEvents;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandListActivity;
import net.osmand.plus.resources.RegionAddressRepository;
import net.osmand.plus.resources.ResourceManager;
import net.osmand.util.GeoPointParserUtil;
import net.osmand.util.MapUtils;
import android.app.Dialog;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener; import android.content.DialogInterface.OnCancelListener;
@ -41,9 +10,44 @@ import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.ResultMatcher;
import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
import net.osmand.data.City;
import net.osmand.data.LatLon;
import net.osmand.data.MapObject;
import net.osmand.data.PointDescription;
import net.osmand.data.Street;
import net.osmand.plus.AppInitializer;
import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.AppInitializer.InitEvents;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandListActivity;
import net.osmand.plus.resources.RegionAddressRepository;
import net.osmand.plus.resources.ResourceManager;
import net.osmand.util.GeoPointParserUtil;
import net.osmand.util.MapUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import gnu.trove.map.hash.TLongObjectHashMap;
public class GeoIntentActivity extends OsmandListActivity { public class GeoIntentActivity extends OsmandListActivity {
private static final String TAG = "GeoIntentActivity";
private ProgressDialog progressDlg; private ProgressDialog progressDlg;
private LatLon location; private LatLon location;
@ -206,7 +210,7 @@ public class GeoIntentActivity extends OsmandListActivity {
* geo:0,0?q=34.99,-106.61(Treasure)<br/> * geo:0,0?q=34.99,-106.61(Treasure)<br/>
* geo:0,0?q=1600+Amphitheatre+Parkway%2C+CA<br/> * geo:0,0?q=1600+Amphitheatre+Parkway%2C+CA<br/>
* *
* @param data * @param uri
* The intent uri * The intent uri
* @return * @return
*/ */