Greasy Fork

Greasy Fork is available in English.

GeoWKTer

GeoWKTer is a JavaScript library designed to convert Well-Known Text (WKT) representations of geometries into GeoJSON format. This tool is useful for developers and GIS specialists who need to work with geographic data across different standards.

当前为 2025-01-16 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/523986/1521860/GeoWKTer.js

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
JS55CT
版本
0.0.1.20250116223818
创建于
2025-01-16
更新于
2025-01-16
大小
8.7 KB
许可证
暂无

GeoWKTer: WKT to GeoJSON Converter

GeoWKTer is a JavaScript library designed to convert Well-Known Text (WKT) representations of geometries into GeoJSON format. This tool is useful for developers and GIS specialists who need to work with geographic data across different standards.

Features

  • Supports conversion of various WKT geometry types including POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, and GEOMETRYCOLLECTION.
  • Handles multi-line WKT inputs.
  • Provides a streamlined API for converting WKT to GeoJSON FeatureCollections.

Usage

Here's a basic example of how to use the GeoWKTer library:

// Initialize the GeoWKTer instance
let geoWKTer = new GeoWKTer();

// Example WKT input
let wktText = `
GEOMETRYCOLLECTION(POINT(4 6), LINESTRING(4 6, 7 10))
GEOMETRYCOLLECTION(POLYGON((8 4, 11 4, 9 7, 8 4)))
`;

// Convert WKT to GeoJSON
let wktDataArray = geoWKTer.read(wktText, 'Example Label');
let geoJsonData = geoWKTer.toGeoJSON(wktDataArray);

// Output GeoJSON
console.log(JSON.stringify(geoJsonData, null, 2));

API

GeoWKTer

  • read(wktText, label): Parses a WKT string and returns an array of geometry objects. It splits multi-line WKT text and labels each geometry.

  • toGeoJSON(dataArray): Converts the parsed WKT data array into a GeoJSON FeatureCollection.

License

GeoWKTer is licensed under the GNU General Public License v3.0. See the LICENSE file for more details.

Acknowledgments

GeoWKTer was derived from and inspired by the work of Wicket, authored by K. Arthur Endsley at the Michigan Tech Research Institute (MTRI). Wicket is shared under the terms of the GNU General Public License. We extend our gratitude for this foundational work. For more information on the original project, please refer to the Wicket repository.

Inspired by the need to bridge WKT with GeoJSON for versatile geographic data transformations.