From 62b83bada63e467a978df829e3025bdd0f754fec Mon Sep 17 00:00:00 2001 From: Hyeonsoo David Lee Date: Sat, 30 Mar 2019 12:17:55 +0900 Subject: [PATCH] [utm] Add new definitions for utm (#34216) * [utm] Add new definitions for utm * add 'strictFunctionTypes' in tsconfig.json * What the... --- types/utm/index.d.ts | 27 +++++++++++++++++++++++++++ types/utm/tsconfig.json | 23 +++++++++++++++++++++++ types/utm/tslint.json | 1 + types/utm/utm-tests.ts | 23 +++++++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 types/utm/index.d.ts create mode 100644 types/utm/tsconfig.json create mode 100644 types/utm/tslint.json create mode 100644 types/utm/utm-tests.ts diff --git a/types/utm/index.d.ts b/types/utm/index.d.ts new file mode 100644 index 0000000000..e52f6e01db --- /dev/null +++ b/types/utm/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for utm 1.1 +// Project: https://github.com/timothygu/utm#readme +// Definitions by: Hyeonsoo David Lee +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function fromLatLon( + latitude: number, + longitude: number, + forceZoneNum?: number, +): { + easting: number + northing: number + zoneNum: number + zoneLetter: string +}; + +export function toLatLon( + easting: number, + northing: number, + zoneNum: number, + zoneLetter: string, + northern: boolean, + strict?: boolean, +): { + latitude: number + longitude: number +}; diff --git a/types/utm/tsconfig.json b/types/utm/tsconfig.json new file mode 100644 index 0000000000..581d9d392d --- /dev/null +++ b/types/utm/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "utm-tests.ts" + ] +} diff --git a/types/utm/tslint.json b/types/utm/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/utm/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/utm/utm-tests.ts b/types/utm/utm-tests.ts new file mode 100644 index 0000000000..10b3a984f6 --- /dev/null +++ b/types/utm/utm-tests.ts @@ -0,0 +1,23 @@ +import { fromLatLon, toLatLon } from 'utm'; + +const latLon1 = { + lat: 37.240778, + lon: 131.869556, +}; + +const utmCoord1 = fromLatLon(latLon1.lat, latLon1.lon); + +const latLon2 = toLatLon( + utmCoord1.easting, + utmCoord1.northing, + utmCoord1.zoneNum, + utmCoord1.zoneLetter, + true, +); + +const utmCoord2 = fromLatLon(latLon2.latitude, latLon2.longitude); + +utmCoord1.easting === utmCoord2.easting; +utmCoord1.northing === utmCoord2.northing; +utmCoord1.zoneNum === utmCoord2.zoneNum; +utmCoord1.zoneLetter === utmCoord2.zoneLetter;