This commit is contained in:
Hannes Janetzek 2013-02-04 17:38:30 +01:00
parent 76e1dcae7c
commit fb1b0d4087
2 changed files with 18 additions and 2 deletions

View File

@ -82,6 +82,12 @@ public final class MercatorProjection {
* ((long) Tile.TILE_SIZE << mapPosition.zoomLevel);
}
/**
* Projects a longitude coordinate (in degrees) to the range [0.0,1.0]
* @param latitude
* the latitude coordinate that should be converted.
* @return the position .
*/
public static double latitudeToY(double latitude) {
double sinLatitude = Math.sin(latitude * (Math.PI / 180));
return 0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI);
@ -147,6 +153,12 @@ public final class MercatorProjection {
* ((long) Tile.TILE_SIZE << mapPosition.zoomLevel);
}
/**
* Projects a longitude coordinate (in degrees) to the range [0.0,1.0]
* @param longitude
* the longitude coordinate that should be converted.
* @return the position .
*/
public static double longitudeToX(double longitude) {
return (longitude + 180) / 360;
}

View File

@ -26,8 +26,12 @@ import org.oscim.view.MapView;
import android.opengl.GLES20;
import android.opengl.Matrix;
// http://safari.informit.com/9780321563835
// http://www.opengles-book.com
/*
* This is an example how to integrate custom OpenGL drawing routines as map overlay
*
* based on chapter 2 from:
* https://github.com/dalinaum/opengl-es-book-samples/tree/master/Android
* */
public class CustomOverlay extends RenderOverlay {