From: Keith Packard Date: Thu, 13 Feb 2020 03:59:19 +0000 (-0800) Subject: altoslib: Add 'gauss' units for magnetic field strength X-Git-Tag: android-26~14 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=4435843fc8eb06751dbb1ba00fb2856563963e5e altoslib: Add 'gauss' units for magnetic field strength Compute in gauss, but display in nT (G * 100000) Signed-off-by: Keith Packard --- diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index ce1b8f7f..89f36a6c 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -473,7 +473,7 @@ public class AltosConvert { public static AltosPyroName pyro_name = new AltosPyroName(); - public static AltosUnits magnetic_field = null; + public static AltosUnits magnetic_field = new AltosGauss(); public static String show_gs(String format, double a) { a = meters_to_g(a); diff --git a/altoslib/AltosGauss.java b/altoslib/AltosGauss.java new file mode 100644 index 00000000..0eed3fac --- /dev/null +++ b/altoslib/AltosGauss.java @@ -0,0 +1,62 @@ +/* + * Copyright © 2020 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.altoslib_13; + +import java.io.*; + +public class AltosGauss extends AltosUnits { + + public double value(double v, boolean imperial_units) { + return v; + } + + public double inverse(double v, boolean imperial_units) { + return v; + } + + public String show_units(boolean imperial_units) { + return "G"; + } + + public String say_units(boolean imperial_units) { + return "gauss"; + } + + public int show_fraction(int width, boolean imperial_units) { + return width - 1; + } + + public AltosGauss() { + range_metric = new AltosUnitsRange[1]; + + range_metric[0] = new AltosUnitsRange(0, "γ", "nano tesla") { + double value(double v) { + return v * 100000; + } + int show_fraction(int width) { + return width / 9; + } + int say_fraction() { + return 0; + } + }; + + range_imperial = range_metric; + } +} diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 59a3b2ca..b7d30051 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -70,6 +70,7 @@ altoslib_JAVA = \ AltosGPS.java \ AltosGPSTimeValue.java \ AltosGPSSat.java \ + AltosGauss.java \ AltosGreatCircle.java \ AltosHexfile.java \ AltosHexsym.java \