Skip to content

Commit

Permalink
upgrade tooling
Browse files Browse the repository at this point in the history
  • Loading branch information
Fil committed Jun 9, 2024
1 parent 58506d8 commit bdc6ba0
Show file tree
Hide file tree
Showing 50 changed files with 1,577 additions and 1,490 deletions.
6 changes: 1 addition & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
"sourceType": "module",
"ecmaVersion": 8
},
"env": {
"es6": true
},
"rules": {
"no-cond-assign": 0,
"no-constant-condition": 0,
"no-floating-decimal": 2
"no-constant-condition": 0
}
}
18 changes: 18 additions & 0 deletions .github/eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "eslint-compact",
"pattern": [
{
"regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5,
"code": 6
}
]
}
]
}
30 changes: 30 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn --frozen-lockfile
- run: |
echo ::add-matcher::.github/eslint.json
yarn run eslint src test --format=compact
- run: yarn test
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.sublime-workspace
.DS_Store
dist/
test/output/
node_modules
npm-debug.log
5 changes: 1 addition & 4 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2017 Mike Bostock
Copyright 2017-2024 Mike Bostock

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
Expand All @@ -12,8 +12,6 @@ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.



Philippe Rivière’s implementation of the Gray-Fuller raw projection (grayfuller.js)
belongs to the public domain.

Expand All @@ -26,4 +24,3 @@ belongs to the public domain.
>
> To the extent possible under law, Philippe Rivière has waived all copyright
> and related or neighboring rights to this implementation. (Public Domain.)

109 changes: 59 additions & 50 deletions README.md

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions d3-geo-polygon.sublime-project

This file was deleted.

Binary file removed img/airocean.png
Binary file not shown.
Binary file removed img/cahillKeyes.png
Binary file not shown.
Binary file removed img/complexLog.png
Binary file not shown.
Binary file removed img/cox.png
Binary file not shown.
Binary file removed img/cubic.png
Binary file not shown.
Binary file removed img/dodecahedral.png
Binary file not shown.
Binary file removed img/icosahedral.png
Binary file not shown.
Binary file removed img/imago.png
Binary file not shown.
Binary file removed img/polyhedralButterfly.png
Binary file not shown.
Binary file removed img/polyhedralCollignon.png
Binary file not shown.
Binary file removed img/polyhedralWaterman.png
Binary file not shown.
Binary file removed img/tetrahedralLee.png
Binary file not shown.
Binary file removed img/tetrahedralLeeSouth.png
Binary file not shown.
53 changes: 31 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
"name": "d3-geo-polygon",
"version": "1.12.1",
"description": "Clipping and geometric operations for spherical polygons.",
"homepage": "https://github.com/d3/d3-geo-polygon",
"repository": {
"type": "git",
"url": "https://github.com/d3/d3-geo-polygon.git"
},
"keywords": [
"d3",
"d3-module",
"cartography",
"projection",
"polygon"
],
"homepage": "https://github.com/d3/d3-geo-polygon",
"license": "ISC",
"author": {
"name": "Mike Bostock",
Expand All @@ -25,35 +29,40 @@
"url": "https://visionscarto.net"
}
],
"main": "dist/d3-geo-polygon.js",
"unpkg": "dist/d3-geo-polygon.min.js",
"jsdelivr": "dist/d3-geo-polygon.min.js",
"type": "module",
"files": [
"dist/**/*.js",
"src/**/*.js"
],
"module": "src/index.js",
"repository": {
"type": "git",
"url": "https://github.com/d3/d3-geo-polygon.git"
},
"scripts": {
"pretest": "rollup -c",
"test": "tape 'test/**/*-test.js' && eslint src",
"prepublishOnly": "rm -rf dist && yarn test && mkdir -p test/output && test/compare-images",
"postpublish": "git push && git push --tags && zip -j dist/d3-geo-polygon.zip -- LICENSE README.md dist/d3-geo-polygon.js dist/d3-geo-polygon.min.js"
"main": "src/index.js",
"jsdelivr": "dist/d3-geo-polygon.min.js",
"unpkg": "dist/d3-geo-polygon.min.js",
"exports": {
"umd": "./dist/d3-geo-polygon.min.js",
"default": "./src/index.js"
},
"sideEffects": false,
"dependencies": {
"d3-array": "1 - 2",
"d3-geo": "1.12.0 - 2"
"d3-array": "2.5.0 - 3",
"d3-geo": "2 - 3"
},
"sideEffects": false,
"devDependencies": {
"canvas": "1 - 2",
"eslint": "5",
"rollup": "0.64",
"rollup-plugin-terser": "1",
"tape": "4",
"@rollup/plugin-terser": "0.4",
"canvas": "2",
"eslint": "8",
"mocha": "10",
"pixelmatch": "5",
"pngjs": "6",
"rollup": "3",
"topojson-client": "3",
"world-atlas": "1"
},
"scripts": {
"test": "mocha 'test/**/*-test.js' && eslint src test",
"prepublishOnly": "rm -rf dist && rollup -c"
},
"engines": {
"node": ">=6.0.0"
"node": ">=12"
}
}
39 changes: 27 additions & 12 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
import {terser} from "rollup-plugin-terser";
import * as meta from "./package.json";
import { readFileSync } from "fs";
import terser from "@rollup/plugin-terser";
import meta from "./package.json" assert { type: "json" };

// Extract copyrights from the LICENSE.
const copyright = readFileSync("./LICENSE", "utf-8")
.split(/\n/g)
.filter((line) => /^Copyright\s+/.test(line))
.map((line) => line.replace(/^Copyright\s+/, ""))
.join(", ");

const config = {
input: "src/index.js",
external: Object.keys(meta.dependencies || {}).filter(key => /^d3-/.test(key)),
external: Object.keys(meta.dependencies || {}).filter((key) =>
/^d3-/.test(key)
),
output: {
file: `dist/${meta.name}.js`,
name: "d3",
format: "umd",
indent: false,
extend: true,
banner: `// ${meta.homepage} v${meta.version} Copyright ${(new Date).getFullYear()} ${meta.author.name}`,
globals: Object.assign({}, ...Object.keys(meta.dependencies || {}).filter(key => /^d3-/.test(key)).map(key => ({[key]: "d3"})))
banner: `// ${meta.homepage} v${meta.version} Copyright ${copyright}`,
globals: Object.assign(
{},
...Object.keys(meta.dependencies || {})
.filter((key) => /^d3-/.test(key))
.map((key) => ({ [key]: "d3" }))
),
},
plugins: []
plugins: [],
};

export default [
Expand All @@ -22,15 +37,15 @@ export default [
...config,
output: {
...config.output,
file: `dist/${meta.name}.min.js`
file: `dist/${meta.name}.min.js`,
},
plugins: [
...config.plugins,
terser({
output: {
preamble: config.output.banner
}
})
]
}
preamble: config.output.banner,
},
}),
],
},
];
43 changes: 21 additions & 22 deletions src/imago.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import {
sign,
sin,
sqrt,
tan
} from "./math";
tan,
} from "./math.js";
import { geoProjectionMutator as projectionMutator } from "d3-geo";
import { default as clipPolygon } from "./clip/polygon.js";
import { solve } from "./newton.js";
Expand All @@ -33,20 +33,20 @@ var ASIN_ONE_THD = asin(1 / 3),
[halfPi, 0, 0, -halfPi, 0, sqrt(3)],
[-ASIN_ONE_THD, 0, pi, halfPi, 0, -sqrt(3)],
[-ASIN_ONE_THD, (2 * pi) / 3, pi, (5 * pi) / 6, 3, 0],
[-ASIN_ONE_THD, (-2 * pi) / 3, pi, pi / 6, -3, 0]
[-ASIN_ONE_THD, (-2 * pi) / 3, pi, pi / 6, -3, 0],
],
TETRAHEDRON_WIDE_VERTEX = {
sphereSym: 3,
planarSym: 6,
width: 6,
height: 2 * sqrt(3),
centrums,
rotateOOB: function(x, y, xCen, yCen) {
rotateOOB: function (x, y, xCen, yCen) {
yCen * 0;
if (abs(x) > this.width / 2) return [2 * xCen - x, -y];
else return [-x, this.height * sign(y) - y];
},
inBounds: () => true
inBounds: () => true,
},
configuration = TETRAHEDRON_WIDE_VERTEX;

Expand All @@ -60,7 +60,7 @@ export function imagoRaw(k) {

function faceInverse(r, th) {
const l = solve(
l => atan(((l - asin(sin(l) / sqrt(3))) / pi) * sqrt(12)),
(l) => atan(((l - asin(sin(l) / sqrt(3))) / pi) * sqrt(12)),
th,
th / 2
),
Expand Down Expand Up @@ -221,7 +221,7 @@ export function imagoBlock() {
m = projectionMutator(imagoRaw),
p = m(k);

p.k = function(_) {
p.k = function (_) {
return arguments.length ? m((k = +_)) : k;
};

Expand All @@ -232,14 +232,16 @@ export function imagoBlock() {
[180 - epsilon, a + epsilon],
[180 - epsilon, a - epsilon],
[-180 + epsilon, a - epsilon],
[-180 + epsilon, a + epsilon]
[-180 + epsilon, a + epsilon],
];

return p
.preclip(clipPolygon({
type: "Polygon",
coordinates: [border]
}))
.preclip(
clipPolygon({
type: "Polygon",
coordinates: [border],
})
)
.scale(144.04)
.rotate([18, -12.5, 3.5])
.center([0, 35.2644]);
Expand Down Expand Up @@ -283,16 +285,16 @@ function imagoWideRaw(k, shift) {
return forward;
}

export default function() {
export default function () {
var k = 0.59,
shift = 1.16,
m = projectionMutator(imagoWideRaw),
p = m(k, shift);

p.shift = function(_) {
p.shift = function (_) {
return arguments.length ? clipped(m(k, (shift = +_))) : shift;
};
p.k = function(_) {
p.k = function (_) {
return arguments.length ? clipped(m((k = +_), shift)) : k;
};

Expand All @@ -305,21 +307,18 @@ export default function() {
center = p.center(),
translate = p.translate(),
rotate = p.rotate();
p.scale(1)
.center([0, 90])
.rotate([0, 0])
.translate([shift, 0]);
p.scale(1).center([0, 90]).rotate([0, 0]).translate([shift, 0]);
for (let i = N - epsilon; i > 0; i--) {
border.unshift(
p.invert([
1.5 * configuration.height - e,
((configuration.width / 2) * i) / N
((configuration.width / 2) * i) / N,
])
);
border.push(
p.invert([
-0.5 * configuration.height + e,
((configuration.width / 2) * i) / N
((configuration.width / 2) * i) / N,
])
);
}
Expand All @@ -333,7 +332,7 @@ export default function() {
.preclip(
clipPolygon({
type: "Polygon",
coordinates: [border]
coordinates: [border],
})
);
}
Expand Down
Loading

0 comments on commit bdc6ba0

Please sign in to comment.