Truncate subs union
This commit is contained in:
parent
5f329f5210
commit
47b55267df
3 changed files with 24 additions and 2 deletions
|
|
@ -6,17 +6,21 @@
|
||||||
import { Map } from 'react-leaflet';
|
import { Map } from 'react-leaflet';
|
||||||
import LGeo from 'leaflet-geodesy';
|
import LGeo from 'leaflet-geodesy';
|
||||||
import tunion from '@turf/union';
|
import tunion from '@turf/union';
|
||||||
|
import ttrunc from '@turf/truncate';
|
||||||
import { check, Match } from 'meteor/check';
|
import { check, Match } from 'meteor/check';
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/35394577/leaflet-js-union-merge-circles
|
// https://stackoverflow.com/questions/35394577/leaflet-js-union-merge-circles
|
||||||
|
const truncOptions = { precision: 6, coordinates: 2 };
|
||||||
|
|
||||||
function unify(polyList) {
|
function unify(polyList) {
|
||||||
let unionTemp;
|
let unionTemp;
|
||||||
for (let i = 0; i < polyList.length; i += 1) {
|
for (let i = 0; i < polyList.length; i += 1) {
|
||||||
|
const pol = polyList[i].toGeoJSON();
|
||||||
|
const cleanPol = ttrunc(pol, truncOptions);
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
unionTemp = polyList[i].toGeoJSON();
|
unionTemp = cleanPol;
|
||||||
} else {
|
} else {
|
||||||
unionTemp = tunion(unionTemp, polyList[i].toGeoJSON());
|
unionTemp = tunion(unionTemp, cleanPol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return unionTemp;
|
return unionTemp;
|
||||||
|
|
|
||||||
17
package-lock.json
generated
17
package-lock.json
generated
|
|
@ -25,6 +25,23 @@
|
||||||
"resolved": "https://registry.npmjs.org/@turf/helpers/-/helpers-5.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@turf/helpers/-/helpers-5.1.5.tgz",
|
||||||
"integrity": "sha1-FTQFInq5M9AEpbuWQantmZ/L4M8="
|
"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": {
|
"@turf/union": {
|
||||||
"version": "5.1.5",
|
"version": "5.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@turf/union/-/union-5.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@turf/union/-/union-5.1.5.tgz",
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cleverbeagle/dates": "^0.5.1",
|
"@cleverbeagle/dates": "^0.5.1",
|
||||||
"@cleverbeagle/seeder": "^1.3.1",
|
"@cleverbeagle/seeder": "^1.3.1",
|
||||||
|
"@turf/truncate": "^5.1.5",
|
||||||
"@turf/union": "^5.1.5",
|
"@turf/union": "^5.1.5",
|
||||||
"babel-runtime": "^6.26.0",
|
"babel-runtime": "^6.26.0",
|
||||||
"bcrypt": "^1.0.3",
|
"bcrypt": "^1.0.3",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue