mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
[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:
committed by
Ron Buckton
parent
95d0278f0e
commit
62b83bada6
Vendored
+27
@@ -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
|
||||
};
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user