Search in sources :

Example 1 with VisibleForTesting

use of com.github.davidmoten.guavamini.annotations.VisibleForTesting in project risky by amsa-code.

the class Grid method getStartLat.

@VisibleForTesting
static BigDecimal getStartLat(Options options) {
    final long moveStartLatUpByCells;
    if (options.getFilterBounds().getTopLeftLat() == options.getOriginLat().doubleValue())
        moveStartLatUpByCells = 0;
    else
        moveStartLatUpByCells = Math.max(0, Math.round(Math.floor((options.getFilterBounds().getTopLeftLat() - options.getOriginLat().doubleValue()) / options.getCellSizeDegrees().doubleValue()) + 1));
    BigDecimal result = options.getOriginLat();
    for (int i = 0; i < moveStartLatUpByCells; i++) result = result.add(options.getCellSizeDegrees());
    return result;
}
Also used : BigDecimal(java.math.BigDecimal) VisibleForTesting(com.github.davidmoten.guavamini.annotations.VisibleForTesting)

Example 2 with VisibleForTesting

use of com.github.davidmoten.guavamini.annotations.VisibleForTesting in project risky by amsa-code.

the class StringSockets method socketCreator.

@VisibleForTesting
static Func0<Socket> socketCreator(final String host, final int port, long quietTimeoutMs) {
    return Checked.f0(() -> {
        Socket socket = new Socket(host, port);
        socket.setSoTimeout((int) quietTimeoutMs);
        return socket;
    });
}
Also used : Socket(java.net.Socket) VisibleForTesting(com.github.davidmoten.guavamini.annotations.VisibleForTesting)

Example 3 with VisibleForTesting

use of com.github.davidmoten.guavamini.annotations.VisibleForTesting in project risky by amsa-code.

the class Grid method getStartLon.

@VisibleForTesting
static BigDecimal getStartLon(Options options) {
    final long moveStartLonLeftByCells;
    if (options.getFilterBounds().getTopLeftLon() == options.getOriginLon().doubleValue())
        moveStartLonLeftByCells = 0;
    else {
        moveStartLonLeftByCells = Math.max(0, Math.round(Math.floor((options.getOriginLon().doubleValue() - options.getFilterBounds().getTopLeftLon()) / options.getCellSizeDegrees().doubleValue()) + 1));
    }
    BigDecimal result = options.getOriginLon();
    for (int i = 0; i < moveStartLonLeftByCells; i++) result = result.subtract(options.getCellSizeDegrees());
    return result;
}
Also used : BigDecimal(java.math.BigDecimal) VisibleForTesting(com.github.davidmoten.guavamini.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.github.davidmoten.guavamini.annotations.VisibleForTesting)3 BigDecimal (java.math.BigDecimal)2 Socket (java.net.Socket)1