{"id":37112262,"url":"https://github.com/xvill/xutil","last_synced_at":"2026-01-14T13:17:07.427Z","repository":{"id":57499249,"uuid":"128583854","full_name":"xvill/xutil","owner":"xvill","description":"经纬度转换，sqlldr入库，Geometry工具","archived":false,"fork":false,"pushed_at":"2025-07-21T08:08:21.000Z","size":305,"stargazers_count":16,"open_issues_count":0,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-14T05:53:38.972Z","etag":null,"topics":["bd09","csv","gcj-02","geo","mercator-projection","sqlldr","wgs","wkt"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xvill.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-04-08T01:28:40.000Z","updated_at":"2025-07-21T08:08:24.000Z","dependencies_parsed_at":"2025-03-24T03:29:03.096Z","dependency_job_id":"84ef4be2-b98d-4eb8-b505-97e5bb80ea8a","html_url":"https://github.com/xvill/xutil","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xvill/xutil","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xvill%2Fxutil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xvill%2Fxutil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xvill%2Fxutil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xvill%2Fxutil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xvill","download_url":"https://codeload.github.com/xvill/xutil/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xvill%2Fxutil/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28420958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bd09","csv","gcj-02","geo","mercator-projection","sqlldr","wgs","wkt"],"created_at":"2026-01-14T13:17:06.666Z","updated_at":"2026-01-14T13:17:07.415Z","avatar_url":"https://github.com/xvill.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xutil\n\n## install\ngo get -u github.com/xvill/xutil\n\n\n## usage\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/xvill/xutil\"\n)\n\nfunc main() {\n\tg, _ := xutil.FromWKT(\"POINT(121.44528145 30.96964209)\")\n\tg.Wgs2gcj()\n\tg.FlipCoordinates()\n\tfmt.Println(g)\n\n\twktstr := []string{\n\t\t\"POINT(1 2)\",\n\t\t\"LINESTRING(3 4,10 50,20 25)\",\n\t\t\"POLYGON((30 10, 40 40, 20 40, 10 20, 30 10))\",\n\t\t\"POLYGON((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))\", //POLYGON with hole\n\t\t\"MULTIPOINT (10 40, 40 30, 20 20, 30 10)\",\n\t\t\"MULTILINESTRING((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))\",\n\t\t\"MULTIPOLYGON(((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))\",\n\t\t\"MULTIPOLYGON(((40 40, 20 45, 45 30, 40 40)),((20 35, 10 30, 10 10, 30 5, 45 20, 20 35),(30 20, 20 15, 20 25, 30 20)))\",\n\t}\n\tfor _, s := range wktstr {\n\t\tg, _ := xutil.FromWKT(s)\n\t\tfmt.Println(g.GeoJSON())\n\t}\n}\n```\n## function\n\n```go\nfunc CsvWriteALL(data [][]string, wfile string, comma rune) error {} // 生成CSV\nfunc Sqlldr(timeflag, userid, data, control, baddir string)(rows, badrows int, err error)  {}    // 执行成功返回入库记录数,失败则保留log和data到baddir\nfunc IsFileExist(path string) (isExist, isDir bool, err error) {}    // 文件是否存在\n \nfunc FromWKT(wkt string) (Geo, error){}  // 解析WKT为Geo\nfunc (g Geo) ToWKT() (wkt string) {} // 生成WKT\nfunc (g Geo) GeoJSON() (s string, err error) {}  // 生成GeoJSON\nfunc (g Geo) Lines() []Line {} // 所有线段\nfunc (g Geo) Points() []Point {} // 所有点\nfunc (g Geo) Copy() Geo {} // 复制\nfunc (g Geo) PointFunc(f func(lon, lat float64) (float64, float64)) {} // 对所有点应用函数\nfunc (g Geo) FlipCoordinates() {}  // 转换Lat,Lng 位置\nfunc (g Geo) Wgs2gcj(){} // 经纬度坐标系转换 wgs-\u003e gcj\nfunc (g Geo) Gcj2bd() {} // 经纬度坐标系转换 gcj-\u003eBD09\nfunc (g Geo) Wgs2bd() {} // 经纬度坐标系转换 wgs-\u003eBD09\nfunc (g Geo) Box() []float64 {}  // 方框边界 minx, miny, maxx, maxy \n \nfunc Wgs2gcj(lon, lat float64) (float64, float64){}  // WGS坐标系 ----\u003e GCJ坐标系\nfunc Gcj2bd(lon, lat float64) (float64, float64){}   //  火星(GCJ-02)坐标系 ----\u003e 百度(BD-09)坐标系\nfunc Gcj2Wgs(lon, lat float64) (float64, float64){}   //  火星(GCJ-02)坐标系 ----\u003e WGS坐标系\nfunc Bd2gcj(lon, lat float64) (float64, float64) {}  //  百度(BD-09)坐标系 ----\u003e 火星(GCJ-02)坐标系\nfunc Wgs2bd(lon, lat float64) (float64, float64) {}  // WGS坐标系 ----\u003e 百度坐标系\n\nfunc Wgs2Tile(lng, lat float64, z int) (x, y int) {} //瓦片:lnglat转XY\nfunc Tile2Wgs(x, y, z int) (lat, lng float64) {} //瓦片:XY转lnglat\n\nfunc Bd09ToTile(x, y float64, zoom int) (int, int) {} //百度经纬度转换为瓦片编号\nfunc MercatorToBd09(x, y float64) (float64, float64) {} //墨卡托坐标转百度经纬度坐标\nfunc Bd09ToMercator(lng, lat float64) (float64, float64){} //百度经纬度坐标转墨卡托坐标\n\nfunc Azimuth(lon1, lat1, lon2, lat2 float64) float64 {} // P1到P2 的方位角\nfunc PointDistance(lon1, lat1, lon2, lat2 float64) float64 {} // 两经纬度距离\nfunc PointDistHaversine(lon1, lat1, lon2, lat2 float64) float64 {} // 两经纬度距离\nfunc PointMid(lon1, lat1, lon2, lat2 float64) (float64, float64) {} // P1和P2中间点\nfunc PointAt(lon, lat, dist, azimuth float64) (float64, float64) {} // 根据起点、距离、方位角计算另一个点\n\nfunc ToFixed(f float64, n int) float64 {}    // 浮点数保留\n\n/**身份证**/\nfunc IDsumY(id string) string {} \t// IDsumY 计算身份证的第十八位校验码\nfunc ID15to18(id string) string {} \t// ID15to18 将15位身份证转换为18位的\nfunc IDisValid(id string) bool {} \t// IDisValid 校验身份证第18位是否正确\nfunc IDisPattern(id string) bool {} \t// IDisPattern 二代身份证正则表达式\nfunc NewIDCard(id string) (c IDCard, err error) {} \t// NewIDCard  获取身份证信息\n\n\n/**地址解析**/\nfunc NewMapAPI(ak string) MapAPI {}  //高德、百度地址解析封装\nfunc (m MapAPI) AmapGeoCode(address string) (poi Poi) {} //高德地址解析\nfunc (m MapAPI) BdmapGeoCode(address string) (poi Poi) {} //百度地址解析\nfunc (m *MapAPI) AmapGeoCodeALL(addrsMap map[string]string, poolsize int) (addrsAll map[string]Poi) {} //多线程解析\nfunc (m *MapAPI) BdmapGeoCodeALL(addrsMap map[string]string, poolsize int) (addrsAll map[string]Poi) {} //多线程解析\n```\n\n## reference\n\n- [中华人民共和国国家统计局\u003e\u003e统计用区划和城乡划分代码](http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/)\n- [中华人民共和国民政部\u003e\u003e2018年中华人民共和国行政区划代码](http://www.mca.gov.cn/article/sj/xzqh/2018/)\n- [中华人民共和国民政部\u003e\u003e全国行政区划信息查询平台](http://xzqh.mca.gov.cn/map)\n- [Calculate distance, bearing and more between Latitude/Longitude points](http://www.movable-type.co.uk/scripts/latlong.html)\n- [Well-known text - Wikipedia](https://en.wikipedia.org/wiki/Well-known_text)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxvill%2Fxutil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxvill%2Fxutil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxvill%2Fxutil/lists"}