mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-08 15:58:49 +00:00
better handling of 'Sitzenbleiber'
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@178 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
edab600f71
commit
76026f46ce
2 changed files with 63 additions and 68 deletions
|
@ -468,8 +468,8 @@ public class MvvProvider implements NetworkProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Pattern P_CONNECTION_DETAILS_HEAD = Pattern.compile(".*<b>Detailansicht</b>.*?" //
|
private static final Pattern P_CONNECTION_DETAILS_HEAD = Pattern.compile(".*?<b>Detailansicht</b>.*?" //
|
||||||
+ "<b>Datum:[\\xa0\\s]+</b>\\w{2}\\.,\\s(\\d+)\\.\\s(\\w{3,4})\\.[\\xa0\\s]+(\\d{4}).*", Pattern.DOTALL);
|
+ "<b>Datum:[\\xa0\\s]+</b>\\w{2}\\.,\\s(\\d+)\\.\\s(\\w{3,4})\\.[\\xa0\\s]+(\\d{4}).*?", Pattern.DOTALL);
|
||||||
private static final Pattern P_CONNECTION_DETAILS_COARSE = Pattern.compile("" //
|
private static final Pattern P_CONNECTION_DETAILS_COARSE = Pattern.compile("" //
|
||||||
+ "<tr bgcolor=\"#(\\w{6})\">\r\\x0a(.+?)</tr>.*?" //
|
+ "<tr bgcolor=\"#(\\w{6})\">\r\\x0a(.+?)</tr>.*?" //
|
||||||
+ "<tr bgcolor=\"#\\1\">\r\\x0a(.+?)</tr>.*?" //
|
+ "<tr bgcolor=\"#\\1\">\r\\x0a(.+?)</tr>.*?" //
|
||||||
|
@ -477,15 +477,16 @@ public class MvvProvider implements NetworkProvider
|
||||||
static final Pattern P_CONNECTION_DETAILS_FINE = Pattern.compile("(?:" //
|
static final Pattern P_CONNECTION_DETAILS_FINE = Pattern.compile("(?:" //
|
||||||
+ "<td colspan=\"\\d+\">ab (\\d{1,2}:\\d{2})\\s(.*?)\\s*<.*?" // departureTime, departure
|
+ "<td colspan=\"\\d+\">ab (\\d{1,2}:\\d{2})\\s(.*?)\\s*<.*?" // departureTime, departure
|
||||||
+ "(?:<img src=\"images/means.*?\" alt=\"(.*?)\" />.*?)?" // product
|
+ "(?:<img src=\"images/means.*?\" alt=\"(.*?)\" />.*?)?" // product
|
||||||
+ "<td>\\s*(.*?)\\s*<br />Richtung\\s*(.*?)\\s*</td>.*?" //
|
+ "<td>\\s*(.*?)\\s*<br />Richtung\\s*(.*?)\\s*</td>.*?" // line, destination
|
||||||
+ "<td colspan=\"\\d+\">an (\\d{1,2}:\\d{2})\\s(.*?)\\s*<" //
|
+ "<td colspan=\"\\d+\">an (\\d{1,2}:\\d{2})\\s(.*?)\\s*<" // arrivalTime, arrival
|
||||||
+ "|" //
|
+ "|" //
|
||||||
+ "<td colspan=\"\\d+\">ab (.*?)\\s*<.*?" // departure
|
+ "<td colspan=\"\\d+\">ab (.*?)\\s*<.*?" // departure
|
||||||
+ "Fußweg[\\xa0\\s]+\\(ca\\.[\\xa0\\s]+(\\d+)[\\xa0\\s]+Minute.*?" //
|
+ "Fußweg[\\xa0\\s]+\\(ca\\.[\\xa0\\s]+(\\d+)[\\xa0\\s]+Minute.*?" // min
|
||||||
+ "<td colspan=\"\\d+\">an (.*?)\\s*<" //
|
+ "<td colspan=\"\\d+\">an (.*?)\\s*<" // arrival
|
||||||
|
+ "|" //
|
||||||
|
+ ".*?<img src=\"images/means/seat.gif\" alt=\"Sitzenbleiber\" />" //
|
||||||
+ ").*?", Pattern.DOTALL);
|
+ ").*?", Pattern.DOTALL);
|
||||||
private static final Pattern P_CONNECTION_DETAILS_ERRORS = Pattern.compile("(session has expired)", Pattern.CASE_INSENSITIVE);
|
private static final Pattern P_CONNECTION_DETAILS_ERRORS = Pattern.compile("(session has expired)", Pattern.CASE_INSENSITIVE);
|
||||||
private static final String SITZENBLEIBER = "Sitzenbleiber";
|
|
||||||
|
|
||||||
public GetConnectionDetailsResult getConnectionDetails(final String uri) throws IOException
|
public GetConnectionDetailsResult getConnectionDetails(final String uri) throws IOException
|
||||||
{
|
{
|
||||||
|
@ -515,15 +516,12 @@ public class MvvProvider implements NetworkProvider
|
||||||
oldZebra = zebra;
|
oldZebra = zebra;
|
||||||
|
|
||||||
final String set = mDetCoarse.group(2) + mDetCoarse.group(3) + mDetCoarse.group(4);
|
final String set = mDetCoarse.group(2) + mDetCoarse.group(3) + mDetCoarse.group(4);
|
||||||
if (!set.contains(SITZENBLEIBER))
|
|
||||||
{
|
|
||||||
final Matcher mDetFine = P_CONNECTION_DETAILS_FINE.matcher(set);
|
final Matcher mDetFine = P_CONNECTION_DETAILS_FINE.matcher(set);
|
||||||
if (mDetFine.matches())
|
if (mDetFine.matches())
|
||||||
{
|
{
|
||||||
if (mDetFine.group(8) == null)
|
if (mDetFine.group(1) != null)
|
||||||
{
|
{
|
||||||
final Date departureTime = upTime(lastTime, ParserUtils.joinDateTime(currentDate, ParserUtils
|
final Date departureTime = upTime(lastTime, ParserUtils.joinDateTime(currentDate, ParserUtils.parseTime(mDetFine.group(1))));
|
||||||
.parseTime(mDetFine.group(1))));
|
|
||||||
|
|
||||||
final String departure = ParserUtils.resolveEntities(mDetFine.group(2));
|
final String departure = ParserUtils.resolveEntities(mDetFine.group(2));
|
||||||
if (departure != null && firstDeparture == null)
|
if (departure != null && firstDeparture == null)
|
||||||
|
@ -550,7 +548,7 @@ public class MvvProvider implements NetworkProvider
|
||||||
lastArrival = arrival;
|
lastArrival = arrival;
|
||||||
lastArrivalTime = arrivalTime;
|
lastArrivalTime = arrivalTime;
|
||||||
}
|
}
|
||||||
else
|
else if (mDetFine.group(8) != null)
|
||||||
{
|
{
|
||||||
final String departure = ParserUtils.resolveEntities(mDetFine.group(8));
|
final String departure = ParserUtils.resolveEntities(mDetFine.group(8));
|
||||||
if (departure != null && firstDeparture == null)
|
if (departure != null && firstDeparture == null)
|
||||||
|
@ -578,7 +576,6 @@ public class MvvProvider implements NetworkProvider
|
||||||
throw new IllegalArgumentException("cannot parse '" + set + "' on " + uri);
|
throw new IllegalArgumentException("cannot parse '" + set + "' on " + uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (firstDepartureTime == null && lastArrivalTime == null && parts.size() == 1 && parts.get(0) instanceof Connection.Footway)
|
if (firstDepartureTime == null && lastArrivalTime == null && parts.size() == 1 && parts.get(0) instanceof Connection.Footway)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,13 +17,12 @@
|
||||||
|
|
||||||
package de.schildbach.pte;
|
package de.schildbach.pte;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertNull;
|
|
||||||
import static junit.framework.Assert.assertNotNull;
|
import static junit.framework.Assert.assertNotNull;
|
||||||
|
import static junit.framework.Assert.assertNull;
|
||||||
import static junit.framework.Assert.assertTrue;
|
import static junit.framework.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,8 +70,7 @@ public class MvvProviderTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("deactivated because there is no time")
|
public void tripSitzenbleiber()
|
||||||
public void tripWithoutTime()
|
|
||||||
{
|
{
|
||||||
final Matcher m = assertFineConnectionDetails("" //
|
final Matcher m = assertFineConnectionDetails("" //
|
||||||
+ "<td colspan=\"4\">ab Neufahrn <a class=\"imgLink\" href=\"XSLT_TRIP_REQUEST2?language=de&tripSelector2=on&sessionID=MVV2_1678243657&requestID=1&tripSelection=on&itdLPxx_view=map_2&itdLPxx_img=FILELOAD?Filename=mvv2_4C45BE6910.png&itdLPxx_partialRoute=2&imageFormat=PNG&imageWidth=400&imageHeight=300&imageOnly=1&imageNoTiles=1&itdLPxx_usage=departure\"><img src=\"images/pdf.gif\" border=\"0\" alt=\"Karte\" /></a>\n" //
|
+ "<td colspan=\"4\">ab Neufahrn <a class=\"imgLink\" href=\"XSLT_TRIP_REQUEST2?language=de&tripSelector2=on&sessionID=MVV2_1678243657&requestID=1&tripSelection=on&itdLPxx_view=map_2&itdLPxx_img=FILELOAD?Filename=mvv2_4C45BE6910.png&itdLPxx_partialRoute=2&imageFormat=PNG&imageWidth=400&imageHeight=300&imageOnly=1&imageNoTiles=1&itdLPxx_usage=departure\"><img src=\"images/pdf.gif\" border=\"0\" alt=\"Karte\" /></a>\n" //
|
||||||
|
@ -87,8 +85,8 @@ public class MvvProviderTest
|
||||||
+ "<td colspan=\"4\">an Neufahrn <a class=\"imgLink\" href=\"XSLT_TRIP_REQUEST2?language=de&tripSelector2=on&sessionID=MVV2_1678243657&requestID=1&tripSelection=on&itdLPxx_view=map_2&itdLPxx_img=FILELOAD?Filename=mvv2_4C45BE6911.png&itdLPxx_partialRoute=2&imageFormat=PNG&imageWidth=400&imageHeight=300&imageOnly=1&imageNoTiles=1&command=nop&itdLPxx_usage=arrival\"><img src=\"images/pdf.gif\" border=\"0\" alt=\"Karte\" /></a>\n" //
|
+ "<td colspan=\"4\">an Neufahrn <a class=\"imgLink\" href=\"XSLT_TRIP_REQUEST2?language=de&tripSelector2=on&sessionID=MVV2_1678243657&requestID=1&tripSelection=on&itdLPxx_view=map_2&itdLPxx_img=FILELOAD?Filename=mvv2_4C45BE6911.png&itdLPxx_partialRoute=2&imageFormat=PNG&imageWidth=400&imageHeight=300&imageOnly=1&imageNoTiles=1&command=nop&itdLPxx_usage=arrival\"><img src=\"images/pdf.gif\" border=\"0\" alt=\"Karte\" /></a>\n" //
|
||||||
+ "</td>\n");
|
+ "</td>\n");
|
||||||
|
|
||||||
assertNotNull(m.group(2)); // departure
|
assertNull(m.group(1));
|
||||||
assertNotNull(m.group(3)); // product
|
assertNull(m.group(8));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue