
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
ng2-haversine
Advanced tools
An Angular 2 library to calculate the distance between a pair of coordinates using the Haversine formula.
An Angular 2 library to calculate the distance between a pair of coordinates using the Haversine formula.
Install ng2-haversine
using npm
within your Angular 2 app directory:
$ npm install ng2-haversine --save
Once the package is installed, set the provider for HaversineService
in your AppModule
:
import { HaversineService } from "ng2-haversine";
@NgModule({
...
providers: [HaversineService]
...
})
export class AppModule { }
Now you're ready to use ng2-haversine
!
You can use HaversineService
from a Service or from a Component: just inject it as a dependency. Remember to import GeoCoord
as well:
import { HaversineService, GeoCoord } from "ng2-haversine";
@Component({ ... })
export class MyComponent {
constructor(private _haversineService: HaversineService) { }
}
Then, use one of the provided functions in HaversineService
to calcule the distance between two points:
tryHaversine(): void {
let madrid: GeoCoord = {
latitude: 40.416775,
longitude: -3.703790
};
let bilbao: GeoCoord = {
latitude: 43.262985,
longitude: -2.935013
};
let meters = this._haversineService.getDistanceInMeters(madrid, bilbao);
let kilometers = this._haversineService.getDistanceInKilometers(madrid, bilbao);
let miles = this._haversineService.getDistanceInMiles(madrid, bilbao);
console.log(`
The distance between Madrid and Bilbao is:
- ${meters} meters
- ${kilometers} kilometers
- ${miles} miles
`);
}
As you have guessed:
getDistanceInMeters(coord1: GeoCoord, coord2: GeoCoord): number
calculates a distance in meters.getDistanceInKilometers(coord1: GeoCoord, coord2: GeoCoord): number
calculates a distance in kilometers.getDistanceInMiles(coord1: GeoCoord, coord2: GeoCoord): number
calculates a distance in miles.GeoCoord
is an interface with latitude: number
and longitude: number
.To load ng2-haversine
using SystemJS is as simple as this. Open your systemjs.config.js
file and set paths
, map
and packages
properties this way:
(function (global) {
System.config({
paths: {
"npm:": "node_modules/"
},
map: {
...
"ng2-haversine": "npm:ng2-haversine"
},
packages: {
...
"ng2-haversine": {
main: "./index.js",
defaultExtension: "js"
}
}
});
})(this);
That's it :)
Code released under the MIT license.
FAQs
An Angular 2 library to calculate the distance between a pair of coordinates using the Haversine formula.
We found that ng2-haversine demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.