Skip to content

JS,XSLT, Julia, C and Swift tools to render GPX encoded geo tracks to a SVG path

License

Notifications You must be signed in to change notification settings

OpenDGPS/gpx-to-svg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gpx-to-svg

Some tools to render GPX encoded geo tracks to a SVG path.

The sample track (gpx/train-track.gpx) is generated by the iOS app Track (version 2.3) by 7SOLS.

The sample map (svg/italy-map.svg) is free licenced for non commercial use by https://www.amcharts.com/svg-maps/.

svg sample

Sample SVG rendering from multiple trips in Umbria, Italy.

1. XSLT

Reads SVG file as map and transform a new SVG file

The example file ('italy-map.svg') comes from https://www.amcharts.com/svg-maps/

If there is a path element with id="odgps-insert" it will replace this path with a new path generated from a GPX track.

The available tracks are defined in $doc-list as '' multiple files seperate by comma (sample: train-track.gpx)

The map has to be normalized. Set $lat-root to the coordinates of the top coordinates (svg position:y) and $lon-root to the very left coordinates (svg position:x)

Run:

java -jar <xslt2-processor> svg/italy-map.svg xslt/gpx-to-svg.xslt > out/out.svg

Run (with saxon):

java -jar saxon9.jar svg/italy-map.svg xslt/gpx-to-svg.xslt > out/out.svg

2. JavaScript

Read a track file via XmlHTTPRequest method, get all track points and build a pathString from @lat/@lon.

Run:

open italy-map-js.svg in your fav browser. 

Make sure to enable XmlHTTPRequest for file:// protocoll, otherwise run the request from a local http-server.

3. Julia

gpx-to-svg.jl uses LightXML to parse both the GPX track file and the SVG.

Currently not many more track entries than 1k can be parsed. Any number significant higher kills the Julia-kernel with no explanations. The error could be in the browser-backend communication or in the LightXML.

Run:

copy the gpx-to-svg.jl into a jupyter notebook and make sure the gpx/1k.gpx file is available  

4. C

The C implementation (c/gpx-to-svg.c) use libxml2 to read, parse and write both the SVG and the GPX files. The sample GPX (gpx/train-track.gpx) contains 7000+ track points. With under 0.2 sec on a MacBook (2,4GHz Core 2 Duo) it is of course the fastest solution.

Compile:

gcc -Wall -lxml2 -I /usr/include/libxml2 -o c/xpath c/xpath.c

Run:

c/xpath <SVG file> <GPX file>

5. Swift (<=2.3)

The Swift implementation (swift/gpx-to-svg.swift) use Fuzi XML/XPath Framework (https://github.com/cezheng/Fuzi) to read, parse and write both the SVG and the GPX files. Even if this is a first draft it is fast as the C version. Mainly because both make heavily usage of libXML2.

Usage: create a new Project in XCode, replace the main.swift with the content of gpx-to-svg.swift, follow the instructions auf Fuzi and add the 1k.gpx to the project.

About

JS,XSLT, Julia, C and Swift tools to render GPX encoded geo tracks to a SVG path

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published