GeoGPXer

GeoGPXer is a JavaScript library designed to convert GPX data into GeoJSON format efficiently. It supports the conversion of waypoints, tracks, and routes, with additional handling for GPX extensions.

Este script no debería instalarse directamente. Es una biblioteca que utilizan otros scripts mediante la meta-directiva de inclusión // @require https://update.greasyforks.org/scripts/523870/1614123/GeoGPXer.js

Autor
JS55CT
Versión
2.1.1
Creado
15/01/2025
Actualizado
25/06/2025
Tamaño
8.48 KB
Licencia
GNU General Public License v3.0

GeoGPXer

GeoGPXer is a JavaScript library designed to convert GPX data into GeoJSON format efficiently. It supports the conversion of waypoints, tracks, and routes, with additional handling for GPX extensions.

License

This project is free software licensed under the GNU LESSER GENERAL PUBLIC LICENS v3. See the LICENSE file for more details.

Overview

GeoGPXer provides an easy-to-use API to parse GPX files and convert them into a GeoJSON FeatureCollection, making it suitable for use in web mapping applications and geographic data visualization.

Features

  • Convert GPX to GeoJSON: Supports waypoints, tracks, and routes.
  • Handle Extensions: Converts GPX <extensions> to prefixed GeoJSON properties to avoid conflicts.
  • No External Dependencies: Lightweight and easy to integrate into various projects.

Usage

To use GeoGPXer, create an instance of GeoGPXer and use its methods to perform the conversion from GPX strings to GeoJSON objects.

Example

var geoGPXer = new GeoGPXer(); // Create a new instance of GeoGPXer

// Sample GPX data input
const gpxData = `...GPX data string...`;

// Parse the GPX data
const xmlDoc = geoGPXer.read(gpxData);

// Convert to GeoJSON
const geoJson = geoGPXer.toGeoJSON(xmlDoc);

console.log(geoJson);

Key Methods

  • read(gpxText): Parses a GPX string into an XML Document using DOMParser.
  • toGeoJSON(document): Converts an XML Document into a GeoJSON FeatureCollection.
  • extractProperties(node): Extracts properties from a GPX node, including handling of by prefixing property names.

Acknowledgments

The code in this project is derived from the logic of gpx2geojson by M-Reimer.

Project Home

https://github.com/JS55CT/GeoGPXer

长期地址
遇到问题?请前往 GitHub 提 Issues。