mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-16 17:39:49 +00:00
hasLocation() convenience methods
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@474 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
2cc93f99bd
commit
8b72c7cafe
5 changed files with 18 additions and 8 deletions
|
@ -1476,7 +1476,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
|
||||
protected void appendLocation(final StringBuilder uri, final Location location, final String paramSuffix)
|
||||
{
|
||||
if ((location.type == LocationType.POI || location.type == LocationType.ADDRESS) && location.lat != 0 && location.lon != 0)
|
||||
if ((location.type == LocationType.POI || location.type == LocationType.ADDRESS) && location.hasLocation())
|
||||
{
|
||||
uri.append("&type_").append(paramSuffix).append("=coord");
|
||||
uri.append("&name_").append(paramSuffix).append("=")
|
||||
|
|
|
@ -550,9 +550,9 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
{
|
||||
if (location.type == LocationType.STATION && location.id != 0)
|
||||
return "<Station externalId=\"" + location.id + "\" />";
|
||||
if (location.type == LocationType.POI && (location.lat != 0 || location.lon != 0))
|
||||
if (location.type == LocationType.POI && location.hasLocation())
|
||||
return "<Poi type=\"WGS84\" x=\"" + location.lon + "\" y=\"" + location.lat + "\" />";
|
||||
if (location.type == LocationType.ADDRESS && (location.lat != 0 || location.lon != 0))
|
||||
if (location.type == LocationType.ADDRESS && location.hasLocation())
|
||||
return "<Address type=\"WGS84\" x=\"" + location.lon + "\" y=\"" + location.lat + "\" />";
|
||||
|
||||
throw new IllegalArgumentException("cannot handle: " + location.toDebugString());
|
||||
|
@ -562,7 +562,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
{
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append("A=").append(locationType(location));
|
||||
if (location.lat != 0 || location.lon != 0)
|
||||
if (location.hasLocation())
|
||||
builder.append("@X=" + location.lon + "@Y=" + location.lat);
|
||||
if (location.name != null)
|
||||
builder.append("@G=" + location.name);
|
||||
|
@ -577,7 +577,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
|||
return 1;
|
||||
if (location.type == LocationType.POI)
|
||||
return 4;
|
||||
if (location.type == LocationType.ADDRESS && (location.lat != 0 || location.lon != 0))
|
||||
if (location.type == LocationType.ADDRESS && location.hasLocation())
|
||||
return 16;
|
||||
if (location.type == LocationType.ADDRESS && location.name != null)
|
||||
return 2;
|
||||
|
|
|
@ -253,7 +253,7 @@ public final class BvgProvider extends AbstractHafasProvider
|
|||
|
||||
private static final void appendLocationBvg(final StringBuilder uri, final Location location, final String paramSuffix, final String paramWgs)
|
||||
{
|
||||
if (location.type == LocationType.ADDRESS && location.lat != 0 && location.lon != 0 && paramWgs != null)
|
||||
if (location.type == LocationType.ADDRESS && location.hasLocation() && paramWgs != null)
|
||||
{
|
||||
uri.append("&").append(paramWgs).append("=").append(ParserUtils.urlEncode("A=16@X=" + location.lon + "@Y=" + location.lat));
|
||||
}
|
||||
|
|
|
@ -70,6 +70,11 @@ public final class Location implements Serializable
|
|||
this.name = null;
|
||||
}
|
||||
|
||||
public final boolean hasLocation()
|
||||
{
|
||||
return lat != 0 || lon != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -32,8 +32,8 @@ public final class Station
|
|||
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, final float distance,
|
||||
final String[] lines, final int[][] lineColors)
|
||||
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.place = place;
|
||||
|
@ -46,6 +46,11 @@ public final class Station
|
|||
this.lineColors = lineColors;
|
||||
}
|
||||
|
||||
public final boolean hasLocation()
|
||||
{
|
||||
return latitude != 0 || longitude != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue