Giter VIP home page Giter VIP logo

org-osm's Introduction

OSM maps in Emacs and Org mode

osm-maps.el provides functions to produce SVG images with PNG map tiles as backgrounds and your tracks on top of them. Tracks are made of lists of pairs of coordinates.

Implemented features

  • Download and caching of background tiles. Sources are OSM (default) or google maps.
  • Optionally use online resources as background tiles.
  • Maps are saved as SVG files and thus may share cached background tiles.
  • Working Org links. The link type is track:. Clicking a track: link pops up a map of the track. The map is created if it does not exist yet.
  • Interactive creation of Org track: links.
  • HTML export of links and maps. Maps will be modified to work in the publishing directory and are referenced through hyperlinks (customizable).
  • LaTeX export of links. Maps will be referenced by a hyperlink.
  • Import org track links from GPX files semi-interactively.
  • Export org track links to GPX. Either the next link or all links in a region. Each track is added only once, provided track-filename and choords match.
  • org-track-extract.pl extracts tracks from your org file again and prints statistics or a GPX file. The export may be restricted to a subtre and/or a certain number of tracks. Here is an example:
    org-track-extract.pl --max 2 --format gpx \
           --subtree 4.1.1 ~/training.org 2>debug.log
        
  • SVGs may be published along with your Org-files. See Publishing Setup below.

Setup

Just make sure osm-maps.el and org-osm-link.el are in your load-path, and add this line to your setup (.emacs probably):

(require 'org-osm-link)

After restarting Emacs (or evalutating the code above) you may customize the new OSM features:

M-x customize-group RET osm-maps RET

The most important feature is to adjust ist the caching behaviour. This is currently controlled by the variable osm-do-cache. If this variable is non-nil, the background tiles are downloaded and stored to disc for local (fast) use. I use symbolic links, to make the tiles available in several directories.

Be careful! Caching can take hours on slow connections for bigger areas. But only once per zoom level though. The area I use for my training diary uses 26 MB disc space currently for tiles with zoom-level 15.

Producing the images without caching is just as fast, but you will need to be online when browsing the results. Also, you’ll need to be patient when visiting maps that use online resources (background tiles on OSM servers). In the future I hope to restrict the caching to certain customizable areas.

What do the links look like?

A link to a track looks like this:

[[track:((9.707032442092896 52.37033874553582)(9.711474180221558 52.375238282987))FILENAME.svg][DESCRIPTION]]
               ^^^               ^^^
            longitude          latitude

…or this (filename first):

[[track:FILENAME.svg((9.707032442092896 52.37033874553582)(9.711474180221558 52.375238282987))][DESCRIPTION]]

Negative latitudes are on the southern hemisphere.

Once you click the link the image is created for you and shown in a new buffer. Existing tracks are re-used. You may provide a custom funciton to show the images. See the docs for the custom variable `osm-org-image-viewer-function’ in org-osm-link.el.

How to insert track links easily

There are two ways to insert links appart from adding them by hand.

  1. M-x osm-org-compose-link asks for the list of coords, the filename and the link description and inserts the link at point.
  2. M-x osm-org-gpx-to-links asks for a gpx file to read and inserts all the tracks found in that file interactively.

How to publish the maps with HTML?

See the docs for `osm-publish-map-for-html’ in org-osm-link.el (or simply type C-h f osm-pu TAB RET).

Can I export osm-org track: links to GPX?

Yes. From within Emacs use

M-X osm-org-track-links-to-gpx

which works on the track: link point is in or the next link found. If a region is active, export all track: links found in there to a single GPX file.

From the command line, use org-track-extract.pl like this:

perl org-track-extract.pl -f gpx path-to-file.org

Will extract all track: links in path-to-file.org and write a complete GPX file to stdout.

For more information try

perl org-track-extract.pl -h

Caveats

Crashes caused by looong lines in tooltips

Did not see this bug for long time now, though. I use the bleeding edge emacs from git…

Emacs used to crash every now and so often when I moved the mouse over a track link. This was caused by a bug with those very long lines in tooltips. You can avoid tooltips per file by adding these lines to the end of your training diaries:

# Local Variables:
# eval: (tooltip-mode -1)
# End:

Publishing Setup

This is my publishing setup. Well - the short version :)

(setq org-publish-project-alist
      '(
        ;; Publishes the HTML pages.
        ;; NOTE, that the OSM map tile directory is excluded!
        ("org-notes"
         :base-directory "~/org/notes/"
         :recursive t
         :base-extension "org"
         ;; this could be: "/ssh:user@host:~/html/notebook/"
         :publishing-directory "~/public_html/org-notes/"
         :publishing-function org-html-publish-to-html
         :exclude "OSM"
         )

        ;; Publish the tracks
        ("org-osm-maps"
         :base-directory "~/org/notes/tracks/"
         :publishing-directory "~/public_html/tracks/"
         :recursive t
         :base-extension "svg"
         :osm-cache-directory "~/org/notes/img/OSM/"
         :publishing-function osm-publish-map-for-html
         )

        ;; Publishing static content.
        ;; AGAIN:  The OSM map tile directory is excluded!
        ("org-notes-static"
         :base-directory "~/org/notes/"
         :exclude "OSM\\|oman-2010"
         :recursive t
         :base-extension "css\\|js\\|png\\|jpg\\|gif\\|ico\\|pdf\\|mp3\\|ogg\\|swf\\|txt\\|htm\\|html\\|dtd\\|php"
         :publishing-directory "~/public_html/org-notes/"
         :publishing-function org-publish-attachment)

        ("org" :components ("org-notes" "org-osm-maps" "org-notes-static"))))

Things you might wanna add

  • Better documentation.
  • Configure zoom levels and areas to cache the images for. Produce SVGs with online tiles for tracks outside of those areas, use the cached tile for tracks in those areas.
  • Produce a draggable JavaScript map on HTML export.
  • Reuse the draggable JavaScript map to draw new tracks.
  • Allow for POIs.
  • Draw kilometer or mile markers.
  • Configure start and destination icons.
  • Allow for multiple tracks on one map.
  • Draw a legend.
  • Restrict images to a certain size and adjust the zoom level accordingly.
  • Restrict the caching to certain customizable areas.
  • HTML export: Produce thumbnails and link to bigger images.

org-osm's People

Watchers

Pavel Tokarev avatar

Forkers

whrl

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.