Gets the XY meters in Spherical Mercator EPSG:900913, converted from lat/lon in WGS84
324590
def meters(self):
        """"""
        latitude, longitude = self.latitude_longitude
        meter_x = longitude * ORIGIN_SHIFT / 180.0
        meter_y = math.log(math.tan((90.0 + latitude) * math.pi / 360.0)) / (math.pi / 180.0)
        meter_y = meter_y * ORIGIN_SHIFT / 180.0
        return meter_x, meter_y
457363
function sphericalCoordinates(pos){
    var rad = len(pos);
    var inc = Math.acos(pos.z / rad) / Math.PI;
    var ang = Math.atan2(pos.y, pos.x) / (Math.PI*2);
    return {rad: rad, ang: ang, inc: inc};
  }
1096647
function toLatLng()
	{
		$airy1830 = new ReferenceEllipsoid;
		$OSGB_F0  = 0.9996012717;
		$N0       = -100000.0;
		$E0       = 400000.0;
		$phi0     = deg2rad(49.0);
		$lambda0  = deg2rad(-2.0);
		$a        = $airy1830->maj;
		$b        = $airy1830->min;
		$eSquared = $airy1830->ecc;
		$phi      = 0.0;
		$lambda   = 0.0;
		$E        = $this->easting;
		$N        = $this->northing;
		$n        = ($a - $b) / ($a + $b);
		$M        = 0.0;
		$phiPrime = (($N - $N0) / ($a * $OSGB_F0)) + $phi0;

		$phiPrimeSecant     = Trig::sec($phiPrime);
		$phiPrimeSinSquared = Trig::sinSquared($phiPrime);
		$phiPrimeTanSquared = Trig::tanSquared($phiPrime);

		do {
			$M =
				($b * $OSGB_F0)
				* (((1 + $n + ((5.0 / 4.0) * $n * $n) + ((5.0 / 4.0) * $n * $n * $n))
					* ($phiPrime - $phi0))
					- (((3 * $n) + (3 * $n * $n) + ((21.0 / 8.0) * $n * $n * $n))
					* sin($phiPrime - $phi0)
					* cos($phiPrime + $phi0))
					+ ((((15.0 / 8.0) * $n * $n) + ((15.0 / 8.0) * $n * $n * $n))
					* sin(2.0 * ($phiPrime - $phi0))
					* cos(2.0 * ($phiPrime + $phi0)))
					- (((35.0 / 24.0) * $n * $n * $n)
					* sin(3.0 * ($phiPrime - $phi0))
					* cos(3.0 * ($phiPrime + $phi0))));
			$phiPrime += ($N - $N0 - $M) / ($a * $OSGB_F0);
		} while (($N - $N0 - $M) >= 0.001);

		$v = $a * $OSGB_F0 * pow(1.0 - $eSquared * $phiPrimeSinSquared, -0.5);

		$rho = $a
			* $OSGB_F0
			* (1.0 - $eSquared)
			* pow(1.0 - $eSquared * $phiPrimeSinSquared, -1.5);

		$etaSquared = ($v / $rho) - 1.0;

		$VII = tan($phiPrime) / (2 * $rho * $v);

		$VIII = (tan($phiPrime) / (24.0 * $rho * pow($v, 3.0)))
			* (5.0
			+ (3.0 * $phiPrimeTanSquared)
			+ $etaSquared
			- (9.0 * $phiPrimeTanSquared * $etaSquared));

		$IX = (tan($phiPrime) / (720.0 * $rho * pow($v, 5.0)))
			* (61.0
			+ (90.0 * $phiPrimeTanSquared)
			+ (45.0 * $phiPrimeTanSquared * $phiPrimeTanSquared));

		$X = $phiPrimeSecant / $v;

		$XI = ($phiPrimeSecant / (6.0 * $v * $v * $v))
			* (($v / $rho) + (2 * $phiPrimeTanSquared));

		$XII = ($phiPrimeSecant / (120.0 * pow($v, 5.0)))
			* (5.0
			+ (28.0 * $phiPrimeTanSquared)
			+ (24.0 * $phiPrimeTanSquared * $phiPrimeTanSquared));

		$XIIA = ($phiPrimeSecant / (5040.0 * pow($v, 7.0)))
			* (61.0
			+ (662.0 * $phiPrimeTanSquared)
			+ (1320.0 * $phiPrimeTanSquared * $phiPrimeTanSquared)
			+ (720.0
				* $phiPrimeTanSquared
				* $phiPrimeTanSquared
				* $phiPrimeTanSquared));

		$phi = $phiPrime
			- ($VII * pow($E - $E0, 2.0))
			+ ($VIII * pow($E - $E0, 4.0))
			- ($IX * pow($E - $E0, 6.0));

		$lambda = $lambda0
			+ ($X * ($E - $E0))
			- ($XI * pow($E - $E0, 3.0))
			+ ($XII * pow($E - $E0, 5.0))
			- ($XIIA * pow($E - $E0, 7.0));

		return new LatLng(rad2deg($phi), rad2deg($lambda));
	}
1357979
def wgs84togcj02(lng, lat):
    
    if out_of_china(lng, lat):  # 判断是否在国内
        return lng, lat
    dlat = transformlat(lng - 105.0, lat - 35.0)
    dlng = transformlng(lng - 105.0, lat - 35.0)
    radlat = lat / 180.0 * pi
    magic = math.sin(radlat)
    magic = 1 - ee * magic * magic
    sqrtmagic = math.sqrt(magic)
    dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * pi)
    dlng = (dlng * 180.0) / (a / sqrtmagic * math.cos(radlat) * pi)
    mglat = lat + dlat
    mglng = lng + dlng
    return [mglng, mglat]
175276
def gprmc_to_degdec(lat, latDirn, lng, lngDirn):
    """"""
    x = float(lat[0:2]) + float(lat[2:]) / 60
    y = float(lng[0:3]) + float(lng[3:]) / 60

    if latDirn == 'S':
        x = -x
    if lngDirn == 'W':
        y = -y

    return x, y
635519
function (latlon) {
        return {
            x: latlon.lng * 6378137 * Math.PI / 180,
            y: Math.log(Math.tan((90 + latlon.lat) * Math.PI / 360)) * 6378137
        };
    }
1097608
def to_lat_lon
      k0 = 0.9996
      x  = @e - 500000 # Remove Longitude offset
      y  = @n

      # Set hemisphere (1=Northern, 0=Southern)
      y    -= 10000000.0 unless UTMZones::northern_hemisphere? @zone

      ecc = @ellipsoid.eccentricity
      eccPrimeSquared = (ecc)/(1-ecc)
      m  = y / k0
      mu = m / (@ellipsoid.radius * (1 - ecc / 4 - 3 * ecc ** 2 / 64 - 5 * ecc ** 3 / 256))
      e1 = (1 - Math::sqrt(1 - ecc)) / (1 + Math::sqrt(1 - ecc))
      phi1rad = mu +
        (3 * e1 / 2 - 27 * e1 ** 3 / 32) * Math::sin(2 * mu) +
        (21 * e1 ** 2 / 16 - 55 * e1 ** 4 / 32) * Math::sin(4 * mu) +
        (151 * e1 ** 3 / 96) * Math::sin(6 * mu)
      n1 = @ellipsoid.radius / Math::sqrt(1 - ecc * Math::sin(phi1rad) ** 2)
      t1 = Math::tan(phi1rad) ** 2
      c1 = ecc * Math::cos(phi1rad)**2
      r1 = @ellipsoid.radius * (1 - ecc) / ((1 - ecc * Math::sin(phi1rad) ** 2) ** 1.5)
      d = x / (n1 * k0)
      latitude_rad = phi1rad-
        (n1 * Math::tan(phi1rad) / r1) * (d * d / 2 - 
                                    (5 + 3 * t1 + 10 * c1 - 4 * c1 * c1 - 9 * eccPrimeSquared) * d ** 4 / 24 +
                                    (61 + 90 * t1 + 298 * c1 + 45 * t1 * t1 - 
                                     252 * eccPrimeSquared - 3 * c1 * c1) * d ** 6 / 720)
      latitude_deg = latitude_rad * 180.0 / Math::PI
      lon_tmp = (d - (1 + 2 * t1 + c1) * d ** 3 / 6 +
                   (5 - 2 * c1 + 28 * t1 - 3 * c1 * c1 + 8 * eccPrimeSquared +
                    24 * t1 * t1) * d ** 5 / 120) / Math::cos(phi1rad)
      longitude_deg = UTMZones::lon_origin(@zone) + lon_tmp * 180.0 / Math::PI
      LatLon.new latitude_deg, longitude_deg
    end
720404
public static double getMetersAsWGS84( double meters, Coordinate c ) {
        GeodeticCalculator gc = new GeodeticCalculator(DefaultGeographicCRS.WGS84);
        gc.setStartingGeographicPoint(c.x, c.y);
        gc.setDirection(90, meters);
        Point2D destinationGeographicPoint = gc.getDestinationGeographicPoint();
        double degrees = Math.abs(destinationGeographicPoint.getX() - c.x);
        return degrees;
    }
102417
def ToLatLng(self):
    
    rad_lat = math.atan2(self.z, math.sqrt(self.x * self.x + self.y * self.y))
    rad_lng = math.atan2(self.y, self.x)
    return (rad_lat * 180.0 / math.pi, rad_lng * 180.0 / math.pi)
1156295
function parsePolygonGeometry(coordinates) {
		var polygonWkt = [];
		for (var i = 0; i < coordinates.length; i++) {
			polygonWkt.push('(' + parseLineGeometry(coordinates[i]) + ')');
		}
		return polygonWkt.join(', ');
	}
1300507
def drawHealpixMap(hpxmap, lon, lat, size=1.0, xsize=501, coord='GC', **kwargs):
    
    ax = plt.gca()
    x = np.linspace(-size,size,xsize)
    y = np.linspace(-size,size,xsize)
    xx, yy = np.meshgrid(x,y)
    
    coord = coord.upper()
        
    if coord == 'GC':
        #Assumes map and (lon,lat) are Galactic, but plotting celestial
        llon, llat = image2sphere(*gal2cel(lon,lat),x=xx.flat,y=yy.flat)
        pix = ang2pix(get_nside(hpxmap),*cel2gal(llon,llat))
    elif coord == 'CG':
        #Assumes map and (lon,lat) are celestial, but plotting Galactic
        llon, llat = image2sphere(*cel2gal(lon,lat),x=xx.flat,y=yy.flat)
        pix = ang2pix(get_nside(hpxmap),*gal2cel(llon,llat))
    else:
        #Assumes plotting the native coordinates
        llon, llat = image2sphere(lon,lat,xx.flat,yy.flat)
        pix = ang2pix(get_nside(hpxmap),llon,llat)

    values = hpxmap[pix].reshape(xx.shape)
    zz = np.ma.array(values,mask=(values==hp.UNSEEN),fill_value=np.nan)

    return drawProjImage(xx,yy,zz,coord=coord,**kwargs)
98088
def _lats(self):
        
        lats = 90. - _np.arccos(self.zeros) * 180. / _np.pi
        return lats
964476
def ConvertCH1903(x, y):
  ""
  yb = (x - 600000.0) / 1e6;
  xb = (y - 200000.0) / 1e6;
  lam = 2.6779094 \
     + 4.728982 * yb \
     + 0.791484 * yb * xb \
     + 0.1306 * yb * xb * xb \
     - 0.0436 * yb * yb * yb
  phi = 16.9023892 \
     + 3.238372 * xb \
     - 0.270978 * yb * yb \
     - 0.002582 * xb * xb \
     - 0.0447 * yb * yb * xb \
     - 0.0140 * xb * xb * xb
  return (phi * 100.0 / 36.0, lam * 100.0 / 36.0)
683043
def xy2geom(x, y, t_srs=None):
    
    geom_wkt = 'POINT({0} {1})'.format(x, y)
    geom = ogr.CreateGeometryFromWkt(geom_wkt)
    if t_srs is not None and not wgs_srs.IsSame(t_srs):
        ct = osr.CoordinateTransformation(t_srs, wgs_srs)
        geom.Transform(ct)
        geom.AssignSpatialReference(t_srs)
    return geom
228385
def to_latlon(geojson, origin_espg=None):
    

    if isinstance(geojson, dict):

        # get epsg code:
        if origin_espg:
            code = origin_espg
        else:
            code = epsg_code(geojson)
        if code:
            origin = Proj(init='epsg:%s' % code)
            wgs84 = Proj(init='epsg:4326')
            wrapped = test_wrap_coordinates(geojson['coordinates'], origin, wgs84)
            new_coords = convert_coordinates(geojson['coordinates'], origin, wgs84, wrapped)
            if new_coords:
                geojson['coordinates'] = new_coords
            try:
                del geojson['crs']
            except KeyError:
                pass

    return geojson
219600
def _cartesian_to_spherical(cls, coord, center):
        
        x, y, z, vx, vy, vz = coord
        r = np.linalg.norm(coord[:3])
        phi = arcsin(z / r)
        theta = arctan2(y, x)

        r_dot = (x * vx + y * vy + z * vz) / r
        phi_dot = (vz * (x ** 2 + y ** 2) - z * (x * vx + y * vy)) / (r ** 2 * sqrt(x ** 2 + y ** 2))
        theta_dot = (x * vy - y * vx) / (x ** 2 + y ** 2)

        return np.array([r, theta, phi, r_dot, theta_dot, phi_dot], dtype=float)
864093
def _convert_pix_coords(self):
        
        if self.region_type in ['polygon', 'line']:
            # have to special-case polygon in the phys coord case
            # b/c can't typecheck when iterating as in sky coord case
            coords = [PixCoord(self.coord[0::2], self.coord[1::2])]
        else:
            temp = [_.value for _ in self.coord]
            coord = PixCoord(temp[0], temp[1])
            coords = [coord] + temp[2:]

        # The angle remains as a quantity object.
        # Modulus check makes sure that it works for ellipse/rectangle annulus
        if self.region_type in ['ellipse', 'rectangle'] and len(coords) % 2 == 0:
            coords[-1] = self.coord[-1]

        return coords