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.
- package/README.md +1 -1
- package/dist/w-gis.umd.js +2 -2
- package/dist/w-gis.umd.js.map +1 -1
- package/docs/-_class.mjs.html +1 -1
- package/docs/convertCoordinate.mjs.html +1 -1
- package/docs/examples/ex-getCenterOfMassMultiPolygon.html +1 -1
- package/docs/examples/ex-getCentroidMultiPolygon.html +1 -1
- package/docs/index.html +1 -1
- package/docs/w-gis.html +1 -1
- package/g-getCenterOfMassMultiPolygon.mjs +3 -3
- package/g-getCentroidMultiPolygon.mjs +3 -3
- package/package.json +2 -1
- package/src/WGis.mjs +18 -585
- package/src/{convertTurfCode.mjs → _convertTurfCode.mjs} +5 -5
- package/src/{importTurfBrowser.mjs → _importTurfBrowser.mjs} +1 -4
- package/src/{importTurfNode.mjs → _importTurfNode.mjs} +0 -0
- package/src/_turfCoreBrowser.mjs +1 -0
- package/src/calcContours.mjs +267 -0
- package/src/clipMultiPolygon.mjs +15 -0
- package/src/distilMultiPolygon.mjs +30 -0
- package/src/fixGeometryMultiPolygon.mjs +52 -0
- package/src/getArea.mjs +20 -0
- package/src/getCenterOfMassMultiPolygon.mjs +24 -0
- package/src/getCentroidMultiPolygon.mjs +24 -0
- package/src/getTurf.mjs +32 -0
- package/src/intersectMultiPolygon.mjs +21 -0
- package/src/invCoordMultiPolygon.mjs +22 -0
- package/src/invCoordPolygon.mjs +24 -0
- package/src/isPointInPolygon.mjs +21 -0
- package/src/maskMultiPolygon.mjs +21 -0
- package/src/parseGeometryCollection.mjs +27 -0
- package/src/simplifyMultiPolygon.mjs +41 -0
- package/src/splineMultiPolygon.mjs +38 -0
- package/src/toMultiPolygon.mjs +49 -0
- package/toolg/gPackageIndex.mjs +46 -0
- package/src/importTurfBrowser.json +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import map from 'lodash/map'
|
|
2
|
+
import get from 'lodash/get'
|
|
3
|
+
import size from 'lodash/size'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function pointDepth(v) {
|
|
7
|
+
let ip1 = size(get(v, '0', null))
|
|
8
|
+
let ip2 = size(get(v, '0.0', null))
|
|
9
|
+
let ip3 = size(get(v, '0.0.0', null))
|
|
10
|
+
if (ip3 === 2) {
|
|
11
|
+
return 3
|
|
12
|
+
}
|
|
13
|
+
if (ip2 === 2) {
|
|
14
|
+
return 2
|
|
15
|
+
}
|
|
16
|
+
if (ip1 === 2) {
|
|
17
|
+
return 1
|
|
18
|
+
}
|
|
19
|
+
if (ip1 === 0) {
|
|
20
|
+
return 0
|
|
21
|
+
}
|
|
22
|
+
console.log('invalid point depth', v)
|
|
23
|
+
return null
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
function toMultiPolygon(v) {
|
|
28
|
+
|
|
29
|
+
let d = pointDepth(v)
|
|
30
|
+
if (d === 3) {
|
|
31
|
+
return v
|
|
32
|
+
}
|
|
33
|
+
if (d === 2) {
|
|
34
|
+
//return [v]
|
|
35
|
+
return map(v, (vv) => {
|
|
36
|
+
return [vv]
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
if (d === 1) {
|
|
40
|
+
return [[v]]
|
|
41
|
+
}
|
|
42
|
+
if (d === 0) {
|
|
43
|
+
return []
|
|
44
|
+
}
|
|
45
|
+
return v
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
export default toMultiPolygon
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import _ from 'lodash'
|
|
3
|
+
import w from 'wsemi'
|
|
4
|
+
import getFiles from 'w-package-tools/src/getFiles.mjs'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
let fd = './src/'
|
|
8
|
+
let fnIndex = 'WGis.mjs'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
function main() {
|
|
12
|
+
//由src內取得指定函數檔案, 再自動產生WGeo.mjs, 供rollup編譯之用
|
|
13
|
+
|
|
14
|
+
//getFiles
|
|
15
|
+
let ltfs = getFiles(fd)
|
|
16
|
+
|
|
17
|
+
//pull
|
|
18
|
+
_.pull(ltfs, 'WGis.mjs')
|
|
19
|
+
|
|
20
|
+
//filter
|
|
21
|
+
ltfs = _.filter(ltfs, (v) => {
|
|
22
|
+
return w.strleft(v, 1) !== '_'
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
//get names
|
|
26
|
+
let ns = _.map(ltfs, function(v) {
|
|
27
|
+
return v.replace('.mjs', '')
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
//scs
|
|
31
|
+
let scs = []
|
|
32
|
+
_.each(ns, function(name) {
|
|
33
|
+
//let sc = `export ${name} from './${name}.mjs'` //stage1語法, 需要安裝@babel/plugin-proposal-export-default-from
|
|
34
|
+
let sc = `export { default as ${name} } from './${name}.mjs'`
|
|
35
|
+
scs.push(sc)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
//merge content
|
|
39
|
+
let c = _.join(scs, '\r\n')
|
|
40
|
+
|
|
41
|
+
//write
|
|
42
|
+
//console.log(c)
|
|
43
|
+
fs.writeFileSync(fd + fnIndex, c, 'utf8')
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
main()
|