org.osmdroid.views.util.MyMath Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of osmdroid-android Show documentation
Show all versions of osmdroid-android Show documentation
An Android library to display OpenStreetMap views.
// Created by plusminus on 20:36:01 - 26.09.2008
package org.osmdroid.views.util;
/**
*
* @author Nicolas Gramlich
*
*/
public class MyMath {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
// ===========================================================
// Constructors
// ===========================================================
/**
* This is a utility class with only static members.
*/
private MyMath() {
}
// ===========================================================
// Getter & Setter
// ===========================================================
// ===========================================================
// Methods from SuperClass/Interfaces
// ===========================================================
// ===========================================================
// Methods
// ===========================================================
/**
* Calculates i.e. the increase of zoomlevel needed when the visible latitude needs to be bigger
* by factor
.
*
* Assert.assertEquals(1, getNextSquareNumberAbove(1.1f)); Assert.assertEquals(2,
* getNextSquareNumberAbove(2.1f)); Assert.assertEquals(2, getNextSquareNumberAbove(3.9f));
* Assert.assertEquals(3, getNextSquareNumberAbove(4.1f)); Assert.assertEquals(3,
* getNextSquareNumberAbove(7.9f)); Assert.assertEquals(4, getNextSquareNumberAbove(8.1f));
* Assert.assertEquals(5, getNextSquareNumberAbove(16.1f));
*
* Assert.assertEquals(-1, - getNextSquareNumberAbove(1 / 0.4f) + 1); Assert.assertEquals(-2, -
* getNextSquareNumberAbove(1 / 0.24f) + 1);
*
* @param factor
* @return
*/
public static int getNextSquareNumberAbove(final float factor) {
int out = 0;
int cur = 1;
int i = 1;
while (true) {
if (cur > factor)
return out;
out = i;
cur *= 2;
i++;
}
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy