geogrid 0.0.1 → 0.0.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "geogrid",
3
- "version": "0.0.1",
4
- "description": "xxx",
3
+ "version": "0.0.4",
4
+ "description": "Regular and irregular geoJSON grids ",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
7
7
  "jsdelivr": "dist/index.min.js",
@@ -24,9 +24,10 @@
24
24
  "url": "git+https://github.com/neocarto/geogrid.git"
25
25
  },
26
26
  "keywords": [
27
- "xxx",
28
- "xxx",
29
- "d3xxx"
27
+ "grid",
28
+ "regular mesh",
29
+ "maps",
30
+ "geo"
30
31
  ],
31
32
  "author": "Nicolas Lambert",
32
33
  "license": "MIT",
@@ -35,16 +36,24 @@
35
36
  },
36
37
  "homepage": "https://github.com/neocarto/geogrid#readme",
37
38
  "dependencies": {
39
+ "@turf/area": "^7.2.0",
40
+ "@turf/bbox": "^7.2.0",
41
+ "@turf/boolean-intersects": "^7.2.0",
38
42
  "@turf/boolean-point-in-polygon": "^7.1.0",
43
+ "@turf/boolean-within": "^7.2.0",
39
44
  "@turf/helpers": "^7.1.0",
40
45
  "@turf/intersect": "^7.1.0",
46
+ "@turf/length": "^7.2.0",
47
+ "@turf/line-split": "^7.2.0",
41
48
  "d3-array": "^3.2.4",
42
49
  "d3-delaunay": "^6.0.4",
43
50
  "d3-geo": "^3.1.1",
51
+ "d3-geo-projection": "^4.0.0",
44
52
  "docs": "^0.3.2-canary.0",
45
53
  "documentation": "^14.0.3",
46
54
  "geojson2h3": "^1.2.0",
47
55
  "h3-js": "^4.1.0",
56
+ "rbush": "^4.0.1",
48
57
  "rollup": "^4.10.0"
49
58
  },
50
59
  "devDependencies": {
@@ -1,26 +1,49 @@
1
- import { range } from "d3-array";
2
- const d3 = Object.assign({}, { range });
1
+ import { createSteppedArray } from "../helpers/createSteppedArray.js";
3
2
 
4
3
  /**
5
- * @function make.diamond
6
- * @description The `make.diamond()` function allows to create a diamond geoJSON grid in SVG coordinates.
7
- * @property {number} [step = 50] - step of the grid
8
- * @property {number} [width = 1000] - width of the grid
9
- * @property {number} [height = 500] - height of the grid
4
+ * @function diamond
5
+ * @summary Compute a diamond grid.
6
+ * @description The `diamond()` function allows to create a diamond grid in SVG coordinates.
7
+ * @param {number} [step = 50] - Step of the grid.
8
+ * @param {array} [start = [0,0]] - Positioning coordinates [x,y].
9
+ * @param {number} [width = 1000] - Width of the grid
10
+ * @param {number} [height = 500] - Height of the grid
11
+ * @param {boolean} [overflow = true] - Depending on the step you choose, the grid may be smaller than the bounding box defined by with and height. With overflow = true, the grid is allowed to exceed the bounding box.
12
+ * @returns {object} - A GeoJSON FeatureCollection
13
+ * @example
14
+ * geogrid.diamond({step:30})
10
15
  */
11
- export function diamond({ step = 50, width = 1000, height = 500 } = {}) {
16
+ export function diamond({
17
+ start = [0, 0],
18
+ width = 1000,
19
+ height = 500,
20
+ step = 50,
21
+ overflow = true,
22
+ } = {}) {
12
23
  let size = step * Math.sqrt(2);
13
24
 
14
- // build grid
15
- let x = d3.range(0, width + size, size);
16
- let y = d3.range(0, height + size, size / 2).reverse();
25
+ let x0 = overflow ? start[0] : start[0] + size / 2;
26
+ let y0 = overflow ? start[1] : start[1] + size / 2;
27
+ let xend = start[0] + width + size / 2;
28
+ let yend = start[1] + height + size / 2;
29
+
30
+ let x = createSteppedArray(x0, xend, size);
31
+ let y = createSteppedArray(y0, yend, size / 2, false);
17
32
  let grid = x.map((x) => y.map((y, j) => [x, y, j % 2])).flat();
18
33
  grid = grid.map((d) => {
19
- return d[2] == 1 ? [d[0] + size / 2, d[1]] : [d[0], d[1]];
34
+ return d[2] === 1 ? [d[0] + size / 2, d[1]] : [d[0], d[1]];
20
35
  });
21
36
 
37
+ grid = overflow
38
+ ? grid.filter((d) => d[0] <= start[0] + width + size / 2)
39
+ : grid.filter((d) => d[0] <= start[0] + width - size / 2);
40
+
41
+ grid = overflow
42
+ ? grid.filter((d) => d[1] <= start[1] + height + size / 2)
43
+ : grid.filter((d) => d[1] <= start[1] + height - size / 2);
44
+
22
45
  let s = size / 2;
23
- // build object
46
+
24
47
  let result = grid.map((d, i) => {
25
48
  return {
26
49
  type: "Feature",
@@ -41,6 +64,7 @@ export function diamond({ step = 50, width = 1000, height = 500 } = {}) {
41
64
  },
42
65
  };
43
66
  });
67
+
44
68
  return {
45
69
  type: "FeatureCollection",
46
70
  grid: "diamond",
package/src/grid/dot.js CHANGED
@@ -1,17 +1,33 @@
1
- import { range } from "d3-array";
2
- const d3 = Object.assign({}, { range });
1
+ import { createSteppedArray } from "../helpers/createSteppedArray.js";
3
2
 
4
3
  /**
5
- * @function make.dot
6
- * @description The `make.dot()` function allows to create a geoJSON vith regular dots in SVG coordinates.
7
- * @property {number} [step = 50] - step of the grid
8
- * @property {number} [width = 1000] - width of the grid
9
- * @property {number} [height = 500] - height of the grid
4
+ * @function dot
5
+ * @summary Compute a dot grid.
6
+ * @description The `dot()` function allows to create a square grid in SVG coordinates.
7
+ * @param {number} [step = 50] - Step of the grid.
8
+ * @param {array} [start = [0,0]] - Positioning coordinates [x,y].
9
+ * @param {number} [width = 1000] - Width of the grid
10
+ * @param {number} [height = 500] - Height of the grid
11
+ * @param {boolean} [overflow = true] - Depending on the step you choose, the grid may be smaller than the bounding box defined by with and height. With overflow = true, the grid is allowed to exceed the bounding box.
12
+ * @returns {object} - A GeoJSON FeatureCollection
13
+ * @example
14
+ * geogrid.dot({step:30})
10
15
  */
11
- export function dot({ step = 30, width = 1000, height = 500 } = {}) {
16
+ export function dot({
17
+ step = 30,
18
+ start = [0, 0],
19
+ width = 1000,
20
+ height = 500,
21
+ overflow = true,
22
+ } = {}) {
12
23
  // build grid
13
- let y = d3.range(0 + step / 2, height, step).reverse();
14
- let x = d3.range(0 + step / 2, width, step);
24
+ let x0 = overflow ? start[0] - step / 2 : start[0];
25
+ let y0 = overflow ? start[1] - step / 2 : start[1];
26
+ let xend = overflow ? start[0] + width + step : start[0] + width;
27
+ let yend = overflow ? start[1] + height + step : start[1] + height;
28
+ let x = createSteppedArray(x0, xend, step);
29
+ let y = createSteppedArray(y0, yend, step, true);
30
+
15
31
  let grid = x.map((x) => y.map((y) => [x, y])).flat();
16
32
  let s = step / 2;
17
33
  // build object
package/src/grid/h3.js CHANGED
@@ -6,11 +6,11 @@ import {
6
6
  } from "h3-js";
7
7
 
8
8
  import { featureToH3Set, h3SetToFeatureCollection } from "geojson2h3";
9
- import { rewind as rrewind } from "../helpers/rewind";
9
+ import { rewind as rrewind } from "geotoolbox";
10
10
 
11
11
  /**
12
- * @function make.h3
13
- * @description The `make.h3()` function allows to create a hexbin geoJSON grid in geographical coordinates.
12
+ * @function h3
13
+ * @description The `h3()` function allows to create a hexbin geoJSON grid in geographical coordinates.
14
14
  * @property {number} [level = 0] - level of the grid. Form 0 (large hexagons) to 4 (small hexagons). See: https://h3geo.org
15
15
  * @property {object} [domain] - a geoJSON to define an extent
16
16
  * @property {boolen} [rewind] - to rewind the output
@@ -1,52 +1,79 @@
1
- import { range, max } from "d3-array";
2
- const d3 = Object.assign({}, { range, max });
3
-
1
+ import { createSteppedArray } from "../helpers/createSteppedArray.js";
4
2
  /**
5
- * @function make.hexbin
6
- * @description The `make.hexbin()` function allows to create a hexbin geoJSON grid in SVG coordinates.
7
- * @property {number} [step = 50] - step of the grid
8
- * @property {number} [width = 1000] - width of the grid
9
- * @property {number} [height = 500] - height of the grid
3
+ * @function hexbin
4
+ * @summary Compute a hexbin grid.
5
+ * @description The `hexbin()` function allows to create a hexbin grid in SVG coordinates.
6
+ * @param {number} [step = 50] - Step of the grid.
7
+ * @param {array} [start = [0,0]] - Positioning coordinates [x,y].
8
+ * @param {number} [width = 1000] - Width of the grid
9
+ * @param {number} [height = 500] - Height of the grid
10
+ * @param {boolean} [overflow = true] - Depending on the step you choose, the grid may be smaller than the bounding box defined by with and height. With overflow = true, the grid is allowed to exceed the bounding box.
11
+ * @returns {object} - A GeoJSON FeatureCollection
12
+ * @example
13
+ * geogrid.hexbin({step:30})
10
14
  */
11
- export function hexbin({ step = 50, width = 1000, height = 500 } = {}) {
12
- let w = step;
13
- let size = w / Math.sqrt(3);
14
- let h = 2 * size * (3 / 4);
15
-
16
- // build grid
17
- let y = d3.range(0, height + size, h).reverse();
18
- if (y.length % 2) {
19
- y.unshift(d3.max(y) + h);
20
- }
21
- let x = d3.range(0, width + size, w);
22
- let grid = x.map((x) => y.map((y) => [x, y])).flat();
23
- grid = grid.map((d, i) => {
24
- return i % 2 == 1 ? [d[0] + w / 2, d[1]] : d;
15
+ export function hexbin({
16
+ step = 50,
17
+ width = 1000,
18
+ height = 500,
19
+ start = [0, 0],
20
+ overflow = true,
21
+ } = {}) {
22
+ const w = step;
23
+ const size = w / Math.sqrt(3);
24
+ const h = size * 1.5;
25
+
26
+ const x0 = overflow ? start[0] - w / 2 : start[0];
27
+ //const x0 = start[0];
28
+ const y0 = overflow ? start[1] - size : start[1];
29
+
30
+ const yEnd = overflow ? height + y0 + size * 2 : height + y0 - size;
31
+ const y = createSteppedArray(y0 + size, yEnd, h);
32
+
33
+ const grid = [];
34
+
35
+ // Pour chaque ligne Y
36
+ y.forEach((yy, row) => {
37
+ const offset = (row % 2) * (w / 2);
38
+ let xEnd = overflow ? width + x0 : width + x0 - w - w / 2;
39
+
40
+ const x = createSteppedArray(x0 + offset + w / 2, xEnd, w);
41
+
42
+ x.forEach((xx) => {
43
+ if (xx <= width + x0) {
44
+ grid.push([xx, yy]);
45
+ }
46
+ });
47
+
48
+ if (x[x.length - 1] < width + x0) {
49
+ grid.push([x[x.length - 1] + w, yy]);
50
+ }
25
51
  });
26
- let s = step / 2;
27
- // build object
28
- let result = grid.map((d, i) => {
29
- let hex = [];
30
- for (let i = 0; i < 6; i++) {
31
- let ang = (Math.PI / 180) * (60 * i - 30);
32
- hex.push([d[0] + size * Math.cos(ang), d[1] + size * Math.sin(ang)]);
52
+
53
+ const features = grid.map(([cx, cy], i) => {
54
+ const hex = [];
55
+ for (let a = 0; a < 6; a++) {
56
+ const angle = (Math.PI / 180) * (60 * a - 30);
57
+ hex.push([cx + size * Math.cos(angle), cy + size * Math.sin(angle)]);
33
58
  }
59
+ hex.push(hex[0]);
34
60
 
35
61
  return {
36
62
  type: "Feature",
37
63
  geometry: {
38
64
  type: "Polygon",
39
- coordinates: [[hex[0], hex[1], hex[2], hex[3], hex[4], hex[5], hex[0]]],
65
+ coordinates: [hex],
40
66
  },
41
67
  properties: {
42
68
  index: i,
43
69
  },
44
70
  };
45
71
  });
72
+
46
73
  return {
47
74
  type: "FeatureCollection",
48
75
  grid: "hexbin",
49
76
  geo: false,
50
- features: result,
77
+ features: features,
51
78
  };
52
79
  }
@@ -2,25 +2,44 @@ import { Delaunay } from "d3-delaunay";
2
2
  const d3 = Object.assign({}, { Delaunay });
3
3
 
4
4
  /**
5
- * @function make.random
6
- * @description The `make.random()` function allows to create an arbitrary geoJSON grid in SVG coordinates.
7
- * @property {number} [step = 50] - step of the grid
8
- * @property {number} [width = 1000] - width of the grid
9
- * @property {number} [height = 500] - height of the grid
5
+ * @function hexbin
6
+ * @summary Compute a hexbin grid.
7
+ * @description The `hexbin()` function allows to create a hexbin grid in SVG coordinates.
8
+ * @param {number} [step = 50] - Step of the grid.
9
+ * @param {array} [start = [0,0]] - Positioning coordinates [x,y].
10
+ * @param {number} [width = 1000] - Width of the grid
11
+ * @param {number} [height = 500] - Height of the grid
12
+ * @param {boolean} [overflow = true] - Depending on the step you choose, the grid may be smaller than the bounding box defined by with and height. With overflow = true, the grid is allowed to exceed the bounding box.
13
+ * @returns {object} - A GeoJSON FeatureCollection
14
+ * @example
15
+ * geogrid.hexbin({step:30})
10
16
  */
11
17
 
12
- export function random({ step = 50, width = 1000, height = 500 } = {}) {
18
+ export function random({
19
+ start = [0, 0],
20
+ width = 1000,
21
+ height = 500,
22
+ step = 50,
23
+ overflow = false,
24
+ } = {}) {
25
+ let x0 = overflow ? start[0] - step : start[0];
26
+ let y0 = overflow ? start[1] - step : start[1];
27
+ let xend = overflow ? start[0] + width + step : x0 + width;
28
+ let yend = overflow ? start[1] + height + step : y0 + height;
29
+
30
+ let w = overflow ? width + step * 2 : width;
31
+ let h = overflow ? height + step * 2 : height;
13
32
  let grid = [];
14
33
  let nb = Math.round((width / step) * (height / step));
15
34
  for (let i = 0; i < nb; i++) {
16
- grid.push([Math.random() * width, Math.random() * height]);
35
+ grid.push([Math.random() * w + x0, Math.random() * h + y0]);
17
36
  }
18
37
 
19
38
  let voronoi = d3.Delaunay.from(
20
39
  grid,
21
40
  (d) => d[0],
22
41
  (d) => d[1]
23
- ).voronoi([0, 0, width, height]);
42
+ ).voronoi([x0, y0, xend, yend]);
24
43
 
25
44
  // build object
26
45
  let result = grid.map((d, i) => {
@@ -35,6 +54,8 @@ export function random({ step = 50, width = 1000, height = 500 } = {}) {
35
54
  },
36
55
  };
37
56
  });
57
+
58
+ // return result;
38
59
  return {
39
60
  type: "FeatureCollection",
40
61
  grid: "random",
@@ -1,17 +1,42 @@
1
- import { range } from "d3-array";
2
- const d3 = Object.assign({}, { range });
1
+ import { createSteppedArray } from "../helpers/createSteppedArray.js";
3
2
 
4
3
  /**
5
- * @function make.square
6
- * @description The `make.square()` function allows to create a square geoJSON grid in SVG coordinates.
7
- * @property {number} [step = 50] - step of the grid
8
- * @property {number} [width = 1000] - width of the grid
9
- * @property {number} [height = 500] - height of the grid
4
+ * @function square
5
+ * @summary Compute a square grid.
6
+ * @description The `square()` function allows to create a square grid in SVG coordinates.
7
+ * @param {number} [step = 50] - Step of the grid.
8
+ * @param {array} [start = [0,0]] - Positioning coordinates [x,y].
9
+ * @param {number} [width = 1000] - Width of the grid
10
+ * @param {number} [height = 500] - Height of the grid
11
+ * @param {boolean} [overflow = true] - Depending on the step you choose, the grid may be smaller than the bounding box defined by with and height. With overflow = true, the grid is allowed to exceed the bounding box.
12
+ * @returns {object} - A GeoJSON FeatureCollection
13
+ * @example
14
+ * geogrid.square({step:30})
10
15
  */
11
- export function square({ step = 50, width = 1000, height = 500 } = {}) {
16
+ export function square({
17
+ start = [0, 0],
18
+ width = 1000,
19
+ height = 500,
20
+ step = 50,
21
+ overflow = true,
22
+ } = {}) {
12
23
  // build grid
13
- let y = d3.range(0 + step / 2, height, step).reverse();
14
- let x = d3.range(0 + step / 2, width, step);
24
+
25
+ let x0 = overflow ? start[0] : start[0] + step / 2;
26
+ let y0 = overflow ? start[1] : start[1] + step / 2;
27
+
28
+ let y = createSteppedArray(y0, start[1] + height - step / 2, step, true);
29
+ let x = createSteppedArray(x0, start[0] + width - step / 2, step);
30
+
31
+ if (overflow) {
32
+ if (y[0] + step / 2 < start[1] + height) {
33
+ y.unshift(y[0] + step);
34
+ }
35
+ if (x.at(-1) + step / 2 < start[0] + width) {
36
+ x.push(x.at(-1) + step);
37
+ }
38
+ }
39
+
15
40
  let grid = x.map((x) => y.map((y) => [x, y])).flat();
16
41
 
17
42
  let s = step / 2;
@@ -1,14 +1,25 @@
1
- import { range, max } from "d3-array";
2
- const d3 = Object.assign({}, { range, max });
1
+ import { createSteppedArray } from "../helpers/createSteppedArray.js";
3
2
 
4
3
  /**
5
- * @function make.triangle
6
- * @description The `make.triangle()` function allows to create a triangle geoJSON grid in SVG coordinates.
7
- * @property {number} [step = 50] - step of the grid
8
- * @property {number} [width = 1000] - width of the grid
9
- * @property {number} [height = 500] - height of the grid
4
+ * @function triangle
5
+ * @summary Compute a triangle grid.
6
+ * @description The `triangle()` function allows to create a triangle grid in SVG coordinates.
7
+ * @param {number} [step = 50] - Step of the grid.
8
+ * @param {array} [start = [0,0]] - Positioning coordinates [x,y].
9
+ * @param {number} [width = 1000] - Width of the grid
10
+ * @param {number} [height = 500] - Height of the grid
11
+ * @param {boolean} [overflow = true] - Depending on the step you choose, the grid may be smaller than the bounding box defined by with and height. With overflow = true, the grid is allowed to exceed the bounding box.
12
+ * @returns {object} - A GeoJSON FeatureCollection
13
+ * @example
14
+ * geogrid.triangle({step:30})
10
15
  */
11
- export function triangle({ step = 50, width = 1000, height = 500 } = {}) {
16
+ export function triangle({
17
+ start = [0, 0],
18
+ width = 1000,
19
+ height = 500,
20
+ step = 50,
21
+ overflow = true,
22
+ } = {}) {
12
23
  let triangletop = (p, size) => {
13
24
  let h = (Math.sqrt(3) / 2) * size;
14
25
  let p1 = [p[0] + size / 2, p[1]];
@@ -29,12 +40,18 @@ export function triangle({ step = 50, width = 1000, height = 500 } = {}) {
29
40
  let h = (Math.sqrt(3) / 2) * step;
30
41
 
31
42
  // build grid
43
+ let x0 = overflow ? start[0] - step / 2 : start[0];
44
+ let y0 = overflow ? start[1] - h / 2 : start[1];
45
+ let xend = start[0] + width + h;
46
+ let yend = x0 + height + h;
47
+
48
+ let x = createSteppedArray(x0, xend, step);
49
+ let y = createSteppedArray(y0, yend, h, true);
32
50
 
33
- let y = d3.range(0, height + size, h).reverse();
34
51
  if (y.length % 2) {
35
- y.unshift(d3.max(y) + h);
52
+ y.unshift(y[0] + h);
36
53
  }
37
- let x = d3.range(0, width + size, step);
54
+
38
55
  let grid = x.map((x, i) => y.map((y) => [x, y])).flat();
39
56
  grid = grid.map((d, i) => {
40
57
  return i % 2 == 1 ? [d[0] + step / 2, d[1]] : d;
@@ -43,20 +60,71 @@ export function triangle({ step = 50, width = 1000, height = 500 } = {}) {
43
60
  let nb = grid.length;
44
61
  grid = grid.concat(grid);
45
62
 
46
- // build object
47
- let result = grid.map((d, i) => {
48
- return {
49
- type: "Feature",
50
- geometry: {
51
- type: "Polygon",
52
- coordinates:
53
- i < nb ? [triangletop(d, step)] : [trianglebottom(d, step)],
54
- },
55
- properties: {
56
- index: i,
57
- },
58
- };
63
+ // Build triangles
64
+ let triangles = [];
65
+ grid.forEach((d, i) => {
66
+ if (overflow) {
67
+ // triangle top
68
+ if (i < nb) {
69
+ if (
70
+ d[0] <= x0 + width + step &&
71
+ d[0] > x0 &&
72
+ d[1] >= y0 + step / 2 &&
73
+ d[1] <= start[1] + height + h
74
+ ) {
75
+ triangles.push(triangletop(d, step));
76
+ }
77
+ }
78
+ //triangle bottom
79
+ else {
80
+ if (
81
+ d[0] <= x0 + width + step &&
82
+ d[0] > x0 &&
83
+ d[1] <= start[1] + height
84
+ ) {
85
+ triangles.push(trianglebottom(d, step));
86
+ }
87
+ }
88
+ } else {
89
+ // triangle top
90
+ if (i < nb) {
91
+ if (
92
+ d[0] <= x0 + width - step / 2 &&
93
+ d[0] > x0 &&
94
+ d[1] <= y0 + height &&
95
+ d[1] > y0
96
+ ) {
97
+ triangles.push(triangletop(d, step));
98
+ }
99
+ }
100
+ //triangle bottom
101
+ else {
102
+ if (
103
+ d[0] <= x0 + width - step / 2 &&
104
+ d[0] > x0 &&
105
+ d[1] <= y0 + height - h
106
+ ) {
107
+ triangles.push(trianglebottom(d, step));
108
+ }
109
+ }
110
+ }
59
111
  });
112
+
113
+ // Build geojson
114
+
115
+ let result = triangles.map((d, i) => ({
116
+ type: "Feature",
117
+ geometry: {
118
+ type: "Polygon",
119
+ //coordinates: d
120
+ coordinates: [d],
121
+ },
122
+ properties: {
123
+ index: i,
124
+ coords: d,
125
+ },
126
+ }));
127
+
60
128
  return {
61
129
  type: "FeatureCollection",
62
130
  grid: "triangle",
@@ -0,0 +1,7 @@
1
+ export function createSteppedArray(start, max, step, reverse = false) {
2
+ const result = [];
3
+ for (let i = start; i <= max; i += step) {
4
+ result.push(i);
5
+ }
6
+ return reverse ? result.reverse() : result;
7
+ }
@@ -0,0 +1,14 @@
1
+ import { geoProject } from "d3-geo-projection";
2
+ const d3 = Object.assign({}, { geoProject });
3
+
4
+ /**
5
+ * @function project
6
+ * @description The function `project` use geoproject from d3-geo-projection to project a geoJSON. It returns a GeoJSON FeatureCollection with coordinates in the page map.
7
+ * @property {object} data - a GeoJSON FeatureCollection
8
+ * @property {function} options.projection - projection definition. See [d3-geo](https://github.com/d3/d3-geo) & [d3-geo-projection](https://github.com/d3/d3-geo-projection)
9
+ * @example
10
+ * let newGeoJSON = project(world, { projection: d3.geoOrthographic()})
11
+ */
12
+ export function project(data, { projection = null } = {}) {
13
+ return projection == null ? data : d3.geoProject(data, projection);
14
+ }
package/src/index.js CHANGED
@@ -1,21 +1,11 @@
1
- import { square } from "./grid/square.js";
2
- import { triangle } from "./grid/triangle.js";
3
- import { dot } from "./grid/dot.js";
4
- import { random } from "./grid/random.js";
5
- import { diamond } from "./grid/diamond.js";
6
- import { hexbin } from "./grid/hexbin.js";
7
- import { h3 } from "./grid/h3.js";
8
-
9
- export let make = {
10
- square,
11
- triangle,
12
- dot,
13
- diamond,
14
- random,
15
- hexbin,
16
- h3,
17
- };
18
-
19
- import { pointstogrid } from "./operator/pointstogrid.js";
20
- import { polygonstogrid } from "./operator/polygonstogrid.js";
21
- export let op = { pointstogrid, polygonstogrid };
1
+ // export { square } from "./grid/square.js";
2
+ // export { triangle } from "./grid/triangle.js";
3
+ // export { dot } from "./grid/dot.js";
4
+ //export { random } from "./grid/random.js";
5
+ // export { diamond } from "./grid/diamond.js";
6
+ export { hexbin } from "./grid/hexbin.js";
7
+ // export { h3 } from "./grid/h3.js";
8
+ export { pointstogrid } from "./operator/pointstogrid.js";
9
+ // export { polygonstogrid } from "./operator/polygonstogrid.js";
10
+ // export { linestogrid } from "./operator/linestogrid.js";
11
+ // export { project } from "./helpers/project.js";