1.0.0本地计算

轨迹格式转换:GPX 与 GeoJSON 线路互转

在浏览器本地把 GPX 或 GeoJSON 线路转换为另一种格式,保留坐标顺序与已有高程,并主动剥离时间、设备、姓名和原始 metadata。

选择本地轨迹并设置输出格式

仅支持 GPX / GeoJSON;最大 20 MB、200,000 个坐标点。文件不会上传。

文件只在当前页面内读取,不上传,也不会在刷新后保留。

输出格式

默认选择与输入相反的格式。只导出线路、坐标与可用高程,不导出时间、设备、姓名或原始 metadata。

公式与适用条件

这个工具做什么

轨迹格式转换读取一条线路,按你选择的输出格式重新写出文件,并提供下载。它适合把手表或应用导出的 GPX 变成 GeoJSON,或把 GeoJSON 线路变成 GPX 交给其他工具,而不把原始文件里的个人信息一起带过去。

转换输出包括线路几何、坐标顺序、每个线段的分段关系,以及点上有可靠高程时的 <ele> 或第三个坐标值。工具不会写入时间戳、设备名称、人名、文件名或其他原始 metadata。它也不会把缺失的高程补成 0。

接受哪些输入

  • GPX:优先读取 trk 下的 trkseg;如果没有 trkseg,再读取路线 rte。每个 trkseg 或 rte 作为独立线段处理,不把不同线段的端点连接起来。
  • GeoJSON:接受 LineString、MultiLineString,以及只包含这些类型的 FeatureCollection 或 Feature。坐标顺序固定为经度、纬度,第三位可选高程。

点集、多边形或其他非线路几何类型会被拒绝并报错,而不是被悄悄转换成一条假线路。文件上限为 20 MB、200,000 个坐标点;仅支持本地读取,不上传服务器。

输出与隐私

输出是重新序列化的文件,因此即使输出格式与输入相同,字节内容也可能与原始文件不同,例如缩进、数字写法或元素顺序会变化。需要保留原始文件时,请自行保留;工具不会修改或覆盖它。

下载文件由浏览器在本地生成。文件内容不会上传、不会写入服务器日志,也不会在刷新后保留。公共设备上处理含家庭住址的轨迹时,请先考虑是否适合打开。

验证算例

一条包含三个点的 GeoJSON 线路:[0, 0, 10]、[0.001, 0]、[0.002, 0, 15]。转换后仍应只有一个线段、三个坐标点,其中两个点带高程(10 与 15),中间点没有高程。坐标顺序与数值不得改变,缺失高程不能用 null 或 0 冒充。该算例由独立往返检查核对,不依赖页面脚本的显示结果。

不能回答的问题

转换工具不判断线路是否为官方赛道、是否获得通行许可、是否适合比赛,也不认证距离。它只改变文件格式。若要读取距离、点数与起终点,使用轨迹查看;若要减少点数,使用轨迹简化并在输出中核对点数与距离变化。

来源与适用范围

文件结构依据 GPX 1.1 规范与 RFC 7946 GeoJSON 规范。本文与工具核验日期为 2026-10-27。

实现规范(英文原文)

以下字段用于实现与审阅核对,正文提供中文解释。

公式与适用条件
Parse only line geometry. GPX trkseg and rte elements become independent segments; GeoJSON LineString, MultiLineString and FeatureCollection or Feature wrappers containing only those types are accepted. Serialize the ordered coordinates to the target format, writing elevation only when a point has it. The output contains no timestamps, device names, person names or original metadata.
适用条件
  • Input coordinates are WGS84 longitude and latitude in that order.
  • Only line geometry is accepted; points, polygons and other geometry types are rejected rather than silently discarded.
  • Distance is the WGS84 geodesic distance between consecutive points and is informational, not a certified course measurement.
  • Conversion re-serializes the geometry, so the output is not byte-identical to the original even when the format is unchanged.
  • Missing elevation stays missing; it is never written as zero.
  • Input files are limited to 20 MB and 200,000 coordinate points; larger files are rejected before processing.
舍入规则
Coordinates and elevation values are preserved as parsed; distance is reported to the nearest whole metre; file size is reported in bytes, with binary-friendly units only for display.

独立算例

期望值由独立算术或已核验算法得出,不由页面脚本生成。

case-track-convert-elevation独立算例

Independent round-trip check: the GeoJSON LineString has one segment and three positions. Two positions carry an elevation value (10 and 15); the middle point has no elevation and must not be replaced by zero. Conversion must preserve order and coordinates.

输入
{
  "sourceFormat": "geojson",
  "targetFormat": "geojson",
  "coordinates": [
    [
      0,
      0,
      10
    ],
    [
      0.001,
      0
    ],
    [
      0.002,
      0,
      15
    ]
  ]
}
期望
{
  "segmentCount": 1,
  "pointCount": 3,
  "elevationPointCount": 2
}

来源与证据

GPS Exchange Format (GPX) 1.1

GPX is an XML schema for exchanging GPS data. GPX 1.1 defines track, route and waypoint structures with latitude, longitude and optional elevation.

TopoGrafix · 查阅 2026年10月26日

RFC 7946: The GeoJSON Format

GeoJSON defines JSON-based geospatial objects including LineString coordinates. GeoJSON coordinates use longitude, latitude order and positions may include elevation.

Internet Engineering Task Force · 查阅 2026年10月26日

版本与审阅

撰写: RunMap editorial desk (AI-assisted draft and review)

更新于: 2026年10月28日

审阅于: 2026年10月28日 · 1 条审阅记录

返回全部工具