Zürich directions

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@595 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach@gmail.com 2011-05-03 23:01:45 +00:00
parent adcb971057
commit b07910898b
3 changed files with 24 additions and 5 deletions

View file

@ -689,7 +689,12 @@ public abstract class AbstractHafasProvider implements NetworkProvider
XmlPullUtil.exit(pp); XmlPullUtil.exit(pp);
XmlPullUtil.exit(pp); XmlPullUtil.exit(pp);
final String lineStr = _normalizeLine(category, name, longCategory); final char type = normalizeType(category);
final String lineStr;
if (type != 0)
lineStr = type + name;
else
lineStr = _normalizeLine(category, name); // for compatibility
line = new Line(lineStr, lineColors(lineStr)); line = new Line(lineStr, lineColors(lineStr));
} }
else if (tag.equals("Walk") || tag.equals("Transfer") || tag.equals("GisRoute")) else if (tag.equals("Walk") || tag.equals("Transfer") || tag.equals("GisRoute"))
@ -1188,7 +1193,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
private static final Pattern P_LINE_S = Pattern.compile("S\\d+"); private static final Pattern P_LINE_S = Pattern.compile("S\\d+");
private static final Pattern P_LINE_SN = Pattern.compile("SN\\d*"); private static final Pattern P_LINE_SN = Pattern.compile("SN\\d*");
private final String _normalizeLine(final String type, final String name, final String longCategory) private final String _normalizeLine(final String type, final String name)
{ {
final String normalizedType = type.split(" ", 2)[0]; final String normalizedType = type.split(" ", 2)[0];
final String normalizedName = normalizeWhitespace(name); final String normalizedName = normalizeWhitespace(name);
@ -1316,8 +1321,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
if ("TRN".equals(normalizedType)) if ("TRN".equals(normalizedType))
return "?" + normalizedName; return "?" + normalizedName;
throw new IllegalStateException("cannot normalize type '" + normalizedType + "' (" + type + ") name '" + normalizedName + "' longCategory '" throw new IllegalStateException("cannot normalize type '" + normalizedType + "' (" + type + ") name '" + normalizedName + "'");
+ longCategory + "'");
} }
private static final Pattern P_CONNECTION_ID = Pattern.compile("co=(C\\d+-\\d+)&"); private static final Pattern P_CONNECTION_ID = Pattern.compile("co=(C\\d+-\\d+)&");

View file

@ -48,7 +48,7 @@ public class ZvvProvider extends AbstractHafasProvider
public boolean hasCapabilities(Capability... capabilities) public boolean hasCapabilities(Capability... capabilities)
{ {
for (final Capability capability : capabilities) for (final Capability capability : capabilities)
if (capability == Capability.DEPARTURES) if (capability == Capability.DEPARTURES || capability == Capability.CONNECTIONS)
return true; return true;
return false; return false;

View file

@ -17,13 +17,17 @@
package de.schildbach.pte.live; package de.schildbach.pte.live;
import java.util.Date;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.Test;
import de.schildbach.pte.ZvvProvider; import de.schildbach.pte.ZvvProvider;
import de.schildbach.pte.NetworkProvider.WalkSpeed;
import de.schildbach.pte.dto.Location; import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult; import de.schildbach.pte.dto.NearbyStationsResult;
import de.schildbach.pte.dto.QueryConnectionsResult;
import de.schildbach.pte.dto.QueryDeparturesResult; import de.schildbach.pte.dto.QueryDeparturesResult;
/** /**
@ -32,6 +36,7 @@ import de.schildbach.pte.dto.QueryDeparturesResult;
public class ZvvProviderLiveTest public class ZvvProviderLiveTest
{ {
private final ZvvProvider provider = new ZvvProvider(); private final ZvvProvider provider = new ZvvProvider();
private static final String ALL_PRODUCTS = "IRSUTBFC";
@Test @Test
public void autocomplete() throws Exception public void autocomplete() throws Exception
@ -64,4 +69,14 @@ public class ZvvProviderLiveTest
System.out.println(result.stationDepartures); System.out.println(result.stationDepartures);
} }
@Test
public void shortConnection() throws Exception
{
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 8503000, null, "Zürich HB"), null,
new Location(LocationType.STATION, 8507785, null, "Bern, Hauptbahnhof"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
}
} }