Convert CH y/x to WGS lat
775462
function CHtoWGSlat(y, x) {

  // Converts militar to civil and  to unit = 1000km
  // Axiliary values (% Bern)
  const y_aux = (y - 600000) / 1000000;
  const x_aux = (x - 200000) / 1000000;

  // Process lat
  let lat = 16.9023892 +
      3.238272 * x_aux -
      0.270978 * Math.pow(y_aux, 2) -
      0.002528 * Math.pow(x_aux, 2) -
      0.0447 * Math.pow(y_aux, 2) * x_aux -
      0.0140 * Math.pow(x_aux, 3);

  // Unit 10000" to 1 " and converts seconds to degrees (dec)
  lat = lat * 100 / 36;

  return lat;

}
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
1072501
def to_latlng(easting, northing, type = :gb)

  	    if type == :ie
          @OSGB_F0  = 1.000035
          @N0       = 250000.0
          @E0       = 200000.0
          @phi0     = deg_to_rad(53.5)
          @lambda0  = deg_to_rad(-8.0)
          @a        = 6377340.189
          @b        = 6356034.447
        else
          @OSGB_F0  = 0.9996012717
          @N0       = -100000.0
          @E0       = 400000.0
          @phi0     = deg_to_rad(49.0)
          @lambda0  = deg_to_rad(-2.0)
          @a        = 6377563.396
          @b        = 6356256.909
        end 

        @eSquared = ((@a * @a) - (@b * @b)) / (@a * @a)
        @phi      = 0.0
        @lambda   = 0.0
        @E        = easting
        @N        = northing
        @n        = (@a - @b) / (@a + @b)
        @M        = 0.0
        @phiPrime = ((@N - @N0) / (@a * @OSGB_F0)) + @phi0

  	     begin

  	       @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))\
  	               * Math.sin(@phiPrime - @phi0)\
  	               * Math.cos(@phiPrime + @phi0))\
  	             + ((((15.0 / 8.0) * @n * @n) + ((15.0 / 8.0) * @n * @n * @n))\
  	               * Math.sin(2.0 * (@phiPrime - @phi0))\
  	               * Math.cos(2.0 * (@phiPrime + @phi0)))\
  	             - (((35.0 / 24.0) * @n * @n * @n)\
  	               * Math.sin(3.0 * (@phiPrime - @phi0))\
  	               * Math.cos(3.0 * (@phiPrime + @phi0))))

  	       @phiPrime += (@N - @N0 - @M) / (@a * @OSGB_F0)

  	     end while ((@N - @N0 - @M) >= 0.001)

  	     @v = @a * @OSGB_F0 * ((1.0 - @eSquared * sin_pow_2(@phiPrime)) ** -0.5)
  	     @rho =
  	       @a\
  	         * @OSGB_F0\
  	         * (1.0 - @eSquared)\
  	         * ((1.0 - @eSquared * sin_pow_2(@phiPrime)) ** -1.5)
  	     @etaSquared = (@v / @rho) - 1.0
  	     @VII = Math.tan(@phiPrime) / (2 * @rho * @v)
  	     @VIII =
  	       (Math.tan(@phiPrime) / (24.0 * @rho * (@v ** 3.0)))\
  	         * (5.0\
  	           + (3.0 * tan_pow_2(@phiPrime))\
  	           + @etaSquared\
  	           - (9.0 * tan_pow_2(@phiPrime) * @etaSquared))
  	     @IX =
  	       (Math.tan(@phiPrime) / (720.0 * @rho * (@v ** 5.0)))\
  	         * (61.0\
  	           + (90.0 * tan_pow_2(@phiPrime))\
  	           + (45.0 * tan_pow_2(@phiPrime) * tan_pow_2(@phiPrime)))
  	     @X = sec(@phiPrime) / @v
  	     @XI =
  	       (sec(@phiPrime) / (6.0 * @v * @v * @v))\
  	         * ((@v / @rho) + (2 * tan_pow_2(@phiPrime)))
  	     @XII =
  	       (sec(@phiPrime) / (120.0 * (@v ** 5.0)))\
  	         * (5.0\
  	           + (28.0 * tan_pow_2(@phiPrime))\
  	           + (24.0 * tan_pow_2(@phiPrime) * tan_pow_2(@phiPrime)))
  	     @XIIA =
  	       (sec(@phiPrime) / (5040.0 * (@v ** 7.0)))\
  	         * (61.0\
  	           + (662.0 * tan_pow_2(@phiPrime))\
  	           + (1320.0 * tan_pow_2(@phiPrime) * tan_pow_2(@phiPrime))\
  	           + (720.0\
  	             * tan_pow_2(@phiPrime)\
  	             * tan_pow_2(@phiPrime)\
  	             * tan_pow_2(@phiPrime)))
  	     @phi =
  	       @phiPrime\
  	         - (@VII * ((@E - @E0) ** 2.0))\
  	         + (@VIII * ((@E - @E0) ** 4.0))\
  	         - (@IX * ((@E - @E0) ** 6.0))
  	     @lambda =
  	       @lambda0\
  	         + (@X * (@E - @E0))\
  	         - (@XI * ((@E - @E0) ** 3.0))\
  	         + (@XII * ((@E - @E0) ** 5.0))\
  	         - (@XIIA * ((@E - @E0) ** 7.0))

  	    { :latitude => rad_to_deg(@phi), :longitude => rad_to_deg(@lambda) }

  	  end
1335534
def y_pos(self, yval):
        ""
        off = self.y_coord.get_canvas_pos(self.size[1], yval,
                                          self.y_range[0], self.y_range[1])
        return self.loc[1] + off
686228
function (gcjLon, gcjLat) {
        if (this.outOfChina(gcjLat, gcjLon))
            return [gcjLon, gcjLat];

        var d = this.delta(gcjLat, gcjLon);
        return [gcjLon - d.lon, gcjLat - d.lat];
    }
260825
def wcs_to_axes(w, npix):
    """"""

    npix = npix[::-1]

    x = np.linspace(-(npix[0]) / 2., (npix[0]) / 2.,
                    npix[0] + 1) * np.abs(w.wcs.cdelt[0])
    y = np.linspace(-(npix[1]) / 2., (npix[1]) / 2.,
                    npix[1] + 1) * np.abs(w.wcs.cdelt[1])

    if w.wcs.naxis == 2:
        return x, y

    cdelt2 = np.log10((w.wcs.cdelt[2] + w.wcs.crval[2]) / w.wcs.crval[2])

    z = (np.linspace(0, npix[2], npix[2] + 1)) * cdelt2
    z += np.log10(w.wcs.crval[2])

    return x, y, z
482675
function _haversineCalculation(coordinateOne, coordinateTwo) {
// Credits
// https://www.movable-type.co.uk/scripts/latlong.html
// https://en.wikipedia.org/wiki/Haversine_formula
  let latitudeOneRadians = _convertDegreesToRadians(coordinateOne.latitude);
  let latitudeTwoRadians = _convertDegreesToRadians(coordinateTwo.latitude);

  let longitudeOneRadians = _convertDegreesToRadians(coordinateOne.longitude);
  let longitudeTwoRadians = _convertDegreesToRadians(coordinateTwo.longitude);

  let differenceOfLatitude = latitudeOneRadians - latitudeTwoRadians;
  let differenceOfLongitude = longitudeOneRadians - longitudeTwoRadians;

  // The square of half the chord length between the points
  let a = Math.sin(differenceOfLatitude / 2) * Math.sin(differenceOfLatitude / 2)
    + Math.sin(differenceOfLongitude / 2) * Math.sin(differenceOfLongitude / 2)
    * Math.cos(latitudeOneRadians) * Math.cos(latitudeTwoRadians);

  let angularDistanceInRadians = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));

  let distanceBetweenKM = EARTH_RADIUS_KM * angularDistanceInRadians;

  return distanceBetweenKM;
}
961518
function(x, y) {
            var m0 = this.m[0],
                m1 = this.m[1],
                m2 = this.m[2],
                m3 = this.m[3],
                m4 = this.m[4],
                m5 = this.m[5],
                yt = ((m0 * (y - m5)) - (m1 * (x - m4))) / ((m0 * m3) - (m1 * m2)),
                xt = (x - m4 - (m2 * yt)) / m0;

            return this.translate(xt, yt);
        }
1266152
def tinygps_to_degdec(lat, lng):
    """"""
    x = float(lat[:-5] + '.' + lat[-5:])
    y = float(lng[:-5] + '.' + lng[-5:])

    return x, y
729134
function () {
		var series = this,
			yAxis = series.yAxis;

		seriesTypes.area.prototype.translate.apply(series);

		// Set plotLow and plotHigh
		each(series.points, function (point) {

			var low = point.low,
				high = point.high,
				plotY = point.plotY;

			if (high === null && low === null) {
				point.y = null;
			} else if (low === null) {
				point.plotLow = point.plotY = null;
				point.plotHigh = yAxis.translate(high, 0, 1, 0, 1);
			} else if (high === null) {
				point.plotLow = plotY;
				point.plotHigh = null;
			} else {
				point.plotLow = plotY;
				point.plotHigh = yAxis.translate(high, 0, 1, 0, 1);
			}
		});

		// Postprocess plotHigh
		if (this.chart.polar) {
			each(this.points, function (point) {
				series.highToXY(point);
			});
		}
	}
505101
def interpolate_cubic(self, lons, lats, data):
        
        return self.interpolate(lons, lats, data, order=3)
576680
public double toScreenY(double y)
    {
        Point2D src = srcPnt.get();
        Point2D dst = dstPnt.get();
        src.setLocation(0, y);
        combinedTransform.transform(src, dst);
        return dst.getY();
    }
1022516
function(sexagesimal) {

			if (sexagesimal in geolib.decimal) {
				return geolib.decimal[sexagesimal];
			}

			var	regEx = new RegExp(sexagesimalPattern);
			var	data = regEx.exec(sexagesimal);

			if(data) {
				var min = parseFloat(data[2]/60);
				var sec = parseFloat(data[4]/3600) || 0;
			}

			var	dec = ((parseFloat(data[1]) + min + sec)).toFixed(8);
				// South and West are negative decimals
				dec = (data[7] == 'S' || data[7] == 'W') ? dec * -1 : dec;

			geolib.decimal[sexagesimal] = dec;

			return dec;

		}
636196
function (val, backwards, cvsCoord, old, handleLog, pointPlacement) {
            var axis = this,
              sign = 1,
              cvsOffset = 0,
              localA = old ? axis.oldTransA : axis.transA,
              localMin = old ? axis.oldMin : axis.min,
              returnValue,
              minPixelPadding = axis.minPixelPadding,
              postTranslate = (axis.options.ordinal || (axis.isLog && handleLog)) && axis.lin2val;

            if (!localA) {
                localA = axis.transA;
            }

            // In vertical axes, the canvas coordinates start from 0 at the top like in
            // SVG.
            if (cvsCoord) {
                sign *= -1; // canvas coordinates inverts the value
                cvsOffset = axis.len;
            }

            // Handle reversed axis
            if (axis.reversed) {
                sign *= -1;
                cvsOffset -= sign * (axis.sector || axis.len);
            }

            // From pixels to value
            if (backwards) { // reverse translation

                val = val * sign + cvsOffset;
                val -= minPixelPadding;
                returnValue = val / localA + localMin; // from chart pixel to value
                if (postTranslate) { // log and ordinal axes
                    returnValue = axis.lin2val(returnValue);
                }

                // From value to pixels
            } else {
                if (postTranslate) { // log and ordinal axes
                    val = axis.val2lin(val);
                }
                if (pointPlacement === 'between') {
                    pointPlacement = 0.5;
                }
                returnValue = sign * (val - localMin) * localA + cvsOffset + (sign * minPixelPadding) +
                  (isNumber(pointPlacement) ? localA * pointPlacement * axis.pointRange : 0);
            }

            return returnValue;
        }
987855
function(dx, dy, ref) {

            // Revert the translation and measure the change in angle around x-axis.
            return this.clone().offset(-dx, -dy).theta(ref) - this.theta(ref);
        }
1084074
def convert(y, m, d)
      nongDate = []   
      i = 0
      temp = 0
      leap = 0
      baseDate = Date.new(0 + 1900, 1, 31)
         
      objDate = Date.new(y, m, d);
      offset = objDate - baseDate
      nongDate[5] = offset + 40;
      nongDate[4] = 14;

      i = 1900
      while (i < 2050 && offset > 0)
        temp = days_in_lunar_date(i)
        offset -= temp
        nongDate[4] += 12

        i += 1
      end

      if (offset < 0)
        offset += temp
        i -= 1
        nongDate[4] -= 12
      end

      nongDate[0] = i
      nongDate[3] = i - 1864
      leap = leap_month(i) #闰哪个月
      nongDate[6] = 0

      i = 1  
      while(i<13 && offset > 0)
        #闰月
        if (leap > 0 && i == (leap + 1) && nongDate[6] == 0)
          i -= 1
          nongDate[6] = 1
          temp = leap_days( nongDate[0])
        else  
          temp = monthDays( nongDate[0], i)
        end   

        #解除闰月   
        if (nongDate[6] == 1 && i == (leap + 1))
          nongDate[6] = 0  
        end   
          offset -= temp   
          if (nongDate[6] == 0)   
            nongDate[4] += 1  
        end   

        i += 1  
      end   
      
      if (offset == 0 && leap > 0 && i == leap + 1)
        if (nongDate[6] == 1)
          nongDate[6] = 0
        else  
          nongDate[6] = 1
          i -= 1  
          nongDate[4] -= 1  
        end
      end   
      
      if (offset < 0)
        offset += temp
        i -= 1
        nongDate[4] -= 1
      end
      
      nongDate[1] = i
      nongDate[2] = offset + 1
    
      nongDate
    end
941549
def lat_to_deg(lat):
    """"""
    if isinstance(lat, str) and (':' in lat):
        # TODO: handle other coordinate systems
        lat_deg = dmsStrToDeg(lat)
    else:
        lat_deg = float(lat)
    return lat_deg