JavaScript 空間分析庫——JSTS和Turf【轉】


https://blog.csdn.net/neimeng0/article/details/80363468

前言

項目中有管線的空間拓撲關系查詢需求,在npm中檢索到JSTS和Turf兩個JavaScript 空間分析庫。

JSTS

       JSTS是一個符合OGC規范的簡單要素空間位置判定函數JavaScript庫,JSTS也是Java類庫JTS的一個接口,且與OpenLayer3具有互操作性。
       目前原生的OpenLayers3並不支持空間拓撲關系查詢,此類庫可以作為重要的補充。通過此類庫,可以判斷多種空間幾何的位置關系,最初建立這個工程的目的是為web地圖應用提供一套完整的類庫來處理和分析簡單幾何體,但jsts也可以作為一個獨立的幾何庫。
       JSTS是利用原JTS java源碼通過AST AST自動翻譯轉換而成並保持了該API,除了對IO相關的部分類進行了選擇性的並手動移植使其支持WKT,GeoJSON和OpenLayers 3。
Turf.js

       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


---------------------
作者:neimeng0
來源:CSDN
原文:https://blog.csdn.net/neimeng0/article/details/80363468
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM