-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
RouteDirectionInfo.java
135 lines (103 loc) · 3.19 KB
/
RouteDirectionInfo.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package net.osmand.plus.routing;
import androidx.annotation.Nullable;
import net.osmand.binary.RouteDataObject;
import net.osmand.plus.utils.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.router.ExitInfo;
import net.osmand.router.TurnType;
public class RouteDirectionInfo {
// location when you should action (turn or go ahead)
public int routePointOffset;
// location where direction end. useful for roundabouts.
public int routeEndPointOffset;
// Type of action to take
private final TurnType turnType;
// Description of the turn and route after
private String descriptionRoute = ""; //$NON-NLS-1$
// Speed after the action till next turn
private float averageSpeed;
private String ref;
private String streetName;
private String destinationName;
private RouteDataObject routeDataObject;
@Nullable
private ExitInfo exitInfo;
public String getDestinationName() {
return destinationName;
}
public void setDestinationName(String destinationName) {
this.destinationName = destinationName;
}
// Constructor to verify average speed always > 0
public RouteDirectionInfo(float averageSpeed, TurnType turnType) {
this.averageSpeed = averageSpeed == 0 ? 1 : averageSpeed;
this.turnType = turnType;
}
public RouteDataObject getRouteDataObject() {
return routeDataObject;
}
public void setRouteDataObject(RouteDataObject routeDataObject) {
this.routeDataObject = routeDataObject;
}
public String getDescriptionRoute(OsmandApplication ctx) {
if (!descriptionRoute.endsWith(OsmAndFormatter.getFormattedDistance(distance, ctx))) {
descriptionRoute += " " + OsmAndFormatter.getFormattedDistance(distance, ctx);
}
return descriptionRoute.trim();
}
public String getDescriptionRoute(OsmandApplication ctx, int collectedDistance) {
if (!descriptionRoute.endsWith(OsmAndFormatter.getFormattedDistance(collectedDistance, ctx))) {
descriptionRoute += " " + OsmAndFormatter.getFormattedDistance(collectedDistance, ctx);
}
return descriptionRoute.trim();
}
public String getDescriptionRoutePart() {
return descriptionRoute;
}
public String getRef() {
return ref;
}
public void setRef(String ref) {
this.ref = ref;
}
public String getStreetName() {
return streetName;
}
public void setStreetName(String streetName) {
this.streetName = streetName;
}
public void setDescriptionRoute(String descriptionRoute) {
this.descriptionRoute = descriptionRoute;
}
public float getAverageSpeed() {
return averageSpeed;
}
public void setAverageSpeed(float averageSpeed) {
this.averageSpeed = averageSpeed == 0 ? 1 : averageSpeed;
}
// expected time after route point
public int getExpectedTime() {
return Math.round(distance / averageSpeed);
}
public TurnType getTurnType() {
return turnType;
}
// calculated vars
// after action (excluding expectedTime)
public int afterLeftTime;
// distance after action (for i.e. after turn to next turn)
public int distance;
public int getDistance() {
return distance;
}
public void setDistance(int distance) {
this.distance = distance;
}
@Nullable
public ExitInfo getExitInfo() {
return exitInfo;
}
public void setExitInfo(@Nullable ExitInfo exitInfo) {
this.exitInfo = exitInfo;
}
}