Add lanes info
This commit is contained in:
parent
708f9677c8
commit
7b0b04f701
7 changed files with 90 additions and 7 deletions
|
@ -173,6 +173,18 @@ public class RouteDataObject {
|
|||
}
|
||||
return highway;
|
||||
}
|
||||
|
||||
public int getLanes() {
|
||||
int sz = types.length;
|
||||
for (int i = 0; i < sz; i++) {
|
||||
RouteTypeRule r = region.quickGetEncodingRule(types[i]);
|
||||
int ln = r.lanes();
|
||||
if (ln > 0) {
|
||||
return ln;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Gives route direction of EAST degrees from NORTH ]-PI, PI]
|
||||
public double directionRoute(int startPoint, boolean plus) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import gnu.trove.map.hash.TLongObjectHashMap;
|
|||
import java.io.IOException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
|
@ -903,10 +904,22 @@ public class BinaryRoutePlanner {
|
|||
if (ref != null) {
|
||||
name += " " + ref;
|
||||
}
|
||||
StringBuilder additional = new StringBuilder();
|
||||
additional.append("time = \"").append(res.getSegmentTime()).append("\" ");
|
||||
additional.append("name = \"").append(name).append("\" ");
|
||||
additional.append("distance = \"").append(res.getDistance()).append("\" ");
|
||||
if(res.getTurnType() != null) {
|
||||
additional.append("turn = \"").append(res.getTurnType()).append("\" ");
|
||||
if(res.getTurnType().getLanes() != null) {
|
||||
additional.append("lanes = \"").append(Arrays.toString(res.getTurnType().getLanes())).append("\" ");
|
||||
}
|
||||
}
|
||||
additional.append("start_bearing = \"").append(res.getBearingBegin()).append("\" ");
|
||||
additional.append("end_bearing = \"").append(res.getBearingEnd()).append("\" ");
|
||||
additional.append("description = \"").append(res.getDescription()).append("\" ");
|
||||
println(MessageFormat.format(
|
||||
"\t<segment id=\"{0}\" start=\"{1}\" end=\"{2}\" time=\"{4}\" name=\"{3}\" distance=\"{5}\" start_bearing=\"{6}\" end_bearing=\"{7}\" description=\"{8}\"/>",
|
||||
(res.getObject().getId()) + "", res.getStartPointIndex() + "", res.getEndPointIndex() + "", name,
|
||||
res.getSegmentTime(),res.getDistance(), res.getBearingBegin() + "", res.getBearingEnd() + "", res.getDescription()+""));
|
||||
"\t<segment id=\"{0}\" start=\"{1}\" end=\"{2}\" {3}/>",
|
||||
(res.getObject().getId()) + "", res.getStartPointIndex() + "", res.getEndPointIndex() + "", additional.toString()));
|
||||
}
|
||||
println("</test>");
|
||||
}
|
||||
|
@ -954,7 +967,7 @@ public class BinaryRoutePlanner {
|
|||
if (prev != null) {
|
||||
// add description about turn
|
||||
double mpi = MapUtils.degreesDiff(prev.getBearingEnd(), rr.getBearingBegin());
|
||||
|
||||
int[] lanes = null;
|
||||
if (mpi >= 50) {
|
||||
if (mpi < 60) {
|
||||
t = TurnType.valueOf(TurnType.TSLL, leftSide);
|
||||
|
@ -980,16 +993,48 @@ public class BinaryRoutePlanner {
|
|||
boolean kl = false;
|
||||
boolean kr = false;
|
||||
List<RouteSegmentResult> attachedRoutes = rr.getAttachedRoutes(rr.getStartPointIndex());
|
||||
int ls = prev.getObject().getLanes();
|
||||
int left = 0;
|
||||
int right = 0;
|
||||
if (ls > 0) {
|
||||
lanes = new int[ls];
|
||||
}
|
||||
if(attachedRoutes != null){
|
||||
for(RouteSegmentResult rs : attachedRoutes){
|
||||
double ex = MapUtils.degreesDiff(rs.getBearingBegin(), rr.getBearingBegin());
|
||||
if(ex < 30 && ex >= 0) {
|
||||
kl = true;
|
||||
int lns = rs.getObject().getLanes();
|
||||
if (lns > 0) {
|
||||
right += lns;
|
||||
}
|
||||
} else if(ex > -30 && ex <= 0) {
|
||||
kr = true;
|
||||
int lns = rs.getObject().getLanes();
|
||||
if (lns > 0) {
|
||||
left += lns;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int current = rr.getObject().getLanes();
|
||||
if (current <= 0) {
|
||||
current = 1;
|
||||
}
|
||||
if(lanes != null) {
|
||||
if(current + left + right != ls){
|
||||
lanes = null;
|
||||
} else {
|
||||
for(int it=0; it< ls; it++) {
|
||||
if(it < left || it >= left + current) {
|
||||
lanes[it] = 0;
|
||||
} else {
|
||||
lanes[it] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (kl) {
|
||||
t = TurnType.valueOf(TurnType.KL, leftSide);
|
||||
} else if(kr){
|
||||
|
@ -998,7 +1043,12 @@ public class BinaryRoutePlanner {
|
|||
}
|
||||
if(t != null) {
|
||||
t.setTurnAngle((float) -mpi);
|
||||
|
||||
if (lanes != null) {
|
||||
t.setLanes(lanes);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ public class TurnType {
|
|||
private boolean isLeftSide;
|
||||
// calculated CW head rotation if previous direction to NORTH
|
||||
private float turnAngle;
|
||||
private int[] lanes;
|
||||
|
||||
private static TurnType getExitTurn(int out, float angle, boolean leftSide) {
|
||||
TurnType r = new TurnType("EXIT", out, leftSide); //$NON-NLS-1$
|
||||
|
@ -76,6 +77,17 @@ public class TurnType {
|
|||
return value.equals("EXIT"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// lanes encoded as array of int
|
||||
// last bit is 1, 0 (should we take this lane)
|
||||
// first bits 0 - left, 1 - straight, 2 - right
|
||||
public void setLanes(int[] lanes) {
|
||||
this.lanes = lanes;
|
||||
}
|
||||
|
||||
public int[] getLanes() {
|
||||
return lanes;
|
||||
}
|
||||
|
||||
public boolean keepLeft() {
|
||||
return value.equals(KL);
|
||||
}
|
||||
|
|
1
OsmAnd/.gitignore
vendored
1
OsmAnd/.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
bin/
|
||||
dist/
|
||||
gen/
|
||||
local.properties
|
||||
raw/
|
||||
|
|
|
@ -42,9 +42,11 @@ then == ['then.ogg', delay_350].
|
|||
reached_destination == ['you_have_reached_your_destination.ogg'].
|
||||
bear_right == ['keep_right-e.ogg'].
|
||||
bear_left == ['keep_left-e.ogg'].
|
||||
route_recalc(_Dist) == []. % ['recalc.ogg']. %nothing to said possibly beep?
|
||||
route_recalc(_Dist) == ['recalc.ogg']. %nothing to said possibly beep?
|
||||
route_new_calc(Dist) == ['the_trip_is_more_than.ogg', delay_150, D] :- distance(Dist) == D. % nothing to said possibly beep?
|
||||
|
||||
% location_lost == ['gps_signal_lost.ogg'].
|
||||
|
||||
go_ahead(Dist) == ['drive_for-h.ogg', delay_250, D]:- distance(Dist) == D.
|
||||
go_ahead == ['continue_straight-e.ogg'].
|
||||
|
||||
|
|
|
@ -45,6 +45,8 @@ bear_left == ['keep_left-e.ogg'].
|
|||
route_recalc(_Dist) == []. % ['recalc.ogg']. %nothing to said possibly beep?
|
||||
route_new_calc(Dist) == ['the_trip_is_more_than.ogg', delay_150, D] :- distance(Dist) == D. % nothing to said possibly beep?
|
||||
|
||||
% location_lost == ['no_file.ogg'].
|
||||
|
||||
go_ahead(Dist) == ['Drive-n.ogg', delay_250, D]:- distance(Dist) == D.
|
||||
go_ahead == ['continue_straight-e.ogg'].
|
||||
|
||||
|
|
|
@ -42,8 +42,12 @@ reached_destination == ['you_have_reached_your_destination.ogg'].
|
|||
bear_right == ['keep_right-e.ogg'].
|
||||
location_lost == ['gps_signal_lost.ogg'].
|
||||
bear_left == ['keep_left-e.ogg'].
|
||||
route_recalc(_Dist) == []. % 'recalc.ogg'
|
||||
route_new_calc(_Dist) == ['have_a_nice_trip_drive_carefully.ogg'].
|
||||
% route_recalc(_Dist) == []. % 'recalc.ogg'
|
||||
route_recalc(Dist) == Res :- go_ahead(Dist) == Res .
|
||||
% route_new_calc(_Dist) == ['have_a_nice_trip_drive_carefully.ogg'].
|
||||
route_new_calc(Dist) == Res :- go_ahead(Dist) == Res .
|
||||
|
||||
location_lost == ['gps_signal_lost.ogg'].
|
||||
|
||||
go_ahead(Dist) == ['Drive-n.ogg', D]:- distance(Dist) == D.
|
||||
go_ahead == ['continue_straight-e.ogg'].
|
||||
|
|
Loading…
Reference in a new issue