nearby stations and departures for Rhein-Neckar

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@233 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach 2010-10-03 18:15:21 +00:00
parent c5016a846b
commit 3e0e8f6218
2 changed files with 142 additions and 0 deletions

View file

@ -0,0 +1,93 @@
/*
* Copyright 2010 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.Date;
/**
* @author Andreas Schildbach
*/
public class VrnProvider extends AbstractEfaProvider
{
public static final String NETWORK_ID = "fahrplanauskunft.vrn.de";
private static final String API_BASE = "http://fahrplanauskunft.vrn.de/vrn_mobile/";
public boolean hasCapabilities(final Capability... capabilities)
{
for (final Capability capability : capabilities)
if (capability == Capability.DEPARTURES)
return true;
return false;
}
@Override
protected String autocompleteUri(CharSequence constraint)
{
throw new UnsupportedOperationException();
}
@Override
protected String nearbyLatLonUri(final int lat, final int lon)
{
return null;
}
private static final String NEARBY_STATION_URI = API_BASE
+ "XSLT_DM_REQUEST"
+ "?outputFormat=XML&coordOutputFormat=WGS84&name_dm=%s&type_dm=stop&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&mergeDep=1&useAllStops=1&mode=direct&deleteAssignedStop=0";
@Override
protected String nearbyStationUri(final String stationId)
{
return String.format(NEARBY_STATION_URI, stationId);
}
public StationLocationResult stationLocation(String stationId) throws IOException
{
throw new UnsupportedOperationException();
}
public String departuresQueryUri(final String stationId, final int maxDepartures)
{
final StringBuilder uri = new StringBuilder();
uri.append(API_BASE).append("XSLT_DM_REQUEST");
uri.append("?outputFormat=XML");
uri.append("&coordOutputFormat=WGS84");
uri.append("&type_dm=stop");
uri.append("&name_dm=").append(stationId);
uri.append("&mode=direct");
return uri.toString();
}
public QueryConnectionsResult queryConnections(LocationType fromType, String from, LocationType viaType, String via, LocationType toType,
String to, Date date, boolean dep, WalkSpeed walkSpeed) throws IOException
{
throw new UnsupportedOperationException();
}
public QueryConnectionsResult queryMoreConnections(String uri) throws IOException
{
throw new UnsupportedOperationException();
}
public GetConnectionDetailsResult getConnectionDetails(String connectionUri) throws IOException
{
throw new UnsupportedOperationException();
}
}

View file

@ -0,0 +1,49 @@
/*
* Copyright 2010 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.List;
import org.junit.Test;
import de.schildbach.pte.QueryDeparturesResult;
import de.schildbach.pte.Station;
import de.schildbach.pte.VrnProvider;
/**
* @author Andreas Schildbach
*/
public class VrnProviderLiveTest
{
private final VrnProvider provider = new VrnProvider();
@Test
public void nearbyStation() throws Exception
{
final List<Station> results = provider.nearbyStations("6032236", 0, 0, 0, 0);
System.out.println(results.size() + " " + results);
}
@Test
public void departures() throws Exception
{
final QueryDeparturesResult result = provider.queryDepartures(provider.departuresQueryUri("6032236", 0));
System.out.println(result.departures.size() + " " + result.departures);
}
}