将 GeoJson 转换为 GPX
被设计为浏览器库. 将 Gpx XMLDocument 解释一个 Geojson 对象 。 从那里您可以将其转换成字符串,下载或张贴文档.
可以和节点一起使用,不过可以做一些诸如:
import { DOMImplementation } from '@xmldom/xmldom';
import GeoJsonToGpx from "@dwayneparton/geojson-to-gpx"
const implementation = new DOMImplementation();
const gpx = GeoJsonToGpx(geojson, options, implementation);
捐款
欢迎捐款.
目标和参数
- 0 依赖性
- 轻巧
- i/o - GeoJson - > XML文档
- 司马 https://www.topografix.com/GPX/1/1/ 互联网档案馆的存檔,存档日期2014-12-11
安装
npm install @dwayneparton/geojson-to-gpx
支助
乔治·杰森
- 特性
- 特性集合 - 每个特性( LineSting QQMultiLine String) 被解释为它自己的trk, (Point QMultipoint) 将会被新 wtt
地貌图
- 点
- 多点 - 为每个点添加 wpt
- 线条
- MultiLineString - 每个链接字符串被分解成一个净trkseg
不相容的地美图被忽略了. 为什么? GPX格式用于存储出行点,出行道,出行道.
示例
这些示例将geijson对象转换为gpx文件,供用户下载.
import GeoJsonToGpx from "@dwayneparton/geojson-to-gpx"
const options = {
metadata: {
name: 'A grand adventure',
author: {
name: 'Dwayne Parton',
link: {
href: 'https://www.dwayneparton.com'
}
}
}
}
const geojson = {
type: "Feature",
properties : {
name : 'Slow journey from null island'
},
geometry: {
type: "LineString",
coordinates: [
[0.0, 0.0],
[0.0, 1.0],
[0.0, 2.0],
[0.0, 3.0]
]
},
};
// Will convert geojson into xml document
const gpx = GeoJsonToGpx(geojson, options);
// convert document to string or post process it
const gpxString = new XMLSerializer().serializeToString(gpx);
// @see https://stackoverflow.com/questions/10654971/create-text-file-from-string-using-js-and-html5
const link = document.createElement('a');
link.download = 'geojson-to-gpx.gpx';
const blob = new Blob([gpxString], {type: 'text/xml'});
link.href = window.URL.createObjectURL(blob);
link.click();