mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-19 16:59:51 +00:00
125 lines
3.1 KiB
Java
125 lines
3.1 KiB
Java
/*
|
|
* Copyright 2010-2014 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
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package de.schildbach.pte;
|
|
|
|
import de.schildbach.pte.dto.Product;
|
|
|
|
/**
|
|
* @author Andreas Schildbach
|
|
*/
|
|
public class VbnProvider extends AbstractHafasProvider
|
|
{
|
|
public static final NetworkId NETWORK_ID = NetworkId.VBN;
|
|
private static final String API_BASE = "http://www.fahrplaner.de/hafas/";
|
|
|
|
public VbnProvider()
|
|
{
|
|
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dny", API_BASE + "query.exe/dn", 10);
|
|
|
|
setStationBoardHasStationTable(false);
|
|
}
|
|
|
|
public NetworkId id()
|
|
{
|
|
return NETWORK_ID;
|
|
}
|
|
|
|
@Override
|
|
protected void setProductBits(final StringBuilder productBits, final Product product)
|
|
{
|
|
if (product == Product.HIGH_SPEED_TRAIN)
|
|
{
|
|
productBits.setCharAt(0, '1'); // Hochgeschwindigkeitszug
|
|
productBits.setCharAt(1, '1'); // IC/EC
|
|
productBits.setCharAt(2, '1'); // Fernverkehrszug
|
|
}
|
|
else if (product == Product.REGIONAL_TRAIN)
|
|
{
|
|
productBits.setCharAt(3, '1'); // Regionalverkehrszug
|
|
}
|
|
else if (product == Product.SUBURBAN_TRAIN)
|
|
{
|
|
productBits.setCharAt(4, '1'); // S-Bahn
|
|
}
|
|
else if (product == Product.SUBWAY)
|
|
{
|
|
productBits.setCharAt(7, '1'); // U-Bahn
|
|
}
|
|
else if (product == Product.TRAM)
|
|
{
|
|
productBits.setCharAt(8, '1'); // Stadtbahn
|
|
}
|
|
else if (product == Product.BUS)
|
|
{
|
|
productBits.setCharAt(5, '1'); // Bus
|
|
}
|
|
else if (product == Product.ON_DEMAND)
|
|
{
|
|
productBits.setCharAt(9, '1'); // Anruf-Sammel-Taxi
|
|
}
|
|
else if (product == Product.FERRY)
|
|
{
|
|
productBits.setCharAt(6, '1'); // Schiff
|
|
}
|
|
else if (product == Product.CABLECAR)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
throw new IllegalArgumentException("cannot handle: " + product);
|
|
}
|
|
}
|
|
|
|
private static final String[] PLACES = { "Bremen", "Bremerhaven", "Oldenburg(Oldb)", "Göttingen" };
|
|
|
|
@Override
|
|
protected String[] splitPlaceAndName(final String name)
|
|
{
|
|
for (final String place : PLACES)
|
|
{
|
|
if (name.startsWith(place + " ") || name.startsWith(place + "-"))
|
|
return new String[] { place, name.substring(place.length() + 1) };
|
|
}
|
|
|
|
return super.splitPlaceAndName(name);
|
|
}
|
|
|
|
@Override
|
|
protected char normalizeType(final String type)
|
|
{
|
|
final String ucType = type.toUpperCase();
|
|
|
|
if ("P".equals(ucType)) // Brohltalbahn
|
|
return 'R';
|
|
|
|
if ("RFTAST".equals(ucType))
|
|
return 'B';
|
|
|
|
if ("BUSFÄHRE".equals(ucType)) // Blexen - Bremerhaven
|
|
return 'F';
|
|
|
|
if ("SEILB".equals(ucType))
|
|
return 'C';
|
|
|
|
final char t = super.normalizeType(type);
|
|
if (t != 0)
|
|
return t;
|
|
|
|
return 0;
|
|
}
|
|
}
|