From 8dffdd92cf965d725b5b9db79ba05a77f432c0a8 Mon Sep 17 00:00:00 2001 From: Tomasz Janusz <424941+TomaszJanusz@users.noreply.github.com> Date: Wed, 20 Dec 2017 00:12:52 +0100 Subject: [PATCH 1/4] Add isFlat method to LineUtil definition --- types/leaflet/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index 71c6ea4adf..095dadcbc0 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -22,6 +22,7 @@ export class Transformation { transform(point: Point, scale?: number): Point; untransform(point: Point, scale?: number): Point; + } export namespace LineUtil { @@ -30,6 +31,8 @@ export namespace LineUtil { function pointToSegmentDistance(p: Point, p1: Point, p2: Point): number; function closestPointOnSegment(p: Point, p1: Point, p2: Point): Point; + + function isFlat(latlngs: LatLngExpression[]): boolean; } export namespace PolyUtil { From fea29359dffdd3b5516365f6eba57d6713b836bc Mon Sep 17 00:00:00 2001 From: Tomasz Janusz Date: Wed, 20 Dec 2017 00:22:26 +0100 Subject: [PATCH 2/4] fix linter errors --- types/leaflet/index.d.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index 095dadcbc0..310977d9f4 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -18,20 +18,14 @@ export class Class { export class Transformation { constructor(a: number, b: number, c: number, d: number); - transform(point: Point, scale?: number): Point; - untransform(point: Point, scale?: number): Point; - } export namespace LineUtil { function simplify(points: Point[], tolerance: number): Point[]; - function pointToSegmentDistance(p: Point, p1: Point, p2: Point): number; - function closestPointOnSegment(p: Point, p1: Point, p2: Point): Point; - function isFlat(latlngs: LatLngExpression[]): boolean; } From cb6b5b8a41d87f9b68d6b69f48b3046dfc0f4d7d Mon Sep 17 00:00:00 2001 From: Tomasz Janusz <424941+TomaszJanusz@users.noreply.github.com> Date: Wed, 20 Dec 2017 00:24:45 +0100 Subject: [PATCH 3/4] Remove linter errors --- types/leaflet/index.d.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index 095dadcbc0..310977d9f4 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -18,20 +18,14 @@ export class Class { export class Transformation { constructor(a: number, b: number, c: number, d: number); - transform(point: Point, scale?: number): Point; - untransform(point: Point, scale?: number): Point; - } export namespace LineUtil { function simplify(points: Point[], tolerance: number): Point[]; - function pointToSegmentDistance(p: Point, p1: Point, p2: Point): number; - function closestPointOnSegment(p: Point, p1: Point, p2: Point): Point; - function isFlat(latlngs: LatLngExpression[]): boolean; } From 16ce77ee6d9d5d57ff6f686b7257e3759e8e98c6 Mon Sep 17 00:00:00 2001 From: Tomasz Janusz Date: Thu, 21 Dec 2017 17:26:48 +0100 Subject: [PATCH 4/4] Fix proj4leaflet tests & types errors GeoJSON does not have a CRS object in the specification, so the proj4leaflet tests did not pass. Fixed :) --- types/proj4leaflet/index.d.ts | 5 ++++- types/proj4leaflet/proj4leaflet-tests.ts | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/types/proj4leaflet/index.d.ts b/types/proj4leaflet/index.d.ts index 81a16100e4..a33a3efb32 100644 --- a/types/proj4leaflet/index.d.ts +++ b/types/proj4leaflet/index.d.ts @@ -42,7 +42,7 @@ declare module 'leaflet' { class GeoJSON extends L.GeoJSON {} - const geoJson: (geojson?: geojson.GeoJsonObject, options?: GeoJSONOptions) => GeoJSON; + const geoJson: (geojson?: Proj4GeoJSONFeature, options?: GeoJSONOptions) => GeoJSON; class ImageOverlay extends L.ImageOverlay {} @@ -57,3 +57,6 @@ declare module 'leaflet' { } } } +export type Proj4GeoJSONFeature = geojson.Feature & { + crs?: { type: string; properties: { name: string } } +}; diff --git a/types/proj4leaflet/proj4leaflet-tests.ts b/types/proj4leaflet/proj4leaflet-tests.ts index e061a4ca3a..930473d793 100644 --- a/types/proj4leaflet/proj4leaflet-tests.ts +++ b/types/proj4leaflet/proj4leaflet-tests.ts @@ -1,6 +1,5 @@ import * as L from 'leaflet'; -import 'proj4leaflet'; - +import * as proj4leaflet from "proj4leaflet"; import * as proj4 from 'proj4'; import LatLngBoundsExpression = L.LatLngBoundsExpression; @@ -43,12 +42,13 @@ const crs3 = new L.Proj.CRS('EPSG:3006', // geoJson proj4.defs("urn:ogc:def:crs:EPSG::26915", "+proj=utm +zone=15 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"); -const geojson = { +const geojson: proj4leaflet.Proj4GeoJSONFeature = { type: "Feature", geometry: { type: "Point", coordinates: [481650, 4980105] }, + properties: {}, crs: { type: "name", properties: {