Constructor

@param   {Number}    lat         Latitude
@param   {Number}    long        Longitude
@param   {Boolean}   inRadians   true if latitude and longitude are in radians
437412
function GeoPoint(lat, lon, inRadians) {
    if (!isNumber(lat)) {
      throw new Error('Invalid latitude');
    }
    if (!isNumber(lon)) {
      throw new Error('Invalid longitude');
    }
    if (inRadians === true) {
      this._degLat = GeoPoint.radiansToDegrees(lat);
      this._degLon = GeoPoint.radiansToDegrees(lon);
      this._radLat = lat;
      this._radLon = lon;
    } else {
      this._degLat = lat;
      this._degLon = lon;
      this._radLat = GeoPoint.degreesToRadians(lat);
      this._radLon = GeoPoint.degreesToRadians(lon);
    }
    if (this._radLat < MIN_LAT || this._radLat > MAX_LAT) {
      throw new Error('Latitude out of bounds');
    } else if (this._radLon < MIN_LON || this._radLon > MAX_LON) {
      throw new Error('Longitude out of bounds');
    }
  }
141086
def inMicrolensRegion_main(args=None):
    """"""
    import argparse
    parser = argparse.ArgumentParser(
                    description="Check if a celestial coordinate is "
                                "inside the K2C9 microlensing superstamp.")
    parser.add_argument('ra', nargs=1, type=float,
                        help="Right Ascension in decimal degrees (J2000).")
    parser.add_argument('dec', nargs=1, type=float,
                        help="Declination in decimal degrees (J2000).")
    args = parser.parse_args(args)
    if inMicrolensRegion(args.ra[0], args.dec[0]):
        print("Yes! The coordinate is inside the K2C9 superstamp.")
    else:
        print("Sorry, the coordinate is NOT inside the K2C9 superstamp.")
1288658
function (angle) {
		
		var toRad = function (number) {
			return number * L.LatLng.DEG_TO_RAD;
		};
		
		var toDeg = function (number) {
			return number * L.LatLng.RAD_TO_DEG;
		};
		
		var angleRadians = toRad(angle);
		var angularDistance = this.options.radius / L.RegularPolygon.M_PER_KM / L.RegularPolygon.R;
		var lat1 = toRad(this._centerLatLng.lat);
		var lon1 = toRad(this._centerLatLng.lng);
		var lat2 = Math.asin(Math.sin(lat1) * Math.cos(angularDistance) + Math.cos(lat1) * Math.sin(angularDistance) * Math.cos(angleRadians));
		var lon2 = lon1 + Math.atan2(Math.sin(angleRadians) * Math.sin(angularDistance) * Math.cos(lat1), Math.cos(angularDistance) - Math.sin(lat1) * Math.sin(lat2));
		
		lat2 = toDeg(lat2);
		lon2 = toDeg(lon2);
		
		return new L.LatLng(lat2, lon2);
	}
223322
private void setPosition(float latitude, float longitude, boolean updateMap, boolean updateAddress) {

        m_editValue.setLatitude(latitude);
        m_editValue.setLongitude(longitude);
        m_popupContent.displayValues(m_editValue);
        if (updateMap) {
            updateMarkerPosition();
        }
        if (updateAddress) {
            updateAddress();
        }
    }
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};
  }
882345
def parse_elements(elements):
        
        if not len(elements) in (6, 7):
            raise ValueError('Invalid GLL position data')
        # Latitude and longitude are checked for validity during Fix
        # instantiation
        latitude = parse_latitude(elements[0], elements[1])
        longitude = parse_longitude(elements[2], elements[3])
        hour, minute, second = [int(elements[4][i:i + 2])
                                for i in range(0, 6, 2)]
        usecond = int(elements[4][6:8]) * 10000
        time = datetime.time(hour, minute, second, usecond)
        active = True if elements[5] == 'A' else False
        mode = elements[6] if len(elements) == 7 else None
        return LoranPosition(latitude, longitude, time, active, mode)
1231945
function distance(from, to) {
  const degrees2radians = Math.PI / 180;
  const dLat = degrees2radians * (to[1] - from[1]);
  const dLon = degrees2radians * (to[0] - from[0]);
  const lat1 = degrees2radians * from[1];
  const lat2 = degrees2radians * to[1];

  const a = Math.pow(Math.sin(dLat / 2), 2) +
        Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
  return Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
}
1138846
static double computeAngleBetween(IGeoPoint from, IGeoPoint to) {
        return distanceRadians(toRadians(from.getLatitude()), toRadians(from.getLongitude()),
            toRadians(to.getLatitude()), toRadians(to.getLongitude()));
    }
521882
def greatCircleDistance(self, lat1, long1, lat2, long2, radius):
    

    # Convert latitude and longitude to
    # spherical coordinates in radians.
    degrees_to_radians = np.pi/180.0
         
    # theta = colatitude = 90 - latitude
    theta1rad = (90.0 - lat1)*degrees_to_radians
    theta2rad = (90.0 - lat2)*degrees_to_radians
         
    # lambda = longitude
    lambda1rad = long1*degrees_to_radians
    lambda2rad = long2*degrees_to_radians
         
    # Compute spherical distance from spherical coordinates.
         
    # For two locations in spherical coordinates
    # (1, theta, phi) and (1, theta, phi)
    # cosine( arc length ) =
    #    sin(theta) * sin(theta') * cos(theta-theta') + cos(phi) * cos(phi')
    # distance = radius * arc length
     
    cos_arc_length = np.sin(theta1rad) * np.sin(theta2rad) * \
                     np.cos(lambda1rad - lambda2rad) + \
                     np.cos(theta1rad) * np.cos(theta2rad)
    arc = np.arccos( cos_arc_length )
 
    great_circle_distance = radius * arc
    
    return great_circle_distance
240261
def _inc_lat(self, latitude, delta):
        """"""
        y = self._convert_latitude(latitude)
        y += delta
        return 360 / pi * atan(
            exp((180 - y * 360 / (2 ** self._zoom) / self._size) * pi / 180)) - 90
827249
@Override
    public IDocumentQuery<T> withinRadiusOf(String fieldName, double radius, double latitude, double longitude) {
        return withinRadiusOf(fieldName, radius, latitude, longitude, null, Constants.Documents.Indexing.Spatial.DEFAULT_DISTANCE_ERROR_PCT);
    }
863393
function getCoordDistance($latitude1, $longitude1, $latitude2, $longitude2)
        {
            $earth_radius = 6371;

            $latitude1 = floatval($latitude1);
            $longitude1 = floatval($longitude1);
            $latitude2 = floatval($latitude2);
            $longitude2 = floatval($longitude2);

            $dLat = deg2rad($latitude2 - $latitude1);
            $dLon = deg2rad($longitude2 - $longitude1);

            $a = sin($dLat / 2) * sin($dLat / 2) + cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * sin($dLon / 2) * sin($dLon / 2);
            $c = 2 * asin(sqrt($a));
            $d = $earth_radius * $c;

            return $d;

        }
383384
function (radians) {
            var lon = radians % this.TWO_PI;

            return lon > Math.PI ? lon - this.TWO_PI : lon < -Math.PI ? this.TWO_PI + lon : lon;
        }
154003
function positionToMercator(position) {
    var lng = position[0];
    var lat = Math.max(Math.min(position[1], 89.99999), -89.99999);
    return [degToRad(lng) * EarthRadius, EarthRadius/2.0 * Math.log( (1.0 + Math.sin(degToRad(lat))) / (1.0 - Math.sin(degToRad(lat))) )];
  }
923556
public LongitudePair getLongitudeOnGreatCircle(Position position, double latitudeDegrees) {
        double lat3 = toRadians(latitudeDegrees);
        double lat1 = toRadians(lat);
        double lon1 = toRadians(lon);
        double lat2 = toRadians(position.getLat());
        double lon2 = toRadians(position.getLon());
        double l12 = lon1 - lon2;
        double sinLat1 = sin(lat1);
        double cosLat2 = cos(lat2);
        double cosLat3 = cos(lat3);
        double cosLat1 = cos(lat1);
        double sinL12 = sin(l12);
        double A = sinLat1 * cosLat2 * cosLat3 * sinL12;
        double B = sinLat1 * cosLat2 * cosLat3 * cos(l12) - cosLat1 * sin(lat2) * cosLat3;
        double C = cosLat1 * cosLat2 * sin(lat3) * sinL12;
        double longitude = atan2(B, A);
        double v = sqrt(sqr(A) + sqr(B));
        if (abs(C) >= v) {
            // not found!
            return null;
        } else {
            double dlon = acos(C / v);
            double lonCandidate1Degrees = to180(FastMath.toDegrees(lon1 + dlon + longitude));
            double lonCandidate2Degrees = to180(FastMath.toDegrees(lon1 - dlon + longitude));
            return new LongitudePair(lonCandidate1Degrees, lonCandidate2Degrees);
        }
    }
218875
private static function distanceRadians( $lat1,  $lng1,  $lat2,  $lng2) {
        return MathUtil::arcHav(MathUtil::havDistance($lat1, $lat2, $lng1 - $lng2));
    }
308623
public void latlonToEqui(double lat, double lon, Point2D_F64 rect) {
		rect.x = UtilAngle.wrapZeroToOne(lon / GrlConstants.PI2 + 0.5)*width;
		rect.y = UtilAngle.reflectZeroToOne(lat / GrlConstants.PI + 0.5)*(height-1);
	}