return pixel coordinates in the map image for a (lat,lon)
        if reverse is set, then return lat/lon for a pixel coordinate
161689
def pixel_coords(self, latlon, reverse=False):
        '''
        '''
        state = self.state
        if reverse:
            (x,y) = latlon
            return self.coordinates(x,y)
        (lat,lon) = (latlon[0], latlon[1])
        return state.mt.coord_to_pixel(state.lat, state.lon, state.width, state.ground_width, lat, lon)
527887
def map_pixel_location(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)
        return np.array([row, col])
606822
def get_latlon(self, use_cached=True):
        """"""
        device_json = self.get_device_json(use_cached)
        lat = device_json.get("dpMapLat")
        lon = device_json.get("dpMapLong")
        return (float(lat) if lat else None,
                float(lon) if lon else None, )
1183865
def coord_to_tile(self, lat, lon, zoom):
		''''''
		world_tiles = 1<<zoom
		x = world_tiles / 360.0 * (lon + 180.0)
		tiles_pre_radian = world_tiles / (2 * math.pi)
		e = math.sin(lat * (1/180.*math.pi))
		y = world_tiles/2 + 0.5*math.log((1+e)/(1-e)) * (-tiles_pre_radian)
		offsetx = int((x - int(x)) * TILES_WIDTH)
		offsety = int((y - int(y)) * TILES_HEIGHT)
		return TileInfo((int(x) % world_tiles, int(y) % world_tiles), zoom, self.service, offset=(offsetx, offsety))
1319657
def lonlat2xyz(lons, lats):
    """"""
    R = 6370997.0
    x_coords = R * da.cos(da.deg2rad(lats)) * da.cos(da.deg2rad(lons))
    y_coords = R * da.cos(da.deg2rad(lats)) * da.sin(da.deg2rad(lons))
    z_coords = R * da.sin(da.deg2rad(lats))
    return x_coords, y_coords, z_coords
622974
def within_bbox(self, bbox):
        
        min_lon, min_lat, max_lon, max_lat = bbox
        lons, lats = self.array['lon'], self.array['lat']
        if cross_idl(lons.min(), lons.max()) or cross_idl(min_lon, max_lon):
            lons = lons % 360
            min_lon, max_lon = min_lon % 360, max_lon % 360
        mask = (min_lon < lons) * (lons < max_lon) * \
               (min_lat < lats) * (lats < max_lat)
        return mask.nonzero()[0]
1170102
def coords_callback(self, data):
        
        for node_id, lon, lat in data:
            self.coords[node_id] = (lon, lat)
670684
def coord_to_pixel(self, lat, lon, width, ground_width, lat2, lon2):
		''''''
		pixel_width = ground_width / float(width)

		if lat is None or lon is None or lat2 is None or lon2 is None:
			return (0,0)

		dx = mp_util.gps_distance(lat, lon, lat, lon2)
		if lon2 < lon:
			dx = -dx
		dy = mp_util.gps_distance(lat, lon, lat2, lon)
		if lat2 > lat:
			dy = -dy

		dx /= pixel_width
		dy /= pixel_width
		return (int(dx), int(dy))
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)
890395
def reverse(self):
        
        return BBox((self.min_y, self.min_x, self.max_y, self.max_x), crs=self.crs)
173362
def lonlat2xyz(lon, lat):
    

    lons = np.array(lon)
    lats = np.array(lat)

    xs = np.cos(lats) * np.cos(lons)
    ys = np.cos(lats) * np.sin(lons)
    zs = np.sin(lats)

    return xs, ys, zs
120432
def gnomonicSphereToImage(lon, lat):
    
    # Convert angle to [-180, 180] interval
    lon = lon - 360.*(lon>180)
    lon = np.radians(lon)
    lat = np.radians(lat)
    r_theta = (180. / np.pi) / np.tan(lat)
    x = r_theta * np.cos(lon)
    y = r_theta * np.sin(lon)
    return x, y
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)
901764
def lonlat2xyz(lon, lat):
    """"""
    lat = xu.deg2rad(lat)
    lon = xu.deg2rad(lon)
    x = xu.cos(lat) * xu.cos(lon)
    y = xu.cos(lat) * xu.sin(lon)
    z = xu.sin(lat)
    return x, y, z
275023
def reverse(self, point, language=None, sensor=False):
        '''
        '''
        params = {
            'latlng': point,
            'sensor': str(sensor).lower()
        }
        
        if language:
            params['language'] = language

        if not self.premier:
            url = self.get_url(params)
        else:
            url = self.get_signed_url(params)

        return self.GetService_url(url)
976826
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;
    }
116918
function () {
    if(this.isHidden()) return;

    var
    offset          = this.model.get("offset"),
    pos             = this.mapView.latLonToPixel(this.model.get("latlng")),
    x               = this.$el.position().left,
    y               = this.$el.position().top,
    containerHeight = this.$el.outerHeight(true),
    containerWidth  = this.$el.width(),
    left            = pos.x - offset[0],
    size            = this.mapView.getSize(),
    bottom          = -1*(pos.y - offset[1] - size.y);

    this.$el.css({ bottom: bottom, left: left });
  }