mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-20 17:29:51 +00:00
119 lines
2.8 KiB
Java
119 lines
2.8 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 java.util.Collection;
|
|
|
|
import de.schildbach.pte.dto.Product;
|
|
|
|
/**
|
|
* @author Andreas Schildbach
|
|
*/
|
|
public class RtProvider extends AbstractHafasProvider
|
|
{
|
|
public static final NetworkId NETWORK_ID = NetworkId.RT;
|
|
private static final String API_BASE = "http://railteam.hafas.de/bin/";
|
|
|
|
public RtProvider()
|
|
{
|
|
super(API_BASE + "stboard.exe/dn", API_BASE + "ajax-getstop.exe/dn", API_BASE + "query.exe/dn", 10, UTF_8);
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public Collection<Product> defaultProducts()
|
|
{
|
|
return Product.ALL;
|
|
}
|
|
|
|
@Override
|
|
protected char normalizeType(final String type)
|
|
{
|
|
final String ucType = type.toUpperCase();
|
|
|
|
if ("E".equals(ucType)) // Romania, Croatia
|
|
return 'R';
|
|
if ("N".equals(ucType)) // Frankreich, Tours
|
|
return 'R';
|
|
|
|
final char t = super.normalizeType(type);
|
|
if (t != 0)
|
|
return t;
|
|
|
|
if (ucType.equals("U70"))
|
|
return '?';
|
|
if (ucType.equals("X70"))
|
|
return '?';
|
|
if (ucType.equals("T84"))
|
|
return '?';
|
|
|
|
return 0;
|
|
}
|
|
}
|