mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
add geoarea
This commit is contained in:
parent
1a02b3c0b9
commit
fc71adb56d
@ -41,6 +41,9 @@ func DisplayStoryJSON(m *ice.Message, arg ...ice.Any) *ice.Message {
|
||||
func DisplayStorySpide(m *ice.Message, arg ...ice.Any) *ice.Message {
|
||||
return DisplayStory(m, "spide", arg...)
|
||||
}
|
||||
func DisplayStoryChina(m *ice.Message, arg ...ice.Any) *ice.Message {
|
||||
return DisplayStory(m, "china", arg...)
|
||||
}
|
||||
func DisplayStudio(m *ice.Message, cmd ...string) *ice.Message {
|
||||
for i, k := range cmd {
|
||||
kit.If(!strings.Contains(cmd[i], nfs.PT), func() { cmd[i] = m.Prefix(k) })
|
||||
|
@ -20,6 +20,9 @@ func ProcessAction() ice.Actions {
|
||||
|
||||
func _process_args(m *ice.Message, args ice.Any) []string {
|
||||
switch cb := args.(type) {
|
||||
case func():
|
||||
cb()
|
||||
return []string{}
|
||||
case func() string:
|
||||
return []string{cb()}
|
||||
case func() []string:
|
||||
|
@ -10,6 +10,6 @@ const NFS = "nfs"
|
||||
var Index = &ice.Context{Name: NFS, Help: "存储模块"}
|
||||
|
||||
func init() {
|
||||
ice.Index.Register(Index, nil, ZIP, TAR, CAT, DIR, PACK, DEFS, SAVE, PUSH, COPY, LINK, GREP, FIND, TRASH)
|
||||
ice.Index.Register(Index, nil, ZIP, TAR, CAT, DIR, PACK, DEFS, SAVE, PUSH, COPY, LINK, GREP, FIND, MOVE, TRASH)
|
||||
}
|
||||
func Prefix(arg ...string) string { return kit.Keys(NFS, arg) }
|
||||
|
@ -72,6 +72,7 @@ const PUSH = "push"
|
||||
const COPY = "copy"
|
||||
const LINK = "link"
|
||||
const LOAD = "load"
|
||||
const MOVE = "move"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
@ -93,6 +94,11 @@ func init() {
|
||||
LINK: {Name: "link file from run", Help: "链接", Hand: func(m *ice.Message, arg ...string) {
|
||||
_link_file(m, arg[0], arg[1])
|
||||
}},
|
||||
MOVE: {Name: "move file from run", Help: "移动", Hand: func(m *ice.Message, arg ...string) {
|
||||
arg[1] = path.Join(m.Option(DIR_ROOT), arg[1])
|
||||
arg[0] = path.Join(m.Option(DIR_ROOT), arg[0])
|
||||
Rename(m, arg[1], arg[0])
|
||||
}},
|
||||
})
|
||||
}
|
||||
func Create(m *ice.Message, p string, cb ice.Any) {
|
||||
|
1
conf.go
1
conf.go
@ -118,6 +118,7 @@ const ( // DIR
|
||||
|
||||
ISH_PLUGED = ".ish/pluged/"
|
||||
USR_MODULES = "usr/node_modules/"
|
||||
USR_GEOAREA = "usr/geoarea/"
|
||||
USR_RELEASE = "usr/release/"
|
||||
USR_LEARNING = "usr/learning/"
|
||||
USR_VOLCANOS = "usr/volcanos/"
|
||||
|
@ -2,6 +2,7 @@ package mall
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/web/html"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
@ -11,6 +12,7 @@ const (
|
||||
AREA = "area"
|
||||
POPULATION = "population"
|
||||
GDP = "gdp"
|
||||
CITY = "city"
|
||||
)
|
||||
const REGION = "region"
|
||||
|
||||
@ -18,8 +20,29 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
REGION: {Help: "地区", Meta: kit.Dict(
|
||||
ice.CTX_TRANS, kit.Dict(html.INPUT, kit.Dict(AREA, "面积(平方公里)", POPULATION, "人口(万人)", GDP, "产值(亿元)")),
|
||||
), Actions: ice.MergeActions(mdb.ExportHashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,gdp,population,area,text")), Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.HashSelect(m, arg...).SortIntR(GDP).StatusTimeCount(m.Stats(GDP, POPULATION, AREA))
|
||||
), Actions: ice.MergeActions(ice.Actions{
|
||||
GDP: {Help: "产值", Hand: func(m *ice.Message, arg ...string) {
|
||||
ctx.ProcessField(m, m.PrefixKey(), func() {
|
||||
m.Push(ctx.DISPLAY, "/plugin/story/china.js?title=全国产值分布(亿元)&field=gdp&style=float")
|
||||
}, arg...)
|
||||
}},
|
||||
POPULATION: {Help: "人口", Hand: func(m *ice.Message, arg ...string) {
|
||||
ctx.ProcessField(m, m.PrefixKey(), func() {
|
||||
m.Push(ctx.DISPLAY, "/plugin/story/china.js?title=全国人口分布(万人)&field=population&style=float")
|
||||
}, arg...)
|
||||
}},
|
||||
AREA: {Help: "土地", Hand: func(m *ice.Message, arg ...string) {
|
||||
ctx.ProcessField(m, m.PrefixKey(), func() {
|
||||
m.Push(ctx.DISPLAY, "/plugin/story/china.js?title=全国土地分布(平方公里)&field=area&style=float")
|
||||
}, arg...)
|
||||
}},
|
||||
CITY: {Help: "本地", Hand: func(m *ice.Message, arg ...string) {
|
||||
ctx.ProcessField(m, m.PrefixKey(), func() {
|
||||
m.Push(ctx.DISPLAY, "/plugin/story/china.js?title=深圳资源分布&field=area&style=float&path=440300")
|
||||
}, arg...)
|
||||
}},
|
||||
}, mdb.ExportHashAction(mdb.SHORT, mdb.NAME, mdb.FIELD, "time,name,gdp,population,area,text")), Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.HashSelect(m, arg...).SortIntR(GDP).Action(mdb.CREATE, GDP, POPULATION, AREA, CITY).StatusTimeCount(m.Stats(GDP, POPULATION, AREA))
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
83
core/wiki/geoarea.go
Normal file
83
core/wiki/geoarea.go
Normal file
@ -0,0 +1,83 @@
|
||||
package wiki
|
||||
|
||||
import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/base/web/html"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const GEOAREA = "geoarea"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
GEOAREA: {Name: "geoarea path auto", Help: "地区", Actions: ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(web.SPIDE, mdb.CREATE, GEOAREA, "https://geo.datav.aliyun.com/areas_v3/bound/")
|
||||
}},
|
||||
nfs.PS: {Hand: func(m *ice.Message, arg ...string) {
|
||||
p := path.Join(ice.USR_GEOAREA, path.Join(arg...))
|
||||
kit.If(!nfs.Exists(m, p), func() { m.Cmd(web.SPIDE, GEOAREA, web.SPIDE_SAVE, p, arg) })
|
||||
m.RenderDownload(p)
|
||||
}},
|
||||
"china": {Hand: func(m *ice.Message, arg ...string) {
|
||||
ctx.ProcessField(m, m.PrefixKey(), func() {
|
||||
m.Push(ctx.STYLE, html.FLOAT)
|
||||
}, arg...)
|
||||
}},
|
||||
"city": {Hand: func(m *ice.Message, arg ...string) {
|
||||
stat := map[string]int{}
|
||||
lead := map[string]string{}
|
||||
list := map[string][]string{}
|
||||
m.Cmdy(nfs.CAT, "usr/geoarea/city.txt", func(ls []string, text string) {
|
||||
if len(ls) < 2 {
|
||||
return
|
||||
}
|
||||
for _, k := range []string{
|
||||
"自治区", "自治州", "自治县", "自治旗", "盟", "旗",
|
||||
"特别行政区", "特别行政区",
|
||||
"地区",
|
||||
"林区",
|
||||
"特区",
|
||||
"省", "市", "县", "区",
|
||||
} {
|
||||
if strings.HasSuffix(ls[1], k) {
|
||||
stat[k]++
|
||||
break
|
||||
}
|
||||
}
|
||||
if strings.HasSuffix(ls[0], "0000") {
|
||||
lead[ls[0][0:2]] = ls[1]
|
||||
kit.If(strings.HasSuffix(ls[1], "市"), func() { stat["直辖市"]++ })
|
||||
stat["省级单位"]++ // 34 = 4 直辖市 23 省 5 自治区 2 特别行政区
|
||||
} else if strings.HasSuffix(ls[0], "00") {
|
||||
list[lead[ls[0][0:2]]] = append(list[lead[ls[0][0:2]]], ls[1])
|
||||
kit.If(strings.HasSuffix(ls[1], "市"), func() { stat["地级市"]++ })
|
||||
stat["地级单位"]++ // 333 = 293 地级市 30 自治州 3 盟 7 地区
|
||||
} else {
|
||||
// list[lead[ls[0][0:2]]] = append(list[lead[ls[0][0:2]]], ls[1])
|
||||
kit.If(strings.HasSuffix(ls[1], "市"), func() { stat["县级市"]++ })
|
||||
stat["县级单位"]++ // 2842 = 388 县级市 1312 县 117 自治县 3 自治旗 49 旗 5 林区 1 特区 967 市辖区
|
||||
}
|
||||
})
|
||||
for k, v := range list {
|
||||
m.Push(mdb.NAME, k)
|
||||
m.Push(mdb.VALUE, len(v))
|
||||
m.Push(mdb.LIST, strings.Join(v, ","))
|
||||
}
|
||||
m.SortIntR(mdb.VALUE).StatusTimeCount(stat)
|
||||
m.Action("china")
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, arg ...string) {
|
||||
ctx.DisplayStoryChina(m.Options(mdb.NAME, "中国", nfs.PATH, kit.Select("", arg, 0)))
|
||||
m.Action("city")
|
||||
}},
|
||||
})
|
||||
|
||||
}
|
3
core/wiki/geoarea.shy
Normal file
3
core/wiki/geoarea.shy
Normal file
@ -0,0 +1,3 @@
|
||||
refer `
|
||||
https://www.mca.gov.cn/mzsj/xzqh/2020/20201201.html
|
||||
`
|
Loading…
x
Reference in New Issue
Block a user