Code Monkey home page Code Monkey logo

gpx-layer's Introduction

gpx-layer

This is a set of scripts for turning a set of GPS tracks in GPX format into a map tracing layer.

Installation

To start out, get a copy of this repository and of datamaps:

$ git clone https://github.com/ericfischer/gpx-layer.git
$ git clone https://github.com/ericfischer/datamaps.git

If you don't already have it, make sure your system has libxml-parser-perl for XML parsing and libpng-dev and pngquant for generating map tiles

$ sudo apt-get install libxml-parser-perl libpng-dev pngquant

Go into the datamaps directory and compile it:

$ cd datamaps
$ make

Then come back here:

$ cd ../gpx-layer

Extracting points from GPX files

The next step is to extract tracks from your GPX files and index them by location. If you keep your files in ~/gpx, index them into a new datamaps directory called gpx.dm by doing

$ find ~/gpx -name '*.gpx' -print0 | xargs -0 ./parse-gpx | ../datamaps/encode -z20 -m8 -o gpx.dm

The -z20 option means to index with enough precision to draw map tiles at zoom level 20. The -m8 option means that there are 8 bits of metadata (in this case, the direction that the GPS is moving) associated with each entry in the file.

If you keep your GPX files in a directory other than ~/gpx, use the name of that directory instead.

If you already have an old gpx.dm directory, you'll first need to

$ rm -r gpx.dm

to get rid of it before you can index new tracks into it.

Making map tiles

Then it is time to make map tiles out of the data. You can do this with

$ ../datamaps/enumerate -s -z18 gpx.dm | xargs -L1 -P8 ./make-tile

This will take a few minutes if you have a few million points in your GPX files, or hours and hours if you have billions.

If you don't want to go all the way to zoom level 18 (or if you want to go even deeper), you can use a different number instead of -z18. If your computer has more than 8 processors, you can use a different number instead of -P8.

Trying out your map tiles

The previous step will have placed the map tiles into a directory called tiles/gpx.dm.

If you the directory you are working in is accessible from a web browser, there is a file called test.html that is already set up to show tiles/gpx.dm in a web map. (You will probably need to scroll and zoom to see anything, since it doesn't know where your GPS tracks are located and is probably pointed to the wrong part of the earth.)

Otherwise, you'll need to copy the tiles directory to a web server to try it out.

Adding your tiles as a tracing layer in iD

To use your tiles in iD, they really need to be on a web server, and you need to make a copy of iD on the web server (or some other web server) too.

On my home machine, the root directory of the web server is /var/www, so I copied my tiles directory into a directory there called tracing with

$ sudo -s
# rsync -vax tiles /var/www/tracing

Then I also checked out a copy of iD in that directory:

# cd /var/www/tracing
# git clone https://github.com/systemed/iD.git

The tricky part is that you then have to edit iD's data/imagery.json file to include your new layer.

The simplest thing is to add it like this at the start, right after the opening bracket:

{
    "name": "GPX overlay",
    "template": "/tracing/tiles/gpx.dm/{z}/{x}/{y}.png",
    "overlay": true,
    "scaleExtent": [ 0, 18 ],
    "extent": [ [ -180.00, -90.00 ], [ 180.00, 90.00 ] ]
},

even though this overstates the area where the layer is relevant. Be sure to include the trailing comma after the closing brace. It's easy to leave off by accident.

You can then open up your modified copy of iD (http://localhost/tracing/iD or wherever you put it instead) in a web browser and turn your new layer on in the Layers popup at the right:

Looking for missing streets

The layer you turn on last draws on top of the other layers, so one nice thing this enables is looking for streets that are missing from the map but are in the GPS logs.

Turn the Locator Overlay off and back on again, and then it looks like this:

with only the GPS tracks that don't quite correspond to streets showing through. In this case, the map of San Francisco is pretty complete, so all that shows through is the ferry route to Sausalito, the Exploratorium pier, and some noise downtown from bad GPS reception.

Using the layer this way is usually practical from zooms 12 to 15, where it is zoomed in enough that the Locator Overlay shows all the streets instead of only the major ones, but not zoomed in enough that iD switches from display to editing.

gpx-layer's People

Contributors

e-n-f avatar

Stargazers

 avatar Ilya Zverev avatar Markus Kohler avatar Martin Raifer avatar Aaron Lidman avatar François Van Der Biest avatar Jon avatar

Watchers

James Cloos avatar  avatar  avatar

gpx-layer's Issues

Some GPS tracks appear to have been rendered with points out-of-order

This spot in Sheffield, UK, shows some weird fragmentary traces on your GPS tiles:
http://bl.ocks.org/ericfischer/raw/713d24985c9a4a085629/#18/53.37675/-1.49182
(I get the same issue when looking using this site or when using iD)

But when I download GPS for the same area using JOSM, I see GPS tracks which are equivalent except they are not weird. Judging by eye, it looks like somehow your renderer might be tripping up and getting the trackpoints in the wrong time-order.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.