public static GeoPosition getPosition ( Point2D pixelCoordinate , int zoom , TileFactoryInfo info ) { // p(" --bitmap to latlon : " + coord + " " + zoom); double wx = pixelCoordinate . getX ( ) ; double wy = pixelCoordinate . getY ( ) ; // this reverses getBitmapCoordinates double flon = ( wx - info . getMapCenterInPixelsAtZoom ( zoom ) . getX ( ) ) / info . getLongitudeDegreeWidthInPixels ( zoom ) ; double e1 = ( wy - info . getMapCenterInPixelsAtZoom ( zoom ) . getY ( ) ) / ( - 1 * info . getLongitudeRadianWidthInPixels ( zoom ) ) ; double e2 = ( 2 * Math . atan ( Math . exp ( e1 ) ) - Math . PI / 2 ) / ( Math . PI / 180.0 ) ; double flat = e2 ; GeoPosition wc = new GeoPosition ( flat , flon ) ; return wc ; }
Convert an on screen pixel coordinate and a zoom level to a geo position