2010-06-14 23:14:36 +02:00
|
|
|
package com.osmand.data;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
2010-07-01 14:41:57 +02:00
|
|
|
import com.osmand.osm.MapUtils;
|
2010-06-14 23:14:36 +02:00
|
|
|
import com.osmand.osm.Relation;
|
|
|
|
import com.osmand.osm.Way;
|
|
|
|
|
|
|
|
public class TransportRoute extends MapObject {
|
|
|
|
private List<Way> ways;
|
|
|
|
private List<TransportStop> forwardStops = new ArrayList<TransportStop>();
|
|
|
|
private List<TransportStop> backwardStops = new ArrayList<TransportStop>();
|
|
|
|
private String ref;
|
2010-07-01 14:41:57 +02:00
|
|
|
private String operator;
|
|
|
|
private String type;
|
2010-06-14 23:14:36 +02:00
|
|
|
|
|
|
|
public TransportRoute(Relation r, String ref){
|
|
|
|
super(r);
|
|
|
|
this.ref = ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<TransportStop> getForwardStops() {
|
|
|
|
return forwardStops;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<TransportStop> getBackwardStops() {
|
|
|
|
return backwardStops;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Way> getWays() {
|
|
|
|
if(ways == null){
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
return ways;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addWay(Way w){
|
|
|
|
if(ways == null){
|
|
|
|
ways = new ArrayList<Way>();
|
|
|
|
}
|
|
|
|
ways.add(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getRef() {
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRef(String ref) {
|
|
|
|
this.ref = ref;
|
|
|
|
}
|
|
|
|
|
2010-07-01 14:41:57 +02:00
|
|
|
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 getAvgBothDistance(){
|
|
|
|
int d = 0;
|
|
|
|
for(int i=1; i< backwardStops.size(); i++){
|
|
|
|
d += MapUtils.getDistance(backwardStops.get(i-1).getLocation(), backwardStops.get(i).getLocation());
|
|
|
|
}
|
|
|
|
for(int i=1; i< forwardStops.size(); i++){
|
|
|
|
d += MapUtils.getDistance(forwardStops.get(i-1).getLocation(), forwardStops.get(i).getLocation());
|
|
|
|
}
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
2010-06-14 23:14:36 +02:00
|
|
|
|
|
|
|
}
|