Add typings for geopoint (#43158)

This adds a type definition for the geopoint npm package
This commit is contained in:
Peter Varg 2020-03-25 13:29:40 +13:00 committed by GitHub
parent eea1cfb40e
commit b2d4d29f9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,21 @@
import GeoPoint = require("geopoint");
function test() {
const geopoint: GeoPoint = new GeoPoint(2.33, 4.66, false);
const boundingCoords: [GeoPoint, GeoPoint] = geopoint.boundingCoordinates(5, 12, true);
const distanceTo: number = geopoint.distanceTo(new GeoPoint(4.20, 6.9));
const latitude: number = geopoint.latitude(false);
const longitude: number = geopoint.longitude(true);
const degToRad: number = GeoPoint.degreesToRadians(1);
const kmToMiles: number = GeoPoint.kilometersToMiles(13.33333);
const milesToKm: number = GeoPoint.milesToKilometers(666);
const radToDeg: number = GeoPoint.radiansToDegrees(3);
}

26
types/geopoint/index.d.ts vendored Normal file
View File

@ -0,0 +1,26 @@
// Type definitions for geopoint 1.0
// Project: https://github.com/davidwood/node-geopoint
// Definitions by: Varg Industries <https://github.com/vargind>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = GeoPoint;
declare class GeoPoint {
constructor(lat: number, lon: number, inRadians?: boolean);
boundingCoordinates(distance: number, radius: number, inKilometers?: boolean): [GeoPoint, GeoPoint];
distanceTo(point: GeoPoint, inKilometers?: boolean): number;
latitude(inRadians?: boolean): number;
longitude(inRadians?: boolean): number;
static degreesToRadians(value: number): number;
static kilometersToMiles(value: number): number;
static milesToKilometers(value: number): number;
static radiansToDegrees(value: number): number;
}

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"geopoint-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }