@loaders.gl/gis 3.1.0-alpha.4 → 3.1.0-beta.3
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/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +5 -0
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/index.js +6 -6
- package/dist/es5/lib/binary-to-geojson.js +93 -139
- package/dist/es5/lib/binary-to-geojson.js.map +1 -1
- package/dist/es5/lib/geojson-to-binary.js +196 -366
- package/dist/es5/lib/geojson-to-binary.js.map +1 -1
- package/dist/es5/lib/transform.js +9 -24
- package/dist/es5/lib/transform.js.map +1 -1
- package/dist/esm/lib/binary-to-geojson.js +2 -2
- package/dist/esm/lib/binary-to-geojson.js.map +1 -1
- package/dist/esm/lib/geojson-to-binary.js +1 -1
- package/dist/esm/lib/geojson-to-binary.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/lib/binary-to-geojson.d.ts +21 -0
- package/dist/lib/binary-to-geojson.d.ts.map +1 -0
- package/dist/lib/binary-to-geojson.js +233 -0
- package/dist/lib/geojson-to-binary.d.ts +39 -0
- package/dist/lib/geojson-to-binary.d.ts.map +1 -0
- package/dist/lib/geojson-to-binary.js +362 -0
- package/dist/lib/transform.d.ts +19 -0
- package/dist/lib/transform.d.ts.map +1 -0
- package/dist/lib/transform.js +59 -0
- package/package.json +5 -5
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformGeoJsonCoords = exports.transformBinaryCoords = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Apply transformation to every coordinate of binary features
|
|
6
|
+
* @param binaryFeatures binary features
|
|
7
|
+
* @param transformCoordinate Function to call on each coordinate
|
|
8
|
+
* @return Transformed binary features
|
|
9
|
+
*/
|
|
10
|
+
function transformBinaryCoords(binaryFeatures, transformCoordinate) {
|
|
11
|
+
if (binaryFeatures.points) {
|
|
12
|
+
transformBinaryGeometryPositions(binaryFeatures.points, transformCoordinate);
|
|
13
|
+
}
|
|
14
|
+
if (binaryFeatures.lines) {
|
|
15
|
+
transformBinaryGeometryPositions(binaryFeatures.lines, transformCoordinate);
|
|
16
|
+
}
|
|
17
|
+
if (binaryFeatures.polygons) {
|
|
18
|
+
transformBinaryGeometryPositions(binaryFeatures.polygons, transformCoordinate);
|
|
19
|
+
}
|
|
20
|
+
return binaryFeatures;
|
|
21
|
+
}
|
|
22
|
+
exports.transformBinaryCoords = transformBinaryCoords;
|
|
23
|
+
/** Transform one binary geometry */
|
|
24
|
+
function transformBinaryGeometryPositions(binaryGeometry, fn) {
|
|
25
|
+
const { positions } = binaryGeometry;
|
|
26
|
+
for (let i = 0; i < positions.value.length; i += positions.size) {
|
|
27
|
+
// @ts-ignore inclusion of bigint causes problems
|
|
28
|
+
const coord = Array.from(positions.value.subarray(i, i + positions.size));
|
|
29
|
+
const transformedCoord = fn(coord);
|
|
30
|
+
// @ts-ignore typescript typing for .set seems to require bigint?
|
|
31
|
+
positions.value.set(transformedCoord, i);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Apply transformation to every coordinate of GeoJSON features
|
|
36
|
+
*
|
|
37
|
+
* @param features Array of GeoJSON features
|
|
38
|
+
* @param fn Function to call on each coordinate
|
|
39
|
+
* @return Transformed GeoJSON features
|
|
40
|
+
*/
|
|
41
|
+
function transformGeoJsonCoords(features, fn) {
|
|
42
|
+
for (const feature of features) {
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
feature.geometry.coordinates = coordMap(feature.geometry.coordinates, fn);
|
|
45
|
+
}
|
|
46
|
+
return features;
|
|
47
|
+
}
|
|
48
|
+
exports.transformGeoJsonCoords = transformGeoJsonCoords;
|
|
49
|
+
function coordMap(array, fn) {
|
|
50
|
+
if (isCoord(array)) {
|
|
51
|
+
return fn(array);
|
|
52
|
+
}
|
|
53
|
+
return array.map((item) => {
|
|
54
|
+
return coordMap(item, fn);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function isCoord(array) {
|
|
58
|
+
return Number.isFinite(array[0]) && Number.isFinite(array[1]);
|
|
59
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/gis",
|
|
3
3
|
"description": "Helpers for GIS category data",
|
|
4
|
-
"version": "3.1.0-
|
|
4
|
+
"version": "3.1.0-beta.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"geometry",
|
|
15
15
|
"GeoJSON"
|
|
16
16
|
],
|
|
17
|
-
"types": "
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
18
|
"main": "dist/es5/index.js",
|
|
19
19
|
"module": "dist/esm/index.js",
|
|
20
20
|
"sideEffects": false,
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"README.md"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@loaders.gl/loader-utils": "3.1.0-
|
|
28
|
-
"@loaders.gl/schema": "3.1.0-
|
|
27
|
+
"@loaders.gl/loader-utils": "3.1.0-beta.3",
|
|
28
|
+
"@loaders.gl/schema": "3.1.0-beta.3",
|
|
29
29
|
"@mapbox/vector-tile": "^1.3.1",
|
|
30
30
|
"pbf": "^3.2.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@math.gl/proj4": "^3.5.1"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "3537c382b3ea4e092b24b6f94c3edee72076039c"
|
|
36
36
|
}
|