地理信息系统工具库,处理常用的地理信息,包括坐标转换、几何计算、地图投影等功能
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 |
介绍
GISTools是一种简单实用的GIS工具,其主要功能如下:
- 扩展的GeoJson和几何对象的转化(包含空间参考),包括Point、Polyline和Polygon的实现
- 常用的空间参考定义和实现
- 坐标转化,实现WGS 1984、GCJ-02、BD-09地理坐标的转换
- 地图投影,实现墨卡托投影和地理坐标的转换
- 几何计算:计算距离、长度、面积
GISTools具有极致轻量化、高效、易学易用的特点,可以在极短的时间内上手的仓颉GIS工具库。
特性
-
纯仓颉语言实现
-
极致轻量化,仅关注核心功能
-
尽可能使用仓颉特性,如Flow表达式等。
-
简单,易用,高效
路线
目前已经更新至0.8.1版本
更新日志v0.8.1
- 修复部分Bug
- 修改部分英文提示
软件架构
架构图
GISTools库包括空间参考(Spatial Reference)、基本库(Base)和几何图形库(Geometry)三个基本层次
源码目录
.
├── build.sh
├── doc
│ ├── design.md
│ └── feature_api.md
├── gitee_gate.cfg
├── LICENSE
├── module.json
├── README.en.md
├── README.md
├── README.OpenSource
├── src
│ └── love
│ └── cangjie
│ └── gistools
│ ├── base
│ │ ├── Coordinate.cj
│ │ ├── CoordinateEngine.cj
│ │ └── Math.cj
│ ├── geometry
│ │ ├── Geometry.cj
│ │ ├── GeometryEngine.cj
│ │ ├── Point.cj
│ │ ├── Polygon.cj
│ │ └── Polyline.cj
│ └── SpatialReference.cj
└── test
├── HLT
├── LLT
└── UT
目录的主要功能如下:
doc文档目录src源码目录test测试目录
主要代码说明如下:
- Coordinate.cj :坐标
- CoordinateEngine.cj :坐标工具
- Math.cj :数学工具
- Geometry.cj :几何
- GeometryEngine.cj :几何工具
- Point.cj :点
- Polyline.cj :线
- Polygon.cj :面
接口说明
主要类和函数接口说明详见 API
使用说明
扩展的GeoJSON格式
本库采用扩展的GeoJSON格式,可以在基本个GeoJSON格式的基础上增加空间参考。
例如,带有空间参考的几何点GeoJSON如下:
{
"geometry": {
"type": "Point",
"coordinates": [116.121100, 38.456400],
"spatialReference": 4326
}
}
例如,带有空间参考的几何面GeoJSON如下:
{
"geometry": {
"type": "Polygon",
"coordinates": [
[116.121100, 38.456400],
[116.121100, 38.466400],
[116.131100, 38.466400],
[116.121100, 38.456400]
],
"spatialReference": 4326
}
}
编译构建
描述具体的编译过程:
cjpm update
cjpm build
功能示例
基本几何功能演示
创建点的对象,并输出相应的信息:
示例代码如下:
from gistools import love.cangjie.gistools.*
from gistools import love.cangjie.gistools.geometry.*
from gistools import love.cangjie.gistools.base.*
main() {
let wgs84Point = Point(116.1211, 38.4564, SpatialReference.wgs84())
println("Point GeoJson : ${wgs84Point.toJson()}")
println(wgs84Point.hasSpatialReference())
}
执行结果如下:
Point GeoJson : {"geometry":{"type":"Point","coordinates":[116.121100,38.456400],"spatialReference":4326}}
true
坐标转换功能演示
转换坐标系统:
示例代码如下:
from gistools import love.cangjie.gistools.*
from gistools import love.cangjie.gistools.geometry.*
from gistools import love.cangjie.gistools.base.*
main() {
let wgs84Point = Point(116.1211, 38.4564, SpatialReference.wgs84())
match (wgs84Point.toGCJ02()) {
case Some(v) => println("to GCJ02 : ${v}")
case None => println("Error to GCJ02!")
}
match (wgs84Point.toBD09()) {
case Some(v) => println("to BD09 : ${v}")
case None => println("Error to BD09!")
}
match (wgs84Point.toWGS1984()) {
case Some(v) => println("to WGS1984 : ${v}")
case None => println("Error to WGS1984!")
}
}
执行结果如下:
to GCJ02 : Point(116.127220,38.457236) sr:GCJ-02
to BD09 : Point(116.133206,38.463787) sr:BD-09
Error to WGS1984!
开源协议
Apache 2.0 License
参与贡献
欢迎给我们提交PR,欢迎给我们提交Issue,欢迎参与任何形式的贡献。