mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 14:28:49 +00:00
autocomplete by ajax-getstop where possible
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@591 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
758c24d0de
commit
82413fa953
6 changed files with 85 additions and 12 deletions
|
@ -244,6 +244,10 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
{
|
||||
results.add(new Location(LocationType.POI, localId, lat, lon, null, value));
|
||||
}
|
||||
else if (type == 71) // strange (VBN)
|
||||
{
|
||||
// TODO don't know what to do
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("unknown type " + type + " on " + uri);
|
||||
|
|
|
@ -62,6 +62,27 @@ public class SeptaProvider extends AbstractHafasProvider
|
|||
return TimeZone.getTimeZone("EST");
|
||||
}
|
||||
|
||||
public boolean hasCapabilities(final Capability... capabilities)
|
||||
{
|
||||
for (final Capability capability : capabilities)
|
||||
if (capability == Capability.DEPARTURES)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
||||
+ "ajax-getstop.exe/dny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S=%s?&js=true&";
|
||||
private static final String ENCODING = "ISO-8859-1";
|
||||
|
||||
@Override
|
||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||
{
|
||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
||||
|
||||
return ajaxGetStops(uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected char normalizeType(final String type)
|
||||
{
|
||||
|
@ -96,15 +117,6 @@ public class SeptaProvider extends AbstractHafasProvider
|
|||
return 0;
|
||||
}
|
||||
|
||||
public boolean hasCapabilities(final Capability... capabilities)
|
||||
{
|
||||
for (final Capability capability : capabilities)
|
||||
if (capability == Capability.DEPARTURES)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private final String NEARBY_URI = API_BASE
|
||||
+ "stboard.exe/en?input=%s&selectDate=today&boardType=dep&productsFilter=1111&distance=50&near=Anzeigen";
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ public class SncbProvider extends AbstractHafasProvider
|
|||
{
|
||||
public static final NetworkId NETWORK_ID = NetworkId.SNCB;
|
||||
public static final String OLD_NETWORK_ID = "hari.b-rail.be";
|
||||
private static final String API_BASE = "http://hari.b-rail.be/Hafas/bin/";
|
||||
private static final String API_URI = "http://hari.b-rail.be/Hafas/bin/extxml.exe";
|
||||
|
||||
private static final long PARSER_DAY_ROLLOVER_THRESHOLD_MS = 12 * 60 * 60 * 1000;
|
||||
|
@ -63,6 +64,18 @@ public class SncbProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
||||
+ "ajax-getstop.exe/dny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S=%s?&js=true&";
|
||||
private static final String ENCODING = "ISO-8859-1";
|
||||
|
||||
@Override
|
||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||
{
|
||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
||||
|
||||
return ajaxGetStops(uri);
|
||||
}
|
||||
|
||||
private final String NEARBY_URI = "http://hari.b-rail.be/HAFAS/bin/stboard.exe/en?input=%s&distance=50&near=Anzeigen";
|
||||
|
||||
@Override
|
||||
|
|
|
@ -43,7 +43,7 @@ import de.schildbach.pte.util.ParserUtils;
|
|||
public class VgsProvider extends AbstractHafasProvider
|
||||
{
|
||||
public static final String OLD_NETWORK_ID = "www.vgs-online.de";
|
||||
private static final String API_BASE = "http://www.vgs-online.de/cgi-bin/";
|
||||
private static final String API_BASE = "http://www.vgs-online.de/cgi-bin/"; // "http://www.saarfahrplan.de/cgi-bin/";
|
||||
|
||||
private static final long PARSER_DAY_ROLLOVER_THRESHOLD_MS = 12 * 60 * 60 * 1000;
|
||||
|
||||
|
@ -66,10 +66,16 @@ public class VgsProvider extends AbstractHafasProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
||||
+ "ajax-getstop.exe/eny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=1&getstop=1&noSession=yes&REQ0JourneyStopsB=12&REQ0JourneyStopsS0G=%s?&js=true&";
|
||||
private static final String ENCODING = "ISO-8859-1";
|
||||
|
||||
@Override
|
||||
public List<Location> autocompleteStations(CharSequence constraint) throws IOException
|
||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
||||
|
||||
return ajaxGetStops(uri);
|
||||
}
|
||||
|
||||
private final String NEARBY_URI = API_BASE
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
|
||||
package de.schildbach.pte.live;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import de.schildbach.pte.SeptaProvider;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
|
||||
|
@ -30,6 +33,22 @@ public class SeptaProviderLiveTest
|
|||
{
|
||||
private final SeptaProvider provider = new SeptaProvider();
|
||||
|
||||
@Test
|
||||
public void autocomplete() throws Exception
|
||||
{
|
||||
final List<Location> autocompletes = provider.autocompleteStations("Airport");
|
||||
|
||||
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 nearbyStation() throws Exception
|
||||
{
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
|
||||
package de.schildbach.pte.live;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import de.schildbach.pte.VgsProvider;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
|
||||
|
@ -30,6 +33,22 @@ public class VgsProviderLiveTest
|
|||
{
|
||||
private final VgsProvider provider = new VgsProvider();
|
||||
|
||||
@Test
|
||||
public void autocomplete() throws Exception
|
||||
{
|
||||
final List<Location> autocompletes = provider.autocompleteStations("Flughafen");
|
||||
|
||||
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 nearbyStation() throws Exception
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue