mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-17 12:39:49 +00:00
autocomplete parses stationid where possible
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@129 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
d0162ed846
commit
c632118a6e
6 changed files with 36 additions and 19 deletions
|
@ -51,9 +51,9 @@ public final class BahnProvider implements NetworkProvider
|
|||
}
|
||||
|
||||
private static final String NAME_URL = "http://mobile.bahn.de/bin/mobil/bhftafel.exe/dox?input=";
|
||||
private static final Pattern P_SINGLE_NAME = Pattern
|
||||
.compile(".*<input type=\"hidden\" name=\"input\" value=\"(.+?)#\\d+?\" />.*", Pattern.DOTALL);
|
||||
private static final Pattern P_MULTI_NAME = Pattern.compile("<option value=\".+?#\\d+?\">(.+?)</option>", Pattern.DOTALL);
|
||||
private static final Pattern P_SINGLE_NAME = Pattern.compile(".*<input type=\"hidden\" name=\"input\" value=\"(.+?)#(\\d+)\" />.*",
|
||||
Pattern.DOTALL);
|
||||
private static final Pattern P_MULTI_NAME = Pattern.compile("<option value=\".+?#(\\d+)\">(.+?)</option>", Pattern.DOTALL);
|
||||
|
||||
public List<Autocomplete> autocompleteStations(final CharSequence constraint) throws IOException
|
||||
{
|
||||
|
@ -64,13 +64,13 @@ public final class BahnProvider implements NetworkProvider
|
|||
final Matcher mSingle = P_SINGLE_NAME.matcher(page);
|
||||
if (mSingle.matches())
|
||||
{
|
||||
results.add(new Autocomplete(0, ParserUtils.resolveEntities(mSingle.group(1))));
|
||||
results.add(new Autocomplete(Integer.parseInt(mSingle.group(2)), ParserUtils.resolveEntities(mSingle.group(1))));
|
||||
}
|
||||
else
|
||||
{
|
||||
final Matcher mMulti = P_MULTI_NAME.matcher(page);
|
||||
while (mMulti.find())
|
||||
results.add(new Autocomplete(0, ParserUtils.resolveEntities(mMulti.group(1))));
|
||||
results.add(new Autocomplete(Integer.parseInt(mMulti.group(1)), ParserUtils.resolveEntities(mMulti.group(2))));
|
||||
}
|
||||
|
||||
return results;
|
||||
|
|
|
@ -137,6 +137,21 @@ public class MvvProvider implements NetworkProvider
|
|||
public StationLocationResult stationLocation(final String stationId) throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
// private Pattern P_GEO =
|
||||
// Pattern.compile(".*?var latact = \"(\\d+\\.\\d+)\";.*?var lonact = \"(\\d+\\.\\d+)\";.*?", Pattern.DOTALL);
|
||||
|
||||
// final String urlGeo =
|
||||
// "http://www.mvv-muenchen.de/de/home/fahrgastinformation/mvv-netz/sis/sdb/googlemaps/index.html?id="
|
||||
// + id;
|
||||
// final CharSequence pageGeo = ParserUtils.scrape(urlGeo);
|
||||
// final Matcher mGeo = P_GEO.matcher(pageGeo);
|
||||
// if (mGeo.matches())
|
||||
// {
|
||||
// mvvLat = Double.parseDouble(mGeo.group(1));
|
||||
// mvvLon = Double.parseDouble(mGeo.group(2));
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private String connectionsQueryUri(final LocationType fromType, final String from, final LocationType viaType, final String via,
|
||||
|
|
|
@ -33,7 +33,7 @@ public class OebbProvider implements NetworkProvider
|
|||
private static final String NAME_URL = "http://fahrplan.oebb.at/bin/stboard.exe/dn?input=";
|
||||
private static final Pattern P_SINGLE_NAME = Pattern
|
||||
.compile(".*?<input type=\"hidden\" name=\"input\" value=\"(.+?)#(\\d+)\">.*", Pattern.DOTALL);
|
||||
private static final Pattern P_MULTI_NAME = Pattern.compile("<option value=\".+?#(\\d+?)\">(.+?)</option>", Pattern.DOTALL);
|
||||
private static final Pattern P_MULTI_NAME = Pattern.compile("<option value=\".+?#(\\d+)\">(.+?)</option>", Pattern.DOTALL);
|
||||
|
||||
public List<Autocomplete> autocompleteStations(final CharSequence constraint) throws IOException
|
||||
{
|
||||
|
@ -44,13 +44,13 @@ public class OebbProvider implements NetworkProvider
|
|||
final Matcher mSingle = P_SINGLE_NAME.matcher(page);
|
||||
if (mSingle.matches())
|
||||
{
|
||||
results.add(new Autocomplete(0, ParserUtils.resolveEntities(mSingle.group(1))));
|
||||
results.add(new Autocomplete(Integer.parseInt(mSingle.group(2)), ParserUtils.resolveEntities(mSingle.group(1))));
|
||||
}
|
||||
else
|
||||
{
|
||||
final Matcher mMulti = P_MULTI_NAME.matcher(page);
|
||||
while (mMulti.find())
|
||||
results.add(new Autocomplete(0, ParserUtils.resolveEntities(mMulti.group(2))));
|
||||
results.add(new Autocomplete(Integer.parseInt(mMulti.group(1)), ParserUtils.resolveEntities(mMulti.group(2))));
|
||||
}
|
||||
|
||||
return results;
|
||||
|
|
|
@ -52,9 +52,10 @@ public class RmvProvider implements NetworkProvider
|
|||
}
|
||||
|
||||
private static final String NAME_URL = "http://www.rmv.de/auskunft/bin/jp/stboard.exe/dox?input=";
|
||||
private static final Pattern P_SINGLE_NAME = Pattern
|
||||
.compile(".*<input type=\"hidden\" name=\"input\" value=\"(.+?)#\\d+?\" />.*", Pattern.DOTALL);
|
||||
private static final Pattern P_MULTI_NAME = Pattern.compile("<a href=\"/auskunft/bin/jp/stboard.exe/dox.*?\">\\s*(.*?)\\s*</a>", Pattern.DOTALL);
|
||||
private static final Pattern P_SINGLE_NAME = Pattern.compile(".*<input type=\"hidden\" name=\"input\" value=\"(.+?)#(\\d+)\" />.*",
|
||||
Pattern.DOTALL);
|
||||
private static final Pattern P_MULTI_NAME = Pattern.compile("<a href=\"/auskunft/bin/jp/stboard.exe/dox.*?input=(\\d+)&.*?\">\\s*(.*?)\\s*</a>",
|
||||
Pattern.DOTALL);
|
||||
|
||||
public List<Autocomplete> autocompleteStations(final CharSequence constraint) throws IOException
|
||||
{
|
||||
|
@ -65,13 +66,13 @@ public class RmvProvider implements NetworkProvider
|
|||
final Matcher mSingle = P_SINGLE_NAME.matcher(page);
|
||||
if (mSingle.matches())
|
||||
{
|
||||
results.add(new Autocomplete(0, ParserUtils.resolveEntities(mSingle.group(1))));
|
||||
results.add(new Autocomplete(Integer.parseInt(mSingle.group(2)), ParserUtils.resolveEntities(mSingle.group(1))));
|
||||
}
|
||||
else
|
||||
{
|
||||
final Matcher mMulti = P_MULTI_NAME.matcher(page);
|
||||
while (mMulti.find())
|
||||
results.add(new Autocomplete(0, ParserUtils.resolveEntities(mMulti.group(1))));
|
||||
results.add(new Autocomplete(Integer.parseInt(mMulti.group(1)), ParserUtils.resolveEntities(mMulti.group(2))));
|
||||
}
|
||||
|
||||
return results;
|
||||
|
|
|
@ -66,13 +66,13 @@ public class SbbProvider implements NetworkProvider
|
|||
final Matcher mSingle = P_SINGLE_NAME.matcher(page);
|
||||
if (mSingle.matches())
|
||||
{
|
||||
results.add(new Autocomplete(0, ParserUtils.resolveEntities(mSingle.group(1))));
|
||||
results.add(new Autocomplete(Integer.parseInt(mSingle.group(2)), ParserUtils.resolveEntities(mSingle.group(1))));
|
||||
}
|
||||
else
|
||||
{
|
||||
final Matcher mMulti = P_MULTI_NAME.matcher(page);
|
||||
while (mMulti.find())
|
||||
results.add(new Autocomplete(0, ParserUtils.resolveEntities(mMulti.group(2))));
|
||||
results.add(new Autocomplete(Integer.parseInt(mMulti.group(1)), ParserUtils.resolveEntities(mMulti.group(2))));
|
||||
}
|
||||
|
||||
return results;
|
||||
|
|
|
@ -57,7 +57,8 @@ public final class VbbProvider implements NetworkProvider
|
|||
private static final Pattern P_AUTOCOMPLETE_IS_MAST = Pattern.compile("\\d{6}");
|
||||
private static final String AUTOCOMPLETE_NAME_URL = "http://mobil.bvg.de/Fahrinfo/bin/stboard.bin/dox/dox?input=";
|
||||
private static final Pattern P_SINGLE_NAME = Pattern.compile(".*Haltestelleninfo.*?<strong>(.*?)</strong>.*", Pattern.DOTALL);
|
||||
private static final Pattern P_MULTI_NAME = Pattern.compile("<a href=\\\"/Fahrinfo/bin/stboard.*?\\\">\\s*(.*?)\\s*</a>", Pattern.DOTALL);
|
||||
private static final Pattern P_MULTI_NAME = Pattern.compile("<a href=\\\"/Fahrinfo/bin/stboard\\.bin/dox.*?input=(\\d+)&.*?\">\\s*(.*?)\\s*</a>",
|
||||
Pattern.DOTALL);
|
||||
private static final String AUTOCOMPLETE_MASTID_URL = "http://mobil.bvg.de/IstAbfahrtzeiten/index/mobil?input=";
|
||||
private static final Pattern P_SINGLE_MASTID = Pattern.compile(".*Ist-Abfahrtzeiten.*?<strong>(.*?)</strong>.*", Pattern.DOTALL);
|
||||
|
||||
|
@ -72,7 +73,7 @@ public final class VbbProvider implements NetworkProvider
|
|||
final Matcher mSingle = P_SINGLE_MASTID.matcher(page);
|
||||
if (mSingle.matches())
|
||||
{
|
||||
results.add(new Autocomplete(0, ParserUtils.resolveEntities(mSingle.group(1))));
|
||||
results.add(new Autocomplete(0 /* TODO */, ParserUtils.resolveEntities(mSingle.group(1))));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -82,13 +83,13 @@ public final class VbbProvider implements NetworkProvider
|
|||
final Matcher mSingle = P_SINGLE_NAME.matcher(page);
|
||||
if (mSingle.matches())
|
||||
{
|
||||
results.add(new Autocomplete(0, ParserUtils.resolveEntities(mSingle.group(1))));
|
||||
results.add(new Autocomplete(0 /* TODO */, ParserUtils.resolveEntities(mSingle.group(1))));
|
||||
}
|
||||
else
|
||||
{
|
||||
final Matcher mMulti = P_MULTI_NAME.matcher(page);
|
||||
while (mMulti.find())
|
||||
results.add(new Autocomplete(0, ParserUtils.resolveEntities(mMulti.group(1))));
|
||||
results.add(new Autocomplete(Integer.parseInt(mMulti.group(1)), ParserUtils.resolveEntities(mMulti.group(2))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue