Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

msfs-geo

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

msfs-geo - npm Package Compare versions

Comparing version 0.1.0-alpha1 to 0.1.0-alpha2

1

dist/index.d.ts

@@ -6,3 +6,4 @@ export * from './bearingTo';

export * from './greatCircleIntersection';
export * from './getDistanceBounds';
export * from './placeBearingDistance';
export * from './trig';

@@ -179,2 +179,51 @@ 'use strict';

/**
* Returns the Southwest and Northeast corner of a box around a point with a minimum distance
* @param centre - The centre of the box
* @param distance - Half the side length of the box, the minimum distance to the centre
*/
const getDistanceBounds = (centre, distance) => {
const radLat = DEG_TO_RAD(centre.lat);
const radLong = DEG_TO_RAD(centre.long);
const radDist = distance / EARTH_RADIUS;
let minLat = radLat - radDist;
let maxLat = radLat + radDist;
const MAX_LAT_RAD = DEG_TO_RAD(MAX_LAT);
const MIN_LAT_RAD = DEG_TO_RAD(MIN_LAT);
const MAX_LON_RAD = DEG_TO_RAD(MAX_LON);
const MIN_LON_RAD = DEG_TO_RAD(MIN_LON);
let minLong;
let maxLong;
if (minLat > MIN_LAT_RAD && maxLat < MAX_LAT_RAD) {
const deltaLong = Math.asin(Math.sin(radDist) / Math.cos(radLat));
minLong = radLong - deltaLong;
if (minLong < MIN_LON_RAD) {
minLong += Math.PI * 2;
}
maxLong = radLong + deltaLong;
if (maxLong > MAX_LON_RAD) {
maxLong -= Math.PI * 2;
}
}
else {
// A pole is within the distance.
minLat = Math.max(minLat, MIN_LAT_RAD);
maxLat = Math.min(maxLat, MAX_LAT_RAD);
minLong = MIN_LON_RAD;
maxLong = MAX_LON_RAD;
}
return [
// Southwest
{
lat: RAD_TO_DEG(minLat),
long: RAD_TO_DEG(minLong),
},
// Northeast
{
lat: RAD_TO_DEG(maxLat),
long: RAD_TO_DEG(maxLong),
},
];
};
exports.DEG_TO_RAD = DEG_TO_RAD;

@@ -199,2 +248,3 @@ exports.EARTH_RADIUS = EARTH_RADIUS;

exports.distanceTo = distanceTo;
exports.getDistanceBounds = getDistanceBounds;
exports.greatCircleIntersection = greatCircleIntersection;

@@ -201,0 +251,0 @@ exports.placeBearingDistance = placeBearingDistance;

2

package.json
{
"name": "msfs-geo",
"version": "0.1.0-alpha1",
"version": "0.1.0-alpha2",
"description": "A set of geographic mathematical utility functions, designed for use in aviation, hence the use of Nautical Miles, Feet, and Degrees",

@@ -5,0 +5,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc