decouple station list object from station dto

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@491 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach@gmail.com 2011-02-11 17:43:46 +00:00
parent a990586727
commit 240e95d19b
5 changed files with 9 additions and 20 deletions

View file

@ -293,7 +293,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
{ {
final Location ownLocation = processOdvNameElem(pp, place); final Location ownLocation = processOdvNameElem(pp, place);
final Station ownStation = ownLocation.type == LocationType.STATION ? new Station(ownLocation.id, ownLocation.place, final Station ownStation = ownLocation.type == LocationType.STATION ? new Station(ownLocation.id, ownLocation.place,
ownLocation.name, null, ownLocation.lat, ownLocation.lon, 0, null, null) : null; ownLocation.name, null, ownLocation.lat, ownLocation.lon) : null;
final List<Station> stations = new ArrayList<Station>(); final List<Station> stations = new ArrayList<Station>();
@ -310,8 +310,6 @@ public abstract class AbstractEfaProvider implements NetworkProvider
final String parsedPlace = normalizeLocationName(XmlPullUtil.attr(pp, "place")); final String parsedPlace = normalizeLocationName(XmlPullUtil.attr(pp, "place"));
final int parsedLon = XmlPullUtil.intAttr(pp, "x"); final int parsedLon = XmlPullUtil.intAttr(pp, "x");
final int parsedLat = XmlPullUtil.intAttr(pp, "y"); final int parsedLat = XmlPullUtil.intAttr(pp, "y");
final String parsedDistStr = pp.getAttributeValue(null, "distance");
final int parsedDist = parsedDistStr != null ? Integer.parseInt(parsedDistStr) : 0;
XmlPullUtil.enter(pp, "itdOdvAssignedStop"); XmlPullUtil.enter(pp, "itdOdvAssignedStop");
final String parsedName = normalizeLocationName(pp.getText()); final String parsedName = normalizeLocationName(pp.getText());
XmlPullUtil.exit(pp, "itdOdvAssignedStop"); XmlPullUtil.exit(pp, "itdOdvAssignedStop");
@ -319,8 +317,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
if (!"WGS84".equals(parsedMapName)) if (!"WGS84".equals(parsedMapName))
throw new IllegalStateException("unknown mapName: " + parsedMapName); throw new IllegalStateException("unknown mapName: " + parsedMapName);
final Station newStation = new Station(parsedLocationId, parsedPlace, parsedName, parsedLongName, parsedLat, parsedLon, final Station newStation = new Station(parsedLocationId, parsedPlace, parsedName, parsedLongName, parsedLat, parsedLon);
parsedDist, null, null);
if (!stations.contains(newStation)) if (!stations.contains(newStation))
stations.add(newStation); stations.add(newStation);
} }
@ -358,7 +355,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
final Location location = processOdvNameElem(pp, place); final Location location = processOdvNameElem(pp, place);
if (location.type == LocationType.STATION) if (location.type == LocationType.STATION)
{ {
final Station newStation = new Station(location.id, null, null, location.name, location.lat, location.lon, 0, null, null); final Station newStation = new Station(location.id, null, null, location.name, location.lat, location.lon);
if (!stations.contains(newStation)) if (!stations.contains(newStation))
stations.add(newStation); stations.add(newStation);
} }

View file

@ -793,7 +793,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
} }
final String[] nameAndPlace = splitNameAndPlace(parsedName); final String[] nameAndPlace = splitNameAndPlace(parsedName);
stations.add(new Station(parsedId, nameAndPlace[0], nameAndPlace[1], parsedName, parsedLat, parsedLon, 0, null, null)); stations.add(new Station(parsedId, nameAndPlace[0], nameAndPlace[1], parsedName, parsedLat, parsedLon));
} }
else else
{ {

View file

@ -96,7 +96,7 @@ public final class BahnProvider extends AbstractHafasProvider
final int sId = Integer.parseInt(m.group(1)); final int sId = Integer.parseInt(m.group(1));
final String sName = ParserUtils.resolveEntities(m.group(2).trim()); final String sName = ParserUtils.resolveEntities(m.group(2).trim());
final Station station = new Station(sId, null, sName, null, 0, 0, 0, null, null); final Station station = new Station(sId, null, sName, null, 0, 0);
stations.add(station); stations.add(station);
} }
} }
@ -113,10 +113,9 @@ public final class BahnProvider extends AbstractHafasProvider
final int sLon = Integer.parseInt(m.group(1)); final int sLon = Integer.parseInt(m.group(1));
final int sLat = Integer.parseInt(m.group(2)); final int sLat = Integer.parseInt(m.group(2));
final int sDist = Integer.parseInt(m.group(4));
final String sName = ParserUtils.resolveEntities(m.group(5).trim()); final String sName = ParserUtils.resolveEntities(m.group(5).trim());
final Station station = new Station(sId, null, sName, null, sLat, sLon, sDist, null, null); final Station station = new Station(sId, null, sName, null, sLat, sLon);
stations.add(station); stations.add(station);
} }
} }

View file

@ -212,14 +212,14 @@ public final class BvgProvider extends AbstractHafasProvider
else if (parsedName.startsWith("Frankfurt (Oder), ")) else if (parsedName.startsWith("Frankfurt (Oder), "))
{ {
place = "Frankfurt (Oder)"; place = "Frankfurt (Oder)";
name = parsedName.substring(19); name = parsedName.substring(18);
} }
else else
{ {
longName = parsedName; longName = parsedName;
} }
return new Station(id, place, name, longName, lat, lon, 0, null, null); return new Station(id, place, name, longName, lat, lon);
} }
public static final String STATION_URL_CONNECTION = "http://mobil.bvg.de/Fahrinfo/bin/query.bin/dox"; public static final String STATION_URL_CONNECTION = "http://mobil.bvg.de/Fahrinfo/bin/query.bin/dox";

View file

@ -28,12 +28,8 @@ public final class Station
public final String name; public final String name;
public final String longName; public final String longName;
public final int latitude, longitude; public final int latitude, longitude;
public float distance;
public final String[] lines;
public final int[][] lineColors;
public Station(final int id, final String place, final String name, final String longName, final int latitude, final int longitude, public Station(final int id, final String place, final String name, final String longName, final int latitude, final int longitude)
final float distance, final String[] lines, final int[][] lineColors)
{ {
this.id = id; this.id = id;
this.place = place; this.place = place;
@ -41,9 +37,6 @@ public final class Station
this.longName = longName; this.longName = longName;
this.latitude = latitude; this.latitude = latitude;
this.longitude = longitude; this.longitude = longitude;
this.distance = distance;
this.lines = lines;
this.lineColors = lineColors;
} }
public final boolean hasLocation() public final boolean hasLocation()