Package: tunnelx Version: 20160713-3 Severity: normal Tags: patch I'm too lazy to type decimal points, so my Survex data files have
/-------- | *units tape 0.001 metres | *units compass clino 0.1 degrees \-------- When I import this as centreline, Tunnel does nothing, but prints an exception to its output. It will only accept angle units that are exactly 1.0 of the known measures. I've written a patch to permit angle units of any size. As I couldn't find any unit tests in the source package, it's just been tested with my own data files (as above), and I don't use grads or percent, so those are tested only by inspection. However, the patch is probably still suitable for forwarding upstream.
Index: tunnelx-20160713/src/LegLineFormat.java =================================================================== --- tunnelx-20160713.orig/src/LegLineFormat.java +++ tunnelx-20160713/src/LegLineFormat.java @@ -28,9 +28,10 @@ import java.util.ArrayList; // public class LegLineFormat// implements Cloneable { - static int DEGREES = 0; - static int GRADS = 1; - static int PERCENT = 2; + // angular units are positive for degrees; negative for percent + static final float DEGREES = 1; + static final float GRADS = 400F / 360F; + static final float PERCENT = 1; static float TAPEFAC_M = 1.0F; static float TAPEFAC_CM = 0.01F; @@ -57,12 +58,13 @@ public class LegLineFormat// implements float compassnegoffset = 0.0F; float backcompassnegoffset = 0.0F; float compassnegoffsetdeclination = 0.0F; // a secondary offset value (separates the calibration from the magnetic wandering (declination)) - int compassfac = DEGREES; + float compassfac = DEGREES; int clinoindex = 4; int backclinoindex = -1; float clinonegoffset = 0.0F; - int clinofac = DEGREES; + float clinofac = DEGREES; + boolean clinopercent = false; int dxindex = -1; int dyindex = -1; @@ -331,8 +333,7 @@ public class LegLineFormat// implements return OneLeg.INVALID_COMPASSCLINO; float compass = GetFLval(acompass) - (bback ? backcompassnegoffset : compassnegoffset) - compassnegoffsetdeclination; - if (compassfac == GRADS) - compass *= 360.0F / 400.0F; + compass *= compassfac; while (compass < 0.0F) compass += 360.0F; @@ -359,9 +360,8 @@ public class LegLineFormat// implements { clino = GetFLval(aclino); clino -= clinonegoffset; // is there a different setting for backclino? - if (clinofac == GRADS) - clino *= 360.0F / 400.0F; - if (clinofac == PERCENT) + clino *= clinofac; + if (clinopercent) clino = (float)TN.percentdeg(clino); } return clino; @@ -618,25 +618,28 @@ public class LegLineFormat// implements else if (sunitype.equalsIgnoreCase("bearing") || sunitype.equalsIgnoreCase("compass")) { - assert sunitval2.equals("") || (fac == 1.0); + assert sunitval2.equals("") || (fac != 0); if (sunitval.equalsIgnoreCase("degrees")) - compassfac = DEGREES; + compassfac = DEGREES * fac; else if (sunitval.equalsIgnoreCase("grads")) - compassfac = GRADS; + compassfac = GRADS * fac; else TN.emitWarning("don't know *Units bearing " + sunitval1 + "," + sunitval2); } else if (sunitype.equalsIgnoreCase("gradient") || sunitype.equalsIgnoreCase("clino")) { - assert sunitval2.equals("") || (fac == 1.0); - if (sunitval.equalsIgnoreCase("degrees")) - clinofac = DEGREES; - else if (sunitval.equalsIgnoreCase("grads")) - clinofac = GRADS; - else if (sunitval.equalsIgnoreCase("percent")) - clinofac = PERCENT; - else + assert sunitval2.equals("") || (fac != 0); + if (sunitval.equalsIgnoreCase("degrees")) { + clinopercent = false; + clinofac = DEGREES * fac; + } else if (sunitval.equalsIgnoreCase("grads")) { + clinopercent = false; + clinofac = GRADS * fac; + } else if (sunitval.equalsIgnoreCase("percent")) { + clinopercent = true; + clinofac = PERCENT * fac; + } else TN.emitWarning("don't know *Units gradient " + sunitval1 + "," + sunitval2); }
-- System Information: Debian Release: 9.0 APT prefers testing APT policy: (900, 'testing'), (900, 'stable'), (400, 'unstable') Architecture: amd64 (x86_64) Foreign Architectures: i386, armel Kernel: Linux 3.16.7-ckt2-balti (SMP w/8 CPU cores; PREEMPT) Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: sysvinit (via /sbin/init) Versions of packages tunnelx depends on: ii default-jre [java8-runtime] 2:1.8-58 ii gcj-4.8-jre [java5-runtime] 4.8.5-4 ii jarwrapper 0.59 ii openjdk-8-jre [java8-runtime] 8u111-b14-3 tunnelx recommends no packages. tunnelx suggests no packages. -- no debconf information