開放街圖標誌 OpenStreetMap 開放街圖

Hiking relations in wiki table

於 2018年十二月10日 由 CascaficoItalian (Italiano)發表。

Intro

When adding several hiking routes, sometime it comes handy having updated tables in wiki format to be easily added in specific wiki pages.

Recipe

  • overpass query on area name
  • some awk insertions
  • pyhon script csv2wiki

overpass-query

This overpass query will generate a csv file(ie: stregna.csv) with local network hiking paths. Example output:

@id,name,ref,network
2071931,,747,lwn
6934010,Sentiero Italia - Tappa A14,SI,lwn
7112799,Sentiero Hum,,lwn

This awk will add OSM link to each relation:
$ awk -F “,” ‘FNR == 1 {print $0} FNR > 1 { print “[osm.org/relation/”$1” “$1”],”$2”,”$3”,”$4 }’ stregna.csv > stregna.txt

actual wiki formatting

Python script will generate the actual wiki text:
$ python csv2wiki stregna.txt > stregna.wiki

summarizing script

This script performs the steps above (here you can customize query with whatever relation tags). Just provide an OSM area name.

電子郵件圖示 藍天圖示 Facebook 圖示 LinkedIn 圖示 乳齒象圖示 Telegram 圖示 X 圖示

討論

ikonor2018年12月10日 17時24分 發表的評論

Thanks for sharing.

I always thought that it would be nice to replace those routes wiki tables with dynamically generated ones in HTML/JavaScript.

There was an attempt to add a table tab to Overpass Turbo, but unfortunately didn’t complete.

Or a dedicated web page that can list relations of a given type for a specific area, e.g. using DataTables or similar, and maybe show a map next to it. Completion percentage could be calculated from the distance tag and the actual length of the way members.

qwerty222018年12月11日 22時55分 發表的評論

Thanks for sharing. It is very useful for me.

登入 來留下評論