mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 19:51:53 +00:00
Implement Geodesy definition (#14004)
* Implement Geodesy definition * Geodesy - added tslint * Fixed Geodesy build failing - Removed patch release - strictNullChecks = null - Export class Dms
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
import {
|
||||
Mgrs,
|
||||
Utm,
|
||||
Dms,
|
||||
Vector3d,
|
||||
OsGridRef,
|
||||
LatLonEllipsoidal as LatLon } from 'geodesy';
|
||||
|
||||
/**
|
||||
* Mgrs
|
||||
*/
|
||||
const mgrs = new Mgrs(31, 'U', 'D', 'Q', 48251, 11932);
|
||||
const bandMgrs = mgrs.band;
|
||||
const datumMgrs = mgrs.datum;
|
||||
const e100kMgrs = mgrs.e100k;
|
||||
const e100kLettersMgrs = mgrs.e100kLetters;
|
||||
const eastingMgrs = mgrs.easting;
|
||||
const latBandsMgrs = mgrs.latBands;
|
||||
const n100kMgrs = mgrs.n100k;
|
||||
const n100kLettersMgrs = mgrs.n100kLetters;
|
||||
const northingMgrs = mgrs.northing;
|
||||
const zoneMgrs = mgrs.zone;
|
||||
mgrs.toString();
|
||||
mgrs.toUtm();
|
||||
|
||||
|
||||
// Static Functions
|
||||
Mgrs.parse('31U DQ 48251 11932');
|
||||
|
||||
/**
|
||||
* Utm
|
||||
*/
|
||||
const utm = new Utm(31, 'N', 448251, 5411932);
|
||||
const convergenceUtm = utm.convergence;
|
||||
const datumUtm = utm.datum;
|
||||
const eastingUtm = utm.easting;
|
||||
const hemisphereUtm = utm.hemisphere;
|
||||
const northingUtm = utm.northing;
|
||||
const scaleUtm = utm.scale;
|
||||
utm.toLatLonE();
|
||||
utm.toMgrs();
|
||||
utm.toString();
|
||||
|
||||
// Static Functions
|
||||
Utm.parse('31 N 448251 5411932');
|
||||
|
||||
/**
|
||||
* Dms
|
||||
*/
|
||||
|
||||
Dms.separator = '\u202f';
|
||||
|
||||
// Static Functions
|
||||
Dms.parseDMS('51° 28′ 40.12″ N');
|
||||
|
||||
Dms.toDMS(45);
|
||||
Dms.toDMS(45, 'dm');
|
||||
Dms.toDMS(45, 'd', 2);
|
||||
Dms.toDMS(45, 'dms', 4);
|
||||
|
||||
Dms.toLat(45);
|
||||
Dms.toLat(45, 'dm');
|
||||
Dms.toLat(45, 'd', 2);
|
||||
Dms.toLat(45, 'dms', 4);
|
||||
|
||||
Dms.toLon(45);
|
||||
Dms.toLon(45, 'dm');
|
||||
Dms.toLon(45, 'd', 2);
|
||||
Dms.toLon(45, 'dms', 4);
|
||||
|
||||
Dms.toBrng(90);
|
||||
Dms.toBrng(90, 'dm');
|
||||
Dms.toBrng(90, 'd', 2);
|
||||
Dms.toBrng(90, 'dms', 4);
|
||||
|
||||
Dms.compassPoint(180);
|
||||
Dms.compassPoint(180, 1);
|
||||
Dms.compassPoint(180, 2);
|
||||
Dms.compassPoint(180, 3);
|
||||
|
||||
/**
|
||||
* Vector3d
|
||||
*/
|
||||
const v1 = new Vector3d(4, 23, 13);
|
||||
const v2 = new Vector3d(5, 42, 33);
|
||||
const v3 = new Vector3d(8, 12, 43);
|
||||
|
||||
v1.cross(v2).dot(v3);
|
||||
|
||||
/**
|
||||
* LatLon
|
||||
*/
|
||||
const latlon = new LatLon(52.65798, 1.71605);
|
||||
const latlonWGS84 = new LatLon(51.4778, -0.0016, LatLon.datum.WGS84);
|
||||
const pWGS84 = new LatLon(51.4778, -0.0016, LatLon.datum.WGS84);
|
||||
const pOSGB = pWGS84.convertDatum(LatLon.datum.OSGB36);
|
||||
|
||||
latlon.toUtm();
|
||||
latlon.toCartesian();
|
||||
latlon.toString();
|
||||
latlon.toString('dm');
|
||||
latlon.toString('d', 0);
|
||||
|
||||
const mgrsGrid = new LatLon(45.4215296, -75.697193).toUtm().toMgrs();
|
||||
mgrsGrid.toString(6);
|
||||
|
||||
/**
|
||||
* OsGridRef
|
||||
*/
|
||||
const gridref = new OsGridRef(651409, 313177);
|
||||
const osgrid = new OsGridRef(651409.903, 313177.270);
|
||||
new OsGridRef(651409, 313177).toString();
|
||||
|
||||
// Static Functions
|
||||
OsGridRef.latLonToOsGrid(latlon);
|
||||
OsGridRef.osGridToLatLon(gridref);
|
||||
OsGridRef.osGridToLatLon(gridref, LatLon.datum.OSGB36);
|
||||
OsGridRef.parse('TG 51409 13177');
|
||||
Vendored
+149
@@ -0,0 +1,149 @@
|
||||
// Type definitions for geodesy 1.1
|
||||
// Project: https://github.com/chrisveness/geodesy
|
||||
// Definitions by: Denis Carriere <https://github.com/DenisCarriere>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export type format = 'd' | 'dm' | 'dms';
|
||||
export type datum = 'ED50'| 'Irl1975'| 'NAD27'| 'NAD83'| 'NTF'| 'OSGB36'| 'Potsdam'| 'TokyoJapan'| 'WGS72'| 'WGS84';
|
||||
export type hemisphere = 'N' | 'S';
|
||||
export type ellipsoid = 'WGS84' | 'Airy1830' | 'AiryModified' | 'Bessel1841' | 'Clarke1866' | 'Clarke1880IGN' | 'GRS80' | 'Intl1924' | 'WGS72';
|
||||
export type transform = [number, number, number, number, number, number, number];
|
||||
export type LatLon = LatLonEllipsoidal;
|
||||
|
||||
export interface Datum {
|
||||
ellipsoid: Ellipsoid;
|
||||
transform: [number, number, number, number, number, number, number];
|
||||
}
|
||||
|
||||
export interface Datums {
|
||||
ED50: Datum;
|
||||
Irl1975: Datum;
|
||||
NAD27: Datum;
|
||||
NAD83: Datum;
|
||||
NTF: Datum;
|
||||
OSGB36: Datum;
|
||||
Potsdam: Datum;
|
||||
TokyoJapan: Datum;
|
||||
WGS72: Datum;
|
||||
WGS84: Datum;
|
||||
}
|
||||
|
||||
export interface Ellipsoid {
|
||||
a: number;
|
||||
b: number;
|
||||
f: number;
|
||||
}
|
||||
|
||||
export interface Ellipsoids {
|
||||
WGS84: Ellipsoid;
|
||||
GRS80: Ellipsoid;
|
||||
Airy1830: Ellipsoid;
|
||||
AiryModified: Ellipsoid;
|
||||
Intl1924: Ellipsoid;
|
||||
Bessel1841: Ellipsoid;
|
||||
}
|
||||
|
||||
export declare class Mgrs {
|
||||
zone: number;
|
||||
band: string;
|
||||
e100k: string;
|
||||
n100k: string;
|
||||
easting: number;
|
||||
northing: number;
|
||||
datum: datum;
|
||||
latBands: string;
|
||||
e100kLetters: string;
|
||||
n100kLetters: string;
|
||||
constructor(
|
||||
zone: number,
|
||||
band: string,
|
||||
e100k: string,
|
||||
n100k: string,
|
||||
easting: number,
|
||||
northing: number,
|
||||
datum?: datum
|
||||
)
|
||||
static parse(mgrsGridRef: string): Mgrs;
|
||||
toUtm(): Utm;
|
||||
toString(digits?: 2 | 4 | 6 | 8 | 10): string;
|
||||
}
|
||||
|
||||
export declare class Utm {
|
||||
zone: number;
|
||||
hemisphere: hemisphere;
|
||||
easting: number;
|
||||
northing: number;
|
||||
datum: Datum;
|
||||
convergence: number;
|
||||
scale: number;
|
||||
constructor(
|
||||
zone: number,
|
||||
hemisphere: hemisphere,
|
||||
easting: number,
|
||||
northing: number,
|
||||
datum?: datum,
|
||||
convergence?: number,
|
||||
scale?: number
|
||||
);
|
||||
static parse(utmCoord: string, datum?: datum): Utm;
|
||||
toLatLonE(): LatLon;
|
||||
toMgrs(): Mgrs;
|
||||
toString(digits?: number): string;
|
||||
}
|
||||
|
||||
export declare namespace Dms {
|
||||
export let separator: string;
|
||||
}
|
||||
|
||||
export declare class Dms {
|
||||
static parseDMS(dmsStr: string): number;
|
||||
static toDMS(deg: number, format?: format, dp?: 0 | 2 | 4): string;
|
||||
static toLat(deg: number, format?: format, dp?: 0 | 2 | 4): string;
|
||||
static toLon(deg: number, format?: format, dp?: 0 | 2 | 4): string;
|
||||
static toBrng(deg: number, format?: format, dp?: 0 | 2 | 4): string;
|
||||
static compassPoint(bearing: number, precision?: 1 | 2 | 3): string;
|
||||
}
|
||||
|
||||
export declare class Vector3d {
|
||||
x: number;
|
||||
y: number;
|
||||
z: number;
|
||||
constructor(x: number, y: number, z: number);
|
||||
plus(v: Vector3d): Vector3d;
|
||||
minus(v: Vector3d): Vector3d;
|
||||
times(x: number): Vector3d;
|
||||
dividedBy(x: number): Vector3d;
|
||||
dot(v: Vector3d): number;
|
||||
cross(v: Vector3d): Vector3d;
|
||||
negate(): Vector3d;
|
||||
length(): number;
|
||||
unit(): Vector3d;
|
||||
angleTo(v: Vector3d, n?: Vector3d): number;
|
||||
rotateAround(axis: Vector3d, theta: number): Vector3d;
|
||||
toString(precision?: number): string;
|
||||
toLatLonE(datum: Datum): LatLon;
|
||||
applyTransform(t: number[]): Vector3d;
|
||||
}
|
||||
|
||||
export declare class OsGridRef {
|
||||
easting: number;
|
||||
northing: number;
|
||||
constructor(easting: number, northing: number);
|
||||
static latLonToOsGrid(p: LatLon): OsGridRef;
|
||||
static osGridToLatLon(gridref: OsGridRef, datum?: Datum): LatLon;
|
||||
static parse(gridref: string): OsGridRef;
|
||||
toString(digits?: number): string;
|
||||
}
|
||||
|
||||
export declare class LatLonEllipsoidal {
|
||||
lat: number;
|
||||
lon: number;
|
||||
datum: Datum;
|
||||
constructor(lat: number, lon: number, datum?: Datum);
|
||||
toUtm(): Utm;
|
||||
convertDatum(toDatum: Datum): LatLon;
|
||||
toCartesian(): Vector3d;
|
||||
toString(format?: format, dp?: 0 | 2 | 4): string;
|
||||
static datum: Datums;
|
||||
static ellipsoid: Ellipsoids;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"geodesy-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user