destinations now are locations

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@934 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach@gmail.com 2012-02-09 10:02:24 +00:00
parent c009e99d8c
commit 7fdd00a5ae
11 changed files with 53 additions and 55 deletions

View file

@ -1297,12 +1297,14 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
{ {
final String assignedStopIdStr = pp.getAttributeValue(null, "assignedStopID"); final String assignedStopIdStr = pp.getAttributeValue(null, "assignedStopID");
final int assignedStopId = assignedStopIdStr != null ? Integer.parseInt(assignedStopIdStr) : 0; final int assignedStopId = assignedStopIdStr != null ? Integer.parseInt(assignedStopIdStr) : 0;
final String destination = normalizeLocationName(pp.getAttributeValue(null, "direction")); final String destinationName = normalizeLocationName(pp.getAttributeValue(null, "direction"));
final String destinationIdStr = pp.getAttributeValue(null, "destID"); final String destinationIdStr = pp.getAttributeValue(null, "destID");
final int destinationId = (destinationIdStr != null && destinationIdStr.length() > 0) ? Integer.parseInt(destinationIdStr) final int destinationId = (destinationIdStr != null && destinationIdStr.length() > 0) ? Integer.parseInt(destinationIdStr)
: 0; : 0;
final LineDestination line = new LineDestination(processItdServingLine(pp), destinationId, destination); final Location destination = new Location(destinationId > 0 ? LocationType.STATION : LocationType.ANY, destinationId, null,
destinationName);
final LineDestination line = new LineDestination(processItdServingLine(pp), destination);
StationDepartures assignedStationDepartures; StationDepartures assignedStationDepartures;
if (assignedStopId == 0) if (assignedStopId == 0)
@ -1363,10 +1365,12 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
XmlPullUtil.require(pp, "itdServingLine"); XmlPullUtil.require(pp, "itdServingLine");
final boolean isRealtime = pp.getAttributeValue(null, "realtime").equals("1"); final boolean isRealtime = pp.getAttributeValue(null, "realtime").equals("1");
final String destination = normalizeLocationName(pp.getAttributeValue(null, "direction")); final String destinationName = normalizeLocationName(pp.getAttributeValue(null, "direction"));
final String destinationIdStr = pp.getAttributeValue(null, "destID"); final String destinationIdStr = pp.getAttributeValue(null, "destID");
final int destinationId = destinationIdStr != null ? Integer.parseInt(destinationIdStr) : 0; final int destinationId = destinationIdStr != null ? Integer.parseInt(destinationIdStr) : 0;
final Location destination = new Location(destinationId > 0 ? LocationType.STATION : LocationType.ANY, destinationId, null,
destinationName);
final Line line = processItdServingLine(pp); final Line line = processItdServingLine(pp);
if (isRealtime && !predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY)) if (isRealtime && !predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY))
@ -1374,7 +1378,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
final Departure departure = new Departure(plannedDepartureTime.getTime(), final Departure departure = new Departure(plannedDepartureTime.getTime(),
predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY) ? predictedDepartureTime.getTime() : null, line, position, predictedDepartureTime.isSet(Calendar.HOUR_OF_DAY) ? predictedDepartureTime.getTime() : null, line, position,
destinationId, destination, null, null); destination, null, null);
assignedStationDepartures.departures.add(departure); assignedStationDepartures.departures.add(departure);
XmlPullUtil.exit(pp, "itdDeparture"); XmlPullUtil.exit(pp, "itdDeparture");

View file

@ -612,13 +612,13 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
final String position = platform != null ? "Gl. " + ParserUtils.resolveEntities(platform) : null; final String position = platform != null ? "Gl. " + ParserUtils.resolveEntities(platform) : null;
final String destination; final String destinationName;
if (dir != null) if (dir != null)
destination = dir.trim(); destinationName = dir.trim();
else if (targetLoc != null) else if (targetLoc != null)
destination = targetLoc.trim(); destinationName = targetLoc.trim();
else else
destination = null; destinationName = null;
final int destinationId; final int destinationId;
if (dirnr != null) if (dirnr != null)
@ -626,6 +626,9 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
else else
destinationId = 0; destinationId = 0;
final Location destination = new Location(destinationId > 0 ? LocationType.STATION : LocationType.ANY, destinationId, null,
destinationName);
final Line prodLine = parseLineAndType(prod); final Line prodLine = parseLineAndType(prod);
final Line line; final Line line;
if (classStr != null) if (classStr != null)
@ -665,7 +668,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
} }
final Departure departure = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line, final Departure departure = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line,
position, destinationId, destination, capacity, message); position, destination, capacity, message);
departures.add(departure); departures.add(departure);
} }

View file

@ -332,12 +332,12 @@ public final class BvgProvider extends AbstractHafasProvider
final String position = null; final String position = null;
final int destinationId = 0; final String destinationName = ParserUtils.resolveEntities(mDepFine.group(4));
final Location destination = new Location(LocationType.ANY, 0, null, destinationName);
final String destination = ParserUtils.resolveEntities(mDepFine.group(4)); final String message = messages.get(line.label);
final Departure dep = new Departure(plannedTime, predictedTime, line, position, destinationId, destination, null, final Departure dep = new Departure(plannedTime, predictedTime, line, position, destination, null, message);
messages.get(line.label));
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);
} }
@ -403,10 +403,11 @@ public final class BvgProvider extends AbstractHafasProvider
final String position = ParserUtils.resolveEntities(mDepFine.group(3)); final String position = ParserUtils.resolveEntities(mDepFine.group(3));
final int destinationId = Integer.parseInt(mDepFine.group(4)); final int destinationId = Integer.parseInt(mDepFine.group(4));
final String destinationName = ParserUtils.resolveEntities(mDepFine.group(5));
final Location destination = new Location(destinationId > 0 ? LocationType.STATION : LocationType.ANY, destinationId, null,
destinationName);
final String destination = ParserUtils.resolveEntities(mDepFine.group(5)); final Departure dep = new Departure(plannedTime, null, line, position, destination, null, null);
final Departure dep = new Departure(plannedTime, null, line, position, destinationId, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);
} }

View file

@ -238,13 +238,14 @@ public class InvgProvider extends AbstractHafasProvider
final Line line = parseLine(lineType, ParserUtils.resolveEntities(mDepFine.group(4)), false); final Line line = parseLine(lineType, ParserUtils.resolveEntities(mDepFine.group(4)), false);
final int destinationId = mDepFine.group(5) != null ? Integer.parseInt(mDepFine.group(5)) : 0; final int destinationId = mDepFine.group(5) != null ? Integer.parseInt(mDepFine.group(5)) : 0;
final String destinationName = ParserUtils.resolveEntities(mDepFine.group(6));
final String destination = ParserUtils.resolveEntities(mDepFine.group(6)); final Location destination = new Location(destinationId > 0 ? LocationType.STATION : LocationType.ANY, destinationId, null,
destinationName);
final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null; final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null;
final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line, final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line,
position, destinationId, destination, null, null); position, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);

View file

@ -162,7 +162,8 @@ public class NsProvider extends AbstractHafasProvider
{ {
final Line line = parseLineWithoutType(ParserUtils.resolveEntities(mDepFine.group(1))); final Line line = parseLineWithoutType(ParserUtils.resolveEntities(mDepFine.group(1)));
final String destination = ParserUtils.resolveEntities(mDepFine.group(2)); final String destinationName = ParserUtils.resolveEntities(mDepFine.group(2));
final Location destination = new Location(LocationType.ANY, 0, null, destinationName);
final Calendar parsedTime = new GregorianCalendar(timeZone()); final Calendar parsedTime = new GregorianCalendar(timeZone());
parsedTime.setTimeInMillis(currentTime.getTimeInMillis()); parsedTime.setTimeInMillis(currentTime.getTimeInMillis());
@ -173,7 +174,7 @@ public class NsProvider extends AbstractHafasProvider
mDepFine.group(4); // TODO delay mDepFine.group(4); // TODO delay
final Departure dep = new Departure(parsedTime.getTime(), null, line, null, 0, destination, null, null); final Departure dep = new Departure(parsedTime.getTime(), null, line, null, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);

View file

@ -243,7 +243,8 @@ public class RmvProvider extends AbstractHafasProvider
{ {
final Line line = parseLineWithoutType(ParserUtils.resolveEntities(mDepFine.group(1))); final Line line = parseLineWithoutType(ParserUtils.resolveEntities(mDepFine.group(1)));
final String destination = ParserUtils.resolveEntities(mDepFine.group(2)); final String destinationName = ParserUtils.resolveEntities(mDepFine.group(2));
final Location destination = new Location(LocationType.ANY, 0, null, destinationName);
final Calendar plannedTime = new GregorianCalendar(timeZone()); final Calendar plannedTime = new GregorianCalendar(timeZone());
plannedTime.setTimeInMillis(currentTime.getTimeInMillis()); plannedTime.setTimeInMillis(currentTime.getTimeInMillis());
@ -270,7 +271,7 @@ public class RmvProvider extends AbstractHafasProvider
final String position = ParserUtils.resolveEntities(ParserUtils.selectNotNull(mDepFine.group(5), mDepFine.group(6))); final String position = ParserUtils.resolveEntities(ParserUtils.selectNotNull(mDepFine.group(5), mDepFine.group(6)));
final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line, final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line,
position, 0, destination, null, null); position, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);

View file

@ -260,13 +260,14 @@ public class SeptaProvider extends AbstractHafasProvider
final Line line = parseLine(lineType, ParserUtils.resolveEntities(mDepFine.group(4)), false); final Line line = parseLine(lineType, ParserUtils.resolveEntities(mDepFine.group(4)), false);
final int destinationId = mDepFine.group(5) != null ? Integer.parseInt(mDepFine.group(5)) : 0; final int destinationId = mDepFine.group(5) != null ? Integer.parseInt(mDepFine.group(5)) : 0;
final String destinationName = ParserUtils.resolveEntities(mDepFine.group(6));
final String destination = ParserUtils.resolveEntities(mDepFine.group(6)); final Location destination = new Location(destinationId > 0 ? LocationType.STATION : LocationType.ANY, destinationId, null,
destinationName);
final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null; final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null;
final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line, final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line,
position, destinationId, destination, null, null); position, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);

View file

@ -226,12 +226,13 @@ public class ShProvider extends AbstractHafasProvider
final Line line = parseLine(lineType, ParserUtils.resolveEntities(mDepFine.group(3).trim()), false); final Line line = parseLine(lineType, ParserUtils.resolveEntities(mDepFine.group(3).trim()), false);
final int destinationId = mDepFine.group(4) != null ? Integer.parseInt(mDepFine.group(4)) : 0; final int destinationId = mDepFine.group(4) != null ? Integer.parseInt(mDepFine.group(4)) : 0;
final String destinationName = ParserUtils.resolveEntities(mDepFine.group(5));
final String destination = ParserUtils.resolveEntities(mDepFine.group(5)); final Location destination = new Location(destinationId > 0 ? LocationType.STATION : LocationType.ANY, destinationId, null,
destinationName);
final String position = mDepFine.group(6) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(6)) : null; final String position = mDepFine.group(6) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(6)) : null;
final Departure dep = new Departure(plannedTime.getTime(), null, line, position, destinationId, destination, null, null); final Departure dep = new Departure(plannedTime.getTime(), null, line, position, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);

View file

@ -267,13 +267,14 @@ public class VgsProvider extends AbstractHafasProvider
final Line line = parseLine(lineType, ParserUtils.resolveEntities(mDepFine.group(4)), false); final Line line = parseLine(lineType, ParserUtils.resolveEntities(mDepFine.group(4)), false);
final int destinationId = mDepFine.group(5) != null ? Integer.parseInt(mDepFine.group(5)) : 0; final int destinationId = mDepFine.group(5) != null ? Integer.parseInt(mDepFine.group(5)) : 0;
final String destinationName = ParserUtils.resolveEntities(mDepFine.group(6));
final String destination = ParserUtils.resolveEntities(mDepFine.group(6)); final Location destination = new Location(destinationId > 0 ? LocationType.STATION : LocationType.ANY, destinationId, null,
destinationName);
final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null; final String position = mDepFine.group(7) != null ? "Gl. " + ParserUtils.resolveEntities(mDepFine.group(7)) : null;
final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line, final Departure dep = new Departure(plannedTime.getTime(), predictedTime != null ? predictedTime.getTime() : null, line,
position, destinationId, destination, null, null); position, destination, null, null);
if (!departures.contains(dep)) if (!departures.contains(dep))
departures.add(dep); departures.add(dep);

View file

@ -28,19 +28,17 @@ public final class Departure
final public Date predictedTime; final public Date predictedTime;
final public Line line; final public Line line;
final public String position; final public String position;
final public int destinationId; final public Location destination;
final public String destination;
final public int[] capacity; final public int[] capacity;
final public String message; final public String message;
public Departure(final Date plannedTime, final Date predictedTime, final Line line, final String position, final int destinationId, public Departure(final Date plannedTime, final Date predictedTime, final Line line, final String position, final Location destination,
final String destination, final int[] capacity, final String message) final int[] capacity, final String message)
{ {
this.plannedTime = plannedTime; this.plannedTime = plannedTime;
this.predictedTime = predictedTime; this.predictedTime = predictedTime;
this.line = line; this.line = line;
this.position = position; this.position = position;
this.destinationId = destinationId;
this.destination = destination; this.destination = destination;
this.capacity = capacity; this.capacity = capacity;
this.message = message; this.message = message;
@ -58,8 +56,6 @@ public final class Departure
builder.append(","); builder.append(",");
builder.append(position != null ? position : "null"); builder.append(position != null ? position : "null");
builder.append(","); builder.append(",");
builder.append(destinationId);
builder.append(",");
builder.append(destination != null ? destination : "null"); builder.append(destination != null ? destination : "null");
builder.append(")"); builder.append(")");
return builder.toString(); return builder.toString();
@ -79,9 +75,7 @@ public final class Departure
return false; return false;
if (!nullSafeEquals(this.line, other.line)) if (!nullSafeEquals(this.line, other.line))
return false; return false;
if (this.destinationId != other.destinationId) if (!nullSafeEquals(this.destination, other.destination))
return false;
if (!this.destination.equals(other.destination))
return false; return false;
return true; return true;
} }
@ -96,9 +90,7 @@ public final class Departure
hashCode *= 29; hashCode *= 29;
hashCode += nullSafeHashCode(line); hashCode += nullSafeHashCode(line);
hashCode *= 29; hashCode *= 29;
hashCode += destinationId; hashCode += nullSafeHashCode(destination);
hashCode *= 29;
hashCode += destination.hashCode();
return hashCode; return hashCode;
} }

View file

@ -23,13 +23,11 @@ package de.schildbach.pte.dto;
public final class LineDestination public final class LineDestination
{ {
final public Line line; final public Line line;
final public int destinationId; final public Location destination;
final public String destination;
public LineDestination(final Line line, final int destinationId, final String destination) public LineDestination(final Line line, final Location destination)
{ {
this.line = line; this.line = line;
this.destinationId = destinationId;
this.destination = destination; this.destination = destination;
} }
@ -39,8 +37,6 @@ public final class LineDestination
StringBuilder builder = new StringBuilder("LineDestination("); StringBuilder builder = new StringBuilder("LineDestination(");
builder.append(line != null ? line : "null"); builder.append(line != null ? line : "null");
builder.append(","); builder.append(",");
builder.append(destinationId);
builder.append(",");
builder.append(destination != null ? destination : "null"); builder.append(destination != null ? destination : "null");
builder.append(")"); builder.append(")");
return builder.toString(); return builder.toString();
@ -56,8 +52,6 @@ public final class LineDestination
final LineDestination other = (LineDestination) o; final LineDestination other = (LineDestination) o;
if (!nullSafeEquals(this.line, other.line)) if (!nullSafeEquals(this.line, other.line))
return false; return false;
if (this.destinationId != other.destinationId)
return false;
if (!nullSafeEquals(this.destination, other.destination)) if (!nullSafeEquals(this.destination, other.destination))
return false; return false;
return true; return true;
@ -69,8 +63,6 @@ public final class LineDestination
int hashCode = 0; int hashCode = 0;
hashCode += nullSafeHashCode(line); hashCode += nullSafeHashCode(line);
hashCode *= 29; hashCode *= 29;
hashCode += destinationId;
hashCode *= 29;
hashCode += nullSafeHashCode(destination); hashCode += nullSafeHashCode(destination);
return hashCode; return hashCode;
} }