parse messages for on-demand products

This commit is contained in:
Andreas Schildbach 2012-10-20 21:40:41 +02:00
parent b43a74a079
commit 8d63a50801
5 changed files with 42 additions and 14 deletions

View file

@ -1492,12 +1492,12 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
if (isRealtime && !predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY))
predictedDepartureTime.setTimeInMillis(plannedDepartureTime.getTimeInMillis());
XmlPullUtil.exit(pp, "itdDeparture");
final Departure departure = new Departure(plannedDepartureTime.getTime(),
predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY) ? predictedDepartureTime.getTime() : null, line, position,
destination, null, null);
assignedStationDepartures.departures.add(departure);
XmlPullUtil.exit(pp, "itdDeparture");
}
XmlPullUtil.exit(pp, "itdDepartureList");
@ -1614,12 +1614,23 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
XmlPullUtil.enter(pp, "itdServingLine");
String noTrainName = null;
String message = null;
if (XmlPullUtil.test(pp, "itdNoTrain"))
{
noTrainName = pp.getAttributeValue(null, "name");
if (!pp.isEmptyElementTag())
{
XmlPullUtil.enter(pp, "itdNoTrain");
final String text = pp.getText();
if (noTrainName.toLowerCase().contains("ruf") && text.toLowerCase().contains("ruf"))
message = text;
XmlPullUtil.exit(pp, "itdNoTrain");
}
}
XmlPullUtil.exit(pp, "itdServingLine");
final String label = parseLine(motType, number, number, noTrainName);
return new Line(id, label, lineStyle(label));
return new Line(id, label, lineStyle(label), message);
}
private static final Pattern P_STATION_NAME_WHITESPACE = Pattern.compile("\\s+");
@ -2095,6 +2106,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
XmlPullUtil.next(pp);
boolean lowFloorVehicle = false;
String message = null;
if (XmlPullUtil.test(pp, "itdInfoTextList"))
{
if (!pp.isEmptyElementTag())
@ -2106,6 +2118,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final String text = pp.getText();
if ("Niederflurwagen soweit verfügbar".equals(text)) // KVV
lowFloorVehicle = true;
else if (text.toLowerCase().contains("ruf")) // RufBus, RufTaxi
message = text;
XmlPullUtil.exit(pp, "infoTextListElem");
}
XmlPullUtil.exit(pp, "itdInfoTextList");
@ -2218,7 +2232,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
parts.add(new Connection.Trip(line, destination, departureTargetTime != null ? departureTargetTime : departureTime,
departureTargetTime, departurePosition, null, departure, arrivalTargetTime != null ? arrivalTargetTime : arrivalTime,
arrivalTargetTime, arrivalPosition, null, arrival, intermediateStops, path));
arrivalTargetTime, arrivalPosition, null, arrival, intermediateStops, path, message));
}
XmlPullUtil.exit(pp, "itdPartialRoute");

View file

@ -1290,7 +1290,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
if (min == 0 || line != null)
{
parts.add(new Connection.Trip(line, destination, departureTime, null, departurePos, null, sectionDeparture, arrivalTime,
null, arrivalPos, null, sectionArrival, intermediateStops, path));
null, arrivalPos, null, sectionArrival, intermediateStops, path, null));
}
else
{
@ -1872,7 +1872,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
predictedDepartureTime != 0 ? new Date(predictedDepartureTime) : null, plannedDeparturePosition,
predictedDeparturePosition, departure, plannedArrivalTime != 0 ? new Date(plannedArrivalTime) : null,
predictedArrivalTime != 0 ? new Date(predictedArrivalTime) : null, plannedArrivalPosition,
predictedArrivalPosition, arrival, intermediateStops, null);
predictedArrivalPosition, arrival, intermediateStops, null, null);
}
else
{

View file

@ -435,7 +435,7 @@ public class SadProvider extends AbstractNetworkProvider {
// intermediateStops, path
parts.add(new Trip(new Line(lineId, lineId, DEFAULT_STYLE), null, responseDate.get(0), null, null, null,
soapToLocation((SoapObject) tratto.getProperty("nodo_partenza")), responseDate.get(1), null, null, null,
soapToLocation((SoapObject) tratto.getProperty("nodo_arrivo")), null, null));
soapToLocation((SoapObject) tratto.getProperty("nodo_arrivo")), null, null, null));
} catch (ParseException e) {
e.printStackTrace();
}

View file

@ -232,11 +232,12 @@ public final class Connection implements Serializable
public final String arrivalPosition; // TODO rename to plannedArrivalPosition
public final String predictedArrivalPosition;
public final List<Stop> intermediateStops;
public final String message;
public Trip(final Line line, final Location destination, final Date plannedDepartureTime, final Date predictedDepartureTime,
final String departurePosition, final String predictedDeparturePosition, final Location departure, final Date plannedArrivalTime,
final Date predictedArrivalTime, final String arrivalPosition, final String predictedArrivalPosition, final Location arrival,
final List<Stop> intermediateStops, final List<Point> path)
final List<Stop> intermediateStops, final List<Point> path, final String message)
{
super(departure, arrival, path);
@ -251,6 +252,7 @@ public final class Connection implements Serializable
this.arrivalPosition = arrivalPosition;
this.predictedArrivalPosition = predictedArrivalPosition;
this.intermediateStops = intermediateStops;
this.message = message;
}
public Date getDepartureTime()

View file

@ -32,25 +32,37 @@ public final class Line implements Serializable, Comparable<Line>
private static final long serialVersionUID = -5642533805998375070L;
final public String id;
final private transient char product; // TODO make true field
final public String label;
final public Style style;
final public Set<Attr> attrs;
public final String id;
private final transient char product; // TODO make true field
public final String label;
public final Style style;
public final Set<Attr> attrs;
public final String message;
private static final String PRODUCT_ORDER = "IRSUTBPFC?";
public Line(final String id, final String label, final Style style)
{
this(id, label, style, null);
this(id, label, style, null, null);
}
public Line(final String id, final String label, final Style style, final String message)
{
this(id, label, style, null, message);
}
public Line(final String id, final String label, final Style style, final Set<Attr> attrs)
{
this(id, label, style, attrs, null);
}
private Line(final String id, final String label, final Style style, final Set<Attr> attrs, final String message)
{
this.id = id;
this.label = label;
this.style = style;
this.attrs = attrs;
this.message = message;
product = label != null ? label.charAt(0) : '?';
}