Computes the amount of latitude degrees for a given distance in pixel at a given zoom level.
773420
private static double deltaLat(double deltaPixel, double lat, byte zoom, int tileSize) {
        long mapSize = MercatorProjection.getMapSize(zoom, tileSize);
        double pixelY = MercatorProjection.latitudeToPixelY(lat, mapSize);
        double lat2 = MercatorProjection.pixelYToLatitude(pixelY + deltaPixel, mapSize);

        return Math.abs(lat2 - lat);
    }
847936
function getDistanceInKilometers(p1, p2) {
  // Credit: adapts code for Haversine formula and degrees-to-radian conversion found at:
  // http://www.movable-type.co.uk/scripts/latlong.html

  var R = 6371; // earth's radius in kilometers
  var dLat = degreesToRadians(p2.lat - p1.lat);
  var dLon = degreesToRadians(p2.lng - p1.lng); 
  var lat1 = degreesToRadians(p1.lat);
  var lat2 = degreesToRadians(p2.lat);

  var a = 
    Math.sin(dLat/2) * Math.sin(dLat/2)
    + Math.sin(dLon/2) * Math.sin(dLon/2)
    * Math.cos(lat1) * Math.cos(lat2);

  var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
  var distance = R * c; // kilomter
  return distance;
}
958239
public static double GroundResolutionMapSize(double latitude, final double mapSize) {
		latitude = Clip(latitude, -90, 90);
		return Math.cos(latitude * Math.PI / 180) * 2 * Math.PI * GeoConstants.RADIUS_EARTH_METERS
				/ mapSize;
	}
193635
function projection(c) {
      var zoom = c.zoom,
          max = zoom < 0 ? 1 : 1 << zoom,
          column = c.column % max,
          row = c.row;
      if (column < 0) column += max;
      return {
        locationPoint: function(l) {
          var c = po.map.locationCoordinate(l),
              k = Math.pow(2, zoom - c.zoom);
          return {
            x: tileSize.x * (k * c.column - column),
            y: tileSize.y * (k * c.row - row)
          };
        }
      };
    }
72947
def point_image_value(image, xy, scale=1):
    """"""
    return getinfo(ee.Image(image).reduceRegion(
        reducer=ee.Reducer.first(), geometry=ee.Geometry.Point(xy),
        scale=scale))
488893
def numberOfXTilesAtZoom(self, zoom):
        ""
        [minRow, minCol, maxRow, maxCol] = self.getExtentAddress(zoom)
        return maxCol - minCol + 1
637455
private void calculateMinimapAreaBounds() {
        if (minimapBounds == null) {
            return;
        }

        if (zoom == 1f) {
            miniMapRequired = false;
        } else {
            // Calculates the bounds of the current displayed area
            float x = (-currentXOffset - toCurrentScale(currentFilteredPage * optimalPageWidth)) //
                    / toCurrentScale(optimalPageWidth) * minimapBounds.width();
            float width = getWidth() / toCurrentScale(optimalPageWidth) * minimapBounds.width();
            float y = -currentYOffset / toCurrentScale(optimalPageHeight) * minimapBounds.height();
            float height = getHeight() / toCurrentScale(optimalPageHeight) * minimapBounds.height();
            minimapScreenBounds = new RectF(minimapBounds.left + x, minimapBounds.top + y, //
                    minimapBounds.left + x + width, minimapBounds.top + y + height);
            minimapScreenBounds.intersect(minimapBounds);
            miniMapRequired = true;
        }
    }
1161056
public static function latToPixels($lat, $zoom)
    {
        if ($lat == 90) {
            $pixelY = 0;
        } elseif ($lat == -90) {
            $pixelY = 256;
        } else {
            $latRad = deg2rad($lat);
            $mercY = log(tan(pi() / 4 + $latRad / 2));
            $cartY = pi() - $mercY;
            $pixelY = $cartY * 256 / 2 / pi();
            $pixelY = max(0, $pixelY); // correct rounding errors near north and south poles
            $pixelY = min(256, $pixelY); // correct rounding errors near north and south poles
        }
        $pixelYZoom = $pixelY * pow(2, $zoom);

        return $pixelYZoom;
    }
544060
public static double getLatitudeFromPixel(long height,
			BoundingBox boundingBox, float pixel) {
		return getLatitudeFromPixel(height, boundingBox, boundingBox, pixel);
	}
33527
def bounds(self):
        """"""
        google_x, google_y = self.google
        pixel_x_west, pixel_y_north = google_x * TILE_SIZE, google_y * TILE_SIZE
        pixel_x_east, pixel_y_south = (google_x + 1) * TILE_SIZE, (google_y + 1) * TILE_SIZE

        point_min = Point.from_pixel(pixel_x=pixel_x_west, pixel_y=pixel_y_south, zoom=self.zoom)
        point_max = Point.from_pixel(pixel_x=pixel_x_east, pixel_y=pixel_y_north, zoom=self.zoom)
        return point_min, point_max
903481
def latitude(self, latitude):
        """"""
        if not (-90 <= latitude <= 90):
            raise ValueError('latitude was {}, but has to be in [-90, 90]'
                             .format(latitude))
        self._latitude = latitude
1158243
def tile_at(self, zoom, position):
        
        x, y = self.project_pixels(position, zoom)
        return (zoom, int(x/self.tilesize), int(y/self.tilesize))
1072384
def pixel_coords(latlon, ground_width=0, mt=None, topleft=None, width=None):
    ''''''
    (lat,lon) = (latlon[0], latlon[1])
    return mt.coord_to_pixel(topleft[0], topleft[1], width, ground_width, lat, lon)
580610
def for_point(cls, point, zoom):
        """"""
        latitude, longitude = point.latitude_longitude
        return cls.for_latitude_longitude(latitude=latitude, longitude=longitude, zoom=zoom)
1331705
def _num2deg(self, tile):
        
        n = 2.0 ** tile.zoom
        lon_deg = tile.x / n * 360.0 - 180.0
        lat_rad = mod_math.atan(mod_math.sinh(mod_math.pi * (1 - 2 * tile.y / n)))
        lat_deg = mod_math.degrees(lat_rad)
        return (lat_deg, lon_deg)
208194
def from_latitude_longitude(cls, latitude=0.0, longitude=0.0):
        """"""
        assert -180.0 <= longitude <= 180.0, 'Longitude needs to be a value between -180.0 and 180.0.'
        assert -90.0 <= latitude <= 90.0, 'Latitude needs to be a value between -90.0 and 90.0.'
        return cls(latitude=latitude, longitude=longitude)
1022354
public static double latitudeToPixelY(double latitude, long mapSize) {
        double sinLatitude = Math.sin(latitude * (Math.PI / 180));
        // FIXME improve this formula so that it works correctly without the clipping
        double pixelY = (0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI)) * mapSize;
        return Math.min(Math.max(0, pixelY), mapSize);
    }