Merge pull request #542 from moving-bits/blockformatting

Unify brackets for opening blocks with comments
This commit is contained in:
afischerdev 2023-04-30 10:33:54 +02:00 committed by GitHub
commit 2c707c977b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 83 additions and 164 deletions

View file

@ -46,8 +46,7 @@ final class KinematicPath extends OsmPath {
} else {
double turnspeed = 999.; // just high
if (km.turnAngleDecayTime != 0.) // process turn-angle slowdown
{
if (km.turnAngleDecayTime != 0.) { // process turn-angle slowdown
if (angle < 0) floatingAngleLeft -= (float) angle;
else floatingAngleRight += (float) angle;
float aa = Math.max(floatingAngleLeft, floatingAngleRight);
@ -63,8 +62,7 @@ final class KinematicPath extends OsmPath {
}
}
if (nsection == 0) // process slowdown by crossing geometry
{
if (nsection == 0) { // process slowdown by crossing geometry
double junctionspeed = 999.; // just high
int classifiermask = (int) rc.expctxWay.getClassifierMask();
@ -76,13 +74,11 @@ final class KinematicPath extends OsmPath {
for (OsmPrePath prePath = rc.firstPrePath; prePath != null; prePath = prePath.next) {
KinematicPrePath pp = (KinematicPrePath) prePath;
if (((pp.classifiermask ^ classifiermask) & 8) != 0) // exactly one is linktype
{
if (((pp.classifiermask ^ classifiermask) & 8) != 0) { // exactly one is linktype
continue;
}
if ((pp.classifiermask & 32) != 0) // touching a residential?
{
if ((pp.classifiermask & 32) != 0) { // touching a residential?
hasResidential = true;
}

View file

@ -182,22 +182,17 @@ public class OsmNogoPolygon extends OsmNodeNamed {
final double v12x = p1x - p0x;
final double v12y = p1y - p0y;
if (v10x == 0) // P0->P1 vertical?
{
if (v10y == 0) // P0 == P1?
{
if (v10x == 0) { // P0->P1 vertical?
if (v10y == 0) { // P0 == P1?
return true;
}
if (v12x != 0) // P1->P2 not vertical?
{
if (v12x != 0) { // P1->P2 not vertical?
return false;
}
return (v12y / v10y) >= 1; // P1->P2 at least as long as P1->P0?
}
if (v10y == 0) // P0->P1 horizontal?
{
if (v12y != 0) // P1->P2 not horizontal?
{
if (v10y == 0) { // P0->P1 horizontal?
if (v12y != 0) { // P1->P2 not horizontal?
return false;
}
// if ( P10x == 0 ) // P0 == P1? already tested
@ -233,8 +228,7 @@ public class OsmNogoPolygon extends OsmNodeNamed {
long p0x = p0.x; // need to use long to avoid overflow in products
long p0y = p0.y;
for (int i = isClosed ? 0 : 1; i <= i_last; i++) // edge from v[i] to v[i+1]
{
for (int i = isClosed ? 0 : 1; i <= i_last; i++) { // edge from v[i] to v[i+1]
final Point p1 = points.get(i);
final long p1x = p1.x;
@ -246,16 +240,13 @@ public class OsmNogoPolygon extends OsmNodeNamed {
if (p0y <= py) // start y <= p.y
{
if (p1y > py) // an upward crossing
{ // p left of edge
if (p1y > py) { // an upward crossing, p left of edge
if (((p1x - p0x) * (py - p0y) - (px - p0x) * (p1y - p0y)) > 0) {
++wn; // have a valid up intersect
}
}
} else // start y > p.y (no test needed)
{
if (p1y <= py) // a downward crossing
{ // p right of edge
} else { // start y > p.y (no test needed)
if (p1y <= py) { // a downward crossing, p right of edge
if (((p1x - p0x) * (py - p0y) - (px - p0x) * (p1y - p0y)) < 0) {
--wn; // have a valid down intersect
}
@ -380,8 +371,7 @@ public class OsmNogoPolygon extends OsmNodeNamed {
final int sp0x = seg_p0.x;
final int sp1x = seg_p1.x;
if (sp0x != sp1x) // S is not vertical
{
if (sp0x != sp1x) { // S is not vertical
final int px = p.x;
if (sp0x <= px && px <= sp1x) {
return true;

View file

@ -433,8 +433,7 @@ public final class OsmTrack {
}
}
if (turnInstructionMode == 4) // comment style
{
if (turnInstructionMode == 4) { // comment style
sb.append("<!-- $transport-mode$").append(voiceHints.getTransportMode()).append("$ -->\n");
sb.append("<!-- cmd idx lon lat d2next geometry -->\n");
sb.append("<!-- $turn-instruction-start$\n");
@ -477,8 +476,7 @@ public final class OsmTrack {
sb.append(" </extensions>\n");
sb.append(" </metadata>\n");
}
if (turnInstructionMode == 3 || turnInstructionMode == 8) // osmand style, cruiser
{
if (turnInstructionMode == 3 || turnInstructionMode == 8) { // osmand style, cruiser
float lastRteTime = 0;
sb.append(" <rte>\n");
@ -490,8 +488,7 @@ public final class OsmTrack {
first.append(" <rtept lat=\"").append(formatILat(nodes.get(0).getILat())).append("\" lon=\"")
.append(formatILon(nodes.get(0).getILon())).append("\">\n")
.append(" <desc>start</desc>\n <extensions>\n");
if (rteTime != lastRteTime) // add timing only if available
{
if (rteTime != lastRteTime) { // add timing only if available
double t = rteTime - lastRteTime;
first.append(" <time>").append("" + (int) (t + 0.5)).append("</time>\n");
lastRteTime = rteTime;
@ -518,8 +515,7 @@ public final class OsmTrack {
rteTime = getVoiceHintTime(i + 1);
if (rteTime != lastRteTime) // add timing only if available
{
if (rteTime != lastRteTime) { // add timing only if available
double t = rteTime - lastRteTime;
sb.append(" <time>").append("" + (int) (t + 0.5)).append("</time>\n");
lastRteTime = rteTime;
@ -538,8 +534,7 @@ public final class OsmTrack {
sb.append("</rte>\n");
}
if (turnInstructionMode == 7) // old locus style
{
if (turnInstructionMode == 7) { // old locus style
float lastRteTime = getVoiceHintTime(0);
for (int i = 0; i < voiceHints.list.size(); i++) {
@ -550,8 +545,7 @@ public final class OsmTrack {
.append("<name>").append(hint.getMessageString()).append("</name>")
.append("<extensions><locus:rteDistance>").append("" + hint.distanceToNext).append("</locus:rteDistance>");
float rteTime = getVoiceHintTime(i + 1);
if (rteTime != lastRteTime) // add timing only if available
{
if (rteTime != lastRteTime) { // add timing only if available
double t = rteTime - lastRteTime;
double speed = hint.distanceToNext / t;
sb.append("<locus:rteTime>").append("" + t).append("</locus:rteTime>")
@ -562,8 +556,7 @@ public final class OsmTrack {
.append("</wpt>\n");
}
}
if (turnInstructionMode == 5) // gpsies style
{
if (turnInstructionMode == 5) { // gpsies style
for (VoiceHint hint : voiceHints.list) {
sb.append(" <wpt lon=\"").append(formatILon(hint.ilon)).append("\" lat=\"")
.append(formatILat(hint.ilat)).append("\">")
@ -574,8 +567,7 @@ public final class OsmTrack {
}
}
if (turnInstructionMode == 6) // orux style
{
if (turnInstructionMode == 6) { // orux style
for (VoiceHint hint : voiceHints.list) {
sb.append(" <wpt lat=\"").append(formatILat(hint.ilat)).append("\" lon=\"")
.append(formatILon(hint.ilon)).append("\">")
@ -971,8 +963,7 @@ public final class OsmTrack {
sb.append(',').append((int) hint.angle);
// not always include geometry because longer and only needed for comment style
if (turnInstructionMode == 4) // comment style
{
if (turnInstructionMode == 4) { // comment style
sb.append(",\"").append(hint.formatGeometry()).append("\"");
}
@ -981,8 +972,7 @@ public final class OsmTrack {
sb.deleteCharAt(sb.lastIndexOf(","));
sb.append(" ],\n");
}
if (showSpeedProfile) // set in profile
{
if (showSpeedProfile) { // set in profile
List<String> sp = aggregateSpeedProfile();
if (sp.size() > 0) {
sb.append(" \"speedprofile\": [\n");
@ -1033,8 +1023,7 @@ public final class OsmTrack {
OsmPathElement nn = null;
for (OsmPathElement n : nodes) {
String sele = n.getSElev() == Short.MIN_VALUE ? "" : ", " + n.getElev();
if (showspeed) // hack: show speed instead of elevation
{
if (showspeed) { // hack: show speed instead of elevation
double speed = 0;
if (nn != null) {
int dist = n.calcDistance(nn);

View file

@ -165,8 +165,7 @@ public final class RoutingContext {
showTime = 0.f != expctxGlobal.getVariableValue("showtime", 0.f);
int tiMode = (int) expctxGlobal.getVariableValue("turnInstructionMode", 0.f);
if (tiMode != 1) // automatic selection from coordinate source
{
if (tiMode != 1) { // automatic selection from coordinate source
turnInstructionMode = tiMode;
}
turnInstructionCatchingRange = expctxGlobal.getVariableValue("turnInstructionCatchingRange", 40.f);
@ -431,8 +430,7 @@ public final class RoutingContext {
double r22 = x2 * x2 + y2 * y2;
double radius = Math.abs(r12 < r22 ? y1 * dx - x1 * dy : y2 * dx - x2 * dy) / d;
if (radius < nogo.radius) // 20m
{
if (radius < nogo.radius) { // 20m
double s1 = x1 * dx + y1 * dy;
double s2 = x2 * dx + y2 * dy;

View file

@ -872,8 +872,7 @@ public class RoutingEngine extends Thread {
try {
t = findTrack(cfi == 0 ? "pass0" : "pass1", startWp, endWp, track, refTrack, false);
} catch (IllegalArgumentException iae) {
if (!terminated && matchPath != null) // timeout, but eventually prepare a dirty ref track
{
if (!terminated && matchPath != null) { // timeout, but eventually prepare a dirty ref track
logInfo("supplying dirty reference track after timeout");
foundRawTrack = mergeTrack(matchPath, track);
foundRawTrack.endPoint = endWp;
@ -901,8 +900,7 @@ public class RoutingEngine extends Thread {
OsmPathElement lastElement = null;
boolean wasClean = nearbyTrack != null && !nearbyTrack.isDirty;
if (refTrack == null && !(wasClean && isDirty)) // do not overwrite a clean with a dirty track
{
if (refTrack == null && !(wasClean && isDirty)) { // do not overwrite a clean with a dirty track
logInfo("supplying new reference track, dirty=" + isDirty);
track.endPoint = endWp;
track.nogoChecksums = routingContext.getNogoChecksums();
@ -1175,8 +1173,7 @@ public class RoutingEngine extends Thread {
}
}
if (nodeLimit > 0) // check node-limit for target island search
{
if (nodeLimit > 0) { // check node-limit for target island search
if (--nodeLimit == 0) {
return null;
}
@ -1202,8 +1199,7 @@ public class RoutingEngine extends Thread {
}
if (path.treedepth != 1) {
if (path.treedepth == 0) // hack: sameSegment Paths marked treedepth=0 to pass above check
{
if (path.treedepth == 0) { // hack: sameSegment Paths marked treedepth=0 to pass above check
path.treedepth = 1;
}

View file

@ -214,8 +214,7 @@ public final class VoiceHintProcessor {
hint.distanceToNext += dist;
hint.angle += h2.angle;
i--;
if (h2.isRoundabout()) // if we hit a roundabout, use that as the trigger
{
if (h2.isRoundabout()) { // if we hit a roundabout, use that as the trigger
h2.angle = hint.angle;
hint = h2;
break;