w-gis 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +1 -1
  2. package/dist/w-gis.umd.js +2 -2
  3. package/dist/w-gis.umd.js.map +1 -1
  4. package/docs/-_class.mjs.html +1 -1
  5. package/docs/convertCoordinate.mjs.html +1 -1
  6. package/docs/examples/ex-getCenterOfMassMultiPolygon.html +1 -1
  7. package/docs/examples/ex-getCentroidMultiPolygon.html +1 -1
  8. package/docs/index.html +1 -1
  9. package/docs/w-gis.html +1 -1
  10. package/g-getCenterOfMassMultiPolygon.mjs +3 -3
  11. package/g-getCentroidMultiPolygon.mjs +3 -3
  12. package/package.json +2 -1
  13. package/src/WGis.mjs +18 -585
  14. package/src/{convertTurfCode.mjs → _convertTurfCode.mjs} +5 -5
  15. package/src/{importTurfBrowser.mjs → _importTurfBrowser.mjs} +1 -4
  16. package/src/{importTurfNode.mjs → _importTurfNode.mjs} +0 -0
  17. package/src/_turfCoreBrowser.mjs +1 -0
  18. package/src/calcContours.mjs +267 -0
  19. package/src/clipMultiPolygon.mjs +15 -0
  20. package/src/distilMultiPolygon.mjs +30 -0
  21. package/src/fixGeometryMultiPolygon.mjs +52 -0
  22. package/src/getArea.mjs +20 -0
  23. package/src/getCenterOfMassMultiPolygon.mjs +24 -0
  24. package/src/getCentroidMultiPolygon.mjs +24 -0
  25. package/src/getTurf.mjs +32 -0
  26. package/src/intersectMultiPolygon.mjs +21 -0
  27. package/src/invCoordMultiPolygon.mjs +22 -0
  28. package/src/invCoordPolygon.mjs +24 -0
  29. package/src/isPointInPolygon.mjs +21 -0
  30. package/src/maskMultiPolygon.mjs +21 -0
  31. package/src/parseGeometryCollection.mjs +27 -0
  32. package/src/simplifyMultiPolygon.mjs +41 -0
  33. package/src/splineMultiPolygon.mjs +38 -0
  34. package/src/toMultiPolygon.mjs +49 -0
  35. package/toolg/gPackageIndex.mjs +46 -0
  36. package/src/importTurfBrowser.json +0 -1
@@ -0,0 +1,267 @@
1
+ import each from 'lodash/each'
2
+ import map from 'lodash/map'
3
+ import min from 'lodash/min'
4
+ import max from 'lodash/max'
5
+ import get from 'lodash/get'
6
+ import size from 'lodash/size'
7
+ import isearr from 'wsemi/src/isearr.mjs'
8
+ import { tricontour } from 'd3-tricontour'
9
+ import getArea from './getArea.mjs'
10
+ import getCentroidMultiPolygon from './getCentroidMultiPolygon.mjs'
11
+ import clipMultiPolygon from './clipMultiPolygon.mjs'
12
+ import intersectMultiPolygon from './intersectMultiPolygon.mjs'
13
+
14
+
15
+ function calcContours(points, opt = {}) {
16
+
17
+ function getContours(pts) {
18
+
19
+ //tricontour
20
+ let tric = tricontour()
21
+
22
+ //calc
23
+ let contours = tric(pts)
24
+ // console.log('calcContours contours1', contours)
25
+ // contours = [contours[0], contours[1], contours[2], contours[3]]
26
+ // console.log('calcContours contours2', contours)
27
+
28
+ return contours
29
+ }
30
+
31
+ //containInner
32
+ let containInner = get(opt, 'containInner', null)
33
+
34
+ //clipInner
35
+ let clipInner = get(opt, 'clipInner', null)
36
+
37
+ //clipOuter
38
+ let clipOuter = get(opt, 'clipOuter', null)
39
+
40
+ //valueMin, valueMax
41
+ let valueMin = points[0][2]
42
+ let valueMax = points[0][2]
43
+ for (let i = 1; i < size(points); i++) {
44
+ let value = points[i][2]
45
+ if (valueMin > value) {
46
+ valueMin = value
47
+ }
48
+ if (valueMax < value) {
49
+ valueMax = value
50
+ }
51
+ }
52
+ // console.log('valueMin', valueMin, 'valueMax', valueMax)
53
+
54
+ //contours
55
+ let contours = getContours(points)
56
+ // console.log('contours', cloneDeep(contours))
57
+
58
+ //check
59
+ if (!isearr(contours)) {
60
+ // console.log('can not calculate contours', contours)
61
+ return []
62
+ }
63
+ // console.log('contours.length', contours.length)
64
+
65
+ //polylines
66
+ let polylines = map(contours, (v, k) => {
67
+
68
+ return {
69
+ latLngs: v.coordinates,
70
+ level: v.value,
71
+ effectArea: getArea(v.coordinates),
72
+ effectAreaCentroid: getCentroidMultiPolygon(v.coordinates), //要先計算, 否則之後會被相減計算成真實等值區域, 就不是影響區域的中心了
73
+ }
74
+ })
75
+ // console.log('polylines from contours', cloneDeep(polylines))
76
+
77
+ //針對可能超出數據區添加polyline
78
+ if (true) {
79
+
80
+ //pmin, pmax
81
+ let pmin = min(map(polylines, 'level'))
82
+ let pmax = max(map(polylines, 'level'))
83
+ // console.log('pmin', pmin, 'pmax', pmax)
84
+
85
+ //實際數據有超出contours的最大值, 添加虛擬polyline
86
+ if (pmax < valueMax) {
87
+ polylines.push({
88
+ mode: 'virtualEnd',
89
+ latLngs: [],
90
+ level: valueMax,
91
+ effectArea: 0,
92
+ })
93
+ }
94
+
95
+ //實際數據有低於contours的最小值, 添加虛擬polyline
96
+ if (pmin > valueMin) {
97
+ let pl = {
98
+ mode: 'virtualStart',
99
+ latLngs: [],
100
+ level: valueMin,
101
+ effectArea: 0,
102
+ }
103
+ polylines = [pl, ...polylines]
104
+ }
105
+
106
+ }
107
+ // console.log('polylines for vartual level', cloneDeep(polylines))
108
+
109
+ //若不是於超出數據區新增虛擬polyline, 因tricontour會給出繪圖間距而不是實際資料間距, 故會出現level值大於或小於原數據上下限
110
+ if (true) {
111
+ each(polylines, (v, k) => {
112
+ v.level = Math.min(v.level, valueMax)
113
+ v.level = Math.max(v.level, valueMin)
114
+ })
115
+ }
116
+ // console.log('polylines for limit level', cloneDeep(polylines))
117
+
118
+ //polygonSets, 剔除下1個多邊形區域, 為實際需繪製的等值區
119
+ let polygonSets = []
120
+ for (let i = 0; i <= polylines.length - 2; i++) {
121
+
122
+ //p0,p1,range
123
+ let p0 = polylines[i].latLngs
124
+ let p1 = polylines[i + 1].latLngs
125
+ let range = {
126
+ text: `${polylines[i].level} - ${polylines[i + 1].level}`,
127
+ low: polylines[i].level,
128
+ up: polylines[i + 1].level,
129
+ }
130
+
131
+ //clipMultiPolygon
132
+ let latLngs = []
133
+ latLngs = clipMultiPolygon(p0, p1)
134
+ if (get(polylines[i], 'mode' === 'virtualStart')) { //若為virtualStart, 則代表直接使用下1個polylines成為等值區域, 方能代表凹陷區
135
+ latLngs = p1 //因為既有屬性都是取前者, 故若virtualStart係使用後者p1, 就代表全部polygonSet都會有真實effectArea
136
+ }
137
+ else {
138
+ latLngs = clipMultiPolygon(p0, p1)
139
+ }
140
+
141
+ polygonSets.push({
142
+ ...polylines[i],
143
+ latLngs,
144
+ range,
145
+ })
146
+ }
147
+ // console.log('polygonSets from polylines', cloneDeep(polygonSets))
148
+
149
+ //polygonsContainInner, 保留指定多polygon以內區域
150
+ if (true) {
151
+ let t = []
152
+ each(polygonSets, (polygonSet, k) => {
153
+
154
+ //latLngs
155
+ let latLngs = null
156
+ if (isearr(containInner)) {
157
+
158
+ //intersectMultiPolygon
159
+ latLngs = intersectMultiPolygon(polygonSet.latLngs, containInner)
160
+
161
+ }
162
+ else {
163
+ latLngs = polygonSet.latLngs
164
+ }
165
+
166
+ //check
167
+ if (size(latLngs) > 0) {
168
+ t.push({
169
+ ...polygonSet,
170
+ latLngs,
171
+ })
172
+ }
173
+
174
+ })
175
+ polygonSets = t
176
+ }
177
+ // console.log('polygonSets for polygonsContainInner', cloneDeep(polygonSets))
178
+
179
+ //polygonsClipInner, 剔除指定多polygon以內區域
180
+ if (true) {
181
+ let t = []
182
+ each(polygonSets, (polygonSet, k) => {
183
+
184
+ //latLngs
185
+ let latLngs = null
186
+ if (isearr(clipInner)) {
187
+
188
+ //clipMultiPolygon
189
+ latLngs = clipMultiPolygon(polygonSet.latLngs, clipInner)
190
+
191
+ }
192
+ else {
193
+ latLngs = polygonSet.latLngs
194
+ }
195
+
196
+ //check
197
+ if (size(latLngs) > 0) {
198
+ t.push({
199
+ ...polygonSet,
200
+ latLngs,
201
+ })
202
+ }
203
+
204
+ })
205
+ polygonSets = t
206
+ }
207
+ // console.log('polygonSets for polygonsClipInner', cloneDeep(polygonSets))
208
+
209
+ //polygonClipOuter, 剔除指定polygon以外區域
210
+ if (true) {
211
+ let t = []
212
+ each(polygonSets, (polygonSet) => {
213
+
214
+ //latLngs
215
+ let latLngs = null
216
+ if (isearr(clipOuter)) {
217
+
218
+ //intersectMultiPolygon
219
+ latLngs = intersectMultiPolygon(polygonSet.latLngs, clipOuter)
220
+
221
+ }
222
+ else {
223
+ latLngs = polygonSet.latLngs
224
+ }
225
+
226
+ //check
227
+ if (size(latLngs) > 0) {
228
+ t.push({
229
+ ...polygonSet,
230
+ latLngs,
231
+ })
232
+ }
233
+
234
+ })
235
+ polygonSets = t
236
+ }
237
+ // console.log('polygonSets for polygonClipOuter', cloneDeep(polygonSets))
238
+
239
+ //center
240
+ if (true) {
241
+ let areaMax = 0
242
+ let areaInd = null
243
+ let areaCentroid = null
244
+ each(polygonSets, (polygonSet, k) => {
245
+ if (areaMax < polygonSet.effectArea) {
246
+ areaInd = k
247
+ areaMax = polygonSet.effectArea
248
+ areaCentroid = polygonSet.effectAreaCentroid
249
+ }
250
+ })
251
+ if (areaInd === null) {
252
+ // console.log('can not calculate centroid of contour', polygonSets)
253
+ return []
254
+ }
255
+
256
+ //add center
257
+ each(polygonSets, (polygonSet, k) => {
258
+ polygonSets[k].center = areaCentroid
259
+ })
260
+
261
+ }
262
+
263
+ return polygonSets
264
+ }
265
+
266
+
267
+ export default calcContours
@@ -0,0 +1,15 @@
1
+ import turf from './getTurf.mjs'
2
+ import toMultiPolygon from './toMultiPolygon.mjs'
3
+ import distilMultiPolygon from './distilMultiPolygon.mjs'
4
+
5
+
6
+ function clipMultiPolygon(pgs, pgsCut) {
7
+
8
+ //difference
9
+ let r = turf.difference(turf.helpers.multiPolygon(toMultiPolygon(pgs)), turf.helpers.multiPolygon(toMultiPolygon(pgsCut)))
10
+
11
+ return distilMultiPolygon(r)
12
+ }
13
+
14
+
15
+ export default clipMultiPolygon
@@ -0,0 +1,30 @@
1
+ import get from 'lodash/get'
2
+ import parseGeometryCollection from './parseGeometryCollection.mjs'
3
+
4
+
5
+ function distilMultiPolygon(r) {
6
+ //因turf計算後可能產生多種幾何類型, 例如Polygon,MultiPolygon,LineString,GeometryCollection, 故將全部轉成MultiPolygon後回傳
7
+
8
+ //type
9
+ let type = get(r, 'geometry.type', '')
10
+
11
+ //pgNew
12
+ let pgNew = get(r, 'geometry.coordinates', [])
13
+
14
+ if (type === 'Polygon') {
15
+ return [pgNew]
16
+ }
17
+ else if (type === 'MultiPolygon') {
18
+ return pgNew
19
+ }
20
+ else if (type === 'GeometryCollection') {
21
+ return parseGeometryCollection(r)
22
+ }
23
+ else {
24
+ // console.log('type', type, r)
25
+ return []
26
+ }
27
+ }
28
+
29
+
30
+ export default distilMultiPolygon
@@ -0,0 +1,52 @@
1
+ import each from 'lodash/each'
2
+ import filter from 'lodash/filter'
3
+ import cloneDeep from 'lodash/cloneDeep'
4
+ import isernot from 'wsemi/src/isernot.mjs'
5
+ import turf from './getTurf.mjs'
6
+ import invCoordPolygon from './invCoordPolygon.mjs'
7
+ import distilMultiPolygon from './distilMultiPolygon.mjs'
8
+ import invCoordMultiPolygon from './invCoordMultiPolygon.mjs'
9
+
10
+
11
+ function fixGeometryMultiPolygon(pgs) {
12
+
13
+ function core(pg) {
14
+
15
+ //invCoordPolygon, 因為buffer需要輸入正確經緯度才有辦法運算
16
+ pg = invCoordPolygon(pg)
17
+
18
+ //pgt
19
+ let pgt = turf.polygon(pg)
20
+
21
+ //buffer
22
+ let bf = turf.buffer(pgt, 1, { units: 'kilometers' })
23
+
24
+ //distilMultiPolygon, 因buff後可能為多種幾何類型, 故需先統一轉成MultiPolygon
25
+ let pgsNew = distilMultiPolygon(bf)
26
+
27
+ //invCoordMultiPolygon, 變成MultiPolygon後需反轉座標回原始數據之定義方式
28
+ pgsNew = invCoordMultiPolygon(pgsNew)
29
+
30
+ return pgsNew
31
+ }
32
+
33
+ //cloneDeep
34
+ pgs = cloneDeep(pgs)
35
+
36
+ //core
37
+ let pgsNew = []
38
+ each(pgs, (pg) => {
39
+ let r = core(pg) //回傳是MultiPolygon
40
+ each(r, (v) => {
41
+ pgsNew.push(v)
42
+ })
43
+ })
44
+
45
+ //filter
46
+ pgsNew = filter(pgsNew, isernot)
47
+
48
+ return pgsNew
49
+ }
50
+
51
+
52
+ export default fixGeometryMultiPolygon
@@ -0,0 +1,20 @@
1
+ import isearr from 'wsemi/src/isearr.mjs'
2
+ import turf from './getTurf.mjs'
3
+ import toMultiPolygon from './toMultiPolygon.mjs'
4
+
5
+
6
+ function getArea(pgs) {
7
+
8
+ //check
9
+ if (!isearr(pgs)) {
10
+ return null
11
+ }
12
+
13
+ //area
14
+ let r = turf.area(turf.helpers.multiPolygon(toMultiPolygon(pgs)))
15
+
16
+ return r
17
+ }
18
+
19
+
20
+ export default getArea
@@ -0,0 +1,24 @@
1
+ import get from 'lodash/get'
2
+ import isearr from 'wsemi/src/isearr.mjs'
3
+ import turf from './getTurf.mjs'
4
+ import toMultiPolygon from './toMultiPolygon.mjs'
5
+
6
+
7
+ function getCenterOfMassMultiPolygon(pgs) {
8
+
9
+ //check
10
+ if (!isearr(pgs)) {
11
+ return null
12
+ }
13
+
14
+ //centerOfMass
15
+ let r = turf.centerOfMass(turf.helpers.multiPolygon(toMultiPolygon(pgs)))
16
+
17
+ //pt
18
+ let pt = get(r, 'geometry.coordinates', [])
19
+
20
+ return pt
21
+ }
22
+
23
+
24
+ export default getCenterOfMassMultiPolygon
@@ -0,0 +1,24 @@
1
+ import get from 'lodash/get'
2
+ import isearr from 'wsemi/src/isearr.mjs'
3
+ import turf from './getTurf.mjs'
4
+ import toMultiPolygon from './toMultiPolygon.mjs'
5
+
6
+
7
+ function getCentroidMultiPolygon(pgs) {
8
+
9
+ //check
10
+ if (!isearr(pgs)) {
11
+ return null
12
+ }
13
+
14
+ //centroid
15
+ let r = turf.centroid(turf.helpers.multiPolygon(toMultiPolygon(pgs)))
16
+
17
+ //pt
18
+ let pt = get(r, 'geometry.coordinates', [])
19
+
20
+ return pt
21
+ }
22
+
23
+
24
+ export default getCentroidMultiPolygon
@@ -0,0 +1,32 @@
1
+ import isWindow from 'wsemi/src/isWindow.mjs'
2
+ import turfBrowser from './_importTurfBrowser.mjs'
3
+ import turfNode from './_importTurfNode.mjs'
4
+
5
+
6
+ let turf = null
7
+ if (isWindow()) {
8
+ // console.log('use turfBrowser')
9
+ turf = turfBrowser
10
+ }
11
+ else {
12
+ // console.log('use turfNode')
13
+ turf = turfNode
14
+ }
15
+ // console.log('turf', turf)
16
+
17
+
18
+ // //turf function
19
+ // let helpers = turf.helpers
20
+ // let { polygon, multiPolygon, lineString } = helpers
21
+ // let area = turf.area
22
+ // let centroid = turf.centroid
23
+ // let centerOfMass = turf.centerOfMass
24
+ // let intersect = turf.intersect
25
+ // let mask = turf.mask
26
+ // let difference = turf.difference
27
+ // let bezierSpline = turf.bezierSpline
28
+ // let buffer = turf.buffer
29
+ // let booleanPointInPolygon = turf.booleanPointInPolygon
30
+
31
+
32
+ export default turf
@@ -0,0 +1,21 @@
1
+ import isearr from 'wsemi/src/isearr.mjs'
2
+ import turf from './getTurf.mjs'
3
+ import toMultiPolygon from './toMultiPolygon.mjs'
4
+ import distilMultiPolygon from './distilMultiPolygon.mjs'
5
+
6
+
7
+ function intersectMultiPolygon(pgs, pgsInter) {
8
+
9
+ //check
10
+ if (!isearr(pgs)) {
11
+ return null
12
+ }
13
+
14
+ //pgNew
15
+ let r = turf.intersect(turf.helpers.multiPolygon(toMultiPolygon(pgs)), turf.helpers.multiPolygon(toMultiPolygon(pgsInter)))
16
+
17
+ return distilMultiPolygon(r)
18
+ }
19
+
20
+
21
+ export default intersectMultiPolygon
@@ -0,0 +1,22 @@
1
+ import isearr from 'wsemi/src/isearr.mjs'
2
+ import map from 'lodash/map'
3
+ import invCoordPolygon from './invCoordPolygon.mjs'
4
+
5
+
6
+ function invCoordMultiPolygon(pgs) {
7
+
8
+ //check
9
+ if (!isearr(pgs)) {
10
+ return null
11
+ }
12
+
13
+ //invCoordPolygon
14
+ let r = map(pgs, (pg) => {
15
+ return invCoordPolygon(pg)
16
+ })
17
+
18
+ return r
19
+ }
20
+
21
+
22
+ export default invCoordMultiPolygon
@@ -0,0 +1,24 @@
1
+ import isearr from 'wsemi/src/isearr.mjs'
2
+ import map from 'lodash/map'
3
+
4
+
5
+ function invCoordPolygon(pg) {
6
+ //因為turf的point是先經再緯跟leaflet相反, 故需相反座標
7
+
8
+ //check
9
+ if (!isearr(pg)) {
10
+ return null
11
+ }
12
+
13
+ //交換順序
14
+ let r = map(pg, (v) => {
15
+ return map(v, (vv) => {
16
+ return [vv[1], vv[0]] //一定需為長度2陣列之數據
17
+ })
18
+ })
19
+
20
+ return r
21
+ }
22
+
23
+
24
+ export default invCoordPolygon
@@ -0,0 +1,21 @@
1
+ import isearr from 'wsemi/src/isearr.mjs'
2
+ import turf from './getTurf.mjs'
3
+ import toMultiPolygon from './toMultiPolygon.mjs'
4
+
5
+
6
+ function isPointInPolygon(p, pgs) {
7
+
8
+ //check
9
+ if (!isearr(p)) {
10
+ return null
11
+ }
12
+ if (!isearr(pgs)) {
13
+ return null
14
+ }
15
+
16
+ let r = turf.booleanPointInPolygon(p, turf.helpers.multiPolygon(toMultiPolygon(pgs)))
17
+ return r
18
+ }
19
+
20
+
21
+ export default isPointInPolygon
@@ -0,0 +1,21 @@
1
+ import isearr from 'wsemi/src/isearr.mjs'
2
+ import turf from './getTurf.mjs'
3
+ import toMultiPolygon from './toMultiPolygon.mjs'
4
+ import distilMultiPolygon from './distilMultiPolygon.mjs'
5
+
6
+
7
+ function maskMultiPolygon(pgs) {
8
+
9
+ //check
10
+ if (!isearr(pgs)) {
11
+ return null
12
+ }
13
+
14
+ //pgNew
15
+ let r = turf.mask(turf.helpers.multiPolygon(toMultiPolygon(pgs)))
16
+
17
+ return distilMultiPolygon(r)
18
+ }
19
+
20
+
21
+ export default maskMultiPolygon
@@ -0,0 +1,27 @@
1
+ import get from 'lodash/get'
2
+ import each from 'lodash/each'
3
+
4
+
5
+ function parseGeometryCollection(data) {
6
+
7
+ //gs
8
+ let gs = get(data, 'geometry.geometries', [])
9
+
10
+ //pgs
11
+ let pgs = []
12
+ each(gs, (v) => {
13
+ if (v.type === 'Polygon') {
14
+ pgs.push(v.coordinates)
15
+ }
16
+ else if (v.type === 'MultiPolygon') {
17
+ each(v.coordinates, (vv) => {
18
+ pgs.push(vv)
19
+ })
20
+ }
21
+ })
22
+
23
+ return pgs
24
+ }
25
+
26
+
27
+ export default parseGeometryCollection
@@ -0,0 +1,41 @@
1
+ import get from 'lodash/get'
2
+ import isearr from 'wsemi/src/isearr.mjs'
3
+ import isbol from 'wsemi/src/isbol.mjs'
4
+ import isnum from 'wsemi/src/isnum.mjs'
5
+ import cdbl from 'wsemi/src/cdbl.mjs'
6
+ import turf from './getTurf.mjs'
7
+ import toMultiPolygon from './toMultiPolygon.mjs'
8
+
9
+
10
+ function simplifyMultiPolygon(pgs, opt = {}) {
11
+
12
+ //check
13
+ if (!isearr(pgs)) {
14
+ return null
15
+ }
16
+
17
+ //tolerance
18
+ let tolerance = get(opt, 'tolerance')
19
+ if (!isnum(tolerance)) {
20
+ tolerance = 0.005
21
+ }
22
+ tolerance = cdbl(tolerance)
23
+
24
+ //highQuality
25
+ let highQuality = get(opt, 'highQuality')
26
+ if (!isbol(highQuality)) {
27
+ highQuality = true
28
+ }
29
+
30
+ //simplify
31
+ let r = turf.simplify(turf.multiPolygon(toMultiPolygon(pgs)), { tolerance, highQuality })
32
+
33
+ //get pgs
34
+ r = get(r, 'geometry.coordinates', [])
35
+ // console.log('r',r)
36
+
37
+ return r
38
+ }
39
+
40
+
41
+ export default simplifyMultiPolygon
@@ -0,0 +1,38 @@
1
+ import map from 'lodash/map'
2
+ import get from 'lodash/get'
3
+ import cloneDeep from 'lodash/cloneDeep'
4
+ import turf from './getTurf.mjs'
5
+
6
+
7
+ function splineMultiPolygon(pgs, opt = {}) {
8
+ //splineMultiPolygon(pgs, { resolution: 50000, sharpness: 0.05 })
9
+
10
+ function core(pg, opt = {}) {
11
+
12
+ //cloneDeep
13
+ pg = cloneDeep(pg)
14
+
15
+ //pgNew
16
+ let pgNew = map(pg, (ps, k) => {
17
+ let line = turf.helpers.lineString(ps)
18
+ let r = turf.bezierSpline(line, opt)
19
+ let psNew = get(r, 'geometry.coordinates')
20
+ return psNew
21
+ })
22
+
23
+ return pgNew
24
+ }
25
+
26
+ //cloneDeep
27
+ pgs = cloneDeep(pgs)
28
+
29
+ //core
30
+ pgs = map(pgs, (pg) => {
31
+ return core(pg, opt)
32
+ })
33
+
34
+ return pgs
35
+ }
36
+
37
+
38
+ export default splineMultiPolygon