From a9533e32a2122a39c15ecc429cc7838d0f9ada21 Mon Sep 17 00:00:00 2001 From: "andreas.schildbach" Date: Thu, 2 Sep 2010 17:26:44 +0000 Subject: [PATCH] actually handles addresses git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@126 0924bc21-9374-b0fa-ee44-9ff1593b38f0 --- src/de/schildbach/pte/MvvProvider.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/de/schildbach/pte/MvvProvider.java b/src/de/schildbach/pte/MvvProvider.java index 986243b2..f36f9901 100644 --- a/src/de/schildbach/pte/MvvProvider.java +++ b/src/de/schildbach/pte/MvvProvider.java @@ -171,7 +171,7 @@ public class MvvProvider implements NetworkProvider uri.append("&locationServerActive=1"); uri.append("&useProxFootSearch=1"); // Take nearby stops into account and possibly use them instead uri.append("&anySigWhenPerfectNoOtherMatches=1"); - uri.append("&lineRestriction=403"); + // uri.append("&lineRestriction=403"); if (fromType == LocationType.WGS84) { @@ -195,6 +195,7 @@ public class MvvProvider implements NetworkProvider uri.append("&reducedAnyTooManyObjFilter_origin=2"); uri.append("&type_origin=").append(locationType(fromType)); uri.append("&name_origin=").append(ParserUtils.urlEncode(from, ENCODING)); // fine-grained location + uri.append("&anyObjFilter_origin=").append(locationAnyObjFilter(fromType)); } if (toType == LocationType.WGS84) @@ -219,6 +220,7 @@ public class MvvProvider implements NetworkProvider uri.append("&reducedAnyTooManyObjFilter_destination=2"); uri.append("&type_destination=").append(locationType(toType)); uri.append("&name_destination=").append(ParserUtils.urlEncode(to, ENCODING)); // fine-grained location + uri.append("&anyObjFilter_destination=").append(locationAnyObjFilter(toType)); } if (via != null) @@ -245,6 +247,7 @@ public class MvvProvider implements NetworkProvider uri.append("&reducedAnyTooManyObjFilter_via=2"); uri.append("&type_via=").append(locationType(viaType)); uri.append("&name_via=").append(ParserUtils.urlEncode(via, ENCODING)); + uri.append("&anyObjFilter_via=").append(locationAnyObjFilter(viaType)); } } @@ -261,13 +264,25 @@ public class MvvProvider implements NetworkProvider if (locationType == LocationType.STATION) return "stop"; if (locationType == LocationType.ADDRESS) - return "address"; + return "any"; // strange, matches with anyObjFilter if (locationType == LocationType.ANY) return "any"; // TODO poi throw new IllegalArgumentException(locationType.toString()); } + private static int locationAnyObjFilter(final LocationType locationType) + { + if (locationType == LocationType.STATION) + return 2; + if (locationType == LocationType.ADDRESS) + return 12; + if (locationType == LocationType.ANY) + return 0; + // TODO poi=32 + throw new IllegalArgumentException(locationType.toString()); + } + private static final Pattern P_PRE_ADDRESS = Pattern.compile("", Pattern.DOTALL); private static final Pattern P_ADDRESSES = Pattern.compile("\\s*(.*?)\\s*", Pattern.DOTALL); @@ -278,7 +293,6 @@ public class MvvProvider implements NetworkProvider final LocationType toType, final String to, final Date date, final boolean dep) throws IOException { final String uri = connectionsQueryUri(fromType, from, viaType, via, toType, to, date, dep); - final CharSequence page = ParserUtils.scrape(uri); final Matcher mError = P_CHECK_CONNECTIONS_ERROR.matcher(page);