try to split place from addresses as well

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@683 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach@gmail.com 2011-06-08 21:08:08 +00:00
parent caaf389634
commit b8592a1740

View file

@ -112,8 +112,14 @@ public abstract class AbstractHafasProvider implements NetworkProvider
return 0; return 0;
} }
private static final Pattern P_SPLIT_ADDRESS = Pattern.compile("(\\d{5}\\s+[^,]+),\\s+(.*)");
protected String[] splitPlaceAndName(final String name) protected String[] splitPlaceAndName(final String name)
{ {
final Matcher matcher = P_SPLIT_ADDRESS.matcher(name);
if (matcher.matches())
return new String[] { matcher.group(1), matcher.group(2) };
else
return new String[] { null, name }; return new String[] { null, name };
} }
@ -291,7 +297,8 @@ public abstract class AbstractHafasProvider implements NetworkProvider
} }
else if (type == 2) // address else if (type == 2) // address
{ {
results.add(new Location(LocationType.ADDRESS, 0, lat, lon, null, value)); final String[] placeAndName = splitPlaceAndName(value);
results.add(new Location(LocationType.ADDRESS, 0, lat, lon, placeAndName[0], placeAndName[1]));
} }
else if (type == 4) // poi else if (type == 4) // poi
{ {