Commit 7dddf0a2 authored by Bryan Cazabonne's avatar Bryan Cazabonne
Browse files

Replaced use of Math by FastMath in metric package.

Fixes #861
parent e1f234b2
Pipeline #1560 failed with stages
in 23 minutes and 27 seconds
......@@ -16,6 +16,8 @@
*/
package org.orekit.gnss.metric.ntrip;
import org.hipparchus.util.FastMath;
/** Caster record in source table.
* @author Luc Maisonobe
* @since 11.0
......@@ -44,8 +46,8 @@ public class CasterRecord extends Record {
super(line);
this.port = Integer.parseInt(getField(2));
this.canReceiveNMEA = Integer.parseInt(getField(5)) != 0;
this.latitude = Math.toRadians(Double.parseDouble(getField(7)));
this.longitude = Math.toRadians(Double.parseDouble(getField(8)));
this.latitude = FastMath.toRadians(Double.parseDouble(getField(7)));
this.longitude = FastMath.toRadians(Double.parseDouble(getField(8)));
this.fallbackPort = Integer.parseInt(getField(10));
}
......
......@@ -23,6 +23,8 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.hipparchus.util.FastMath;
/** Data stream record in source table.
* @author Luc Maisonobe
* @since 11.0
......@@ -94,8 +96,8 @@ public class DataStreamRecord extends Record {
of(getField(6).split("\\+")).
map(k -> NavigationSystem.getNavigationSystem(k)).
collect(Collectors.toList());
this.latitude = Math.toRadians(Double.parseDouble(getField(9)));
this.longitude = Math.toRadians(Double.parseDouble(getField(10)));
this.latitude = FastMath.toRadians(Double.parseDouble(getField(9)));
this.longitude = FastMath.toRadians(Double.parseDouble(getField(10)));
this.nmeaRequired = Integer.parseInt(getField(11)) != 0;
this.networked = Integer.parseInt(getField(12)) != 0;
this.authentication = Authentication.getAuthentication(getField(15));
......
......@@ -42,6 +42,7 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.hipparchus.util.FastMath;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitMessages;
import org.orekit.gnss.metric.messages.ParsedMessage;
......@@ -238,14 +239,14 @@ public class NtripClient {
final double undulation) {
// convert latitude
final double latDeg = Math.abs(Math.toDegrees(latitude));
final int dLat = (int) Math.floor(latDeg);
final double latDeg = FastMath.abs(FastMath.toDegrees(latitude));
final int dLat = (int) FastMath.floor(latDeg);
final double mLat = DEG_TO_MINUTES * (latDeg - dLat);
final char cLat = latitude >= 0.0 ? 'N' : 'S';
// convert longitude
final double lonDeg = Math.abs(Math.toDegrees(longitude));
final int dLon = (int) Math.floor(lonDeg);
final double lonDeg = FastMath.abs(FastMath.toDegrees(longitude));
final int dLon = (int) FastMath.floor(lonDeg);
final double mLon = DEG_TO_MINUTES * (lonDeg - dLon);
final char cLon = longitude >= 0.0 ? 'E' : 'W';
......
......@@ -28,6 +28,7 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import org.hipparchus.util.FastMath;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitInternalError;
import org.orekit.errors.OrekitMessages;
......@@ -311,7 +312,7 @@ public class StreamMonitor extends AbstractEncodedMessages implements Runnable {
// manage reconnection
try {
Thread.sleep((int) Math.rint(delay * 1000));
Thread.sleep((int) FastMath.rint(delay * 1000));
} catch (InterruptedException ie) {
// Restore interrupted state...
Thread.currentThread().interrupt();
......
......@@ -16,6 +16,7 @@
*/
package org.orekit.gnss.metric.parser;
import org.hipparchus.util.FastMath;
import org.orekit.errors.OrekitException;
import org.orekit.errors.OrekitMessages;
......@@ -70,7 +71,7 @@ public abstract class AbstractEncodedMessages implements EncodedMessage {
remaining = 8;
}
final int nbBits = Math.min(remaining, needed);
final int nbBits = FastMath.min(remaining, needed);
value = (value << nbBits) | (current >>> (8 - nbBits));
current = (current << nbBits) & 0xFF;
remaining -= nbBits;
......
......@@ -16,6 +16,7 @@
*/
package org.orekit.gnss.metric.ntrip;
import org.hipparchus.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
......@@ -34,8 +35,8 @@ public class CasterRecordTest {
Assert.assertEquals("BKG", cas.getOperator());
Assert.assertEquals(false, cas.canReceiveNMEA());
Assert.assertEquals("DEU", cas.getCountry());
Assert.assertEquals(50.12, Math.toDegrees(cas.getLatitude()), 1.0e-15);
Assert.assertEquals( 8.69, Math.toDegrees(cas.getLongitude()), 1.0e-15);
Assert.assertEquals(50.12, FastMath.toDegrees(cas.getLatitude()), 1.0e-15);
Assert.assertEquals( 8.69, FastMath.toDegrees(cas.getLongitude()), 1.0e-15);
Assert.assertEquals("0.0.0.0", cas.getFallbackHostOrIPAddress());
Assert.assertEquals(0, cas.getFallbackPort());
Assert.assertEquals("http://products.igs-ip.net/home", cas.getMisc());
......@@ -51,8 +52,8 @@ public class CasterRecordTest {
Assert.assertEquals("BKG", cas.getOperator());
Assert.assertEquals(false, cas.canReceiveNMEA());
Assert.assertEquals("DEU", cas.getCountry());
Assert.assertEquals(50.12, Math.toDegrees(cas.getLatitude()), 1.0e-15);
Assert.assertEquals( 8.69, Math.toDegrees(cas.getLongitude()), 1.0e-15);
Assert.assertEquals(50.12, FastMath.toDegrees(cas.getLatitude()), 1.0e-15);
Assert.assertEquals( 8.69, FastMath.toDegrees(cas.getLongitude()), 1.0e-15);
Assert.assertEquals("0.0.0.0", cas.getFallbackHostOrIPAddress());
Assert.assertEquals(0, cas.getFallbackPort());
Assert.assertEquals("http://www.rtcm-ntrip.org/home", cas.getMisc());
......
......@@ -82,8 +82,8 @@ public class DataStreamRecordTest {
Assert.assertEquals(NavigationSystem.GPS, str.getNavigationSystems().get(0));
Assert.assertEquals("MISC", str.getNetwork());
Assert.assertEquals("DEU", str.getCountry());
Assert.assertEquals(49.87, Math.toDegrees(str.getLatitude()), 1.0e-15);
Assert.assertEquals( 8.62, Math.toDegrees(str.getLongitude()), 1.0e-15);
Assert.assertEquals(49.87, FastMath.toDegrees(str.getLatitude()), 1.0e-15);
Assert.assertEquals( 8.62, FastMath.toDegrees(str.getLongitude()), 1.0e-15);
Assert.assertEquals(false, str.isNMEARequired());
Assert.assertEquals(true, str.isNetworked());
Assert.assertEquals("RETINA", str.getGenerator());
......@@ -132,8 +132,8 @@ public class DataStreamRecordTest {
Assert.assertEquals("SBAS", str.getNavigationSystems().get(5).toString());
Assert.assertEquals("MISC", str.getNetwork());
Assert.assertEquals("DEU", str.getCountry());
Assert.assertEquals(48.09, Math.toDegrees(str.getLatitude()), 1.0e-15);
Assert.assertEquals(11.28, Math.toDegrees(str.getLongitude()), 1.0e-15);
Assert.assertEquals(48.09, FastMath.toDegrees(str.getLatitude()), 1.0e-15);
Assert.assertEquals(11.28, FastMath.toDegrees(str.getLongitude()), 1.0e-15);
Assert.assertEquals(false, str.isNMEARequired());
Assert.assertEquals(true, str.isNetworked());
Assert.assertEquals("RETICLE", str.getGenerator());
......
......@@ -22,6 +22,7 @@ import java.net.Proxy;
import java.net.URISyntaxException;
import java.nio.file.Paths;
import org.hipparchus.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
import org.orekit.errors.OrekitException;
......@@ -210,7 +211,7 @@ public class NtripClientTest {
server.run();
NtripClient client = new NtripClient("localhost", server.getServerPort());
client.setTimeout(100);
client.setFix(2, 42, 13.456, Math.toRadians(43.5), Math.toRadians(-1.25), 317.5, 12.2);
client.setFix(2, 42, 13.456, FastMath.toRadians(43.5), FastMath.toRadians(-1.25), 317.5, 12.2);
client.startStreaming("", Type.IGS_SSR, true, true);
try {
Thread.sleep(400);
......@@ -229,7 +230,7 @@ public class NtripClientTest {
server.run();
NtripClient client = new NtripClient("localhost", server.getServerPort());
client.setTimeout(100);
client.setFix(2, 42, 13.456, Math.toRadians(-43.5), Math.toRadians(1.25), 317.5, 12.2);
client.setFix(2, 42, 13.456, FastMath.toRadians(-43.5), FastMath.toRadians(1.25), 317.5, 12.2);
client.startStreaming("", Type.IGS_SSR, true, true);
try {
Thread.sleep(400);
......
......@@ -18,6 +18,7 @@ package org.orekit.gnss.metric.parser;
import java.util.Random;
import org.hipparchus.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
import org.orekit.errors.OrekitException;
......@@ -127,7 +128,7 @@ public abstract class AbstractEncodedMessagesTest {
int index = 0;
int size = 0;
for (int remaining = bits.length; remaining > 0; remaining -= size) {
size = Math.min(remaining, 1 + random.nextInt(63));
size = FastMath.min(remaining, 1 + random.nextInt(63));
long ref = 0l;
for (int k = 0; k < size; ++k) {
ref = (ref << 1) | bits[index++];
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment