Better parsing of query string for geo intent

This commit is contained in:
sanderd17 2012-06-03 16:14:52 +03:00
parent 638bccc572
commit 88b5c7442a

View file

@ -196,11 +196,17 @@ public class GeoIntentActivity extends OsmandListActivity {
private List<String> elements;
public GeoAddressSearch(String query) {
StringTokenizer s = new StringTokenizer(query.substring(query
.indexOf("q=") + 2), ",");
elements = new ArrayList<String>(s.countTokens());
while (s.hasMoreTokens()) {
elements.add(s.nextToken().replace('+', ' ').trim());
query = query.replaceAll("%20", ",").replaceAll("%0A",",")
.replaceAll("\n",",").replaceAll("\t",",")
.replaceAll(" ", ",");
System.out.println(query);
//String is split on each comma
String[] s = query.substring(query
.indexOf("q=") + 2).split(",");
elements = new ArrayList<String>();
for (int i = 0; i<s.length; i++) {
elements.add(s[i].replace('+', ' ').trim());
}
}