Refactor td for leaflet and geojson

This commit is contained in:
Arne Schubert
2017-01-27 17:22:50 +01:00
parent 5cbfe33c13
commit 16e5b26b3d
6 changed files with 1547 additions and 1403 deletions
+103 -24
View File
@@ -1,26 +1,27 @@
var featureCollection: GeoJSON.FeatureCollection<any> = {
import GeometryObject = GeoJSON.GeometryObject;
let featureCollection: GeoJSON.FeatureCollection<any> = {
type: "FeatureCollection",
features: [
{
features: [
{
type: "Feature",
geometry: {
type: "Point",
type: "Point",
coordinates: [102.0, 0.5]
},
properties: {
prop0: "value0"
}
},
{
{
type: "Feature",
geometry: {
type: "LineString",
coordinates: [
[102.0, 0.0],
[103.0, 1.0],
[104.0, 0.0],
[102.0, 0.0],
[103.0, 1.0],
[104.0, 0.0],
[105.0, 1.0]
]
},
@@ -29,7 +30,7 @@ var featureCollection: GeoJSON.FeatureCollection<any> = {
prop1: 0.0
}
},
{
{
type: "Feature",
geometry: {
type: "Polygon",
@@ -52,9 +53,9 @@ var featureCollection: GeoJSON.FeatureCollection<any> = {
type: "proj4"
}
}
}
};
var feature: GeoJSON.Feature<GeoJSON.Polygon> = {
let featureWithPolygon: GeoJSON.Feature<GeoJSON.Polygon> = {
type: "Feature",
bbox: [-180.0, -90.0, 180.0, 90.0],
geometry: {
@@ -67,29 +68,29 @@ var feature: GeoJSON.Feature<GeoJSON.Polygon> = {
};
var point: GeoJSON.Point = {
let point: GeoJSON.Point = {
type: "Point",
coordinates: [100.0, 0.0]
};
// This type is commonly used in the turf package
var pointCoordinates: number[] = point.coordinates
let pointCoordinates: number[] = point.coordinates;
var lineString: GeoJSON.LineString = {
let lineString: GeoJSON.LineString = {
type: "LineString",
coordinates: [ [100.0, 0.0], [101.0, 1.0] ]
};
var polygon: GeoJSON.Polygon = {
let polygon: GeoJSON.Polygon = {
type: "Polygon",
coordinates: [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
]
};
var polygonWithHole: GeoJSON.Polygon = {
let polygonWithHole: GeoJSON.Polygon = {
type: "Polygon",
coordinates: [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
@@ -97,12 +98,12 @@ var polygonWithHole: GeoJSON.Polygon = {
]
};
var multiPoint: GeoJSON.MultiPoint = {
let multiPoint: GeoJSON.MultiPoint = {
type: "MultiPoint",
coordinates: [ [100.0, 0.0], [101.0, 1.0] ]
};
var multiLineString: GeoJSON.MultiLineString = {
let multiLineString: GeoJSON.MultiLineString = {
type: "MultiLineString",
coordinates: [
[ [100.0, 0.0], [101.0, 1.0] ],
@@ -110,25 +111,103 @@ var multiLineString: GeoJSON.MultiLineString = {
]
};
var multiPolygon: GeoJSON.MultiPolygon = {
let multiPolygon: GeoJSON.MultiPolygon = {
type: "MultiPolygon",
coordinates: [
[[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],
[[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
[[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
]
}
};
var geometryCollection: GeoJSON.GeometryCollection = {
let geometryCollection: GeoJSON.GeometryCollection = {
type: "GeometryCollection",
"geometries": [
{
{
type: "Point",
coordinates: [100.0, 0.0]
},
{
{
type: "LineString",
coordinates: [ [101.0, 0.0], [102.0, 1.0] ]
}
]
}
};
let feature: GeoJSON.Feature<GeometryObject> = {
type: "Feature",
geometry: lineString,
properties: null
};
feature = {
type: "Feature",
geometry: polygon,
properties: null
};
feature = {
type: "Feature",
geometry: polygonWithHole,
properties: null
};
feature = {
type: "Feature",
geometry: multiPoint,
properties: null
};
feature = {
type: "Feature",
geometry: multiLineString,
properties: null
};
feature = {
type: "Feature",
geometry: multiPolygon,
properties: null
};
feature = {
type: "Feature",
geometry: geometryCollection,
properties: null
};
featureCollection = {
type: "FeatureCollection",
features: [
{
type: "Feature",
geometry: lineString,
properties: {test: 'OK'}
}, {
type: "Feature",
geometry: polygon,
properties: {test: 'OK'}
}, {
type: "Feature",
geometry: polygonWithHole,
properties: {test: 'OK'}
}, {
type: "Feature",
geometry: multiPoint,
properties: {test: 'OK'}
}, {
type: "Feature",
geometry: multiLineString,
properties: {test: 'OK'}
}, {
type: "Feature",
geometry: multiPolygon,
properties: {test: 'OK'}
}, {
type: "Feature",
geometry: geometryCollection,
properties: {test: 'OK'}
}
],
crs: {
type: "link",
properties: {
href: "http://example.com/crs/42",
type: "proj4"
}
}
};
+40 -50
View File
@@ -1,4 +1,4 @@
// Type definitions for GeoJSON Format Specification
// Type definitions for GeoJSON Format Specification Revision 1.0
// Project: http://geojson.org/
// Definitions by: Jacob Bruun <https://github.com/cobster/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -8,8 +8,7 @@ declare namespace GeoJSON {
/***
* http://geojson.org/geojson-spec.html#geojson-objects
*/
export interface GeoJsonObject
{
export interface GeoJsonObject {
type: string;
bbox?: number[];
crs?: CoordinateReferenceSystem;
@@ -18,116 +17,107 @@ declare namespace GeoJSON {
/***
* http://geojson.org/geojson-spec.html#positions
*/
export type Position = number[]
export type Position = number[];
/***
* http://geojson.org/geojson-spec.html#geometry-objects
*/
export interface GeometryObject extends GeoJsonObject
{
coordinates: any
export interface DirectGeometryObject extends GeoJsonObject {
coordinates: Position[][][] | Position[][] | Position[] | Position;
}
/**
* GeometryObject supports geometry collection as well
*/
export type GeometryObject = DirectGeometryObject | GeometryCollection;
/***
* http://geojson.org/geojson-spec.html#point
*/
export interface Point extends GeometryObject
{
type: 'Point'
coordinates: Position
export interface Point extends DirectGeometryObject {
type: 'Point';
coordinates: Position;
}
/***
* http://geojson.org/geojson-spec.html#multipoint
*/
export interface MultiPoint extends GeometryObject
{
type: 'MultiPoint'
coordinates: Position[]
export interface MultiPoint extends DirectGeometryObject {
type: 'MultiPoint';
coordinates: Position[];
}
/***
* http://geojson.org/geojson-spec.html#linestring
*/
export interface LineString extends GeometryObject
{
type: 'LineString'
coordinates: Position[]
export interface LineString extends DirectGeometryObject {
type: 'LineString';
coordinates: Position[];
}
/***
* http://geojson.org/geojson-spec.html#multilinestring
*/
export interface MultiLineString extends GeometryObject
{
type: 'MultiLineString'
coordinates: Position[][]
export interface MultiLineString extends DirectGeometryObject {
type: 'MultiLineString';
coordinates: Position[][];
}
/***
* http://geojson.org/geojson-spec.html#polygon
*/
export interface Polygon extends GeometryObject
{
type: 'Polygon'
coordinates: Position[][]
export interface Polygon extends DirectGeometryObject {
type: 'Polygon';
coordinates: Position[][];
}
/***
* http://geojson.org/geojson-spec.html#multipolygon
*/
export interface MultiPolygon extends GeometryObject
{
type: 'MultiPolygon'
coordinates: Position[][][]
export interface MultiPolygon extends DirectGeometryObject {
type: 'MultiPolygon';
coordinates: Position[][][];
}
/***
* http://geojson.org/geojson-spec.html#geometry-collection
*/
export interface GeometryCollection extends GeoJsonObject
{
type: 'GeometryCollection'
export interface GeometryCollection extends GeoJsonObject {
type: 'GeometryCollection';
geometries: GeometryObject[];
}
/***
* http://geojson.org/geojson-spec.html#feature-objects
*/
export interface Feature<T extends GeometryObject> extends GeoJsonObject
{
type: 'Feature'
export interface Feature<T extends GeometryObject> extends GeoJsonObject {
type: 'Feature';
geometry: T;
properties: any;
properties: {} | null;
id?: string;
}
/***
* http://geojson.org/geojson-spec.html#feature-collection-objects
*/
export interface FeatureCollection<T extends GeometryObject> extends GeoJsonObject
{
type: 'FeatureCollection'
features: Feature<T>[];
export interface FeatureCollection<T extends GeometryObject> extends GeoJsonObject {
type: 'FeatureCollection';
features: Array<Feature<T>>;
}
/***
* http://geojson.org/geojson-spec.html#coordinate-reference-system-objects
*/
export interface CoordinateReferenceSystem
{
export interface CoordinateReferenceSystem {
type: string;
properties: any;
}
export interface NamedCoordinateReferenceSystem extends CoordinateReferenceSystem
{
properties: { name: string }
export interface NamedCoordinateReferenceSystem extends CoordinateReferenceSystem {
properties: { name: string };
}
export interface LinkedCoordinateReferenceSystem extends CoordinateReferenceSystem
{
properties: { href: string; type: string }
export interface LinkedCoordinateReferenceSystem extends CoordinateReferenceSystem {
properties: { href: string; type: string };
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+1372 -1329
View File
File diff suppressed because it is too large Load Diff
+30
View File
@@ -11,6 +11,14 @@ latLng = L.latLng({lat: 12, lng: 13, alt: 0});
latLng = L.latLng(latLngTuple);
latLng = L.latLng([12, 13, 0]);
latLng = new L.LatLng(12, 13);
latLng = new L.LatLng(12, 13, 0);
latLng = new L.LatLng(latLngLiteral);
latLng = new L.LatLng({lat: 12, lng: 13, alt: 0});
latLng = new L.LatLng(latLngTuple);
latLng = new L.LatLng([12, 13, 0]);
const latLngBoundsLiteral: L.LatLngBoundsLiteral = [[12, 13], latLngTuple];
let latLngBounds: L.LatLngBounds;
@@ -18,6 +26,10 @@ latLngBounds = L.latLngBounds(latLng, latLng);
latLngBounds = L.latLngBounds(latLngLiteral, latLngLiteral);
latLngBounds = L.latLngBounds(latLngTuple, latLngTuple);
latLngBounds = new L.LatLngBounds(latLng, latLng);
latLngBounds = new L.LatLngBounds(latLngLiteral, latLngLiteral);
latLngBounds = new L.LatLngBounds(latLngTuple, latLngTuple);
const pointTuple: L.PointTuple = [0, 0];
let point: L.Point;
@@ -26,6 +38,11 @@ point = L.point(12, 13, true);
point = L.point(pointTuple);
point = L.point({x: 12, y: 13});
point = new L.Point(12, 13);
point = new L.Point(12, 13, true);
point = new L.Point(pointTuple);
point = new L.Point({x: 12, y: 13});
let distance: number;
point.distanceTo(point);
point.distanceTo(pointTuple);
@@ -44,6 +61,11 @@ bounds = L.bounds(pointTuple, pointTuple);
bounds = L.bounds([point, point]);
bounds = L.bounds(boundsLiteral);
bounds = new L.Bounds(point, point);
bounds = new L.Bounds(pointTuple, pointTuple);
bounds = new L.Bounds([point, point]);
bounds = new L.Bounds(boundsLiteral);
let points: Array<L.Point>;
points = L.LineUtil.simplify([point, point], 1);
points = L.LineUtil.simplify([pointTuple, pointTuple], 2);
@@ -143,6 +165,10 @@ map = L.map('foo', mapOptions);
map = L.map(htmlElement);
map = L.map(htmlElement, mapOptions);
map = new L.Map('foo', mapOptions);
map = new L.Map(htmlElement);
map = new L.Map(htmlElement, mapOptions);
let doesItHaveLayer: boolean;
doesItHaveLayer = map.hasLayer(L.tileLayer(''));
@@ -230,6 +256,10 @@ tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png');
tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', tileLayerOptions);
tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}&{bar}&{abc}', {foo: 'bar', bar: (data: any) => 'foo', abc: () => ''});
tileLayer = new L.TileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png');
tileLayer = new L.TileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', tileLayerOptions);
tileLayer = new L.TileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}&{bar}&{abc}', {foo: 'bar', bar: (data: any) => 'foo', abc: () => ''});
let eventHandler = () => {};
let domEvent: Event = {} as Event;
L.DomEvent
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }