package net.osmand.data; import java.util.ArrayList; import java.util.Collections; import java.util.List; import net.osmand.osm.MapUtils; import net.osmand.osm.Relation; import net.osmand.osm.Way; public class TransportRoute extends MapObject { private List ways; private List forwardStops = new ArrayList(); private List backwardStops = new ArrayList(); private String ref; private String operator; private String type; private Integer dist = null; public TransportRoute(Relation r, String ref){ super(r); this.ref = ref; } public TransportRoute(){ } public List getForwardStops() { return forwardStops; } public List getBackwardStops() { return backwardStops; } public List getWays() { if(ways == null){ return Collections.emptyList(); } return ways; } public void addWay(Way w){ if(ways == null){ ways = new ArrayList(); } ways.add(w); } public String getRef() { return ref; } public void setRef(String ref) { this.ref = ref; } public String getOperator() { return operator; } public void setOperator(String operator) { this.operator = operator; } public String getType() { return type; } public void setType(String type) { this.type = type; } public int getDistance(){ if(dist == null){ dist = getAvgBothDistance(); } return dist; } public void setDistance(Integer dist) { this.dist = dist; } public int getAvgBothDistance(){ int d = 0; int bSsize = backwardStops.size(); int fSsize = forwardStops.size(); for(int i=1; i< bSsize; i++){ d += MapUtils.getDistance(backwardStops.get(i-1).getLocation(), backwardStops.get(i).getLocation()); } for(int i=1; i< fSsize; i++){ d += MapUtils.getDistance(forwardStops.get(i-1).getLocation(), forwardStops.get(i).getLocation()); } return d; } }