Skip to content

Commit

Permalink
Switch clipper to polyclip-ts
Browse files Browse the repository at this point in the history
(closes #67)

Also update node engine and ci to Node 18+
Node 16.x is end-of-life
  • Loading branch information
bhousel committed Sep 18, 2023
1 parent f70f21f commit ac53a24
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
node-version: [16.14, 18, 20]
node-version: [18, 20]

steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 3 additions & 3 deletions index.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as CountryCoder from '@rapideditor/country-coder';
import * as Polyclip from 'polyclip-ts';

import calcArea from '@mapbox/geojson-area';
import circleToPolygon from 'circle-to-polygon';
import polygonClipping from 'polygon-clipping';
import precision from 'geojson-precision';
import prettyStringify from '@aitodotai/json-stringify-pretty-compact';

Expand Down Expand Up @@ -345,11 +345,11 @@ export default class {
}


// Wrap the mfogel/polygon-clipping library and return a GeoJSON feature.
// Wrap the https://github.com/luizbarboza/polyclip-ts library and return a GeoJSON feature.
function _clip(features, which) {
if (!Array.isArray(features) || !features.length) return null;

const fn = { UNION: polygonClipping.union, DIFFERENCE: polygonClipping.difference }[which];
const fn = { UNION: Polyclip.union, DIFFERENCE: Polyclip.difference }[which];
const args = features.map(feature => feature.geometry.coordinates);
const coords = fn.apply(null, args);
return {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
"@rapideditor/country-coder": "^5.2.1",
"circle-to-polygon": "^2.2.0",
"geojson-precision": "^1.0.0",
"polygon-clipping": "~0.15.3"
"polyclip-ts": "~0.16.3"
},
"devDependencies": {
"c8": "^8.0.1",
"esbuild": "^0.19.2",
"eslint": "^8.48.0",
"esbuild": "^0.19.3",
"eslint": "^8.49.0",
"npm-run-all": "^4.1.5",
"shx": "^0.3.4",
"tap": "^16.3.8"
Expand All @@ -57,6 +57,6 @@
"access": "public"
},
"engines": {
"node": ">=16.14.0"
"node": ">=18"
}
}

0 comments on commit ac53a24

Please sign in to comment.