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.gf.qytechs.cn/scripts/523986/1521860/GeoWKTer.js

作者
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.

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址