mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-16 01:19:49 +00:00
Extract JSON get stops parameters to method
This commit is contained in:
parent
4a7743d094
commit
7acd4a0afa
21 changed files with 95 additions and 106 deletions
|
@ -347,6 +347,18 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected StringBuilder jsonGetStopsParameters(final CharSequence constraint)
|
||||||
|
{
|
||||||
|
final StringBuilder parameters = new StringBuilder();
|
||||||
|
parameters.append("?getstop=1");
|
||||||
|
parameters.append("&REQ0JourneyStopsS0A=255");
|
||||||
|
parameters.append("&REQ0JourneyStopsS0G=").append(ParserUtils.urlEncode(constraint.toString(), jsonGetStopsEncoding)).append("?");
|
||||||
|
// parameters.append("&REQ0JourneyStopsB=12");
|
||||||
|
parameters.append("&js=true");
|
||||||
|
|
||||||
|
return parameters;
|
||||||
|
}
|
||||||
|
|
||||||
private static final Pattern P_AJAX_GET_STOPS_JSON = Pattern.compile("SLs\\.sls\\s*=\\s*(.*?);\\s*SLs\\.showSuggestion\\(\\);", Pattern.DOTALL);
|
private static final Pattern P_AJAX_GET_STOPS_JSON = Pattern.compile("SLs\\.sls\\s*=\\s*(.*?);\\s*SLs\\.showSuggestion\\(\\);", Pattern.DOTALL);
|
||||||
private static final Pattern P_AJAX_GET_STOPS_ID = Pattern.compile(".*?@L=(\\d+)@.*?");
|
private static final Pattern P_AJAX_GET_STOPS_ID = Pattern.compile(".*?@L=(\\d+)@.*?");
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -196,13 +195,12 @@ public final class BahnProvider extends AbstractHafasProvider
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ISO_8859_1));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -503,13 +502,12 @@ public final class BvgProvider extends AbstractHafasProvider
|
||||||
ParserUtils.parseEuropeanTime(calendar, m.group(2));
|
ParserUtils.parseEuropeanTime(calendar, m.group(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.bin/dny?tpl=suggest2json&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ISO_8859_1));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,7 +19,6 @@ package de.schildbach.pte;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -29,7 +28,6 @@ import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ireland, Dublin
|
* Ireland, Dublin
|
||||||
|
@ -137,13 +135,12 @@ public class EireannProvider extends AbstractHafasProvider
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.bin/en?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ISO_8859_1));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Pattern P_NORMALIZE_LINE = Pattern.compile("([^#]+)#");
|
private static final Pattern P_NORMALIZE_LINE = Pattern.compile("([^#]+)#");
|
||||||
|
|
|
@ -20,14 +20,12 @@ package de.schildbach.pte;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.LocationType;
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -171,14 +169,12 @@ public class NriProvider extends AbstractHafasProvider
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
|
||||||
+ "ajax-getstop.exe/ony?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsS0B=5&REQ0JourneyStopsB=12&getstop=1&noSession=yes&REQ0JourneyStopsS0G=%s?&js=true&";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ISO_8859_1));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
|
@ -31,7 +30,6 @@ import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.dto.QueryTripsContext;
|
import de.schildbach.pte.dto.QueryTripsContext;
|
||||||
import de.schildbach.pte.dto.QueryTripsResult;
|
import de.schildbach.pte.dto.QueryTripsResult;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -44,6 +42,8 @@ public class NsProvider extends AbstractHafasProvider
|
||||||
public NsProvider()
|
public NsProvider()
|
||||||
{
|
{
|
||||||
super(API_BASE + "stboard.exe/nn", API_BASE + "ajax-getstop.exe/nny", API_BASE + "query.exe/nn", 10, null);
|
super(API_BASE + "stboard.exe/nn", API_BASE + "ajax-getstop.exe/nny", API_BASE + "query.exe/nn", 10, null);
|
||||||
|
|
||||||
|
setJsonGetStopsEncoding(UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkId id()
|
public NetworkId id()
|
||||||
|
@ -133,14 +133,12 @@ public class NsProvider extends AbstractHafasProvider
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
|
||||||
+ "ajax-getstop.exe/nny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S=%s?&js=true&";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ISO_8859_1));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
|
@ -31,7 +30,6 @@ import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.dto.QueryTripsContext;
|
import de.schildbach.pte.dto.QueryTripsContext;
|
||||||
import de.schildbach.pte.dto.QueryTripsResult;
|
import de.schildbach.pte.dto.QueryTripsResult;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -184,14 +182,12 @@ public class OebbProvider extends AbstractHafasProvider
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
|
||||||
+ "ajax-getstop.exe/dny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S=%s?&js=true&";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ISO_8859_1));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
|
@ -31,7 +30,6 @@ import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.dto.QueryTripsContext;
|
import de.schildbach.pte.dto.QueryTripsContext;
|
||||||
import de.schildbach.pte.dto.QueryTripsResult;
|
import de.schildbach.pte.dto.QueryTripsResult;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -192,13 +190,12 @@ public class RmvProvider extends AbstractHafasProvider
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), UTF_8));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,14 +20,12 @@ package de.schildbach.pte;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.LocationType;
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -142,13 +140,12 @@ public class RtProvider extends AbstractHafasProvider
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ISO_8859_1));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,14 +20,12 @@ package de.schildbach.pte;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.LocationType;
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -136,13 +134,13 @@ public class SbbProvider extends AbstractHafasProvider
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ISO_8859_1));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
|
return jsonGetStops(uri.toString());
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,7 +20,6 @@ package de.schildbach.pte;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -30,7 +29,6 @@ import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -184,14 +182,12 @@ public class SeProvider extends AbstractHafasProvider
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
|
||||||
+ "ajax-getstop.exe/sny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=7&getstop=1&noSession=yes&REQ0JourneyStopsB=12&REQ0JourneyStopsS0G=&S=%s";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ISO_8859_1));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -287,14 +287,12 @@ public class SeptaProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
|
||||||
+ "ajax-getstop.exe/dny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S=%s?&js=true&";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ISO_8859_1));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,14 +20,12 @@ package de.schildbach.pte;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.LocationType;
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -40,6 +38,8 @@ public class SncbProvider extends AbstractHafasProvider
|
||||||
public SncbProvider()
|
public SncbProvider()
|
||||||
{
|
{
|
||||||
super(API_BASE + "stboard.exe/nn", API_BASE + "ajax-getstop.exe/nny", API_BASE + "query.exe/nn", 16, null);
|
super(API_BASE + "stboard.exe/nn", API_BASE + "ajax-getstop.exe/nny", API_BASE + "query.exe/nn", 16, null);
|
||||||
|
|
||||||
|
setJsonGetStopsEncoding(UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkId id()
|
public NetworkId id()
|
||||||
|
@ -126,14 +126,12 @@ public class SncbProvider extends AbstractHafasProvider
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
|
||||||
+ "ajax-getstop.exe/nny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S=%s?&js=true&";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ISO_8859_1));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -38,7 +37,6 @@ import de.schildbach.pte.dto.QueryTripsContext;
|
||||||
import de.schildbach.pte.dto.QueryTripsResult;
|
import de.schildbach.pte.dto.QueryTripsResult;
|
||||||
import de.schildbach.pte.dto.Style;
|
import de.schildbach.pte.dto.Style;
|
||||||
import de.schildbach.pte.dto.Style.Shape;
|
import de.schildbach.pte.dto.Style.Shape;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -50,7 +48,7 @@ public class StockholmProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
public StockholmProvider()
|
public StockholmProvider()
|
||||||
{
|
{
|
||||||
super(API_BASE + "stboard.exe/sn", API_BASE + "ajax-getstop.exe/sny", API_BASE + "query.exe/sn", 7, null, null, null);
|
super(API_BASE + "stboard.exe/sn", API_BASE + "ajax-getstop.exe/sny", API_BASE + "query.exe/sn", 7, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkId id()
|
public NetworkId id()
|
||||||
|
@ -179,14 +177,12 @@ public class StockholmProvider extends AbstractHafasProvider
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
|
||||||
+ "ajax-getstop.exe/sny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=7&getstop=1&noSession=yes&REQ0JourneyStopsB=12&REQ0JourneyStopsS0G=&S=%s";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ISO_8859_1));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,7 +19,6 @@ package de.schildbach.pte;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -28,7 +27,6 @@ import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -178,12 +176,11 @@ public class VbbProvider extends AbstractHafasProvider
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), UTF_8));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,12 @@ package de.schildbach.pte;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.LocationType;
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.Product;
|
import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -141,14 +139,12 @@ public class VbnProvider extends AbstractHafasProvider
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE
|
|
||||||
+ "ajax-getstop.exe/dny?start=1&tpl=suggest2json&REQ0JourneyStopsS0A=255&REQ0JourneyStopsS0B=5&REQ0JourneyStopsB=12&getstop=1&noSession=yes&REQ0JourneyStopsS0G=%s?&js=true&";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ISO_8859_1));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
|
@ -31,7 +30,6 @@ import de.schildbach.pte.dto.Product;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.dto.QueryTripsContext;
|
import de.schildbach.pte.dto.QueryTripsContext;
|
||||||
import de.schildbach.pte.dto.QueryTripsResult;
|
import de.schildbach.pte.dto.QueryTripsResult;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -160,13 +158,12 @@ public class VgsProvider extends AbstractHafasProvider
|
||||||
return xmlQueryDepartures(uri.toString(), stationId);
|
return xmlQueryDepartures(uri.toString(), stationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String AUTOCOMPLETE_URI = API_BASE + "ajax-getstop.exe/dn?getstop=1&REQ0JourneyStopsS0A=255&S=%s?&js=true&";
|
|
||||||
|
|
||||||
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(Locale.ENGLISH, AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ISO_8859_1));
|
final StringBuilder uri = new StringBuilder(getStopEndpoint);
|
||||||
|
uri.append(jsonGetStopsParameters(constraint));
|
||||||
|
|
||||||
return jsonGetStops(uri);
|
return jsonGetStops(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -73,6 +73,14 @@ public class NsProviderLiveTest extends AbstractProviderLiveTest
|
||||||
print(autocompletes);
|
print(autocompletes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void autocompleteUmlaut() throws Exception
|
||||||
|
{
|
||||||
|
final List<Location> autocompletes = provider.autocompleteStations("Brüssel");
|
||||||
|
|
||||||
|
print(autocompletes);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shortTrip() throws Exception
|
public void shortTrip() throws Exception
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class RtProviderLiveTest extends AbstractProviderLiveTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void autoComplete() throws Exception
|
public void autocomplete() throws Exception
|
||||||
{
|
{
|
||||||
final List<Location> autocompletes = provider.autocompleteStations("haupt");
|
final List<Location> autocompletes = provider.autocompleteStations("haupt");
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class RtProviderLiveTest extends AbstractProviderLiveTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void autoCompleteAddress() throws Exception
|
public void autocompleteAddress() throws Exception
|
||||||
{
|
{
|
||||||
final List<Location> autocompletes = provider.autocompleteStations("Dorfstrasse 10, Dällikon, Schweiz");
|
final List<Location> autocompletes = provider.autocompleteStations("Dorfstrasse 10, Dällikon, Schweiz");
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class RtProviderLiveTest extends AbstractProviderLiveTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void autoCompleteEncoding() throws Exception
|
public void autocompleteEncoding() throws Exception
|
||||||
{
|
{
|
||||||
List<Location> autocompletes = provider.autocompleteStations("Dorfstrasse 1, Schäftland");
|
List<Location> autocompletes = provider.autocompleteStations("Dorfstrasse 1, Schäftland");
|
||||||
assertEquals("Schöftland, Dorfstrasse", autocompletes.get(0).name);
|
assertEquals("Schöftland, Dorfstrasse", autocompletes.get(0).name);
|
||||||
|
|
|
@ -69,7 +69,15 @@ public class SeProviderLiveTest extends AbstractProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autocomplete() throws Exception
|
public void autocomplete() throws Exception
|
||||||
{
|
{
|
||||||
final List<Location> autocompletes = provider.autocompleteStations("Luleå Airport");
|
final List<Location> autocompletes = provider.autocompleteStations("Airport");
|
||||||
|
|
||||||
|
print(autocompletes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void autocompleteUmlaut() throws Exception
|
||||||
|
{
|
||||||
|
final List<Location> autocompletes = provider.autocompleteStations("Luleå");
|
||||||
|
|
||||||
print(autocompletes);
|
print(autocompletes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,15 @@ public class SncbProviderLiveTest extends AbstractProviderLiveTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void autoCompleteAddress() throws Exception
|
public void autocompleteUmlaut() throws Exception
|
||||||
|
{
|
||||||
|
final List<Location> autocompletes = provider.autocompleteStations("Brüssel");
|
||||||
|
|
||||||
|
print(autocompletes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void autocompleteAddress() throws Exception
|
||||||
{
|
{
|
||||||
final List<Location> autocompletes = provider.autocompleteStations("Rue Paul Janson 9, 1030 Bruxelles");
|
final List<Location> autocompletes = provider.autocompleteStations("Rue Paul Janson 9, 1030 Bruxelles");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue