diff --git a/proj4/index.d.ts b/proj4/index.d.ts index d59063f51b..ff2b8334de 100644 --- a/proj4/index.d.ts +++ b/proj4/index.d.ts @@ -1,102 +1,67 @@ -// Type definitions for proj4 2.3.15 +// Type definitions for proj4 2.3 // Project: https://github.com/proj4js/proj4js // Definitions by: Denis Carriere // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module "proj4" { - const TemplateCoordinates: Array | InterfaceCoordinates; +declare namespace proj4 { + type TemplateCoordinates = number[] | InterfaceCoordinates; interface InterfaceCoordinates { - x: number, - y: number, - z?: number, - m?: number + x: number; + y: number; + z?: number; + m?: number; } interface InterfaceDatum { - datum_type: number - a: number - b: number - es: number - ep2: number + datum_type: number; + a: number; + b: number; + es: number; + ep2: number; } - interface Proj4Static { - forward(coordinates: typeof TemplateCoordinates): Array - inverse(coordinates: typeof TemplateCoordinates): Array + interface Static { + forward(coordinates: TemplateCoordinates): number[]; + inverse(coordinates: TemplateCoordinates): number[]; } interface InterfaceProjection { - datum: string - b: number - rf: number - sphere: number - es: number - e: number - ep2: number - forward(coordinates: typeof TemplateCoordinates): Array - inverse(coordinates: typeof TemplateCoordinates): Array + datum: string; + b: number; + rf: number; + sphere: number; + es: number; + e: number; + ep2: number; + forward(coordinates: TemplateCoordinates): number[]; + inverse(coordinates: TemplateCoordinates): number[]; } - namespace proj4 { - /** - * @name defaultDatum - */ - export const defaultDatum: string; + export const defaultDatum: string; - /** - * @name Proj - */ - export function Proj(srsCode:any, callback?: any): InterfaceProjection; - - /** - * @name WGS84 - */ - export const WGS84: any; + export function Proj(srsCode: any, callback?: any): InterfaceProjection; - /** - * Depecrated v3 - * @name Point - */ - export function Point(x: number, y: number, z?: number): InterfaceCoordinates; - export function Point(coordinates: Array): InterfaceCoordinates; - export function Point(coordinates: InterfaceCoordinates): InterfaceCoordinates; - export function Point(coordinates: string): InterfaceCoordinates; - - /** - * @name toPoint - */ - export function toPoint(array: Array): InterfaceCoordinates; - - /** - * @name defs - */ - export function defs(name: string): any; - export function defs(name: string, projection: string): any; - export function defs(name: Array>): any; - - /** - * @name transform - */ - export function transform(source: InterfaceProjection, dest: InterfaceProjection, point: typeof TemplateCoordinates): any; - - /** - * @name mgrs - */ - export function mgrs(coordinates: Array, accuracy: number): string; - - /** - * @name version - */ - export const version: string; - } + export const WGS84: any; /** - * @name proj4 + * Depecrated v3 */ - function proj4(fromProjection: string): Proj4Static; - function proj4(fromProjection: string, toProjection: string): Proj4Static; - function proj4(fromProjection: string, coordinates: typeof TemplateCoordinates): Array; - function proj4(fromProjection: string, toProjection: string, coordinates: typeof TemplateCoordinates): Array; - export = proj4 + export function Point(x: number, y: number, z?: number): InterfaceCoordinates; + export function Point(coordinates: TemplateCoordinates | string): InterfaceCoordinates; + + export function toPoint(array: number[]): InterfaceCoordinates; + + export function defs(name: string, projection?: string): any; + export function defs(name: string[][]): any; + + export function transform(source: InterfaceProjection, dest: InterfaceProjection, point: TemplateCoordinates): any; + + export function mgrs(coordinates: number[], accuracy: number): string; + + export const version: string; } + +declare function proj4(fromProjection: string, toProjection?: string, coordinates?: proj4.TemplateCoordinates): proj4.Static; +declare function proj4(fromProjection: string, coordinates: proj4.TemplateCoordinates): number[]; +export = proj4; diff --git a/proj4/proj4-tests.ts b/proj4/proj4-tests.ts index 72fa804c6e..2c658b8f24 100644 --- a/proj4/proj4-tests.ts +++ b/proj4/proj4-tests.ts @@ -1,49 +1,49 @@ -import * as proj4 from 'proj4' +import * as proj4 from 'proj4'; /////////////////////////////////////////// // Tests data initialisation /////////////////////////////////////////// -const name = 'WGS84' +const name = 'WGS84'; const epsg = { 4269: '+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees', 4326: '+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees', -} -const point1 = [-71, 41] -const point2 = {x: 2, y: 5} -const mgrs = "24XWT783908" +}; +const point1 = [-71, 41]; +const point2 = {x: 2, y: 5}; +const mgrs = "24XWT783908"; /////////////////////////////////////////// // Tests Measurement /////////////////////////////////////////// -proj4(epsg['4269'], epsg['4326'], point1) -proj4(epsg['4269'], point1) -proj4(epsg['4269'], epsg['4326']).forward(point2) -proj4(epsg['4269'], epsg['4326']).inverse(point2) +proj4(epsg['4269'], epsg['4326'], point1); +proj4(epsg['4269'], point1); +proj4(epsg['4269'], epsg['4326']).forward(point2); +proj4(epsg['4269'], epsg['4326']).inverse(point2); /////////////////////////////////// // Named Projections /////////////////////////////////// -proj4.defs('WGS84', epsg['4326']) +proj4.defs('WGS84', epsg['4326']); proj4.defs([ ['EPSG:4326', epsg['4326']], ['EPSG:4269', epsg['4269']] -]) -proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326')) +]); +proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326')); /////////////////////////////////// // Utils /////////////////////////////////// // WGS84 -proj4.WGS84 +proj4.WGS84; // Proj -proj4.Proj('WGS84') +proj4.Proj('WGS84'); // toPoint -proj4.toPoint([1, 2]) -proj4.toPoint([1, 2, 3]) -proj4.toPoint([1, 2, 3, 4]) +proj4.toPoint([1, 2]); +proj4.toPoint([1, 2, 3]); +proj4.toPoint([1, 2, 3, 4]); // Point // WARNING: Deprecated in v3 -proj4.Point([1, 2, 3, 4]) \ No newline at end of file +proj4.Point([1, 2, 3, 4]); \ No newline at end of file diff --git a/proj4/tslint.json b/proj4/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/proj4/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file