proj4: Lint and convert to external module

This commit is contained in:
Andy Hanson 2017-02-16 06:29:56 -08:00
parent 2847281115
commit 3f5ec8ac4a
3 changed files with 65 additions and 99 deletions

125
proj4/index.d.ts vendored
View File

@ -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 <https://github.com/DenisCarriere>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "proj4" {
const TemplateCoordinates: Array<number> | 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<number>
inverse(coordinates: typeof TemplateCoordinates): Array<number>
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<number>
inverse(coordinates: typeof TemplateCoordinates): Array<number>
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<number>): InterfaceCoordinates;
export function Point(coordinates: InterfaceCoordinates): InterfaceCoordinates;
export function Point(coordinates: string): InterfaceCoordinates;
/**
* @name toPoint
*/
export function toPoint(array: Array<number>): InterfaceCoordinates;
/**
* @name defs
*/
export function defs(name: string): any;
export function defs(name: string, projection: string): any;
export function defs(name: Array<Array<string>>): any;
/**
* @name transform
*/
export function transform(source: InterfaceProjection, dest: InterfaceProjection, point: typeof TemplateCoordinates): any;
/**
* @name mgrs
*/
export function mgrs(coordinates: Array<number>, 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<number>;
function proj4(fromProjection: string, toProjection: string, coordinates: typeof TemplateCoordinates): Array<number>;
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;

View File

@ -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])
proj4.Point([1, 2, 3, 4]);

1
proj4/tslint.json Normal file
View File

@ -0,0 +1 @@
{ "extends": "../tslint.json" }