Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup recalcTrack #535

Merged
merged 1 commit into from
Apr 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 10 additions & 30 deletions brouter-core/src/main/java/btools/router/RoutingEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -690,20 +690,10 @@ private void setNewVoiceHint(OsmTrack t, OsmPathElement last, CompactLongMap<Osm
}

private void recalcTrack(OsmTrack t) {

int i = 0;

int lon0,
lat0,
lon1,
lat1,
lon2,
lat2;
int totaldist = 0;
int totaltime = 0;
float lasttime = 0;
float lastenergy = 0;
float speed_avg = 0;
float speed_min = 9999;
Map<Integer, Integer> directMap = new HashMap<>();
float tmptime = 1;
Expand All @@ -719,38 +709,28 @@ private void recalcTrack(OsmTrack t) {
short ele_end = Short.MIN_VALUE;
double eleFactor = routingContext.inverseRouting ? 0.25 : -0.25;

for (i = 0; i < ourSize; i++) {
for (int i = 0; i < ourSize; i++) {
OsmPathElement n = t.nodes.get(i);
if (n.message == null) n.message = new MessageData();
OsmPathElement nLast = null;
if (i == 0) {
lon0 = t.nodes.get(0).getILon();
lat0 = t.nodes.get(0).getILat();
lon1 = t.nodes.get(0).getILat();
lat1 = t.nodes.get(0).getILat();
lon2 = t.nodes.get(i).getILon();
lat2 = t.nodes.get(i).getILat();
angle = 0;
dist = 0;
} else if (i == 1) {
lon0 = t.nodes.get(0).getILon();
lat0 = t.nodes.get(0).getILat();
lon1 = t.nodes.get(1).getILon();
lat1 = t.nodes.get(1).getILat();
lon2 = t.nodes.get(i).getILon();
lat2 = t.nodes.get(i).getILat();
angle = 0;
nLast = t.nodes.get(0);
dist = nLast.calcDistance(n);
} else {
lon0 = t.nodes.get(i - 2).getILon();
lat0 = t.nodes.get(i - 2).getILat();
lon1 = t.nodes.get(i - 1).getILon();
lat1 = t.nodes.get(i - 1).getILat();
lon2 = t.nodes.get(i).getILon();
lat2 = t.nodes.get(i).getILat();
int lon0 = t.nodes.get(i - 2).getILon();
int lat0 = t.nodes.get(i - 2).getILat();
int lon1 = t.nodes.get(i - 1).getILon();
int lat1 = t.nodes.get(i - 1).getILat();
int lon2 = t.nodes.get(i).getILon();
int lat2 = t.nodes.get(i).getILat();
angle = routingContext.anglemeter.calcAngle(lon0, lat0, lon1, lat1, lon2, lat2);
nLast = t.nodes.get(i - 1);
dist = nLast.calcDistance(n);
}
angle = routingContext.anglemeter.calcAngle(lon0, lat0, lon1, lat1, lon2, lat2);
n.message.linkdist = dist;
n.message.turnangle = (float) angle;
totaldist += dist;
Expand Down