Truncate subs union

This commit is contained in:
vjrj 2018-02-12 17:23:01 +01:00
parent 5f329f5210
commit 47b55267df
3 changed files with 24 additions and 2 deletions

View file

@ -6,17 +6,21 @@
import { Map } from 'react-leaflet';
import LGeo from 'leaflet-geodesy';
import tunion from '@turf/union';
import ttrunc from '@turf/truncate';
import { check, Match } from 'meteor/check';
// https://stackoverflow.com/questions/35394577/leaflet-js-union-merge-circles
const truncOptions = { precision: 6, coordinates: 2 };
function unify(polyList) {
let unionTemp;
for (let i = 0; i < polyList.length; i += 1) {
const pol = polyList[i].toGeoJSON();
const cleanPol = ttrunc(pol, truncOptions);
if (i === 0) {
unionTemp = polyList[i].toGeoJSON();
unionTemp = cleanPol;
} else {
unionTemp = tunion(unionTemp, polyList[i].toGeoJSON());
unionTemp = tunion(unionTemp, cleanPol);
}
}
return unionTemp;

17
package-lock.json generated
View file

@ -25,6 +25,23 @@
"resolved": "https://registry.npmjs.org/@turf/helpers/-/helpers-5.1.5.tgz",
"integrity": "sha1-FTQFInq5M9AEpbuWQantmZ/L4M8="
},
"@turf/meta": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/@turf/meta/-/meta-5.2.0.tgz",
"integrity": "sha1-OxrUhe4MOwsXdRMqMsOE1T5LpT0=",
"requires": {
"@turf/helpers": "5.1.5"
}
},
"@turf/truncate": {
"version": "5.1.5",
"resolved": "https://registry.npmjs.org/@turf/truncate/-/truncate-5.1.5.tgz",
"integrity": "sha1-nu37Oxi6gfLJjT6tCUMcyhiErYk=",
"requires": {
"@turf/helpers": "5.1.5",
"@turf/meta": "5.2.0"
}
},
"@turf/union": {
"version": "5.1.5",
"resolved": "https://registry.npmjs.org/@turf/union/-/union-5.1.5.tgz",

View file

@ -8,6 +8,7 @@
"dependencies": {
"@cleverbeagle/dates": "^0.5.1",
"@cleverbeagle/seeder": "^1.3.1",
"@turf/truncate": "^5.1.5",
"@turf/union": "^5.1.5",
"babel-runtime": "^6.26.0",
"bcrypt": "^1.0.3",