[utm] Add new definitions for utm (#34216)

* [utm] Add new definitions for utm

* add 'strictFunctionTypes' in tsconfig.json

* What the...
This commit is contained in:
Hyeonsoo David Lee
2019-03-29 20:17:55 -07:00
committed by Ron Buckton
parent 95d0278f0e
commit 62b83bada6
4 changed files with 74 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
// Type definitions for utm 1.1
// Project: https://github.com/timothygu/utm#readme
// Definitions by: Hyeonsoo David Lee <https://github.com/civilizeddev>
// 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
};
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+23
View File
@@ -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;