Skip to content

Latest commit

 

History

History
110 lines (73 loc) · 3.04 KB

README.md

File metadata and controls

110 lines (73 loc) · 3.04 KB

GPX Route Splitter

A web-based tool that lets you upload a GPX file, visualise the route on an interactive map and split it into multiple sequential segments for download.

Built with JavaScript and Leaflet, it's designed for cyclists, runners and hikers who want to break long routes into manageable parts.


Features

  • Upload via file picker or drag and drop (drop a .gpx file anywhere on the page)
  • Split points are numbered in route order, so they always match Part 1, 2, 3
  • Waypoints are written only to the part of the route they sit on
  • Visualise routes on an interactive map
  • Click anywhere on the route to create up to 10 split points
  • Automatically split GPX into sequential segments
  • Download each segment as a separate GPX file
  • Toggle:
    • Units (km / miles)
    • Waypoint visibility
  • Displays:
    • Distance markers along the route
    • Elevation (when available)
    • Start / end markers
    • Waypoints from GPX files
  • Step-based progress UI for workflow clarity

Demo

Upload a .gpx file → click on map to add split points → export segments → download files.


Tech Stack

  • PHP (for simple templating and cache-busting assets)
  • Vanilla JavaScript (no framework)
  • Leaflet.js for mapping
  • OpenStreetMap tiles

Installation

Simply clone the respository and run it locally or publicly on your own server.


Usage

  • Click Choose GPX File, or drag and drop a .gpx file onto the page
  • The route will appear on the map
  • Click on the route to add split points (max 10). Click a split marker to remove it
  • Click Export Split GPX Files
  • Download generated segments
  • Click Reset to start again with a new file

How it works

1. GPX Parsing

The app parses:

  • <trkpt> for route geometry
  • <wpt> for waypoints

2. Map Rendering

The route is drawn as a polyline using Leaflet and OpenStreetMap tiles.

3. Split Logic

When you click the map:

  • The nearest route point is found
  • Its index is stored (a point that already has a split is ignored)
  • Splits are kept sorted by route position and renumbered automatically
  • The route is sliced at those indices during export

4. Export

  • Each segment is converted back into valid XML and made available as downloadable .gpx file(s).
  • Each waypoint is assigned to the part containing its nearest track point, so it appears in exactly one file.

Notes

  • Everything runs in your browser, so your GPX file is never uploaded and nothing is saved to a server or database
  • Closing or refreshing the page clears your route and splits
  • Only one file can be loaded at a time (via the picker or drag and drop)
  • After exporting, the upload is locked until you click Reset
  • Only track points (<trkpt>), their elevation and waypoints are kept. Other data such as timestamps and extensions isn't carried into the exported files
  • Very large tracks may slow the page down, though this is unlikely

Credits


License

MIT