Convert from latitude to the y position in overall map.
14167
def _convert_latitude(self, latitude):
        """"""
        return int((180 - (180 / pi * log(tan(
            pi / 4 + latitude * pi / 360)))) * (2 ** self._zoom) * self._size / 360)
319911
def map_pixel(self, point_x, point_y):
        '''
        
        '''
        row, col = map_pixel(point_x, point_y,
                             self.x_cell_size, self.y_cell_size, self.xmin, self.ymax)
        try:
            return self.raster[row, col]
        except:
            raise RasterGeoError('Make sure the point belongs to the raster coverage \
                                 and it is in the correct geographic coordinate system.')
950248
def midPoint(self, point):
        """"""
        x = (self.x + point.x)/2.0
        y = (self.y + point.y)/2.0
        z = (self.z + point.z)/2.0
        return MapPoint(x,y,z)
584947
function XYZToLngLat([x, y, z]) {
  const lat = Math.atan2(z, Math.sqrt(x * x + y * y));
  const lng = Math.atan2(y, x);

  return [lng * RADIAN_TO_DEGREE, lat * RADIAN_TO_DEGREE];
}
1338798
def convert_coord_object(coord):
    """"""
    assert isinstance(coord, Coordinate)
    coord = coord.container()
    return Tile(int(coord.zoom), int(coord.column), int(coord.row))
269713
def get_coordinates(self, i, end=False):
        """"""
        if end:
            endpoint = self.endpoints[i][1]
        else:
            endpoint = self.endpoints[i][0]
        return (endpoint.real, endpoint.imag)
1198247
def change_in_longitude(lat, miles):
    """"""

    # Find the radius of a circle around the earth at given latitude.
    r = earth_radius * math.cos(lat * degrees_to_radians)
    return (miles / r) * radians_to_degrees
476942
def get_tile_location(self, x, y):
        """"""
        x1, y1 = self.origin
        x1 += self.BORDER + (self.BORDER + self.cell_width) * x
        y1 += self.BORDER + (self.BORDER + self.cell_height) * y
        return x1, y1
501036
def _at(self, t):
        """"""
        pos, vel = terra(self.latitude.radians, self.longitude.radians,
                         self.elevation.au, t.gast)
        pos = einsum('ij...,j...->i...', t.MT, pos)
        vel = einsum('ij...,j...->i...', t.MT, vel)
        if self.x:
            R = rot_y(self.x * ASEC2RAD)
            pos = einsum('ij...,j...->i...', R, pos)
        if self.y:
            R = rot_x(self.y * ASEC2RAD)
            pos = einsum('ij...,j...->i...', R, pos)
        # TODO: also rotate velocity

        return pos, vel, pos, None
714687
def _compass_position(self, player_x, player_y):
        """"""
        map_dim = self._map.size_x
        third = map_dim * (1/3.0)
        for direction in mgz.const.COMPASS:
            point = mgz.const.COMPASS[direction]
            xlower = point[0] * map_dim
            xupper = (point[0] * map_dim) + third
            ylower = point[1] * map_dim
            yupper = (point[1] * map_dim) + third
            if (player_x >= xlower and player_x < xupper and
                    player_y >= ylower and player_y < yupper):
                return direction
1269742
public LatLong fromPixels(double x, double y) {
        if (this.mapView.getWidth() <= 0 || this.mapView.getHeight() <= 0) {
            return null;
        }

        // this uses the framebuffer position, the mapview position can be out of sync with
        // what the user sees on the screen if an animation is in progress
        MapPosition mapPosition = this.mapView.getModel().frameBufferModel.getMapPosition();

        // this means somehow the mapview is not yet properly set up, see issue #308.
        if (mapPosition == null) {
            return null;
        }

        // calculate the pixel coordinates of the top left corner
        LatLong latLong = mapPosition.latLong;
        long mapSize = MercatorProjection.getMapSize(mapPosition.zoomLevel, this.mapView.getModel().displayModel.getTileSize());
        double pixelX = MercatorProjection.longitudeToPixelX(latLong.longitude, mapSize);
        double pixelY = MercatorProjection.latitudeToPixelY(latLong.latitude, mapSize);
        pixelX -= this.mapView.getWidth() >> 1;
        pixelY -= this.mapView.getHeight() >> 1;

        // catch outer map limits
        try {
            // convert the pixel coordinates to a LatLong and return it
            return new LatLong(MercatorProjection.pixelYToLatitude(pixelY + y, mapSize),
                    MercatorProjection.pixelXToLongitude(pixelX + x, mapSize));
        } catch (Exception e) {
            return null;
        }
    }
1189867
def Y_dist(self, new_y_distance):
        """"""
        self.parent.value('y_distance', new_y_distance)
        self.parent.traces.display()
1006996
def for_latitude_longitude(cls, latitude, longitude, zoom):
        """"""
        point = Point.from_latitude_longitude(latitude=latitude, longitude=longitude)
        pixel_x, pixel_y = point.pixels(zoom=zoom)
        return cls.for_pixels(pixel_x=pixel_x, pixel_y=pixel_y, zoom=zoom)
764871
def position_to_value(self, y):
        """"""
        vsb = self.editor.verticalScrollBar()
        return vsb.minimum()+max([0, (y-self.offset)/self.get_scale_factor()])
819679
def y(self, y):
        """"""
        if y is None:
            return None
        return (self.height * (y - self.box.ymin) / self.box.height)
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)
384121
public double fromScreenY(double y)
    {
        Point2D src = srcPnt.get();
        Point2D dst = dstPnt.get();
        src.setLocation(0, y);
        inverse.transform(src, dst);
        return dst.getY();
    }