Cleanup recalcTrack

This commit is contained in:
quaelnix 2023-04-18 15:11:24 +02:00 committed by GitHub
parent 575c24c93d
commit 4c75de08c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -690,20 +690,10 @@ public class RoutingEngine extends Thread {
} }
private void recalcTrack(OsmTrack t) { private void recalcTrack(OsmTrack t) {
int i = 0;
int lon0,
lat0,
lon1,
lat1,
lon2,
lat2;
int totaldist = 0; int totaldist = 0;
int totaltime = 0; int totaltime = 0;
float lasttime = 0; float lasttime = 0;
float lastenergy = 0; float lastenergy = 0;
float speed_avg = 0;
float speed_min = 9999; float speed_min = 9999;
Map<Integer, Integer> directMap = new HashMap<>(); Map<Integer, Integer> directMap = new HashMap<>();
float tmptime = 1; float tmptime = 1;
@ -719,38 +709,28 @@ public class RoutingEngine extends Thread {
short ele_end = Short.MIN_VALUE; short ele_end = Short.MIN_VALUE;
double eleFactor = routingContext.inverseRouting ? 0.25 : -0.25; 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); OsmPathElement n = t.nodes.get(i);
if (n.message == null) n.message = new MessageData(); if (n.message == null) n.message = new MessageData();
OsmPathElement nLast = null; OsmPathElement nLast = null;
if (i == 0) { if (i == 0) {
lon0 = t.nodes.get(0).getILon(); angle = 0;
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();
dist = 0; dist = 0;
} else if (i == 1) { } else if (i == 1) {
lon0 = t.nodes.get(0).getILon(); angle = 0;
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();
nLast = t.nodes.get(0); nLast = t.nodes.get(0);
dist = nLast.calcDistance(n); dist = nLast.calcDistance(n);
} else { } else {
lon0 = t.nodes.get(i - 2).getILon(); int lon0 = t.nodes.get(i - 2).getILon();
lat0 = t.nodes.get(i - 2).getILat(); int lat0 = t.nodes.get(i - 2).getILat();
lon1 = t.nodes.get(i - 1).getILon(); int lon1 = t.nodes.get(i - 1).getILon();
lat1 = t.nodes.get(i - 1).getILat(); int lat1 = t.nodes.get(i - 1).getILat();
lon2 = t.nodes.get(i).getILon(); int lon2 = t.nodes.get(i).getILon();
lat2 = t.nodes.get(i).getILat(); int lat2 = t.nodes.get(i).getILat();
angle = routingContext.anglemeter.calcAngle(lon0, lat0, lon1, lat1, lon2, lat2);
nLast = t.nodes.get(i - 1); nLast = t.nodes.get(i - 1);
dist = nLast.calcDistance(n); dist = nLast.calcDistance(n);
} }
angle = routingContext.anglemeter.calcAngle(lon0, lat0, lon1, lat1, lon2, lat2);
n.message.linkdist = dist; n.message.linkdist = dist;
n.message.turnangle = (float) angle; n.message.turnangle = (float) angle;
totaldist += dist; totaldist += dist;