@loaders.gl/mvt 3.4.13 → 3.4.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/helpers/binary-util-functions.js +21 -21
- package/dist/es5/helpers/binary-util-functions.js.map +1 -1
- package/dist/es5/helpers/mapbox-util-functions.js +11 -11
- package/dist/es5/helpers/mapbox-util-functions.js.map +1 -1
- package/dist/es5/index.js +3 -3
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +104 -127
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +1 -1
- package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js +13 -20
- package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js.map +1 -1
- package/dist/es5/lib/binary-vector-tile/vector-tile.js +7 -8
- package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +1 -1
- package/dist/es5/lib/geojson-tiler/clip.js +87 -144
- package/dist/es5/lib/geojson-tiler/clip.js.map +1 -1
- package/dist/es5/lib/geojson-tiler/convert.js +33 -72
- package/dist/es5/lib/geojson-tiler/convert.js.map +1 -1
- package/dist/es5/lib/geojson-tiler/feature.js +8 -29
- package/dist/es5/lib/geojson-tiler/feature.js.map +1 -1
- package/dist/es5/lib/geojson-tiler/geojson-tiler.js +114 -121
- package/dist/es5/lib/geojson-tiler/geojson-tiler.js.map +1 -1
- package/dist/es5/lib/geojson-tiler/simplify.js +14 -14
- package/dist/es5/lib/geojson-tiler/simplify.js.map +1 -1
- package/dist/es5/lib/geojson-tiler/tile.js +31 -43
- package/dist/es5/lib/geojson-tiler/tile.js.map +1 -1
- package/dist/es5/lib/geojson-tiler/transform.js +17 -29
- package/dist/es5/lib/geojson-tiler/transform.js.map +1 -1
- package/dist/es5/lib/geojson-tiler/wrap.js +25 -73
- package/dist/es5/lib/geojson-tiler/wrap.js.map +1 -1
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +131 -144
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -1
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js +13 -20
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -1
- package/dist/es5/lib/mapbox-vector-tile/vector-tile.js +7 -8
- package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -1
- package/dist/es5/lib/parse-mvt.js +38 -36
- package/dist/es5/lib/parse-mvt.js.map +1 -1
- package/dist/es5/mvt-loader.js +7 -27
- package/dist/es5/mvt-loader.js.map +1 -1
- package/dist/esm/mvt-loader.js +1 -1
- package/dist/mvt-worker.js +1 -1
- package/package.json +5 -5
|
@@ -6,13 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.convert = convert;
|
|
7
7
|
var _simplify = require("./simplify");
|
|
8
8
|
var _feature = require("./feature");
|
|
9
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
10
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
9
|
function convert(data, options) {
|
|
13
|
-
|
|
10
|
+
const features = [];
|
|
14
11
|
if (data.type === 'FeatureCollection') {
|
|
15
|
-
for (
|
|
12
|
+
for (let i = 0; i < data.features.length; i++) {
|
|
16
13
|
convertFeature(features, data.features[i], options, i);
|
|
17
14
|
}
|
|
18
15
|
} else if (data.type === 'Feature') {
|
|
@@ -28,11 +25,11 @@ function convertFeature(features, geojson, options, index) {
|
|
|
28
25
|
if (!geojson.geometry) {
|
|
29
26
|
return;
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
const coords = geojson.geometry.coordinates;
|
|
29
|
+
const type = geojson.geometry.type;
|
|
30
|
+
const tolerance = Math.pow(options.tolerance / ((1 << options.maxZoom) * options.extent), 2);
|
|
31
|
+
let geometry = [];
|
|
32
|
+
let id = geojson.id;
|
|
36
33
|
if (options.promoteId) {
|
|
37
34
|
id = geojson.properties[options.promoteId];
|
|
38
35
|
} else if (options.generateId) {
|
|
@@ -41,35 +38,17 @@ function convertFeature(features, geojson, options, index) {
|
|
|
41
38
|
if (type === 'Point') {
|
|
42
39
|
convertPoint(coords, geometry);
|
|
43
40
|
} else if (type === 'MultiPoint') {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
48
|
-
var p = _step.value;
|
|
49
|
-
convertPoint(p, geometry);
|
|
50
|
-
}
|
|
51
|
-
} catch (err) {
|
|
52
|
-
_iterator.e(err);
|
|
53
|
-
} finally {
|
|
54
|
-
_iterator.f();
|
|
41
|
+
for (const p of coords) {
|
|
42
|
+
convertPoint(p, geometry);
|
|
55
43
|
}
|
|
56
44
|
} else if (type === 'LineString') {
|
|
57
45
|
convertLine(coords, geometry, tolerance, false);
|
|
58
46
|
} else if (type === 'MultiLineString') {
|
|
59
47
|
if (options.lineMetrics) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var line = _step2.value;
|
|
65
|
-
geometry = [];
|
|
66
|
-
convertLine(line, geometry, tolerance, false);
|
|
67
|
-
features.push((0, _feature.createFeature)(id, 'LineString', geometry, geojson.properties));
|
|
68
|
-
}
|
|
69
|
-
} catch (err) {
|
|
70
|
-
_iterator2.e(err);
|
|
71
|
-
} finally {
|
|
72
|
-
_iterator2.f();
|
|
48
|
+
for (const line of coords) {
|
|
49
|
+
geometry = [];
|
|
50
|
+
convertLine(line, geometry, tolerance, false);
|
|
51
|
+
features.push((0, _feature.createFeature)(id, 'LineString', geometry, geojson.properties));
|
|
73
52
|
}
|
|
74
53
|
return;
|
|
75
54
|
} else {
|
|
@@ -78,36 +57,18 @@ function convertFeature(features, geojson, options, index) {
|
|
|
78
57
|
} else if (type === 'Polygon') {
|
|
79
58
|
convertLines(coords, geometry, tolerance, true);
|
|
80
59
|
} else if (type === 'MultiPolygon') {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
var polygon = _step3.value;
|
|
86
|
-
var newPolygon = [];
|
|
87
|
-
convertLines(polygon, newPolygon, tolerance, true);
|
|
88
|
-
geometry.push(newPolygon);
|
|
89
|
-
}
|
|
90
|
-
} catch (err) {
|
|
91
|
-
_iterator3.e(err);
|
|
92
|
-
} finally {
|
|
93
|
-
_iterator3.f();
|
|
60
|
+
for (const polygon of coords) {
|
|
61
|
+
const newPolygon = [];
|
|
62
|
+
convertLines(polygon, newPolygon, tolerance, true);
|
|
63
|
+
geometry.push(newPolygon);
|
|
94
64
|
}
|
|
95
65
|
} else if (type === 'GeometryCollection') {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
id: id,
|
|
103
|
-
geometry: singleGeometry,
|
|
104
|
-
properties: geojson.properties
|
|
105
|
-
}, options, index);
|
|
106
|
-
}
|
|
107
|
-
} catch (err) {
|
|
108
|
-
_iterator4.e(err);
|
|
109
|
-
} finally {
|
|
110
|
-
_iterator4.f();
|
|
66
|
+
for (const singleGeometry of geojson.geometry.geometries) {
|
|
67
|
+
convertFeature(features, {
|
|
68
|
+
id,
|
|
69
|
+
geometry: singleGeometry,
|
|
70
|
+
properties: geojson.properties
|
|
71
|
+
}, options, index);
|
|
111
72
|
}
|
|
112
73
|
return;
|
|
113
74
|
} else {
|
|
@@ -119,11 +80,11 @@ function convertPoint(coords, out) {
|
|
|
119
80
|
out.push(projectX(coords[0]), projectY(coords[1]), 0);
|
|
120
81
|
}
|
|
121
82
|
function convertLine(ring, out, tolerance, isPolygon) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
for (
|
|
125
|
-
|
|
126
|
-
|
|
83
|
+
let x0, y0;
|
|
84
|
+
let size = 0;
|
|
85
|
+
for (let j = 0; j < ring.length; j++) {
|
|
86
|
+
const x = projectX(ring[j][0]);
|
|
87
|
+
const y = projectY(ring[j][1]);
|
|
127
88
|
out.push(x, y, 0);
|
|
128
89
|
if (j > 0) {
|
|
129
90
|
if (isPolygon) {
|
|
@@ -135,7 +96,7 @@ function convertLine(ring, out, tolerance, isPolygon) {
|
|
|
135
96
|
x0 = x;
|
|
136
97
|
y0 = y;
|
|
137
98
|
}
|
|
138
|
-
|
|
99
|
+
const last = out.length - 3;
|
|
139
100
|
out[2] = 1;
|
|
140
101
|
(0, _simplify.simplify)(out, 0, last, tolerance);
|
|
141
102
|
out[last + 2] = 1;
|
|
@@ -144,8 +105,8 @@ function convertLine(ring, out, tolerance, isPolygon) {
|
|
|
144
105
|
out.end = out.size;
|
|
145
106
|
}
|
|
146
107
|
function convertLines(rings, out, tolerance, isPolygon) {
|
|
147
|
-
for (
|
|
148
|
-
|
|
108
|
+
for (let i = 0; i < rings.length; i++) {
|
|
109
|
+
const geom = [];
|
|
149
110
|
convertLine(rings[i], geom, tolerance, isPolygon);
|
|
150
111
|
out.push(geom);
|
|
151
112
|
}
|
|
@@ -154,8 +115,8 @@ function projectX(x) {
|
|
|
154
115
|
return x / 360 + 0.5;
|
|
155
116
|
}
|
|
156
117
|
function projectY(y) {
|
|
157
|
-
|
|
158
|
-
|
|
118
|
+
const sin = Math.sin(y * Math.PI / 180);
|
|
119
|
+
const y2 = 0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI;
|
|
159
120
|
return y2 < 0 ? 0 : y2 > 1 ? 1 : y2;
|
|
160
121
|
}
|
|
161
122
|
//# sourceMappingURL=convert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert.js","names":["_simplify","require","_feature","_createForOfIteratorHelper","o","allowArrayLike","it","Symbol","iterator","Array","isArray","_unsupportedIterableToArray","length","i","F","s","n","done","value","e","_e","f","TypeError","normalCompletion","didErr","err","call","step","next","_e2","return","minLen","_arrayLikeToArray","Object","prototype","toString","slice","constructor","name","from","test","arr","len","arr2","convert","data","options","features","type","convertFeature","geometry","geojson","index","coords","coordinates","tolerance","Math","pow","maxZoom","extent","id","promoteId","properties","generateId","convertPoint","_iterator","_step","p","convertLine","lineMetrics","_iterator2","_step2","line","push","createFeature","convertLines","_iterator3","_step3","polygon","newPolygon","_iterator4","geometries","_step4","singleGeometry","Error","out","projectX","projectY","ring","isPolygon","x0","y0","size","j","x","y","sqrt","last","simplify","abs","start","end","rings","geom","sin","PI","y2","log"],"sources":["../../../../src/lib/geojson-tiler/convert.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\n\n/* eslint-disable */\n// @ts-nocheck\n\nimport type {Feature} from '@loaders.gl/schema';\nimport type {GeoJSONTileFeature} from './tile';\n\nimport {simplify} from './simplify';\nimport {createFeature} from './feature';\n\n// converts GeoJSON feature into an intermediate projected JSON vector format with simplification data\n\nexport function convert(data: Feature, options): GeoJSONTileFeature[] {\n const features = [];\n if (data.type === 'FeatureCollection') {\n for (let i = 0; i < data.features.length; i++) {\n convertFeature(features, data.features[i], options, i);\n }\n } else if (data.type === 'Feature') {\n convertFeature(features, data, options);\n } else {\n // single geometry or a geometry collection\n convertFeature(features, {geometry: data}, options);\n }\n\n return features;\n}\n\nexport type ConvertFeatureOptions = {\n maxZoom?: number;\n tolerance: number;\n extent: number;\n lineMetrics: boolean;\n};\n\nfunction convertFeature(\n features: GeoJSONTileFeature[],\n geojson: Feature,\n options: ConvertFeatureOptions,\n index: number\n): void {\n if (!geojson.geometry) {\n return;\n }\n\n const coords = geojson.geometry.coordinates;\n const type = geojson.geometry.type;\n const tolerance = Math.pow(options.tolerance / ((1 << options.maxZoom) * options.extent), 2);\n let geometry = [];\n let id = geojson.id;\n if (options.promoteId) {\n id = geojson.properties[options.promoteId];\n } else if (options.generateId) {\n id = index || 0;\n }\n if (type === 'Point') {\n convertPoint(coords, geometry);\n } else if (type === 'MultiPoint') {\n for (const p of coords) {\n convertPoint(p, geometry);\n }\n } else if (type === 'LineString') {\n convertLine(coords, geometry, tolerance, false);\n } else if (type === 'MultiLineString') {\n if (options.lineMetrics) {\n // explode into linestrings to be able to track metrics\n for (const line of coords) {\n geometry = [];\n convertLine(line, geometry, tolerance, false);\n features.push(createFeature(id, 'LineString', geometry, geojson.properties));\n }\n return;\n } else {\n convertLines(coords, geometry, tolerance, false);\n }\n } else if (type === 'Polygon') {\n convertLines(coords, geometry, tolerance, true);\n } else if (type === 'MultiPolygon') {\n for (const polygon of coords) {\n const newPolygon = [];\n convertLines(polygon, newPolygon, tolerance, true);\n geometry.push(newPolygon);\n }\n } else if (type === 'GeometryCollection') {\n for (const singleGeometry of geojson.geometry.geometries) {\n convertFeature(\n features,\n {\n id,\n geometry: singleGeometry,\n properties: geojson.properties\n },\n options,\n index\n );\n }\n return;\n } else {\n throw new Error('Input data is not a valid GeoJSON object.');\n }\n\n features.push(createFeature(id, type, geometry, geojson.properties));\n}\n\nfunction convertPoint(coords, out): void {\n out.push(projectX(coords[0]), projectY(coords[1]), 0);\n}\n\nfunction convertLine(ring: number[], out, tolerance: number, isPolygon: boolean): void {\n let x0, y0;\n let size = 0;\n\n for (let j = 0; j < ring.length; j++) {\n const x = projectX(ring[j][0]);\n const y = projectY(ring[j][1]);\n\n out.push(x, y, 0);\n\n if (j > 0) {\n if (isPolygon) {\n size += (x0 * y - x * y0) / 2; // area\n } else {\n size += Math.sqrt(Math.pow(x - x0, 2) + Math.pow(y - y0, 2)); // length\n }\n }\n x0 = x;\n y0 = y;\n }\n\n const last = out.length - 3;\n out[2] = 1;\n simplify(out, 0, last, tolerance);\n out[last + 2] = 1;\n\n out.size = Math.abs(size);\n out.start = 0;\n out.end = out.size;\n}\n\nfunction convertLines(rings: number[][], out, tolerance: number, isPolygon: boolean): void {\n for (let i = 0; i < rings.length; i++) {\n const geom = [];\n convertLine(rings[i], geom, tolerance, isPolygon);\n out.push(geom);\n }\n}\n\nfunction projectX(x: number): number {\n return x / 360 + 0.5;\n}\n\nfunction projectY(y: number): number {\n const sin = Math.sin((y * Math.PI) / 180);\n const y2 = 0.5 - (0.25 * Math.log((1 + sin) / (1 - sin))) / Math.PI;\n return y2 < 0 ? 0 : y2 > 1 ? 1 : y2;\n}\n"],"mappings":";;;;;;AASA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAAwC,SAAAE,2BAAAC,CAAA,EAAAC,cAAA,QAAAC,EAAA,UAAAC,MAAA,oBAAAH,CAAA,CAAAG,MAAA,CAAAC,QAAA,KAAAJ,CAAA,qBAAAE,EAAA,QAAAG,KAAA,CAAAC,OAAA,CAAAN,CAAA,MAAAE,EAAA,GAAAK,2BAAA,CAAAP,CAAA,MAAAC,cAAA,I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K,CAAC1F,MAAM,EAAEC,CAAC,EAAE,EAAE;IACrC,IAAM0F,IAAI,GAAG,EAAE;IACfnC,WAAW,CAACkC,KAAK,CAACzF,CAAC,CAAC,EAAE0F,IAAI,EAAEhD,SAAS,EAAEkC,SAAS,CAAC;IACjDJ,GAAG,CAACZ,IAAI,CAAC8B,IAAI,CAAC;EAChB;AACF;AAEA,SAASjB,QAAQA,CAACQ,CAAS,EAAU;EACnC,OAAOA,CAAC,GAAG,GAAG,GAAG,GAAG;AACtB;AAEA,SAASP,QAAQA,CAACQ,CAAS,EAAU;EACnC,IAAMS,GAAG,GAAGhD,IAAI,CAACgD,GAAG,CAAET,CAAC,GAAGvC,IAAI,CAACiD,EAAE,GAAI,GAAG,CAAC;EACzC,IAAMC,EAAE,GAAG,GAAG,GAAI,IAAI,GAAGlD,IAAI,CAACmD,GAAG,CAAC,CAAC,CAAC,GAAGH,GAAG,KAAK,CAAC,GAAGA,GAAG,CAAC,CAAC,GAAIhD,IAAI,CAACiD,EAAE;EACnE,OAAOC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAGA,EAAE,GAAG,CAAC,GAAG,CAAC,GAAGA,EAAE;AACrC"}
|
|
1
|
+
{"version":3,"file":"convert.js","names":["_simplify","require","_feature","convert","data","options","features","type","i","length","convertFeature","geometry","geojson","index","coords","coordinates","tolerance","Math","pow","maxZoom","extent","id","promoteId","properties","generateId","convertPoint","p","convertLine","lineMetrics","line","push","createFeature","convertLines","polygon","newPolygon","singleGeometry","geometries","Error","out","projectX","projectY","ring","isPolygon","x0","y0","size","j","x","y","sqrt","last","simplify","abs","start","end","rings","geom","sin","PI","y2","log"],"sources":["../../../../src/lib/geojson-tiler/convert.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\n\n/* eslint-disable */\n// @ts-nocheck\n\nimport type {Feature} from '@loaders.gl/schema';\nimport type {GeoJSONTileFeature} from './tile';\n\nimport {simplify} from './simplify';\nimport {createFeature} from './feature';\n\n// converts GeoJSON feature into an intermediate projected JSON vector format with simplification data\n\nexport function convert(data: Feature, options): GeoJSONTileFeature[] {\n const features = [];\n if (data.type === 'FeatureCollection') {\n for (let i = 0; i < data.features.length; i++) {\n convertFeature(features, data.features[i], options, i);\n }\n } else if (data.type === 'Feature') {\n convertFeature(features, data, options);\n } else {\n // single geometry or a geometry collection\n convertFeature(features, {geometry: data}, options);\n }\n\n return features;\n}\n\nexport type ConvertFeatureOptions = {\n maxZoom?: number;\n tolerance: number;\n extent: number;\n lineMetrics: boolean;\n};\n\nfunction convertFeature(\n features: GeoJSONTileFeature[],\n geojson: Feature,\n options: ConvertFeatureOptions,\n index: number\n): void {\n if (!geojson.geometry) {\n return;\n }\n\n const coords = geojson.geometry.coordinates;\n const type = geojson.geometry.type;\n const tolerance = Math.pow(options.tolerance / ((1 << options.maxZoom) * options.extent), 2);\n let geometry = [];\n let id = geojson.id;\n if (options.promoteId) {\n id = geojson.properties[options.promoteId];\n } else if (options.generateId) {\n id = index || 0;\n }\n if (type === 'Point') {\n convertPoint(coords, geometry);\n } else if (type === 'MultiPoint') {\n for (const p of coords) {\n convertPoint(p, geometry);\n }\n } else if (type === 'LineString') {\n convertLine(coords, geometry, tolerance, false);\n } else if (type === 'MultiLineString') {\n if (options.lineMetrics) {\n // explode into linestrings to be able to track metrics\n for (const line of coords) {\n geometry = [];\n convertLine(line, geometry, tolerance, false);\n features.push(createFeature(id, 'LineString', geometry, geojson.properties));\n }\n return;\n } else {\n convertLines(coords, geometry, tolerance, false);\n }\n } else if (type === 'Polygon') {\n convertLines(coords, geometry, tolerance, true);\n } else if (type === 'MultiPolygon') {\n for (const polygon of coords) {\n const newPolygon = [];\n convertLines(polygon, newPolygon, tolerance, true);\n geometry.push(newPolygon);\n }\n } else if (type === 'GeometryCollection') {\n for (const singleGeometry of geojson.geometry.geometries) {\n convertFeature(\n features,\n {\n id,\n geometry: singleGeometry,\n properties: geojson.properties\n },\n options,\n index\n );\n }\n return;\n } else {\n throw new Error('Input data is not a valid GeoJSON object.');\n }\n\n features.push(createFeature(id, type, geometry, geojson.properties));\n}\n\nfunction convertPoint(coords, out): void {\n out.push(projectX(coords[0]), projectY(coords[1]), 0);\n}\n\nfunction convertLine(ring: number[], out, tolerance: number, isPolygon: boolean): void {\n let x0, y0;\n let size = 0;\n\n for (let j = 0; j < ring.length; j++) {\n const x = projectX(ring[j][0]);\n const y = projectY(ring[j][1]);\n\n out.push(x, y, 0);\n\n if (j > 0) {\n if (isPolygon) {\n size += (x0 * y - x * y0) / 2; // area\n } else {\n size += Math.sqrt(Math.pow(x - x0, 2) + Math.pow(y - y0, 2)); // length\n }\n }\n x0 = x;\n y0 = y;\n }\n\n const last = out.length - 3;\n out[2] = 1;\n simplify(out, 0, last, tolerance);\n out[last + 2] = 1;\n\n out.size = Math.abs(size);\n out.start = 0;\n out.end = out.size;\n}\n\nfunction convertLines(rings: number[][], out, tolerance: number, isPolygon: boolean): void {\n for (let i = 0; i < rings.length; i++) {\n const geom = [];\n convertLine(rings[i], geom, tolerance, isPolygon);\n out.push(geom);\n }\n}\n\nfunction projectX(x: number): number {\n return x / 360 + 0.5;\n}\n\nfunction projectY(y: number): number {\n const sin = Math.sin((y * Math.PI) / 180);\n const y2 = 0.5 - (0.25 * Math.log((1 + sin) / (1 - sin))) / Math.PI;\n return y2 < 0 ? 0 : y2 > 1 ? 1 : y2;\n}\n"],"mappings":";;;;;;AASA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAIO,SAASE,OAAOA,CAACC,IAAa,EAAEC,OAAO,EAAwB;EACpE,MAAMC,QAAQ,GAAG,EAAE;EACnB,IAAIF,IAAI,CAACG,IAAI,KAAK,mBAAmB,EAAE;IACrC,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,IAAI,CAACE,QAAQ,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;MAC7CE,cAAc,CAACJ,QAAQ,EAA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,GAAG,CAAC,CAAC,CAAC,GAAGH,GAAG,KAAK,CAAC,GAAGA,GAAG,CAAC,CAAC,GAAIxC,IAAI,CAACyC,EAAE;EACnE,OAAOC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAGA,EAAE,GAAG,CAAC,GAAG,CAAC,GAAGA,EAAE;AACrC"}
|
|
@@ -4,15 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createFeature = createFeature;
|
|
7
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
8
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
7
|
function createFeature(id, type, geom, tags) {
|
|
11
|
-
|
|
8
|
+
const feature = {
|
|
12
9
|
id: id == null ? null : id,
|
|
13
|
-
type
|
|
10
|
+
type,
|
|
14
11
|
geometry: geom,
|
|
15
|
-
tags
|
|
12
|
+
tags,
|
|
16
13
|
minX: Infinity,
|
|
17
14
|
minY: Infinity,
|
|
18
15
|
maxX: -Infinity,
|
|
@@ -23,36 +20,18 @@ function createFeature(id, type, geom, tags) {
|
|
|
23
20
|
} else if (type === 'Polygon') {
|
|
24
21
|
calcLineBBox(feature, geom[0]);
|
|
25
22
|
} else if (type === 'MultiLineString') {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
30
|
-
var line = _step.value;
|
|
31
|
-
calcLineBBox(feature, line);
|
|
32
|
-
}
|
|
33
|
-
} catch (err) {
|
|
34
|
-
_iterator.e(err);
|
|
35
|
-
} finally {
|
|
36
|
-
_iterator.f();
|
|
23
|
+
for (const line of geom) {
|
|
24
|
+
calcLineBBox(feature, line);
|
|
37
25
|
}
|
|
38
26
|
} else if (type === 'MultiPolygon') {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
43
|
-
var polygon = _step2.value;
|
|
44
|
-
calcLineBBox(feature, polygon[0]);
|
|
45
|
-
}
|
|
46
|
-
} catch (err) {
|
|
47
|
-
_iterator2.e(err);
|
|
48
|
-
} finally {
|
|
49
|
-
_iterator2.f();
|
|
27
|
+
for (const polygon of geom) {
|
|
28
|
+
calcLineBBox(feature, polygon[0]);
|
|
50
29
|
}
|
|
51
30
|
}
|
|
52
31
|
return feature;
|
|
53
32
|
}
|
|
54
33
|
function calcLineBBox(feature, geom) {
|
|
55
|
-
for (
|
|
34
|
+
for (let i = 0; i < geom.length; i += 3) {
|
|
56
35
|
feature.minX = Math.min(feature.minX, geom[i]);
|
|
57
36
|
feature.minY = Math.min(feature.minY, geom[i + 1]);
|
|
58
37
|
feature.maxX = Math.max(feature.maxX, geom[i]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.js","names":["createFeature","id","type","geom","tags","feature","geometry","minX","Infinity","minY","maxX","maxY","calcLineBBox","
|
|
1
|
+
{"version":3,"file":"feature.js","names":["createFeature","id","type","geom","tags","feature","geometry","minX","Infinity","minY","maxX","maxY","calcLineBBox","line","polygon","i","length","Math","min","max"],"sources":["../../../../src/lib/geojson-tiler/feature.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Forked from https://github.com/mapbox/geojson-vt under compatible ISC license\n\nimport {GeoJSONTileFeature} from './tile';\n\nexport function createFeature(id, type, geom, tags): GeoJSONTileFeature {\n const feature: GeoJSONTileFeature = {\n // eslint-disable-next-line\n id: id == null ? null : id,\n type,\n geometry: geom,\n tags,\n minX: Infinity,\n minY: Infinity,\n maxX: -Infinity,\n maxY: -Infinity\n };\n\n if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {\n calcLineBBox(feature, geom);\n } else if (type === 'Polygon') {\n // the outer ring (ie [0]) contains all inner rings\n calcLineBBox(feature, geom[0]);\n } else if (type === 'MultiLineString') {\n for (const line of geom) {\n calcLineBBox(feature, line);\n }\n } else if (type === 'MultiPolygon') {\n for (const polygon of geom) {\n // the outer ring (ie [0]) contains all inner rings\n calcLineBBox(feature, polygon[0]);\n }\n }\n\n return feature;\n}\n\nfunction calcLineBBox(feature, geom) {\n for (let i = 0; i < geom.length; i += 3) {\n feature.minX = Math.min(feature.minX, geom[i]);\n feature.minY = Math.min(feature.minY, geom[i + 1]);\n feature.maxX = Math.max(feature.maxX, geom[i]);\n feature.maxY = Math.max(feature.maxY, geom[i + 1]);\n }\n}\n"],"mappings":";;;;;;AAKO,SAASA,aAAaA,CAACC,EAAE,EAAEC,IAAI,EAAEC,IAAI,EAAEC,IAAI,EAAsB;EACtE,MAAMC,OAA2B,GAAG;IAElCJ,EAAE,EAAEA,EAAE,IAAI,IAAI,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,OAAO,CAACK,IAAI,EAAEP,IAAI,CAACY,CAAC,CAAC,CAAC;IAC9CV,OAAO,CAACM,IAAI,GAAGM,IAAI,CAACE,GAAG,CAACd,OAAO,CAACM,IAAI,EAAER,IAAI,CAACY,CAAC,GAAG,CAAC,CAAC,CAAC;EACpD;AACF"}
|
|
@@ -5,17 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.GeoJSONTiler = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
9
|
var _convert = require("./convert");
|
|
12
10
|
var _clip = require("./clip");
|
|
13
11
|
var _wrap = require("./wrap");
|
|
14
12
|
var _transform = require("./transform");
|
|
15
13
|
var _tile = require("./tile");
|
|
16
|
-
|
|
17
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
-
var DEFAULT_OPTIONS = {
|
|
14
|
+
const DEFAULT_OPTIONS = {
|
|
19
15
|
maxZoom: 14,
|
|
20
16
|
indexMaxZoom: 5,
|
|
21
17
|
indexMaxPoints: 100000,
|
|
@@ -27,17 +23,19 @@ var DEFAULT_OPTIONS = {
|
|
|
27
23
|
generateId: false,
|
|
28
24
|
debug: 0
|
|
29
25
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
(0, _classCallCheck2.default)(this, GeoJSONTiler);
|
|
26
|
+
class GeoJSONTiler {
|
|
27
|
+
constructor(data, options) {
|
|
33
28
|
(0, _defineProperty2.default)(this, "options", void 0);
|
|
34
29
|
(0, _defineProperty2.default)(this, "tiles", {});
|
|
35
30
|
(0, _defineProperty2.default)(this, "tileCoords", []);
|
|
36
31
|
(0, _defineProperty2.default)(this, "stats", {});
|
|
37
32
|
(0, _defineProperty2.default)(this, "total", 0);
|
|
38
|
-
this.options =
|
|
33
|
+
this.options = {
|
|
34
|
+
...DEFAULT_OPTIONS,
|
|
35
|
+
...options
|
|
36
|
+
};
|
|
39
37
|
options = this.options;
|
|
40
|
-
|
|
38
|
+
const debug = options.debug;
|
|
41
39
|
if (debug) console.time('preprocess data');
|
|
42
40
|
if (this.options.maxZoom < 0 || this.options.maxZoom > 24) {
|
|
43
41
|
throw new Error('maxZoom should be in the 0-24 range');
|
|
@@ -45,7 +43,7 @@ var GeoJSONTiler = function () {
|
|
|
45
43
|
if (options.promoteId && this.options.generateId) {
|
|
46
44
|
throw new Error('promoteId and generateId cannot be used together.');
|
|
47
45
|
}
|
|
48
|
-
|
|
46
|
+
let features = (0, _convert.convert)(data, options);
|
|
49
47
|
if (debug) {
|
|
50
48
|
console.timeEnd('preprocess data');
|
|
51
49
|
console.log('index: maxZoom: %d, maxPoints: %d', options.indexMaxZoom, options.indexMaxPoints);
|
|
@@ -63,122 +61,117 @@ var GeoJSONTiler = function () {
|
|
|
63
61
|
console.log('tiles generated:', this.total, JSON.stringify(this.stats));
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
|
-
(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
console.timeEnd('drilling down');
|
|
102
|
-
}
|
|
103
|
-
return this.tiles[id] ? (0, _transform.transformTile)(this.tiles[id], extent) : null;
|
|
64
|
+
getTile(z, x, y) {
|
|
65
|
+
const {
|
|
66
|
+
extent,
|
|
67
|
+
debug
|
|
68
|
+
} = this.options;
|
|
69
|
+
if (z < 0 || z > 24) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const z2 = 1 << z;
|
|
73
|
+
x = x + z2 & z2 - 1;
|
|
74
|
+
const id = toID(z, x, y);
|
|
75
|
+
if (this.tiles[id]) {
|
|
76
|
+
return (0, _transform.transformTile)(this.tiles[id], extent);
|
|
77
|
+
}
|
|
78
|
+
if (debug > 1) console.log('drilling down to z%d-%d-%d', z, x, y);
|
|
79
|
+
let z0 = z;
|
|
80
|
+
let x0 = x;
|
|
81
|
+
let y0 = y;
|
|
82
|
+
let parent;
|
|
83
|
+
while (!parent && z0 > 0) {
|
|
84
|
+
z0--;
|
|
85
|
+
x0 = x0 >> 1;
|
|
86
|
+
y0 = y0 >> 1;
|
|
87
|
+
parent = this.tiles[toID(z0, x0, y0)];
|
|
88
|
+
}
|
|
89
|
+
if (!parent || !parent.source) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
if (debug > 1) {
|
|
93
|
+
console.log('found parent tile z%d-%d-%d', z0, x0, y0);
|
|
94
|
+
console.time('drilling down');
|
|
95
|
+
}
|
|
96
|
+
this.splitTile(parent.source, z0, x0, y0, z, x, y);
|
|
97
|
+
if (debug > 1) {
|
|
98
|
+
console.timeEnd('drilling down');
|
|
104
99
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
100
|
+
return this.tiles[id] ? (0, _transform.transformTile)(this.tiles[id], extent) : null;
|
|
101
|
+
}
|
|
102
|
+
splitTile(features, z, x, y, cz, cx, cy) {
|
|
103
|
+
const stack = [features, z, x, y];
|
|
104
|
+
const options = this.options;
|
|
105
|
+
const debug = options.debug;
|
|
106
|
+
while (stack.length) {
|
|
107
|
+
y = stack.pop();
|
|
108
|
+
x = stack.pop();
|
|
109
|
+
z = stack.pop();
|
|
110
|
+
features = stack.pop();
|
|
111
|
+
const z2 = 1 << z;
|
|
112
|
+
const id = toID(z, x, y);
|
|
113
|
+
let tile = this.tiles[id];
|
|
114
|
+
if (!tile) {
|
|
115
|
+
if (debug > 1) {
|
|
116
|
+
console.time('creation');
|
|
117
|
+
}
|
|
118
|
+
tile = this.tiles[id] = (0, _tile.createTile)(features, z, x, y, options);
|
|
119
|
+
this.tileCoords.push({
|
|
120
|
+
z,
|
|
121
|
+
x,
|
|
122
|
+
y
|
|
123
|
+
});
|
|
124
|
+
if (debug) {
|
|
120
125
|
if (debug > 1) {
|
|
121
|
-
console.
|
|
122
|
-
|
|
123
|
-
tile = this.tiles[id] = (0, _tile.createTile)(features, z, x, y, options);
|
|
124
|
-
this.tileCoords.push({
|
|
125
|
-
z: z,
|
|
126
|
-
x: x,
|
|
127
|
-
y: y
|
|
128
|
-
});
|
|
129
|
-
if (debug) {
|
|
130
|
-
if (debug > 1) {
|
|
131
|
-
console.log('tile z%d-%d-%d (features: %d, points: %d, simplified: %d)', z, x, y, tile.numFeatures, tile.numPoints, tile.numSimplified);
|
|
132
|
-
console.timeEnd('creation');
|
|
133
|
-
}
|
|
134
|
-
var key = "z".concat(z);
|
|
135
|
-
this.stats[key] = (this.stats[key] || 0) + 1;
|
|
136
|
-
this.total++;
|
|
126
|
+
console.log('tile z%d-%d-%d (features: %d, points: %d, simplified: %d)', z, x, y, tile.numFeatures, tile.numPoints, tile.numSimplified);
|
|
127
|
+
console.timeEnd('creation');
|
|
137
128
|
}
|
|
129
|
+
const key = "z".concat(z);
|
|
130
|
+
this.stats[key] = (this.stats[key] || 0) + 1;
|
|
131
|
+
this.total++;
|
|
138
132
|
}
|
|
139
|
-
tile.source = features;
|
|
140
|
-
if (cz === undefined) {
|
|
141
|
-
if (z === options.indexMaxZoom || tile.numPoints <= options.indexMaxPoints) continue;
|
|
142
|
-
} else if (z === options.maxZoom || z === cz) {
|
|
143
|
-
continue;
|
|
144
|
-
} else if (cz !== undefined) {
|
|
145
|
-
var zoomSteps = cz - z;
|
|
146
|
-
if (x !== cx >> zoomSteps || y !== cy >> zoomSteps) continue;
|
|
147
|
-
}
|
|
148
|
-
tile.source = null;
|
|
149
|
-
if (features.length === 0) continue;
|
|
150
|
-
if (debug > 1) console.time('clipping');
|
|
151
|
-
var k1 = 0.5 * options.buffer / options.extent;
|
|
152
|
-
var k2 = 0.5 - k1;
|
|
153
|
-
var k3 = 0.5 + k1;
|
|
154
|
-
var k4 = 1 + k1;
|
|
155
|
-
var tl = null;
|
|
156
|
-
var bl = null;
|
|
157
|
-
var tr = null;
|
|
158
|
-
var br = null;
|
|
159
|
-
var left = (0, _clip.clip)(features, z2, x - k1, x + k3, 0, tile.minX, tile.maxX, options);
|
|
160
|
-
var right = (0, _clip.clip)(features, z2, x + k2, x + k4, 0, tile.minX, tile.maxX, options);
|
|
161
|
-
features = null;
|
|
162
|
-
if (left) {
|
|
163
|
-
tl = (0, _clip.clip)(left, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);
|
|
164
|
-
bl = (0, _clip.clip)(left, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);
|
|
165
|
-
left = null;
|
|
166
|
-
}
|
|
167
|
-
if (right) {
|
|
168
|
-
tr = (0, _clip.clip)(right, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);
|
|
169
|
-
br = (0, _clip.clip)(right, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);
|
|
170
|
-
right = null;
|
|
171
|
-
}
|
|
172
|
-
if (debug > 1) console.timeEnd('clipping');
|
|
173
|
-
stack.push(tl || [], z + 1, x * 2, y * 2);
|
|
174
|
-
stack.push(bl || [], z + 1, x * 2, y * 2 + 1);
|
|
175
|
-
stack.push(tr || [], z + 1, x * 2 + 1, y * 2);
|
|
176
|
-
stack.push(br || [], z + 1, x * 2 + 1, y * 2 + 1);
|
|
177
133
|
}
|
|
134
|
+
tile.source = features;
|
|
135
|
+
if (cz === undefined) {
|
|
136
|
+
if (z === options.indexMaxZoom || tile.numPoints <= options.indexMaxPoints) continue;
|
|
137
|
+
} else if (z === options.maxZoom || z === cz) {
|
|
138
|
+
continue;
|
|
139
|
+
} else if (cz !== undefined) {
|
|
140
|
+
const zoomSteps = cz - z;
|
|
141
|
+
if (x !== cx >> zoomSteps || y !== cy >> zoomSteps) continue;
|
|
142
|
+
}
|
|
143
|
+
tile.source = null;
|
|
144
|
+
if (features.length === 0) continue;
|
|
145
|
+
if (debug > 1) console.time('clipping');
|
|
146
|
+
const k1 = 0.5 * options.buffer / options.extent;
|
|
147
|
+
const k2 = 0.5 - k1;
|
|
148
|
+
const k3 = 0.5 + k1;
|
|
149
|
+
const k4 = 1 + k1;
|
|
150
|
+
let tl = null;
|
|
151
|
+
let bl = null;
|
|
152
|
+
let tr = null;
|
|
153
|
+
let br = null;
|
|
154
|
+
let left = (0, _clip.clip)(features, z2, x - k1, x + k3, 0, tile.minX, tile.maxX, options);
|
|
155
|
+
let right = (0, _clip.clip)(features, z2, x + k2, x + k4, 0, tile.minX, tile.maxX, options);
|
|
156
|
+
features = null;
|
|
157
|
+
if (left) {
|
|
158
|
+
tl = (0, _clip.clip)(left, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);
|
|
159
|
+
bl = (0, _clip.clip)(left, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);
|
|
160
|
+
left = null;
|
|
161
|
+
}
|
|
162
|
+
if (right) {
|
|
163
|
+
tr = (0, _clip.clip)(right, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);
|
|
164
|
+
br = (0, _clip.clip)(right, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);
|
|
165
|
+
right = null;
|
|
166
|
+
}
|
|
167
|
+
if (debug > 1) console.timeEnd('clipping');
|
|
168
|
+
stack.push(tl || [], z + 1, x * 2, y * 2);
|
|
169
|
+
stack.push(bl || [], z + 1, x * 2, y * 2 + 1);
|
|
170
|
+
stack.push(tr || [], z + 1, x * 2 + 1, y * 2);
|
|
171
|
+
stack.push(br || [], z + 1, x * 2 + 1, y * 2 + 1);
|
|
178
172
|
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
}();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
182
175
|
exports.GeoJSONTiler = GeoJSONTiler;
|
|
183
176
|
function toID(z, x, y) {
|
|
184
177
|
return ((1 << z) * y + x) * 32 + z;
|