mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-13 16:20:34 +00:00
ZVV: Replace some line numbers by the line name.
This commit is contained in:
parent
679915bed3
commit
28dd2c8033
3 changed files with 43 additions and 3 deletions
|
@ -846,7 +846,7 @@ public abstract class AbstractHafasClientInterfaceProvider extends AbstractHafas
|
|||
for (int iProd = 0; iProd < prodListLen; iProd++) {
|
||||
final JSONObject prod = prodList.getJSONObject(iProd);
|
||||
final String name = Strings.emptyToNull(prod.getString("name"));
|
||||
final String number = prod.optString("number");
|
||||
final String number = prod.optString("number", null);
|
||||
final int oprIndex = prod.optInt("oprX", -1);
|
||||
final String operator = oprIndex != -1 ? operators.get(oprIndex) : null;
|
||||
final int cls = prod.optInt("cls", -1);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2010-2015 the original author or authors.
|
||||
* Copyright the original author or authors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -22,6 +22,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.Style;
|
||||
import de.schildbach.pte.dto.Style.Shape;
|
||||
|
@ -93,6 +94,27 @@ public class ZvvProvider extends AbstractHafasClientInterfaceProvider {
|
|||
return Product.ALL;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Line newLine(final String operator, final Product product, final String name, final String number) {
|
||||
if (name == null)
|
||||
return super.newLine(operator, product, name, number);
|
||||
final String[] splitName = name.split("\\s+", 2);
|
||||
if (splitName.length != 2)
|
||||
return super.newLine(operator, product, name, number);
|
||||
|
||||
final String newName = name + (number != null ? " (" + number + ")" : "");
|
||||
final String newNumber;
|
||||
if (product == Product.BUS && "Bus".equals(splitName[0]))
|
||||
newNumber = splitName[1];
|
||||
else if (product == Product.BUS && "Tro".equals(splitName[0]))
|
||||
newNumber = splitName[1];
|
||||
else if (product == Product.TRAM && "Trm".equals(splitName[0]))
|
||||
newNumber = splitName[1];
|
||||
else
|
||||
newNumber = splitName[0] + splitName[1];
|
||||
return super.newLine(operator, product, newName, newNumber);
|
||||
}
|
||||
|
||||
private static final Map<String, Style> STYLES = new HashMap<>();
|
||||
|
||||
static {
|
||||
|
|
|
@ -48,7 +48,25 @@ public class ZvvProviderLiveTest extends AbstractProviderLiveTest {
|
|||
|
||||
@Test
|
||||
public void queryDepartures() throws Exception {
|
||||
final QueryDeparturesResult result = queryDepartures("8503000", false);
|
||||
final QueryDeparturesResult result = queryDepartures("8503000", false); // Hauptbahnhof
|
||||
print(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryDeparturesSuburbanTrain() throws Exception {
|
||||
final QueryDeparturesResult result = queryDepartures("8500169", false); // Muriaux
|
||||
print(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryDeparturesTram() throws Exception {
|
||||
final QueryDeparturesResult result = queryDepartures("8591276", false); // Milchbuck
|
||||
print(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryDeparturesTrolley() throws Exception {
|
||||
final QueryDeparturesResult result = queryDepartures("8591177", false); // Hardplatz
|
||||
print(result);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue