mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-10 21:28:52 +00:00
display lines including destinations where possible
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@323 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
ab2f35e542
commit
fcdbabfcd6
11 changed files with 136 additions and 11 deletions
|
@ -40,6 +40,7 @@ import org.xmlpull.v1.XmlPullParserFactory;
|
||||||
import de.schildbach.pte.dto.Connection;
|
import de.schildbach.pte.dto.Connection;
|
||||||
import de.schildbach.pte.dto.Departure;
|
import de.schildbach.pte.dto.Departure;
|
||||||
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||||
|
import de.schildbach.pte.dto.Line;
|
||||||
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;
|
||||||
|
@ -678,9 +679,35 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
||||||
|
|
||||||
final Calendar departureTime = new GregorianCalendar();
|
final Calendar departureTime = new GregorianCalendar();
|
||||||
departureTime.setTimeZone(timeZone());
|
departureTime.setTimeZone(timeZone());
|
||||||
|
|
||||||
|
final List<Line> lines = new ArrayList<Line>(4);
|
||||||
|
|
||||||
|
XmlPullUtil.jumpToStartTag(pp, null, "itdServingLines");
|
||||||
|
if (!pp.isEmptyElementTag())
|
||||||
|
{
|
||||||
|
XmlPullUtil.enter(pp);
|
||||||
|
while (XmlPullUtil.test(pp, "itdServingLine"))
|
||||||
|
{
|
||||||
|
final String line = parseLine(pp.getAttributeValue(null, "motType"), pp.getAttributeValue(null, "number"), pp
|
||||||
|
.getAttributeValue(null, "number"));
|
||||||
|
final String destination = normalizeLocationName(pp.getAttributeValue(null, "direction"));
|
||||||
|
final String destinationIdStr = pp.getAttributeValue(null, "destID");
|
||||||
|
final int destinationId = destinationIdStr.length() > 0 ? Integer.parseInt(destinationIdStr) : 0;
|
||||||
|
lines.add(new Line(line, lineColors(line), destinationId, destination));
|
||||||
|
|
||||||
|
XmlPullUtil.enter(pp);
|
||||||
|
XmlPullUtil.exit(pp);
|
||||||
|
}
|
||||||
|
XmlPullUtil.exit(pp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XmlPullUtil.next(pp);
|
||||||
|
}
|
||||||
|
|
||||||
final List<Departure> departures = new ArrayList<Departure>(8);
|
final List<Departure> departures = new ArrayList<Departure>(8);
|
||||||
|
|
||||||
XmlPullUtil.jumpToStartTag(pp, null, "itdDepartureList");
|
XmlPullUtil.require(pp, "itdDepartureList");
|
||||||
while (XmlPullUtil.nextStartTagInsideTree(pp, null, "itdDeparture"))
|
while (XmlPullUtil.nextStartTagInsideTree(pp, null, "itdDeparture"))
|
||||||
{
|
{
|
||||||
if (Integer.parseInt(pp.getAttributeValue(null, "stopID")) == locationId)
|
if (Integer.parseInt(pp.getAttributeValue(null, "stopID")) == locationId)
|
||||||
|
@ -707,7 +734,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
||||||
XmlPullUtil.skipRestOfTree(pp);
|
XmlPullUtil.skipRestOfTree(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, 0, 0, location), departures);
|
return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, 0, 0, location), departures, lines);
|
||||||
}
|
}
|
||||||
else if ("notidentified".equals(nameState))
|
else if ("notidentified".equals(nameState))
|
||||||
{
|
{
|
||||||
|
|
|
@ -504,7 +504,7 @@ public final class BahnProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), 0, 0, null), departures);
|
return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), 0, 0, null), departures, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -531,7 +531,7 @@ public final class BvgProvider implements NetworkProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), 0, 0, location), departures);
|
return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), 0, 0, location), departures, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -207,7 +207,7 @@ public class NasaProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), 0, 0, location), departures);
|
return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), 0, 0, location), departures, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -535,7 +535,7 @@ public class OebbProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, 0, 0, location), departures);
|
return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, 0, 0, location), departures, null);
|
||||||
}
|
}
|
||||||
catch (final JSONException x)
|
catch (final JSONException x)
|
||||||
{
|
{
|
||||||
|
|
|
@ -520,7 +520,7 @@ public class RmvProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, 0, 0, location), departures);
|
return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, 0, 0, location), departures, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -172,7 +172,7 @@ public class SbbProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, 0, 0, location), departures);
|
return new QueryDeparturesResult(new Location(LocationType.STATION, locationId, 0, 0, location), departures, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class SncbProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), 0, 0, location), departures);
|
return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), 0, 0, location), departures, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -207,7 +207,7 @@ public class VgsProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), 0, 0, location), departures);
|
return new QueryDeparturesResult(new Location(LocationType.STATION, Integer.parseInt(stationId), 0, 0, location), departures, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
95
src/de/schildbach/pte/dto/Line.java
Normal file
95
src/de/schildbach/pte/dto/Line.java
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 the original author or authors.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.schildbach.pte.dto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Andreas Schildbach
|
||||||
|
*/
|
||||||
|
public final class Line
|
||||||
|
{
|
||||||
|
final public String line;
|
||||||
|
final public int[] lineColors;
|
||||||
|
final public int destinationId;
|
||||||
|
final public String destination;
|
||||||
|
|
||||||
|
public Line(final String line, final int[] lineColors, final int destinationId, final String destination)
|
||||||
|
{
|
||||||
|
this.line = line;
|
||||||
|
this.lineColors = lineColors;
|
||||||
|
this.destinationId = destinationId;
|
||||||
|
this.destination = destination;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
StringBuilder builder = new StringBuilder("Line(");
|
||||||
|
builder.append(line != null ? line : "null");
|
||||||
|
builder.append(",");
|
||||||
|
builder.append(destinationId);
|
||||||
|
builder.append(",");
|
||||||
|
builder.append(destination != null ? destination : "null");
|
||||||
|
builder.append(")");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(final Object o)
|
||||||
|
{
|
||||||
|
if (o == this)
|
||||||
|
return true;
|
||||||
|
if (!(o instanceof Line))
|
||||||
|
return false;
|
||||||
|
final Line other = (Line) o;
|
||||||
|
if (!nullSafeEquals(this.line, other.line))
|
||||||
|
return false;
|
||||||
|
if (this.destinationId != other.destinationId)
|
||||||
|
return false;
|
||||||
|
if (!this.destination.equals(other.destination))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
int hashCode = 0;
|
||||||
|
hashCode += nullSafeHashCode(line);
|
||||||
|
hashCode *= 29;
|
||||||
|
hashCode += destinationId;
|
||||||
|
hashCode *= 29;
|
||||||
|
hashCode += destination.hashCode();
|
||||||
|
return hashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean nullSafeEquals(final Object o1, final Object o2)
|
||||||
|
{
|
||||||
|
if (o1 == null && o2 == null)
|
||||||
|
return true;
|
||||||
|
if (o1 != null && o1.equals(o2))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int nullSafeHashCode(final Object o)
|
||||||
|
{
|
||||||
|
if (o == null)
|
||||||
|
return 0;
|
||||||
|
return o.hashCode();
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,12 +32,14 @@ public final class QueryDeparturesResult
|
||||||
public final Status status;
|
public final Status status;
|
||||||
public final Location location;
|
public final Location location;
|
||||||
public final List<Departure> departures;
|
public final List<Departure> departures;
|
||||||
|
public final List<Line> lines;
|
||||||
|
|
||||||
public QueryDeparturesResult(final Location location, final List<Departure> departures)
|
public QueryDeparturesResult(final Location location, final List<Departure> departures, final List<Line> lines)
|
||||||
{
|
{
|
||||||
this.status = Status.OK;
|
this.status = Status.OK;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.departures = departures;
|
this.departures = departures;
|
||||||
|
this.lines = lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryDeparturesResult(final Status status, final int locationId)
|
public QueryDeparturesResult(final Status status, final int locationId)
|
||||||
|
@ -45,5 +47,6 @@ public final class QueryDeparturesResult
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.location = new Location(LocationType.STATION, locationId, 0, 0, null);
|
this.location = new Location(LocationType.STATION, locationId, 0, 0, null);
|
||||||
this.departures = null;
|
this.departures = null;
|
||||||
|
this.lines = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue