git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@771 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach@gmail.com 2011-09-10 10:11:05 +00:00
parent 959fff56db
commit df12d363da
4 changed files with 301 additions and 1 deletions

View file

@ -940,6 +940,96 @@ public abstract class AbstractEfaProvider implements NetworkProvider
return 'R' + name;
if ("RegionalExpress".equals(noTrainName)) // Liechtenstein
return 'R' + name;
if ("Ostdeutsche".equals(type)) // Bayern
return 'R' + type;
if ("Südwestdeutsche".equals(type)) // Bayern
return 'R' + type;
if ("Mitteldeutsche".equals(type)) // Bayern
return 'R' + type;
if ("Norddeutsche".equals(type)) // Bayern
return 'R' + type;
if ("Hellertalbahn".equals(type)) // Bayern
return 'R' + type;
if ("Veolia".equals(type)) // Bayern
return 'R' + type;
if ("vectus".equals(type)) // Bayern
return 'R' + type;
if ("Hessische".equals(type)) // Bayern
return 'R' + type;
if ("Niederbarnimer".equals(type)) // Bayern
return 'R' + type;
if ("Rurtalbahn".equals(type)) // Bayern
return 'R' + type;
if ("Rhenus".equals(type)) // Bayern
return 'R' + type;
if ("Mittelrheinbahn".equals(type)) // Bayern
return 'R' + type;
if ("Hohenzollerische".equals(type)) // Bayern
return 'R' + type;
if ("Städtebahn".equals(type)) // Bayern
return 'R' + type;
if ("Ortenau-S-Bahn".equals(type)) // Bayern
return 'R' + type;
if ("Daadetalbahn".equals(type)) // Bayern
return 'R' + type;
if ("Mainschleifenbahn".equals(type)) // Bayern
return 'R' + type;
if ("Nordbahn".equals(type)) // Bayern
return 'R' + type;
if ("Harzer".equals(type)) // Bayern
return 'R' + type;
if ("cantus".equals(type)) // Bayern
return 'R' + type;
if ("DPF".equals(type)) // Bayern, Vogtland-Express
return 'R' + type;
if ("Freiberger".equals(type)) // Bayern
return 'R' + type;
if ("metronom".equals(type)) // Bayern
return 'R' + type;
if ("Prignitzer".equals(type)) // Bayern
return 'R' + type;
if ("Sächsisch-Oberlausitzer".equals(type)) // Bayern
return 'R' + type;
if ("Ostseeland".equals(type)) // Bayern
return 'R' + type;
if ("NordOstseeBahn".equals(type)) // Bayern
return 'R' + type;
if ("ELBE-WESER".equals(type)) // Bayern
return 'R' + type;
if ("TRILEX".equals(type)) // Bayern
return 'R' + type;
if ("Schleswig-Holstein-Bahn".equals(type)) // Bayern
return 'R' + type;
if ("Vetter".equals(type)) // Bayern
return 'R' + type;
if ("Dessau-Wörlitzer".equals(type)) // Bayern
return 'R' + type;
if ("NATURPARK-EXPRESS".equals(type)) // Bayern
return 'R' + type;
if ("Usedomer".equals(type)) // Bayern
return 'R' + type;
if ("Märkische".equals(type)) // Bayern
return 'R' + type;
if ("Vulkan-Eifel-Bahn".equals(type)) // Bayern
return 'R' + type;
if ("Kandertalbahn".equals(type)) // Bayern
return 'R' + type;
if ("RAD-WANDER-SHUTTLE".equals(type)) // Bayern, Hohenzollerische Landesbahn
return 'R' + type;
if ("RADEXPRESS".equals(type)) // Bayern, RADEXPRESS EYACHTÄLER
return 'R' + type;
if ("Dampfzug".equals(type)) // Bayern
return 'R' + type;
if ("Wutachtalbahn".equals(type)) // Bayern
return 'R' + type;
if ("Grensland-Express".equals(type)) // Bayern
return 'R' + type;
if ("Mecklenburgische".equals(type)) // Bayern
return 'R' + type;
if ("Bentheimer".equals(type)) // Bayern
return 'R' + type;
if ("Pressnitztalbahn".equals(type)) // Bayern
return 'R' + type;
if (type.equals("BSB")) // Breisgau-S-Bahn
return 'S' + str;
@ -952,6 +1042,8 @@ public abstract class AbstractEfaProvider implements NetworkProvider
final Matcher m = P_LINE_S.matcher(name);
if (m.find())
return 'S' + m.group(1);
if ("Breisgau-S-Bahn".equals(type)) // Bayern
return 'S' + type;
if (P_LINE_U.matcher(type).matches())
return 'U' + str;

View file

@ -0,0 +1,68 @@
/*
* Copyright 2010, 2011 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.io.IOException;
import java.util.List;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
/**
* @author Andreas Schildbach
*/
public class BayernProvider extends AbstractEfaProvider
{
public static final NetworkId NETWORK_ID = NetworkId.BAYERN;
private final static String API_BASE = "http://bayern-fahrplan.defas-fgi.de:50200/standard/";
public BayernProvider()
{
super(API_BASE, null);
}
public NetworkId id()
{
return NETWORK_ID;
}
public boolean hasCapabilities(Capability... capabilities)
{
for (final Capability capability : capabilities)
if (capability == Capability.AUTOCOMPLETE_ONE_LINE || capability == Capability.DEPARTURES || capability == Capability.CONNECTIONS)
return true;
return false;
}
private static final String NEARBY_STATION_URI = API_BASE
+ "XSLT_DM_REQUEST"
+ "?outputFormat=XML&coordOutputFormat=WGS84&type_dm=stop&name_dm=%s&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct";
@Override
protected String nearbyStationUri(final int stationId)
{
return String.format(NEARBY_STATION_URI, stationId);
}
@Override
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
{
return xmlStopfinderRequest(new Location(LocationType.ANY, 0, null, constraint.toString()));
}
}

View file

@ -26,7 +26,7 @@ public enum NetworkId
RT,
// Germany
DB, BVG, VBB, RMV, NVV, VRT, MVV, INVG, AVV, VMV, HVV, SH, GVH, BSVAG, BSAG, VBN, NASA, VVO, VMS, VGS, VRR, VRS, MVG, NPH, VRN, VVS, NALDO, DING, KVV, VVM, VAGFR, NVBW,
DB, BVG, VBB, RMV, NVV, VRT, BAYERN, MVV, INVG, AVV, VMV, HVV, SH, GVH, BSVAG, BSAG, VBN, NASA, VVO, VMS, VGS, VRR, VRS, MVG, NPH, VRN, VVS, NALDO, DING, KVV, VVM, VAGFR, NVBW,
// Austria
OEBB, VOR, LINZ, SVV, VMOBIL, IVB, STV,

View file

@ -0,0 +1,140 @@
/*
* Copyright 2010, 2011 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.live;
import java.util.Date;
import java.util.List;
import org.junit.Test;
import de.schildbach.pte.BayernProvider;
import de.schildbach.pte.NetworkProvider.WalkSpeed;
import de.schildbach.pte.dto.Location;
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyStationsResult;
import de.schildbach.pte.dto.QueryConnectionsResult;
import de.schildbach.pte.dto.QueryDeparturesResult;
/**
* @author Andreas Schildbach
*/
public class BayernProviderLiveTest
{
private BayernProvider provider = new BayernProvider();
private static final String ALL_PRODUCTS = "IRSUTBFC";
@Test
public void nearbyStations() throws Exception
{
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.STATION, 3001459), 0, 0);
System.out.println(result.stations.size() + " " + result.stations);
}
@Test
public void nearbyStationsByCoordinate() throws Exception
{
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.ADDRESS, 48135232, 11560650), 0, 0);
System.out.println(result.stations.size() + " " + result.stations);
}
@Test
public void queryDepartures() throws Exception
{
final QueryDeparturesResult result = provider.queryDepartures(80001083, 0, false);
System.out.println(result.stationDepartures);
}
@Test
public void autocompleteIncomplete() throws Exception
{
final List<Location> autocompletes = provider.autocompleteStations("Marien");
list(autocompletes);
}
private void list(final List<Location> autocompletes)
{
System.out.print(autocompletes.size() + " ");
for (final Location autocomplete : autocompletes)
System.out.print(autocomplete.toDebugString() + " ");
System.out.println();
}
@Test
public void shortConnection() throws Exception
{
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 80000793, "München", "Ostbahnhof"), null, new Location(
LocationType.STATION, 80000799, "München", "Pasing"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
}
@Test
public void longConnection() throws Exception
{
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 1005530, "Starnberg", "Arbeitsamt"), null,
new Location(LocationType.STATION, 3001459, "Nürnberg", "Fallrohrstraße"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
// seems like there are no more connections all the time
}
@Test
public void connectionBetweenCoordinates() throws Exception
{
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, 48165238, 11577473), null,
new Location(LocationType.ADDRESS, 0, 47987199, 11326532), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
}
@Test
public void connectionBetweenCoordinateAndStation() throws Exception
{
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, 48238341, 11478230), null,
new Location(LocationType.ANY, 0, null, "Ostbahnhof"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
}
@Test
public void connectionBetweenAddresses() throws Exception
{
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, null, "München, Maximilianstr. 1"),
null, new Location(LocationType.ADDRESS, 0, null, "Starnberg, Jahnstraße 50"), new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
}
@Test
public void connectionBetweenStationAndAddress() throws Exception
{
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.STATION, 1220, null, "Josephsburg"), null,
new Location(LocationType.ADDRESS, 0, 48188018, 11574239, null, "München Frankfurter Ring 35"), new Date(), true, ALL_PRODUCTS,
WalkSpeed.NORMAL);
System.out.println(result);
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
System.out.println(moreResult);
}
}