mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-13 16:20:34 +00:00
Fix Netherlands, but sadly it hasn't got coordinates.
This commit is contained in:
parent
b1a0b6517c
commit
06a9580602
3 changed files with 38 additions and 25 deletions
|
@ -2365,7 +2365,13 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Pattern P_NEARBY_COARSE = Pattern.compile("<tr class=\"(zebra[^\"]*)\">(.*?)</tr>", Pattern.DOTALL);
|
protected void setHtmlNearbyStationsPattern(final Pattern htmlNearbyStationsPattern)
|
||||||
|
{
|
||||||
|
this.htmlNearbyStationsPattern = htmlNearbyStationsPattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Pattern htmlNearbyStationsPattern = Pattern.compile("<tr class=\"(zebra[^\"]*)\">(.*?)</tr>", Pattern.DOTALL);
|
||||||
|
|
||||||
private final static Pattern P_NEARBY_FINE_COORDS = Pattern
|
private final static Pattern P_NEARBY_FINE_COORDS = Pattern
|
||||||
.compile("REQMapRoute0\\.Location0\\.X=(-?\\d+)&(?:amp;)?REQMapRoute0\\.Location0\\.Y=(-?\\d+)&");
|
.compile("REQMapRoute0\\.Location0\\.X=(-?\\d+)&(?:amp;)?REQMapRoute0\\.Location0\\.Y=(-?\\d+)&");
|
||||||
private final static Pattern P_NEARBY_FINE_LOCATION = Pattern.compile("[\\?&;]input=(\\d+)&[^\"]*\">([^<]*)<");
|
private final static Pattern P_NEARBY_FINE_LOCATION = Pattern.compile("[\\?&;]input=(\\d+)&[^\"]*\">([^<]*)<");
|
||||||
|
@ -2377,7 +2383,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
||||||
final CharSequence page = ParserUtils.scrape(uri);
|
final CharSequence page = ParserUtils.scrape(uri);
|
||||||
String oldZebra = null;
|
String oldZebra = null;
|
||||||
|
|
||||||
final Matcher mCoarse = P_NEARBY_COARSE.matcher(page);
|
final Matcher mCoarse = htmlNearbyStationsPattern.matcher(page);
|
||||||
|
|
||||||
while (mCoarse.find())
|
while (mCoarse.find())
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,12 +19,12 @@ package de.schildbach.pte;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -34,9 +34,14 @@ public class NsProvider extends AbstractHafasProvider
|
||||||
public static final NetworkId NETWORK_ID = NetworkId.NS;
|
public static final NetworkId NETWORK_ID = NetworkId.NS;
|
||||||
private static final String API_BASE = "http://hafas.bene-system.com/bin/";
|
private static final String API_BASE = "http://hafas.bene-system.com/bin/";
|
||||||
|
|
||||||
|
private static final Pattern HTML_NEARBY_STATIONS_PATTERN = Pattern.compile("<tr bgcolor=\"#(E7EEF9|99BAE4)\">(.*?)</tr>", Pattern.DOTALL);
|
||||||
|
|
||||||
public NsProvider()
|
public NsProvider()
|
||||||
{
|
{
|
||||||
super(API_BASE + "stboard.exe/nn", API_BASE + "ajax-getstop.exe/nny", API_BASE + "query.exe/nn", 10);
|
super(API_BASE + "stboard.exe/nn", API_BASE + "ajax-getstop.exe/nny", API_BASE + "query.exe/nn", 10);
|
||||||
|
|
||||||
|
setHtmlNearbyStationsPattern(HTML_NEARBY_STATIONS_PATTERN);
|
||||||
|
setStationBoardHasLocation(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkId id()
|
public NetworkId id()
|
||||||
|
@ -47,7 +52,7 @@ public class NsProvider extends AbstractHafasProvider
|
||||||
public boolean hasCapabilities(final Capability... capabilities)
|
public boolean hasCapabilities(final Capability... capabilities)
|
||||||
{
|
{
|
||||||
for (final Capability capability : capabilities)
|
for (final Capability capability : capabilities)
|
||||||
if (capability == Capability.SUGGEST_LOCATIONS || capability == Capability.TRIPS)
|
if (capability == Capability.DEPARTURES || capability == Capability.SUGGEST_LOCATIONS || capability == Capability.TRIPS)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -66,8 +71,16 @@ public class NsProvider extends AbstractHafasProvider
|
||||||
return 'R';
|
return 'R';
|
||||||
if (value == 16)
|
if (value == 16)
|
||||||
return 'S';
|
return 'S';
|
||||||
|
if (value == 32)
|
||||||
|
return 'B';
|
||||||
if (value == 64)
|
if (value == 64)
|
||||||
return 'F';
|
return 'F';
|
||||||
|
if (value == 128)
|
||||||
|
return 'U';
|
||||||
|
if (value == 256)
|
||||||
|
return 'T';
|
||||||
|
if (value == 512)
|
||||||
|
return 'P';
|
||||||
|
|
||||||
throw new IllegalArgumentException("cannot handle: " + value);
|
throw new IllegalArgumentException("cannot handle: " + value);
|
||||||
}
|
}
|
||||||
|
@ -91,15 +104,19 @@ public class NsProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
else if (product == Product.SUBWAY)
|
else if (product == Product.SUBWAY)
|
||||||
{
|
{
|
||||||
// productBits.setCharAt(8, '1');
|
productBits.setCharAt(7, '1');
|
||||||
}
|
}
|
||||||
else if (product == Product.TRAM)
|
else if (product == Product.TRAM)
|
||||||
{
|
{
|
||||||
// productBits.setCharAt(7, '1');
|
productBits.setCharAt(8, '1');
|
||||||
}
|
}
|
||||||
else if (product == Product.BUS || product == Product.ON_DEMAND)
|
else if (product == Product.BUS)
|
||||||
{
|
{
|
||||||
// productBits.setCharAt(5, '1');
|
productBits.setCharAt(5, '1');
|
||||||
|
}
|
||||||
|
else if (product == Product.ON_DEMAND)
|
||||||
|
{
|
||||||
|
productBits.setCharAt(9, '1');
|
||||||
}
|
}
|
||||||
else if (product == Product.FERRY)
|
else if (product == Product.FERRY)
|
||||||
{
|
{
|
||||||
|
@ -123,6 +140,7 @@ public class NsProvider extends AbstractHafasProvider
|
||||||
uri.append("?near=Anzeigen");
|
uri.append("?near=Anzeigen");
|
||||||
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
|
uri.append("&distance=").append(maxDistance != 0 ? maxDistance / 1000 : 50);
|
||||||
uri.append("&input=").append(normalizeStationId(location.id));
|
uri.append("&input=").append(normalizeStationId(location.id));
|
||||||
|
uri.append("&L=profi");
|
||||||
|
|
||||||
return htmlNearbyStations(uri.toString());
|
return htmlNearbyStations(uri.toString());
|
||||||
}
|
}
|
||||||
|
@ -132,12 +150,6 @@ public class NsProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryDeparturesResult queryDepartures(final String stationId, final int maxDepartures, final boolean equivs) throws IOException
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Product> defaultProducts()
|
public Collection<Product> defaultProducts()
|
||||||
{
|
{
|
||||||
|
@ -151,6 +163,10 @@ public class NsProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
if (ucType.equals("SPR"))
|
if (ucType.equals("SPR"))
|
||||||
return 'R';
|
return 'R';
|
||||||
|
if (ucType.equals("E")) // Budapest, Ungarn
|
||||||
|
return 'R';
|
||||||
|
if (ucType.equals("N")) // Avignon
|
||||||
|
return 'R';
|
||||||
|
|
||||||
final char t = super.normalizeType(type);
|
final char t = super.normalizeType(type);
|
||||||
if (t != 0)
|
if (t != 0)
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class NsProviderLiveTest extends AbstractProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void nearbyStations() throws Exception
|
public void nearbyStations() throws Exception
|
||||||
{
|
{
|
||||||
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.STATION, "8400058"), 0, 0);
|
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.STATION, "8800004"), 0, 0);
|
||||||
|
|
||||||
print(result);
|
print(result);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class NsProviderLiveTest extends AbstractProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void queryDepartures() throws Exception
|
public void queryDepartures() throws Exception
|
||||||
{
|
{
|
||||||
final QueryDeparturesResult result = provider.queryDepartures("8400058", 0, false);
|
final QueryDeparturesResult result = provider.queryDepartures("8800004", 0, false);
|
||||||
|
|
||||||
print(result);
|
print(result);
|
||||||
}
|
}
|
||||||
|
@ -99,13 +99,4 @@ public class NsProviderLiveTest extends AbstractProviderLiveTest
|
||||||
|
|
||||||
print(result);
|
print(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void longTrip() throws Exception
|
|
||||||
{
|
|
||||||
final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "100024"), null, new Location(LocationType.STATION, "103624"),
|
|
||||||
new Date(), true, null, WalkSpeed.FAST, Accessibility.NEUTRAL);
|
|
||||||
|
|
||||||
print(result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue