From 2cd11040b32d1326b3775142c9f40457926cfb2f Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Thu, 21 Jan 2021 11:31:29 -0500 Subject: [PATCH] Swap out w8r/martinez clipper for mfogel/polygon-clipping This is a drop in replacement that performs better and yields more correct results see also https://github.com/ideditor/location-conflation/pull/20 --- docs/statistics.html | 85 +++++++++++++++++++-------------- modules/services/vector_tile.js | 6 +-- package.json | 2 +- 3 files changed, 54 insertions(+), 39 deletions(-) diff --git a/docs/statistics.html b/docs/statistics.html index c928779e8..6ad57df7c 100644 --- a/docs/statistics.html +++ b/docs/statistics.html @@ -1,12 +1,13 @@ + - - - - - RollUp Visualizer - - - -
- - + - + const chartNode = document.querySelector("main"); + drawChart(chartNode, data, width, height); + }; + + window.addEventListener('resize', run); + + document.addEventListener('DOMContentLoaded', run); + /*-->*/ + + + diff --git a/modules/services/vector_tile.js b/modules/services/vector_tile.js index 71e40a962..99454be99 100644 --- a/modules/services/vector_tile.js +++ b/modules/services/vector_tile.js @@ -3,7 +3,7 @@ import { dispatch as d3_dispatch } from 'd3-dispatch'; import deepEqual from 'fast-deep-equal'; import turf_bboxClip from '@turf/bbox-clip'; import stringify from 'fast-json-stable-stringify'; -import * as martinez from 'martinez-polygon-clipping'; +import polygonClipping from 'polygon-clipping'; import Protobuf from 'pbf'; import vt from '@mapbox/vector-tile'; @@ -66,13 +66,13 @@ function vtToGeoJSON(data, tile, mergeCache) { var merged = mergeCache[propertyhash]; if (merged && merged.length) { var other = merged[0]; - var coords = martinez.union( + var coords = polygonClipping.union( feature.geometry.coordinates, other.geometry.coordinates ); if (!coords || !coords.length) { - continue; // something failed in martinez union + continue; // something failed in polygon union } merged.push(feature); diff --git a/package.json b/package.json index 0239e3d1a..aee3f4d26 100644 --- a/package.json +++ b/package.json @@ -58,10 +58,10 @@ "fast-json-stable-stringify": "2.1.0", "lodash-es": "~4.17.15", "marked": "~1.2.3", - "martinez-polygon-clipping": "0.7.0", "node-diff3": "2.1.0", "osm-auth": "1.1.0", "pannellum": "2.5.6", + "polygon-clipping": "~0.15.1", "rbush": "3.0.1", "whatwg-fetch": "^3.4.1", "which-polygon": "2.2.0"