项目中有管线的空间拓扑关系查询需求,在npm中检索到JSTS和Turf两个JavaScript 空间分析库。
JSTS是一个符合OGC规范的简单要素空间位置判定函数JavaScript库,JSTS也是Java类库JTS的一个接口,且与OpenLayer3具有互操作性。
目前原生的OpenLayers3并不支持空间拓扑关系查询,此类库可以作为重要的补充。通过此类库,可以判断多种空间几何的位置关系,最初建立这个工程的目的是为web地图应用提供一套完整的类库来处理和分析简单几何体,但jsts也可以作为一个独立的几何库。
JSTS是利用原JTS java源码通过AST AST自动翻译转换而成并保持了该API,除了对IO相关的部分类进行了选择性的并手动移植使其支持WKT,GeoJSON和OpenLayers 3。
Turf.js:JavaScript 空间分析库,由Mapbox 提供,Turf 实现了常用的空间分析操作,例如生成缓冲区、计算等高线,建立 TIN 等等。以往只属于桌面 GIS 的分析功能,已经可以在浏览器中使用。
Turf 使用 JavaScript 编写,通过 npm 进行包管理。良好的模块化设计使得 Turf 不仅可用于浏览器端,还可以通过 Node.js 在服务器端使用。
Turf 原生支持 GeoJSON 矢量数据。GeoJSON 的优点是结构简单,并且得到了所有网页地图API的支持;但 GeoJSON 不支持空间索引,这个缺点可能会限制 Turf 处理大型文件的能力效率。
Turf 可以非方便地集成到 Leaflet.js 地图控件中,Mapbox 也为其提供了相应的 Mapbox.js 插件。
JSTS is an ECMAScript library of spatial predicates and functions for processing geometry conforming to the Simple Features Specification for SQL published by the Open Geospatial Consortium. JSTS is also a port of the well established Java library JTS.
The primary goal of the project is to provide web mapping applications with a complete library for processing and analyzing simple geometries but JSTS can also be used as a free standing geometry library.
JSTS was made using automatic translation of the original JTS Java source via AST to AST transformation preserving the JTS API, except for the I/O related classes which has been selectively and manually ported with support for WKT, GeoJSON and OpenLayers.
Turf is a JavaScript library for spatial analysis. It includes traditional spatial operations, helper functions for creating GeoJSON data, and data classification and statistics tools. Turf can be added to your website as a client-side plugin, or you can run Turf server-side with Node.js
npm: https://www.npmjs.com/search?q=%20processing%20geometry
JSTS: https://www.npmjs.com/package/jsts
Turf: http://turfjs.org/
JSTS学习(一) - 简介
https://bjornharrtell.github.io/jsts/
https://github.com/bjornharrtell/jsts
http://locationtech.github.io/jts/javadoc/
https://github.com/Turfjs/turf
https://openlayers.org/en/latest/examples/turf.html