├── web
├── public
│ ├── download
│ ├── js
│ │ ├── d3
│ │ │ ├── README
│ │ │ ├── LICENSE
│ │ │ └── LICENSE-d3.layout.cloud
│ │ ├── customSelect.jquery.min.js
│ │ ├── jquery.cookie-minified.js
│ │ └── customSelect.jquery.js
│ ├── favicon.ico
│ ├── img
│ │ ├── arrow.png
│ │ ├── error.png
│ │ ├── turbo.png
│ │ ├── logo
│ │ │ ├── by.png
│ │ │ ├── ch.png
│ │ │ ├── ee.png
│ │ │ ├── fr.png
│ │ │ ├── ie.png
│ │ │ ├── it.png
│ │ │ ├── lv.png
│ │ │ ├── ru.png
│ │ │ ├── ua.png
│ │ │ ├── test.png
│ │ │ ├── world.png
│ │ │ ├── taginfo.png
│ │ │ └── taginfo_with_bar.png
│ │ ├── indicator.gif
│ │ ├── mapbg
│ │ │ └── world.png
│ │ ├── sources
│ │ │ ├── db.16.png
│ │ │ ├── db.24.png
│ │ │ ├── db.32.png
│ │ │ ├── db.48.png
│ │ │ ├── db.64.png
│ │ │ ├── db.128.png
│ │ │ ├── josm.128.png
│ │ │ ├── josm.16.png
│ │ │ ├── josm.24.png
│ │ │ ├── josm.32.png
│ │ │ ├── josm.64.png
│ │ │ ├── wiki.16.png
│ │ │ ├── wiki.24.png
│ │ │ ├── wiki.32.png
│ │ │ ├── languages.16.png
│ │ │ ├── languages.24.png
│ │ │ ├── languages.32.png
│ │ │ ├── potlatch.16.png
│ │ │ ├── potlatch.24.png
│ │ │ ├── potlatch.32.png
│ │ │ ├── potlatch.64.png
│ │ │ ├── projects.16.png
│ │ │ ├── projects.24.png
│ │ │ ├── projects.32.png
│ │ │ ├── projects.48.png
│ │ │ └── wiki
│ │ │ │ ├── wiki-e.png
│ │ │ │ ├── wiki-n.png
│ │ │ │ ├── wiki-p.png
│ │ │ │ ├── wiki-r.png
│ │ │ │ └── wiki-t.png
│ │ ├── types
│ │ │ ├── all.16.png
│ │ │ ├── all.20.png
│ │ │ ├── all.24.png
│ │ │ ├── all.32.png
│ │ │ ├── area.16.png
│ │ │ ├── area.20.png
│ │ │ ├── area.24.png
│ │ │ ├── area.32.png
│ │ │ ├── node.16.png
│ │ │ ├── node.20.png
│ │ │ ├── node.24.png
│ │ │ ├── node.32.png
│ │ │ ├── none.16.png
│ │ │ ├── tag.16.png
│ │ │ ├── tag.20.png
│ │ │ ├── tag.24.png
│ │ │ ├── tag.32.png
│ │ │ ├── way.16.png
│ │ │ ├── way.20.png
│ │ │ ├── way.24.png
│ │ │ ├── way.32.png
│ │ │ ├── relation.16.png
│ │ │ ├── relation.20.png
│ │ │ ├── relation.24.png
│ │ │ ├── relation.32.png
│ │ │ ├── closed_way.16.png
│ │ │ ├── closed_way.20.png
│ │ │ ├── closed_way.24.png
│ │ │ └── closed_way.32.png
│ │ └── generic_project_icon.png
│ ├── css
│ │ ├── flexigrid
│ │ │ └── images
│ │ │ │ ├── bg.gif
│ │ │ │ ├── ddn.png
│ │ │ │ ├── dn.png
│ │ │ │ ├── fhbg.gif
│ │ │ │ ├── hl.png
│ │ │ │ ├── last.gif
│ │ │ │ ├── line.gif
│ │ │ │ ├── load.gif
│ │ │ │ ├── load.png
│ │ │ │ ├── next.gif
│ │ │ │ ├── prev.gif
│ │ │ │ ├── up.png
│ │ │ │ ├── uup.png
│ │ │ │ ├── wbg.gif
│ │ │ │ ├── first.gif
│ │ │ │ ├── magnifier.png
│ │ │ │ ├── btn-sprite.gif
│ │ │ │ └── load-large.gif
│ │ └── smoothness
│ │ │ └── images
│ │ │ ├── ui-icons_222222_256x240.png
│ │ │ ├── ui-icons_2e83ff_256x240.png
│ │ │ ├── ui-icons_454545_256x240.png
│ │ │ ├── ui-icons_888888_256x240.png
│ │ │ ├── ui-icons_cd0a0a_256x240.png
│ │ │ ├── ui-bg_flat_0_aaaaaa_40x100.png
│ │ │ ├── ui-bg_flat_75_ffffff_40x100.png
│ │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png
│ │ │ ├── ui-bg_glass_65_ffffff_1x400.png
│ │ │ ├── ui-bg_glass_75_dadada_1x400.png
│ │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png
│ │ │ ├── ui-bg_glass_95_fef1ec_1x400.png
│ │ │ └── ui-bg_highlight-soft_75_cccccc_1x100.png
│ └── robots.txt
├── viewsjs
│ ├── compare.js.erb
│ ├── reports
│ │ ├── database_statistics.js.erb
│ │ ├── wiki_pages_about_non_existing_keys.js.erb
│ │ ├── josm_styles.js.erb
│ │ ├── languages.js.erb
│ │ ├── language_comparison_table_for_keys_in_the_wiki.js.erb
│ │ └── frequently_used_keys_without_wiki_page.js.erb
│ ├── taginfo
│ │ └── i18n.js.erb
│ ├── projects.js.erb
│ ├── texts.js.erb
│ ├── project.js.erb
│ ├── relations.js.erb
│ ├── tags.js.erb
│ └── keys.js.erb
├── views
│ ├── keys.erb
│ ├── tags.erb
│ ├── reports
│ │ ├── languages.erb
│ │ ├── wiki_pages_about_non_existing_keys.erb
│ │ ├── index.erb
│ │ ├── josm_styles.erb
│ │ ├── key_lengths.erb
│ │ ├── frequently_used_keys_without_wiki_page.erb
│ │ ├── language_comparison_table_for_keys_in_the_wiki.erb
│ │ ├── name_tags.erb
│ │ └── characters_in_keys.erb
│ ├── not_found.erb
│ ├── projects.erb
│ ├── relations.erb
│ ├── test
│ │ ├── index.erb
│ │ └── wiki_import.erb
│ ├── taginfo
│ │ ├── project_error_log.erb
│ │ ├── config.erb
│ │ ├── translations.erb
│ │ ├── i18n.erb
│ │ ├── index.erb
│ │ ├── projects.erb
│ │ └── apidoc.erb
│ ├── search_tags.erb
│ ├── help
│ │ ├── search.erb
│ │ └── keyboard.erb
│ ├── about.erb
│ ├── embed
│ │ ├── layout.erb
│ │ ├── relation.erb
│ │ ├── key.erb
│ │ └── tag.erb
│ ├── download.erb
│ ├── search.erb
│ ├── sources.erb
│ ├── project.erb
│ ├── index.erb
│ └── relation.erb
├── lib
│ ├── ui
│ │ ├── help.rb
│ │ ├── test.rb
│ │ ├── reports.rb
│ │ ├── projects.rb
│ │ ├── embed.rb
│ │ ├── relation.rb
│ │ ├── keys.rb
│ │ ├── tags.rb
│ │ └── search.rb
│ ├── language.rb
│ ├── config.rb
│ ├── reports.rb
│ ├── api
│ │ └── v4
│ │ │ ├── site.rb
│ │ │ ├── josm.rb
│ │ │ ├── projects.rb
│ │ │ ├── wiki.rb
│ │ │ ├── project.rb
│ │ │ └── relations.rb
│ ├── sources.rb
│ └── javascript.rb
├── rakefile.rb
├── config.ru
└── test
│ ├── test_utils.rb
│ └── test_sql.rb
├── sources
├── db
│ ├── tagstats
│ ├── show_selection_stats.sql
│ ├── update.sh
│ └── update_characters.rb
├── languages
│ ├── post.sql
│ ├── pre.sql
│ ├── update.sh
│ └── import_unicode_scripts.rb
├── wiki
│ ├── cache.sql
│ ├── README
│ ├── update.sh
│ ├── lib
│ │ └── mediawikiapi.rb
│ └── pre.sql
├── potlatch
│ ├── post.sql
│ ├── pre.sql
│ ├── update.sh
│ └── import_potlatch.rb
├── master
│ ├── history_init.sql
│ ├── history_update.sql
│ ├── search.sql
│ ├── update.sh
│ └── selection.sql
├── init.sql
├── josm
│ ├── post.sql
│ ├── pre.sql
│ └── update.sh
├── projects
│ ├── post.sql
│ ├── update.sh
│ ├── project_list.txt
│ ├── pre.sql
│ └── import.rb
└── update_all.sh
├── tagstats
├── .gitignore
├── README
├── test_tagstats.sh
├── osmstats.cpp
├── Makefile
└── string_store.hpp
├── projects
└── osm-mug.png
├── bin
├── taginfo-config.rb
├── test_langtags.rb
└── check-translations.rb
├── examples
├── get_distribution_image.rb
├── jsonp.html
└── tapi
└── README.md
/web/public/download:
--------------------------------------------------------------------------------
1 | ../../../download
--------------------------------------------------------------------------------
/sources/db/tagstats:
--------------------------------------------------------------------------------
1 | ../../tagstats/tagstats
--------------------------------------------------------------------------------
/web/public/js/d3/README:
--------------------------------------------------------------------------------
1 |
2 | http://d3js.org/
3 |
4 |
--------------------------------------------------------------------------------
/tagstats/.gitignore:
--------------------------------------------------------------------------------
1 | tagstats
2 | osmstats
3 | taginfo-db.db
4 |
--------------------------------------------------------------------------------
/projects/osm-mug.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/projects/osm-mug.png
--------------------------------------------------------------------------------
/web/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/favicon.ico
--------------------------------------------------------------------------------
/web/public/img/arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/arrow.png
--------------------------------------------------------------------------------
/web/public/img/error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/error.png
--------------------------------------------------------------------------------
/web/public/img/turbo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/turbo.png
--------------------------------------------------------------------------------
/web/public/img/logo/by.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/logo/by.png
--------------------------------------------------------------------------------
/web/public/img/logo/ch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/logo/ch.png
--------------------------------------------------------------------------------
/web/public/img/logo/ee.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/logo/ee.png
--------------------------------------------------------------------------------
/web/public/img/logo/fr.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/logo/fr.png
--------------------------------------------------------------------------------
/web/public/img/logo/ie.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/logo/ie.png
--------------------------------------------------------------------------------
/web/public/img/logo/it.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/logo/it.png
--------------------------------------------------------------------------------
/web/public/img/logo/lv.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/logo/lv.png
--------------------------------------------------------------------------------
/web/public/img/logo/ru.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/logo/ru.png
--------------------------------------------------------------------------------
/web/public/img/logo/ua.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/logo/ua.png
--------------------------------------------------------------------------------
/web/public/img/indicator.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/indicator.gif
--------------------------------------------------------------------------------
/web/public/img/logo/test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/logo/test.png
--------------------------------------------------------------------------------
/web/public/img/logo/world.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/logo/world.png
--------------------------------------------------------------------------------
/web/public/img/mapbg/world.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/mapbg/world.png
--------------------------------------------------------------------------------
/web/public/img/logo/taginfo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/logo/taginfo.png
--------------------------------------------------------------------------------
/web/public/img/sources/db.16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/db.16.png
--------------------------------------------------------------------------------
/web/public/img/sources/db.24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/db.24.png
--------------------------------------------------------------------------------
/web/public/img/sources/db.32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/db.32.png
--------------------------------------------------------------------------------
/web/public/img/sources/db.48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/db.48.png
--------------------------------------------------------------------------------
/web/public/img/sources/db.64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/db.64.png
--------------------------------------------------------------------------------
/web/public/img/types/all.16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/all.16.png
--------------------------------------------------------------------------------
/web/public/img/types/all.20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/all.20.png
--------------------------------------------------------------------------------
/web/public/img/types/all.24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/all.24.png
--------------------------------------------------------------------------------
/web/public/img/types/all.32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/all.32.png
--------------------------------------------------------------------------------
/web/public/img/types/area.16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/area.16.png
--------------------------------------------------------------------------------
/web/public/img/types/area.20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/area.20.png
--------------------------------------------------------------------------------
/web/public/img/types/area.24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/area.24.png
--------------------------------------------------------------------------------
/web/public/img/types/area.32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/area.32.png
--------------------------------------------------------------------------------
/web/public/img/types/node.16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/node.16.png
--------------------------------------------------------------------------------
/web/public/img/types/node.20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/node.20.png
--------------------------------------------------------------------------------
/web/public/img/types/node.24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/node.24.png
--------------------------------------------------------------------------------
/web/public/img/types/node.32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/node.32.png
--------------------------------------------------------------------------------
/web/public/img/types/none.16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/none.16.png
--------------------------------------------------------------------------------
/web/public/img/types/tag.16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/tag.16.png
--------------------------------------------------------------------------------
/web/public/img/types/tag.20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/tag.20.png
--------------------------------------------------------------------------------
/web/public/img/types/tag.24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/tag.24.png
--------------------------------------------------------------------------------
/web/public/img/types/tag.32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/tag.32.png
--------------------------------------------------------------------------------
/web/public/img/types/way.16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/way.16.png
--------------------------------------------------------------------------------
/web/public/img/types/way.20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/way.20.png
--------------------------------------------------------------------------------
/web/public/img/types/way.24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/way.24.png
--------------------------------------------------------------------------------
/web/public/img/types/way.32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/way.32.png
--------------------------------------------------------------------------------
/web/public/img/sources/db.128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/db.128.png
--------------------------------------------------------------------------------
/web/public/img/sources/josm.128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/josm.128.png
--------------------------------------------------------------------------------
/web/public/img/sources/josm.16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/josm.16.png
--------------------------------------------------------------------------------
/web/public/img/sources/josm.24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/josm.24.png
--------------------------------------------------------------------------------
/web/public/img/sources/josm.32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/josm.32.png
--------------------------------------------------------------------------------
/web/public/img/sources/josm.64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/josm.64.png
--------------------------------------------------------------------------------
/web/public/img/sources/wiki.16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/wiki.16.png
--------------------------------------------------------------------------------
/web/public/img/sources/wiki.24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/wiki.24.png
--------------------------------------------------------------------------------
/web/public/img/sources/wiki.32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/wiki.32.png
--------------------------------------------------------------------------------
/web/public/img/types/relation.16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/relation.16.png
--------------------------------------------------------------------------------
/web/public/img/types/relation.20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/relation.20.png
--------------------------------------------------------------------------------
/web/public/img/types/relation.24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/relation.24.png
--------------------------------------------------------------------------------
/web/public/img/types/relation.32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/relation.32.png
--------------------------------------------------------------------------------
/web/viewsjs/compare.js.erb:
--------------------------------------------------------------------------------
1 | function page_init() {
2 | up = function() { window.location = '/'; }
3 | page_init2();
4 | }
5 |
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/bg.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/bg.gif
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/ddn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/ddn.png
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/dn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/dn.png
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/fhbg.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/fhbg.gif
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/hl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/hl.png
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/last.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/last.gif
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/line.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/line.gif
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/load.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/load.gif
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/load.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/load.png
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/next.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/next.gif
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/prev.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/prev.gif
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/up.png
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/uup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/uup.png
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/wbg.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/wbg.gif
--------------------------------------------------------------------------------
/web/public/img/generic_project_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/generic_project_icon.png
--------------------------------------------------------------------------------
/web/public/img/logo/taginfo_with_bar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/logo/taginfo_with_bar.png
--------------------------------------------------------------------------------
/web/public/img/sources/languages.16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/languages.16.png
--------------------------------------------------------------------------------
/web/public/img/sources/languages.24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/languages.24.png
--------------------------------------------------------------------------------
/web/public/img/sources/languages.32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/languages.32.png
--------------------------------------------------------------------------------
/web/public/img/sources/potlatch.16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/potlatch.16.png
--------------------------------------------------------------------------------
/web/public/img/sources/potlatch.24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/potlatch.24.png
--------------------------------------------------------------------------------
/web/public/img/sources/potlatch.32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/potlatch.32.png
--------------------------------------------------------------------------------
/web/public/img/sources/potlatch.64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/potlatch.64.png
--------------------------------------------------------------------------------
/web/public/img/sources/projects.16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/projects.16.png
--------------------------------------------------------------------------------
/web/public/img/sources/projects.24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/projects.24.png
--------------------------------------------------------------------------------
/web/public/img/sources/projects.32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/projects.32.png
--------------------------------------------------------------------------------
/web/public/img/sources/projects.48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/projects.48.png
--------------------------------------------------------------------------------
/web/public/img/sources/wiki/wiki-e.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/wiki/wiki-e.png
--------------------------------------------------------------------------------
/web/public/img/sources/wiki/wiki-n.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/wiki/wiki-n.png
--------------------------------------------------------------------------------
/web/public/img/sources/wiki/wiki-p.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/wiki/wiki-p.png
--------------------------------------------------------------------------------
/web/public/img/sources/wiki/wiki-r.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/wiki/wiki-r.png
--------------------------------------------------------------------------------
/web/public/img/sources/wiki/wiki-t.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/sources/wiki/wiki-t.png
--------------------------------------------------------------------------------
/web/public/img/types/closed_way.16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/closed_way.16.png
--------------------------------------------------------------------------------
/web/public/img/types/closed_way.20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/closed_way.20.png
--------------------------------------------------------------------------------
/web/public/img/types/closed_way.24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/closed_way.24.png
--------------------------------------------------------------------------------
/web/public/img/types/closed_way.32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/img/types/closed_way.32.png
--------------------------------------------------------------------------------
/web/viewsjs/reports/database_statistics.js.erb:
--------------------------------------------------------------------------------
1 | function page_init() {
2 | up = function() { window.location = '/reports'; };
3 | }
4 |
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/first.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/first.gif
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/magnifier.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/magnifier.png
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/btn-sprite.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/btn-sprite.gif
--------------------------------------------------------------------------------
/web/public/css/flexigrid/images/load-large.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/flexigrid/images/load-large.gif
--------------------------------------------------------------------------------
/web/public/css/smoothness/images/ui-icons_222222_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/smoothness/images/ui-icons_222222_256x240.png
--------------------------------------------------------------------------------
/web/public/css/smoothness/images/ui-icons_2e83ff_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/smoothness/images/ui-icons_2e83ff_256x240.png
--------------------------------------------------------------------------------
/web/public/css/smoothness/images/ui-icons_454545_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/smoothness/images/ui-icons_454545_256x240.png
--------------------------------------------------------------------------------
/web/public/css/smoothness/images/ui-icons_888888_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/smoothness/images/ui-icons_888888_256x240.png
--------------------------------------------------------------------------------
/web/public/css/smoothness/images/ui-icons_cd0a0a_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/smoothness/images/ui-icons_cd0a0a_256x240.png
--------------------------------------------------------------------------------
/web/public/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
--------------------------------------------------------------------------------
/web/public/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
--------------------------------------------------------------------------------
/web/public/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
--------------------------------------------------------------------------------
/web/public/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
--------------------------------------------------------------------------------
/web/public/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png
--------------------------------------------------------------------------------
/web/public/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
--------------------------------------------------------------------------------
/web/public/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
--------------------------------------------------------------------------------
/web/public/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ubahnverleih/taginfo/master/web/public/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
--------------------------------------------------------------------------------
/sources/languages/post.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Taginfo source: Languages
3 | --
4 | -- post.sql
5 | --
6 |
7 | .bail ON
8 |
9 |
10 |
11 | ANALYZE;
12 |
13 | UPDATE source SET update_end=datetime('now');
14 |
15 |
--------------------------------------------------------------------------------
/web/views/keys.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= h(t.osm.keys) %>
3 |
<%= h(t.pages.keys.intro) %>
4 |
5 |
9 |
--------------------------------------------------------------------------------
/web/views/tags.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= h(t.osm.tags) %>
3 |
<%= h(t.pages.tags.intro) %>
4 |
5 |
9 |
--------------------------------------------------------------------------------
/web/views/reports/languages.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= h(t.reports.languages.name) %>
3 | <%= t.reports.languages.intro %>
4 |
5 |
9 |
--------------------------------------------------------------------------------
/web/views/not_found.erb:
--------------------------------------------------------------------------------
1 |
2 |
404 <%= h(t.pages.not_found.title) %>
3 | <%= h(t.pages.not_found.intro) %>
4 |
5 |
--------------------------------------------------------------------------------
/web/viewsjs/taginfo/i18n.js.erb:
--------------------------------------------------------------------------------
1 | function page_init() {
2 | jQuery('span[title]').tipsy({ opacity: 1, delayIn: 500, gravity: 'w' });
3 | jQuery('#lang').bind('change', function() {
4 | jQuery('form').submit();
5 | });
6 | }
7 |
--------------------------------------------------------------------------------
/web/views/projects.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= h(t.taginfo.projects) %>
3 |
<%= t.pages.projects.intro %>
4 |
5 |
9 |
--------------------------------------------------------------------------------
/web/views/relations.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= h(t.pages.relations.name) %>
3 |
<%= t.pages.relations.intro %>
4 |
5 |
9 |
--------------------------------------------------------------------------------
/sources/db/show_selection_stats.sql:
--------------------------------------------------------------------------------
1 |
2 | SELECT ' interesting_tags count ......... ', count(*) FROM interesting_tags;
3 | SELECT ' frequent_tags count ............ ', count(*) FROM frequent_tags;
4 | SELECT ' interesting_relation_types count ', count(*) FROM interesting_relation_types;
5 |
6 |
--------------------------------------------------------------------------------
/web/lib/ui/help.rb:
--------------------------------------------------------------------------------
1 | # web/lib/ui/help.rb
2 | class Taginfo < Sinatra::Base
3 |
4 | get '/help/keyboard' do
5 | erb :'help/keyboard', :layout => false
6 | end
7 |
8 | get '/help/search' do
9 | erb :'help/search', :layout => false
10 | end
11 |
12 | end
13 |
--------------------------------------------------------------------------------
/web/rakefile.rb:
--------------------------------------------------------------------------------
1 | require 'rake'
2 | require 'rake/testtask'
3 | #require 'rake/clean'
4 |
5 | $: << 'lib'
6 |
7 | task :default => :test
8 |
9 | desc "Run the tests"
10 | Rake::TestTask::new do |t|
11 | t.test_files = FileList['test/test_*.rb']
12 | t.verbose = true
13 | end
14 |
15 |
--------------------------------------------------------------------------------
/web/views/reports/wiki_pages_about_non_existing_keys.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= h(t.reports.wiki_pages_about_non_existing_keys.name) %>
3 | <%= t.reports.wiki_pages_about_non_existing_keys.intro %>
4 |
5 |
9 |
--------------------------------------------------------------------------------
/sources/wiki/cache.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Taginfo source: Wiki
3 | --
4 | -- cache.sql
5 | --
6 |
7 | .bail ON
8 |
9 | CREATE TABLE cache_pages (
10 | title TEXT,
11 | timestamp TEXT,
12 | body TEXT
13 | );
14 |
15 | CREATE INDEX cache_pages_title_timestamp_idx ON cache_pages (title, timestamp);
16 |
17 |
--------------------------------------------------------------------------------
/web/views/test/index.erb:
--------------------------------------------------------------------------------
1 |
2 |
Test
3 |
The test pages are for taginfo development only.
4 |
5 |
11 |
--------------------------------------------------------------------------------
/web/views/taginfo/project_error_log.erb:
--------------------------------------------------------------------------------
1 |
2 |
Error log for project file
3 |
4 |
5 |
Project list
6 |
<%= h(@data['name']) %>
7 |
8 | <%= h(@data['error_log']) %>
9 |
10 |
11 |
--------------------------------------------------------------------------------
/web/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow: /api
3 | Disallow: /compare
4 | Disallow: /css
5 | Disallow: /download
6 | Disallow: /embed
7 | Disallow: /img
8 | Disallow: /js
9 | Disallow: /keys
10 | Disallow: /projects
11 | Disallow: /relations
12 | Disallow: /search/suggest
13 | Disallow: /tags
14 | Disallow: /taginfo/i18n
15 | Disallow: /test
16 |
--------------------------------------------------------------------------------
/web/views/taginfo/config.erb:
--------------------------------------------------------------------------------
1 |
2 |
Config
3 |
Configuration of this taginfo instance. Not all configuration settings are shown.
4 |
5 |
6 |
<%= h(JSON.generate(@config, json_opts('json_pretty'))).gsub(/"[a-z0-9_]+":/, '\0') %>
7 |
8 |
--------------------------------------------------------------------------------
/sources/potlatch/post.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Taginfo source: Potlatch
3 | --
4 | -- post.sql
5 | --
6 |
7 | .bail ON
8 |
9 | -- pull over category name from categories table so we don't need joins later
10 | UPDATE features SET category_name = (SELECT name FROM categories WHERE id=category_id);
11 |
12 | ANALYZE;
13 |
14 | UPDATE source SET update_end=datetime('now');
15 |
16 |
--------------------------------------------------------------------------------
/tagstats/README:
--------------------------------------------------------------------------------
1 |
2 | Tagstats
3 | ========
4 |
5 | Tagstats is a C++ program to create all the database statistics from a planet
6 | or other OSM file. You probably must compile this yourself and copy it in the
7 | ../sources/db directory. Tagstats uses the Osmium framework
8 | (wiki.osm.org/wiki/Osmium) which must be installed on your system before
9 | you try building tagstats.
10 |
11 |
--------------------------------------------------------------------------------
/bin/taginfo-config.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/ruby
2 | #
3 | # taginfo-config.rb KEY [DEFAULT]
4 | #
5 |
6 | require 'rubygems'
7 | require 'json'
8 |
9 | require File.expand_path(File.dirname(__FILE__)) + '/../web/lib/config.rb'
10 |
11 | TaginfoConfig.read
12 |
13 | value = TaginfoConfig.get(ARGV[0], ARGV[1])
14 | if value.nil?
15 | puts ''
16 | exit 1
17 | end
18 |
19 | puts value
20 |
21 |
--------------------------------------------------------------------------------
/examples/get_distribution_image.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/ruby
2 | #
3 | # get_distribution_image DB KEY nodes|ways
4 | #
5 |
6 | require 'rubygems'
7 | require 'sqlite3'
8 |
9 | filename = ARGV[0]
10 | key = ARGV[1]
11 | type = ARGV[2]
12 |
13 | db = SQLite3::Database.new(filename)
14 |
15 | db.execute("SELECT #{type} FROM key_distributions WHERE key=?", key) do |row|
16 | $stdout.write row[0]
17 | end
18 |
19 |
--------------------------------------------------------------------------------
/sources/master/history_init.sql:
--------------------------------------------------------------------------------
1 | -- ============================================================================
2 | --
3 | -- Taginfo
4 | --
5 | -- history_init.sql
6 | --
7 | -- ============================================================================
8 |
9 | .bail ON
10 |
11 | DROP TABLE IF EXISTS history_stats;
12 | CREATE TABLE history_stats (
13 | udate TEXT,
14 | key TEXT,
15 | value INT64
16 | );
17 |
18 |
--------------------------------------------------------------------------------
/web/views/reports/index.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= h(t.taginfo.reports) %>
3 |
<%= h(t.pages.reports.intro) %>
4 |
5 |
6 |
<%= h(t.pages.reports.list) %>
7 |
12 |
13 |
--------------------------------------------------------------------------------
/sources/master/history_update.sql:
--------------------------------------------------------------------------------
1 | -- ============================================================================
2 | --
3 | -- Taginfo
4 | --
5 | -- history_update.sql
6 | --
7 | -- ============================================================================
8 |
9 | .bail ON
10 |
11 | ATTACH DATABASE '__DIR__/taginfo-master.db' AS master;
12 |
13 | INSERT INTO history_stats (udate, key, value) SELECT substr(datetime('now'), 1, 10), key, value FROM master.master_stats;
14 |
15 |
--------------------------------------------------------------------------------
/web/lib/ui/test.rb:
--------------------------------------------------------------------------------
1 | # web/lib/ui/test.rb
2 | class Taginfo < Sinatra::Base
3 |
4 | get! '/test' do
5 | @title = 'Test'
6 | erb :'test/index'
7 | end
8 |
9 | get '/test/wiki_import' do
10 | section :test
11 | @title = ['Wiki Import', 'Test']
12 | @invalid_page_titles = @db.select('SELECT * FROM invalid_page_titles').execute()
13 | @invalid_image_titles = @db.select('SELECT * FROM invalid_image_titles').execute()
14 | erb :'test/wiki_import'
15 | end
16 |
17 | end
18 |
--------------------------------------------------------------------------------
/sources/wiki/README:
--------------------------------------------------------------------------------
1 |
2 | Taginfo Sources: Wiki
3 | =====================
4 |
5 | PREREQUISITES
6 | -------------
7 |
8 | On Debian/Ubuntu you need the following packages:
9 | libjson-ruby sqlite3 packages libsqlite3-ruby1.8
10 |
11 |
12 | RUNNING
13 | -------
14 |
15 | Run ./update.sh DIR
16 |
17 | where DIR is the name of a directory where the data will be stored.
18 |
19 | The file 'allpages.list' is currently not used. But because we get the
20 | information from the wiki anyway, we just store it. Maybe in the future
21 | it is of some use.
22 |
23 |
--------------------------------------------------------------------------------
/sources/init.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- init.sql
3 | --
4 | -- Initialize source database
5 | --
6 |
7 | .bail ON
8 |
9 | --
10 | -- Contains metadata about this source.
11 | --
12 | DROP TABLE IF EXISTS source;
13 | CREATE TABLE source (
14 | id TEXT,
15 | name TEXT,
16 | update_start TEXT,
17 | update_end TEXT,
18 | data_until TEXT
19 | );
20 |
21 | --
22 | -- Contains general statistical data for this source.
23 | --
24 | DROP TABLE IF EXISTS stats;
25 | CREATE TABLE stats (
26 | key TEXT,
27 | value INT64
28 | );
29 |
30 |
--------------------------------------------------------------------------------
/web/views/reports/josm_styles.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= h(t.reports.josm_styles.name) %>
3 |
10 |
11 |
15 | <% javascript do
16 | JS.raw(<<"JAVASCRIPT")
17 | function page_init2() {
18 | create_flexigrid_with_option('standard');
19 | }
20 | JAVASCRIPT
21 | end
22 | %>
23 |
--------------------------------------------------------------------------------
/web/views/search_tags.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= @title %>
3 |
<%= h(t.pages.search.you_were_searching_for) %>: <%= escape_html(@query) %>
4 |
5 |
15 | <% javascript do
16 | JS.raw(%Q{
17 | function page_init2() {
18 | init_tabs([#{ @query.to_json }]);
19 | }
20 | })
21 | end
22 | %>
23 |
--------------------------------------------------------------------------------
/web/lib/ui/reports.rb:
--------------------------------------------------------------------------------
1 | # web/lib/ui/reports.rb
2 | class Taginfo < Sinatra::Base
3 |
4 | get! '/reports' do
5 | @title = t.taginfo.reports
6 | erb :'reports/index'
7 | end
8 |
9 | Report.each do |report|
10 | get report.url do
11 | section :reports
12 | if File.exists?("viewsjs/reports/#{ report.name }.js.erb")
13 | javascript "#{ r18n.locale.code }/reports/#{ report.name }"
14 | end
15 | javascript_for(:flexigrid)
16 | erb ('reports/' + report.name).to_sym
17 | end
18 | end
19 |
20 | end
21 |
--------------------------------------------------------------------------------
/web/views/help/search.erb:
--------------------------------------------------------------------------------
1 | <%= h(t.help.search.intro) %>
2 |
3 | |
4 | <%= h(t.help.search.string) %>:
5 | highway
6 | <%= h(t.help.search.substring) %>:
7 | way
8 | |
9 | <%= h(t.help.search.complete_tags) %>:
10 | highway=residential
11 | <%= h(t.help.search.values_only) %>:
12 | =residential
13 | |
14 |
15 | <%= t.help.search.suggestions %>
16 |
--------------------------------------------------------------------------------
/web/lib/language.rb:
--------------------------------------------------------------------------------
1 | # web/lib/language.rb
2 | class Language
3 |
4 | @@languages = Hash.new
5 |
6 | attr_reader :code, :english_name, :native_name
7 |
8 | def initialize(options)
9 | @code = options['code']
10 | @english_name = options['english_name']
11 | @native_name = options['native_name']
12 | @@languages[@code] = self
13 | end
14 |
15 | def self.[](code)
16 | @@languages[code] || self.new('code' => code, 'english_name' => '(unknown)', 'native_name' => '(unknown)')
17 | end
18 |
19 | def self.each
20 | @@languages.keys.sort.each do |lang|
21 | yield @@languages[lang]
22 | end
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/examples/jsonp.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Taginfo JSONP Test
5 |
6 |
12 |
13 |
17 |
18 |
19 | Taginfo JSONP Test
20 |
21 |
22 |
--------------------------------------------------------------------------------
/web/views/reports/key_lengths.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= t.reports.key_lengths.name %>
3 | <%= t.reports.key_lengths.intro %>
4 |
5 |
6 |
10 |
11 |
<%= t.osm.keys %>
12 |
14 |
15 |
16 |
<%= t.reports.key_lengths.histogram.name %>
17 |
<%= t.reports.key_lengths.histogram.intro %>
18 |
19 |
20 |
21 | <% javascript_for(:d3) %>
22 |
--------------------------------------------------------------------------------
/sources/master/search.sql:
--------------------------------------------------------------------------------
1 | -- ============================================================================
2 | --
3 | -- Taginfo
4 | --
5 | -- search.sql
6 | --
7 | -- ============================================================================
8 |
9 | .bail ON
10 |
11 | PRAGMA journal_mode = OFF;
12 | PRAGMA synchronous = OFF;
13 | PRAGMA count_changes = OFF;
14 | PRAGMA temp_store = MEMORY;
15 | PRAGMA cache_size = 5000000;
16 |
17 | ATTACH DATABASE '__DIR__/db/taginfo-db.db' AS db;
18 |
19 | DROP TABLE IF EXISTS ftsearch;
20 | CREATE VIRTUAL TABLE ftsearch USING fts3 (
21 | key TEXT,
22 | value TEXT,
23 | count_all INTEGER
24 | );
25 |
26 | INSERT INTO ftsearch (key, value, count_all) SELECT key, value, count_all FROM db.tags;
27 |
28 | ANALYZE;
29 |
30 |
--------------------------------------------------------------------------------
/web/config.ru:
--------------------------------------------------------------------------------
1 | #
2 | # For use with Phusion Passenger
3 | #
4 |
5 | Encoding.default_external = 'UTF-8'
6 |
7 | require 'sinatra'
8 | require './taginfo.rb'
9 | require 'json'
10 | require 'lib/config.rb'
11 |
12 | TaginfoConfig.read
13 |
14 | LOGDIR=TaginfoConfig.get('logging.directory', '/osm/taginfo/var/log');
15 |
16 | set :run, false
17 | set :environment, :production
18 |
19 | today = Time.now.strftime('%Y-%m-%d')
20 | log = File.new("#{LOGDIR}/taginfo-#{ today }.log", "a")
21 | log.sync = true
22 |
23 | # https://github.com/joto/taginfo/issues/34
24 | #$stdout.reopen(log)
25 | $stderr.reopen(log)
26 |
27 | $stderr.puts "Taginfo started #{Time.now}"
28 |
29 | $queries_log = File.new("#{LOGDIR}/queries-#{ today }.log", "a")
30 | $queries_log.sync = true
31 |
32 | run Taginfo
33 |
34 |
--------------------------------------------------------------------------------
/bin/test_langtags.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/ruby
2 |
3 | require 'lib/langtag/bcp47.rb'
4 |
5 | BCP47::read_registry
6 |
7 | puts "Languages:"
8 |
9 | BCP47::Entry::entries('language').each do |entry|
10 | defscript = entry.suppress_script ? " (Script: #{entry.suppress_script})" : ''
11 | puts " #{entry.subtag} - #{entry.description}#{defscript}"
12 | end
13 |
14 | puts "\nScripts:"
15 |
16 | BCP47::Entry::entries('script').each do |entry|
17 | puts " #{entry.subtag} - #{entry.description}"
18 | end
19 |
20 | puts "\nRegions:"
21 |
22 | BCP47::Entry::entries('region').each do |entry|
23 | puts " #{entry.subtag} - #{entry.description}"
24 | end
25 |
26 | puts "\nVariants:"
27 |
28 | BCP47::Entry::entries('variant').each do |entry|
29 | puts " #{entry.subtag} - #{entry.description}"
30 | end
31 |
32 |
--------------------------------------------------------------------------------
/web/test/test_utils.rb:
--------------------------------------------------------------------------------
1 | $: << 'lib'
2 | require File.join(File.dirname(__FILE__), '..', 'lib', 'utils.rb')
3 | require 'test/unit'
4 |
5 | class TestSql < Test::Unit::TestCase
6 |
7 | def test_like_escape
8 | assert_equal 'x@%y', like_escape('x%y')
9 | assert_equal 'x@_', like_escape('x_')
10 | assert_equal '@@a', like_escape('@a')
11 | assert_equal '', like_escape('')
12 | assert_equal '', like_escape(nil)
13 | end
14 |
15 | def test_like_prefix
16 | assert_equal 'postal@_%', like_prefix('postal_')
17 | assert_equal '@%foo%', like_prefix('%foo')
18 | end
19 |
20 | def test_like_contains
21 | assert_equal '%name%', like_contains('name')
22 | assert_equal '%foo@_bar%', like_contains('foo_bar')
23 | assert_equal '%@@123%', like_contains('@123')
24 | end
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/web/views/reports/frequently_used_keys_without_wiki_page.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= t.reports.frequently_used_keys_without_wiki_page.name %>
3 | <%= t.reports.frequently_used_keys_without_wiki_page.intro %>
4 |
5 |
15 | <% javascript do
16 | JS.raw(<<"JAVASCRIPT")
17 | function page_init2() {
18 | create_flexigrid_with_option(#{ params[:english] == '1' ? '1' : '0' });
19 | }
20 | JAVASCRIPT
21 | end
22 | %>
23 |
--------------------------------------------------------------------------------
/tagstats/test_tagstats.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # test_tagstats.sh OSMFILE
4 | #
5 | # This is a little helper program to test the function of tagstats.
6 | # Its not supposed to be used in production.
7 | #
8 |
9 | set -e
10 | set -x
11 |
12 | DATABASE=taginfo-db.db
13 | OSMFILE=$1
14 | SELECTION_DB=selection.db
15 | #IMAGE_OPTIONS="--left=5.5 --bottom=47 --right=15 --top=55 --width=200 --height=320"
16 |
17 | rm -f $DATABASE
18 |
19 | sqlite3 $DATABASE <../sources/init.sql
20 | sqlite3 $DATABASE <../sources/db/pre.sql
21 |
22 | #ulimit -c unlimited
23 | rm -f core.*
24 |
25 | if [ -f $SELECTION_DB ]; then
26 | selection_option="--selection-db=$SELECTION_DB"
27 | else
28 | selection_option=""
29 | fi
30 |
31 | #valgrind --leak-check=full --show-reachable=yes
32 | ./tagstats $selection_option --min-tag-combination-count=100 $IMAGE_OPTIONS $OSMFILE $DATABASE
33 |
34 |
--------------------------------------------------------------------------------
/sources/josm/post.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Taginfo source: JOSM
3 | --
4 | -- post.sql
5 | --
6 |
7 | .bail ON
8 |
9 | CREATE INDEX josm_style_rules_idx ON josm_style_rules (style, k, v);
10 |
11 | INSERT INTO stats (key, value) SELECT 'josm_styles', count(*) FROM josm_styles;
12 |
13 | INSERT INTO stats (key, value) SELECT 'josm_style_rules_for_keys', count(*) FROM josm_style_rules WHERE v IS NULL;
14 | INSERT INTO stats (key, value) SELECT 'josm_style_rules_for_tags', count(*) FROM josm_style_rules WHERE v IS NOT NULL;
15 |
16 | INSERT INTO stats (key, value) SELECT 'josm_keys_in_style_rules', count(distinct k) FROM josm_style_rules WHERE v IS NULL;
17 | INSERT INTO stats (key, value) SELECT 'josm_tags_in_style_rules', count(distinct k || '=' || v) FROM josm_style_rules WHERE v IS NOT NULL;
18 |
19 | ANALYZE;
20 |
21 | UPDATE source SET update_end=datetime('now');
22 |
23 |
--------------------------------------------------------------------------------
/sources/languages/pre.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Taginfo source: Languages
3 | --
4 | -- pre.sql
5 | --
6 |
7 | .bail ON
8 |
9 | INSERT INTO source (id, name, update_start, data_until) SELECT 'languages', 'Languages', datetime('now'), datetime('now');
10 |
11 | DROP TABLE IF EXISTS subtags;
12 |
13 | CREATE TABLE subtags (
14 | stype TEXT,
15 | subtag TEXT,
16 | added TEXT,
17 | suppress_script TEXT,
18 | scope TEXT,
19 | description TEXT,
20 | prefix TEXT
21 | );
22 |
23 | DROP TABLE IF EXISTS unicode_scripts;
24 |
25 | CREATE TABLE unicode_scripts (
26 | script TEXT,
27 | name TEXT
28 | );
29 |
30 | DROP TABLE IF EXISTS unicode_codepoint_script_mapping;
31 |
32 | CREATE TABLE unicode_codepoint_script_mapping (
33 | codepoint_from TEXT,
34 | codepoint_to TEXT,
35 | name TEXT
36 | );
37 |
38 |
--------------------------------------------------------------------------------
/web/views/taginfo/translations.erb:
--------------------------------------------------------------------------------
1 |
2 |
Translations Overview
3 |
4 |
5 |
6 | <% r18n.available_locales.sort{ |a,b| a.code <=> b.code }.each do |locale| %>
7 | <% percent = (@num_texts[locale.code].to_f / @num_texts['en'].to_f * 100).to_i %>
8 |
9 | | <%= locale.code %> |
10 | <%= h(::Language[locale.code].english_name) %> |
11 | <%= h(::Language[locale.code].native_name) %> |
12 | <%= @num_texts[locale.code] %>/<%= @num_texts['en'] %> |
13 | <%= percent %>% |
14 | see texts |
15 |
16 | <% end %>
17 |
18 |
19 |
--------------------------------------------------------------------------------
/web/views/test/wiki_import.erb:
--------------------------------------------------------------------------------
1 |
2 |
Wiki Import
3 |
4 |
5 |
Invalid page titles
6 |
7 |
8 | | Reason | Page title |
9 |
10 | <% @invalid_page_titles.each do |row| %>
11 |
12 | | <%= h(row['reason']) %> |
13 | <%= h(row['title']) %> |
14 |
15 | <% end %>
16 |
17 |
18 |
Invalid image titles
19 |
20 |
21 | | Page title | Image title |
22 |
23 | <% @invalid_image_titles.each do |row| %>
24 |
25 | | <%= wiki_link(h(row['page_title'])) %> |
26 | <%= h(row['image_title']) %> |
27 |
28 | <% end %>
29 |
30 |
31 |
--------------------------------------------------------------------------------
/web/lib/ui/projects.rb:
--------------------------------------------------------------------------------
1 | # web/lib/ui/projects.rb
2 | class Taginfo < Sinatra::Base
3 |
4 | get '/projects' do
5 | @title = t.taginfo.projects
6 | javascript_for(:flexigrid)
7 | javascript "#{ r18n.locale.code }/projects"
8 | erb :projects
9 | end
10 |
11 | get %r{^/projects/(.*)} do |project|
12 | if params[:project].nil?
13 | @project_id = project
14 | else
15 | @project_id = params[:project]
16 | end
17 |
18 | @project = @db.select("SELECT * FROM projects.projects").
19 | condition("id = ?", @project_id).execute()[0]
20 |
21 | if !@project
22 | halt 404
23 | end
24 |
25 | @title = [h(@project['name']), t.taginfo.projects]
26 |
27 | section :projects
28 |
29 | javascript_for(:flexigrid)
30 | javascript "#{ r18n.locale.code }/project"
31 | erb :project
32 | end
33 |
34 | end
35 |
--------------------------------------------------------------------------------
/web/viewsjs/projects.js.erb:
--------------------------------------------------------------------------------
1 | function page_init() {
2 | create_flexigrid('grid-projects', {
3 | url: '/api/4/projects/all',
4 | colModel: [
5 | { display: '<%= h(@trans.t.taginfo.project) %>', name: 'name', width: 400, sortable: true },
6 | { display: '<%= h(@trans.t.misc.description) %>', name: 'description', width: 800, sortable: false }
7 | ],
8 | searchitems: [
9 | { display: '<%= h(@trans.t.taginfo.project) %>/<%= h(@trans.t.misc.description) %>', name: 'name' }
10 | ],
11 | sortname: 'name',
12 | sortorder: 'asc',
13 | preProcess: function(data) {
14 | data.rows = jQuery.map(data.data, function(row, i) {
15 | return { 'cell': [
16 | link_to_project(row.id, row.name, row.icon_url),
17 | html_escape(row.description)
18 | ] };
19 | });
20 | return data;
21 | }
22 | });
23 | }
24 |
--------------------------------------------------------------------------------
/sources/projects/post.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Taginfo source: Projects
3 | --
4 | -- post.sql
5 | --
6 |
7 | .bail ON
8 |
9 | INSERT INTO stats (key, value) SELECT 'projects', count(*) FROM projects;
10 | INSERT INTO stats (key, value) SELECT 'projects_ok', count(*) FROM projects WHERE status='OK';
11 | INSERT INTO stats (key, value) SELECT 'project_keys', count(*) FROM project_tags WHERE value IS NULL;
12 | INSERT INTO stats (key, value) SELECT 'project_tags', count(*) FROM project_tags WHERE value IS NOT NULL;
13 |
14 | CREATE TABLE project_counts (
15 | key TEXT NOT NULL,
16 | value TEXT,
17 | num INTEGER
18 | );
19 |
20 | INSERT INTO project_counts (key, value, num) SELECT key, NULL, count(*) FROM (SELECT DISTINCT project_id, key FROM project_tags) GROUP BY key;
21 | INSERT INTO project_counts (key, value, num) SELECT key, value, count(*) FROM (SELECT DISTINCT project_id, key, value FROM project_tags WHERE value IS NOT NULL) GROUP BY key, value;
22 |
23 | ANALYZE;
24 |
25 | UPDATE source SET update_end=datetime('now');
26 |
27 |
--------------------------------------------------------------------------------
/web/views/about.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 | <%= h(t.pages.about.about_taginfo.title) %> |
4 | |
5 | <%= h(t.pages.about.building_on_taginfo.title) %> |
6 | |
7 | <%= h(t.pages.about.software.title) %> |
8 |
9 |
10 | |
11 | <%= t.pages.about.about_taginfo.text %>
12 | |
13 |
14 | <%= t.pages.about.building_on_taginfo.text %>
15 | |
16 |
17 | <%= t.pages.about.software.text %>
18 | |
19 |
20 |
21 | <%= h(t.pages.about.about_site.title) %> |
22 |
23 |
24 | |
25 | <%= TaginfoConfig.get('instance.description') %>
26 | <%= TaginfoConfig.get('instance.about') %>
27 | |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/web/views/taginfo/i18n.erb:
--------------------------------------------------------------------------------
1 |
2 |
Translations of taginfo texts
3 |
4 |
5 | <% if @error %>
6 |
<%= @error %>
7 | <% else %>
8 |
9 | |
10 | on githubEnglish |
11 | on github
12 |
19 | |
20 | <%= i18n_walk(@line, 0, '', @i18n_en, @i18n_lang) %>
21 |
22 |
23 | <% end %>
24 |
--------------------------------------------------------------------------------
/web/lib/config.rb:
--------------------------------------------------------------------------------
1 | # web/lib/config.rb
2 |
3 | class TaginfoConfig
4 |
5 | @@config = {}
6 |
7 | def self.read
8 | open(File.expand_path(File.dirname(__FILE__)) + '/../../../taginfo-config.json') do |file|
9 | @@config = JSON.parse(file.gets(nil), { :create_additions => false })
10 | end
11 | end
12 |
13 | def self.get(key, default=nil)
14 | tree = @@config
15 | key.split('.').each do |i|
16 | tree = tree[i]
17 | return default unless tree
18 | end
19 | return tree.nil? ? default : tree
20 | end
21 |
22 | # Config without anything that a security concious admin wouldn't want to
23 | # be public. Currently everything that contains local paths is removed.
24 | def self.sanitized_config
25 | c = @@config
26 | c['sources'] && c['sources'].delete('db')
27 | c['logging'] && c['logging'].delete('directory')
28 | c['tagstats'] && c['tagstats'].delete('cxxflags')
29 | return c
30 | end
31 |
32 | end
33 |
34 |
--------------------------------------------------------------------------------
/sources/projects/update.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Taginfo source: Projects
4 | #
5 | # update.sh DIR
6 | #
7 |
8 | set -e
9 |
10 | DIR=$1
11 | PROJECT_LIST=project_list.txt
12 |
13 | DATECMD='date +%Y-%m-%dT%H:%M:%S'
14 |
15 | if [ "x" = "x$DIR" ]; then
16 | echo "Usage: update.sh DIR"
17 | exit 1
18 | fi
19 |
20 | echo "`$DATECMD` Start projects..."
21 |
22 | EXEC_RUBY="$TAGINFO_RUBY"
23 | if [ "x$EXEC_RUBY" = "x" ]; then
24 | EXEC_RUBY=ruby
25 | fi
26 | echo "Running with ruby set as '${EXEC_RUBY}'"
27 |
28 | DATABASE=$DIR/taginfo-projects.db
29 |
30 | rm -f $DATABASE
31 |
32 | echo "`$DATECMD` Running init.sql..."
33 | sqlite3 $DATABASE <../init.sql
34 |
35 | echo "`$DATECMD` Running pre.sql..."
36 | sqlite3 $DATABASE
2 |
3 |
4 |
5 |
46 |
47 |
48 |
49 | <%= yield %>
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/sources/projects/project_list.txt:
--------------------------------------------------------------------------------
1 | bano http://bano.openstreetmap.fr/bano_taginfo.json
2 | id_editor https://raw.githubusercontent.com/openstreetmap/iD/master/data/taginfo.json
3 | josm_main_mappaint_style http://josm.openstreetmap.de/download/taginfo/taginfo_style.json
4 | nominatim http://nominatim.openstreetmap.org/taginfo.json
5 | osm24eu http://osm24.eu/taginfo.json
6 | osm_inspector_public_transport_railways http://tools.geofabrik.de/osmi/osmi_pubtrans_railways.json
7 | osm_inspector_public_transport_stops http://tools.geofabrik.de/osmi/osmi_pubtrans_stops.json
8 | osm_mug https://raw.githubusercontent.com/joto/taginfo/master/projects/osm-mug.json
9 | osmcoastline https://raw.githubusercontent.com/joto/osmcoastline/master/taginfo.json
10 | osrm https://raw.githubusercontent.com/Project-OSRM/osrm-backend/develop/taginfo.json
11 | vespucci https://osmeditor4android.googlecode.com/svn/trunk/taginfo.json
12 | waymarkedtrails http://mapstatic.waymarkedtrails.org/taginfo.json
13 | townlands_ie http://www.townlands.ie/taginfo.json
14 | opensnowmap.org http://www.opensnowmap.org/opensnowmap_taginfo.json
15 |
--------------------------------------------------------------------------------
/sources/potlatch/pre.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Taginfo source: Potlatch
3 | --
4 | -- pre.sql
5 | --
6 |
7 | .bail ON
8 |
9 | INSERT INTO source (id, name, update_start, data_until) SELECT 'potlatch', 'Potlatch', datetime('now'), datetime('now');
10 |
11 | --
12 | -- categories
13 | --
14 |
15 | DROP TABLE IF EXISTS categories;
16 |
17 | CREATE TABLE categories (
18 | id TEXT,
19 | name TEXT
20 | );
21 |
22 | --
23 | -- features
24 | --
25 |
26 | DROP TABLE IF EXISTS features;
27 |
28 | CREATE TABLE features (
29 | name TEXT,
30 | category_id TEXT REFERENCES categories (id),
31 | category_name TEXT,
32 | help TEXT,
33 | on_point INTEGER,
34 | on_line INTEGER,
35 | on_area INTEGER,
36 | on_relation INTEGER,
37 | icon_image TEXT,
38 | icon_foreground TEXT,
39 | icon_background TEXT
40 | );
41 |
42 | --
43 | -- tags
44 | --
45 |
46 | DROP TABLE IF EXISTS tags;
47 |
48 | CREATE TABLE tags (
49 | key TEXT,
50 | value TEXT,
51 | feature_name REFERENCES features (name)
52 | );
53 |
54 |
--------------------------------------------------------------------------------
/web/views/embed/relation.erb:
--------------------------------------------------------------------------------
1 | <% if @rtype == '{{{type}}}' %>
2 | taginfo [More...]
3 | Statistics about the relation type will appear here.
4 | <% elsif @dbrtype.nil? %>
5 | taginfo [More...]
6 | This relation type does not appear in the OSM database.
7 | <% else %>
8 | taginfo [More...]
9 | There are
10 | <%= @dbrtype['count'].to_i.to_s_with_ts %> relations
11 | of type '<%= escape_html(@rtype) %>' with
12 | <%= @dbrtype['members_all'].to_i.to_s_with_ts %> members.
13 | <% unless @roles.empty? %>
14 | Prevalent roles:
<%= @roles.join(', ') %>
15 | <% end
16 | end %>
17 |
--------------------------------------------------------------------------------
/web/views/reports/language_comparison_table_for_keys_in_the_wiki.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= h(t.reports.language_comparison_table_for_keys_in_the_wiki.name) %>
3 | <%= t.reports.language_comparison_table_for_keys_in_the_wiki.intro %>
4 |
5 |
6 |
8 |
9 | ![[t]](/img/sources/wiki/wiki-t.png) | <%= h(t.reports.language_comparison_table_for_keys_in_the_wiki.icons.template) %> |
10 | ![[e]](/img/sources/wiki/wiki-e.png) | <%= h(t.reports.language_comparison_table_for_keys_in_the_wiki.icons.error) %> |
11 | ![[p]](/img/sources/wiki/wiki-p.png) | <%= h(t.reports.language_comparison_table_for_keys_in_the_wiki.icons.page) %> |
12 | ![[r]](/img/sources/wiki/wiki-r.png) | <%= h(t.reports.language_comparison_table_for_keys_in_the_wiki.icons.redirect) %> |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/sources/potlatch/update.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Taginfo source: Potlatch
4 | #
5 | # update.sh DIR
6 | #
7 |
8 | set -e
9 |
10 | DIR=$1
11 |
12 | DATECMD='date +%Y-%m-%dT%H:%M:%S'
13 |
14 | if [ "x" = "x$DIR" ]; then
15 | echo "Usage: update.sh DIR"
16 | exit 1
17 | fi
18 |
19 | echo "`$DATECMD` Start potlatch..."
20 |
21 | EXEC_RUBY="$TAGINFO_RUBY"
22 | if [ "x$EXEC_RUBY" = "x" ]; then
23 | EXEC_RUBY=ruby
24 | fi
25 | echo "Running with ruby set as '${EXEC_RUBY}'"
26 |
27 | DATABASE=$DIR/taginfo-potlatch.db
28 |
29 | rm -f $DATABASE
30 |
31 | echo "`$DATECMD` Updating resources..."
32 | if [ -d $DIR/git-source ]; then
33 | cd $DIR/git-source
34 | git pull
35 | cd -
36 | else
37 | git clone git://git.openstreetmap.org/potlatch2.git $DIR/git-source
38 | fi
39 |
40 | echo "`$DATECMD` Running init.sql..."
41 | sqlite3 $DATABASE <../init.sql
42 |
43 | echo "`$DATECMD` Running pre.sql..."
44 | sqlite3 $DATABASE :'embed/layout'
8 | end
9 |
10 | get '/embed/tag' do
11 | @key = params[:key]
12 | @value = params[:value]
13 | @dbtag = @db.select("SELECT * FROM db.tags").condition('key = ?', @key).condition('value = ?', @value).execute()[0]
14 | @dbkey = @db.select("SELECT * FROM db.keys").condition('key = ?', @key).execute()[0]
15 | erb :'embed/tag', :layout => :'embed/layout'
16 | end
17 |
18 | get '/embed/relation' do
19 | @rtype = params[:rtype]
20 | @dbrtype = @db.select("SELECT * FROM db.relation_types").condition('rtype = ?', @rtype).execute()[0]
21 | @roles = @db.select("SELECT role FROM db.prevalent_roles WHERE rtype=? ORDER BY count DESC LIMIT 10", @rtype).execute().map{ |row| row['role'] == '' ? '(empty role)' : row['role'] }
22 | erb :'embed/relation', :layout => :'embed/layout'
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/web/public/js/customSelect.jquery.min.js:
--------------------------------------------------------------------------------
1 | (function(a){a.fn.extend({customSelect:function(b){if(typeof document.body.style.maxHeight!="undefined"){var c={customClass:null,mapClass:true,mapStyle:true};var b=a.extend(c,b);return this.each(function(){var d=a(this);var f=a('');var e=a('').append(f);d.after(e);if(b.customClass){e.addClass(b.customClass)}if(b.mapClass){e.addClass(d.attr("class"))}if(b.mapStyle){e.attr("style",d.attr("style"))}d.bind("update",function(){d.change();var h=parseInt(d.outerWidth())-(parseInt(e.outerWidth())-parseInt(e.width()));e.css({display:"inline-block"});f.css({width:h,display:"inline-block"});var g=e.outerHeight();d.css({"-webkit-appearance":"menulist-button",width:e.outerWidth(),position:"absolute",opacity:0,height:g,fontSize:e.css("font-size")})}).change(function(){var g=d.find(":selected");var h=g.html()||" ";f.html(h).parent().addClass("customSelectChanged");setTimeout(function(){e.removeClass("customSelectOpen")},60)}).bind("mousedown",function(){e.toggleClass("customSelectOpen")}).focus(function(){e.addClass("customSelectFocus")}).blur(function(){e.removeClass("customSelectFocus customSelectOpen")}).trigger("update")})}}})})(jQuery);
--------------------------------------------------------------------------------
/web/views/taginfo/index.erb:
--------------------------------------------------------------------------------
1 |
2 |
taginfo META
3 |
This section is for developers only.
4 |
5 |
6 |
Menu
7 |
14 |
Software Version
15 |
<%= @commit_date %> (<%= @commit[0, 10] %>)
16 |
Config Settings
17 |
18 | | Variable | Setting |
19 | <% [:url, :name, :description, :icon, :contact, :area].each do |k| %>
20 | | <%= k %> | <%= TaginfoConfig.get("instance.#{k}") %> |
21 | <% end %>
22 |
23 |
These config settings are also available from the /api/4/site/info API call.
24 |
25 |
--------------------------------------------------------------------------------
/sources/josm/pre.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Taginfo source: JOSM
3 | --
4 | -- pre.sql
5 | --
6 |
7 | .bail ON
8 |
9 | INSERT INTO source (id, name, update_start, data_until) SELECT 'josm', 'JOSM', datetime('now'), datetime('now');
10 |
11 | --
12 | -- josm_styles
13 | --
14 | -- Contains list of JOSM styles.
15 | --
16 |
17 | DROP TABLE IF EXISTS josm_styles;
18 |
19 | CREATE TABLE josm_styles (
20 | style VARCHAR
21 | );
22 |
23 | --
24 | -- josm_style_rules
25 | --
26 | -- Contains data about JOSM style rules.
27 | --
28 |
29 | DROP TABLE IF EXISTS josm_style_rules;
30 |
31 | CREATE TABLE josm_style_rules (
32 | style VARCHAR,
33 | k VARCHAR,
34 | v VARCHAR,
35 | b VARCHAR,
36 | scale_min INTEGER,
37 | scale_max INTEGER,
38 | icon_source VARCHAR,
39 | line_color VARCHAR,
40 | line_width INTEGER,
41 | line_realwidth INTEGER,
42 | area_color VARCHAR,
43 | rule VARCHAR
44 | );
45 |
46 | --
47 | -- josm_style_images
48 | --
49 | -- Images/Icons used in JOSM style rules
50 | --
51 |
52 | DROP TABLE IF EXISTS josm_style_images;
53 |
54 | CREATE TABLE josm_style_images (
55 | style VARCHAR,
56 | path VARCHAR,
57 | png BLOB
58 | );
59 |
60 |
--------------------------------------------------------------------------------
/sources/josm/update.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Taginfo source: JOSM
4 | #
5 | # update.sh DIR
6 | #
7 |
8 | set -e
9 |
10 | DIR=$1
11 |
12 | DATECMD='date +%Y-%m-%dT%H:%M:%S'
13 |
14 | if [ "x" = "x$DIR" ]; then
15 | echo "Usage: update.sh DIR"
16 | exit 1
17 | fi
18 |
19 | echo "`$DATECMD` Start josm..."
20 |
21 | EXEC_RUBY="$TAGINFO_RUBY"
22 | if [ "x$EXEC_RUBY" = "x" ]; then
23 | EXEC_RUBY=ruby
24 | fi
25 | echo "Running with ruby set as '${EXEC_RUBY}'"
26 |
27 | DATABASE=$DIR/taginfo-josm.db
28 | ELEMSTYLES=$DIR/elemstyles.xml
29 |
30 | rm -f $DATABASE
31 | rm -f $ELEMSTYLES
32 |
33 | echo "`$DATECMD` Getting styles..."
34 | curl --silent --output $ELEMSTYLES http://josm.openstreetmap.de/svn/trunk/styles/standard/elemstyles.xml
35 |
36 | echo "`$DATECMD` Updating images..."
37 | if [ -d $DIR/svn-source ]; then
38 | cd $DIR/svn-source
39 | svn update
40 | cd -
41 | else
42 | svn checkout http://josm.openstreetmap.de/svn/trunk/images/styles $DIR/svn-source
43 | fi
44 |
45 | echo "`$DATECMD` Running init.sql..."
46 | sqlite3 $DATABASE <../init.sql
47 |
48 | echo "`$DATECMD` Running pre.sql..."
49 | sqlite3 $DATABASE $LOGFILE_WIKI_DATA
52 |
53 | echo "`$DATECMD` Getting image info..."
54 | $EXEC_RUBY ./get_image_info.rb $DIR >$LOGFILE_IMAGE_INFO
55 |
56 | echo "`$DATECMD` Extracting words..."
57 | $EXEC_RUBY ./extract_words.rb $DIR
58 |
59 | echo "`$DATECMD` Running post.sql..."
60 | sqlite3 $DATABASE
5 | function page_init() {
6 | up = function() { window.location = '/reports'; };
7 | create_flexigrid('grid-keys', {
8 | url: '/api/4/keys/all?filter=in_wiki,not_in_db&include=wikipages',
9 | colModel: [
10 | { display: '<%= h(osm.key) %>', name: 'key', width: 250, sortable: true, align: 'left' },
11 | { display: '<%= h(page.wiki_pages) %>', name: 'wikipages', width: 600, sortable: false, align: 'left' }
12 | ],
13 | searchitems: [
14 | { display: '<%= h(osm.key) %>', name: 'key' }
15 | ],
16 | sortname: 'count_all',
17 | sortorder: 'desc',
18 | preProcess: function(data) {
19 | data.rows = jQuery.map(data.data, function(row, i) {
20 | var wikilinks = [];
21 | jQuery(row.wikipages).each(function(i, wikipage) {
22 | var w = link_to_wiki(wikipage.title);
23 | if (wikipage.type == 'redirect') {
24 | w += ' (REDIRECT)';
25 | }
26 | wikilinks.push(w);
27 | });
28 | return { 'cell': [
29 | link_to_key(row.key),
30 | wikilinks.join(' • ')
31 | ] };
32 | });
33 | return data;
34 | }
35 | });
36 | }
37 |
--------------------------------------------------------------------------------
/web/public/js/d3/LICENSE-d3.layout.cloud:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012, Jason Davies.
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice, this
8 | list of conditions and the following disclaimer.
9 |
10 | * Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | * The name Jason Davies may not be used to endorse or promote products
15 | derived from this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 | DISCLAIMED. IN NO EVENT SHALL JASON DAVIES BE LIABLE FOR ANY DIRECT, INDIRECT,
21 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 |
--------------------------------------------------------------------------------
/tagstats/osmstats.cpp:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Copyright 2012 Jochen Topf .
4 |
5 | This file is part of Tagstats.
6 |
7 | Tagstats is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | Tagstats is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with Tagstats. If not, see .
19 |
20 | */
21 |
22 | #include
23 |
24 | #define OSMIUM_WITH_PBF_INPUT
25 | #define OSMIUM_WITH_XML_INPUT
26 |
27 | #include
28 | #include
29 |
30 | #include "statistics_handler.hpp"
31 |
32 | int main(int argc, char *argv[]) {
33 | if (argc != 3) {
34 | std::cerr << "Usage: " << argv[0] << " OSMFILE DATABASE" << std::endl;
35 | exit(1);
36 | }
37 |
38 | Osmium::OSMFile infile(argv[1]);
39 |
40 | Sqlite::Database db(argv[2], SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);
41 | db.exec("CREATE TABLE stats (key TEXT, value INT64);");
42 |
43 | StatisticsHandler handler(db);
44 | Osmium::Input::read(infile, handler);
45 |
46 | google::protobuf::ShutdownProtobufLibrary();
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/bin/check-translations.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/ruby
2 | #
3 | # check-translations.rb DIR LANG
4 | #
5 |
6 | v=RUBY_VERSION.split('.').map{ |x| x.to_i }
7 | if (v[0]*100+v[1])*100+v[0] < 10901
8 | STDERR.puts "You need at least Ruby 1.9.1 to run taginfo"
9 | exit(1)
10 | end
11 |
12 | #------------------------------------------------------------------------------
13 |
14 | require 'yaml'
15 |
16 | dir = ARGV[0]
17 | lang = ARGV[1]
18 |
19 | i18n_en = YAML.load_file("#{dir}/en.yml")
20 | i18n_lang = YAML.load_file("#{dir}/#{lang}.yml")
21 |
22 | def look_for_error(path, data)
23 | if data.nil?
24 | puts "No data for #{path.sub(/^\./, '')}"
25 | return true
26 | elsif data.class == Hash
27 | data.keys.sort.each do |key|
28 | if look_for_error(path + '.' + key, data[key])
29 | return true
30 | end
31 | end
32 | end
33 | return false
34 | end
35 |
36 | def walk(path, en, other)
37 | en.keys.sort.each do |key|
38 | name = path.sub(/^\./, '') + '.' + key
39 | if en[key].class == Hash
40 | if other.nil?
41 | puts "MISSING: #{name} [en=#{en[key]}]"
42 | else
43 | walk(path + '.' + key, en[key], other[key])
44 | end
45 | else
46 | # puts "#{name} [#{en[key]}] [#{other[key]}]"
47 | if other.nil?|| ! other[key]
48 | puts "MISSING: #{name} [en=#{en[key]}]"
49 | end
50 | end
51 | end
52 | end
53 |
54 |
55 | if look_for_error('', i18n_lang)
56 | exit 1
57 | end
58 |
59 | walk('', i18n_en, i18n_lang)
60 |
61 |
--------------------------------------------------------------------------------
/web/views/download.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= h(t.taginfo.download) %>
3 | <%= t.pages.download.intro %>
4 |
5 |
6 |
7 |
8 | | <%= h(t.pages.download.file) %> |
9 | <%= h(t.pages.download.packed) %> |
10 | <%= h(t.pages.download.unpacked) %> |
11 | <%= h(t.pages.download.description) %> |
12 |
13 |
14 | | taginfo-master.db.bz2 |
15 | <%= File.size("../../download/taginfo-master.db.bz2").to_bytes rescue "#{ h(t.misc.unknown) }" %> |
16 | <%= File.size("../../data/taginfo-master.db").to_bytes rescue "#{ h(t.misc.unknown) }" %> |
17 | <%= h(t.sources.master.description) %> |
18 |
19 | <% Source.visible.each_with_index do |source, n| c = (n%2==0) ? ' even' : '' %>
20 |
21 | | <%= source.link_download %> |
22 | <%= source.dbpack != 0 ? source.dbpack : "#{ t.misc.unknown }" %> |
23 | <%= source.dbsize != 0 ? source.dbsize : "#{ t.misc.unknown }" %> |
24 | <%= t.sources[source.id].description %> |
25 |
26 | <% end %>
27 |
28 |
29 |
--------------------------------------------------------------------------------
/web/viewsjs/texts.js.erb:
--------------------------------------------------------------------------------
1 | var texts = <%=
2 | {
3 | :flexigrid => {
4 | :pagetext => @trans.t.flexigrid.pagetext,
5 | :pagestat => @trans.t.flexigrid.pagestat,
6 | :outof => @trans.t.flexigrid.outof,
7 | :findtext => @trans.t.flexigrid.findtext,
8 | :procmsg => @trans.t.flexigrid.procmsg,
9 | :nomsg => @trans.t.flexigrid.nomsg,
10 | :errormsg => @trans.t.flexigrid.errormsg,
11 | },
12 | :misc => {
13 | :values_less_than_one_percent => @trans.t.misc.values_less_than_one_percent,
14 | :empty_string => @trans.t.misc.empty_string,
15 | :all => @trans.t.misc.all,
16 | :help => @trans.t.misc.help,
17 | :search_for => @trans.t.misc.search_for,
18 | :no_image => @trans.t.misc.no_image,
19 | },
20 | :osm => {
21 | :key => @trans.t.osm.key,
22 | :keys => @trans.t.osm.keys,
23 | :value => @trans.t.osm.value,
24 | :values => @trans.t.osm.values,
25 | :tag => @trans.t.osm.tag,
26 | :tags => @trans.t.osm.tags,
27 | :node => @trans.t.osm.node,
28 | :nodes => @trans.t.osm.nodes,
29 | :way => @trans.t.osm.way,
30 | :ways => @trans.t.osm.ways,
31 | :relation => @trans.t.osm.relation,
32 | :relations => @trans.t.osm.relations,
33 | :all => @trans.t.osm.all
34 | },
35 | }.to_json
36 | %>;
37 |
--------------------------------------------------------------------------------
/web/viewsjs/reports/josm_styles.js.erb:
--------------------------------------------------------------------------------
1 | <%
2 | osm = @trans.t.osm
3 | misc = @trans.t.misc
4 | %>
5 | function create_flexigrid_with_option(stylename) {
6 | create_flexigrid('grid-rules', {
7 | url: '/api/4/josm/style/rules?style=' + stylename,
8 | colModel: [
9 | { display: '<%= h(osm.key) %>', name: 'key', width: 300, sortable: true },
10 | { display: '<%= h(osm.value) %>', name: 'value', width: 300, sortable: true },
11 | { display: '<%= h(misc.icon) %>', name: 'icon', width: 40, sortable: false, align: 'center' },
12 | { display: '<%= h(misc.line) %>', name: 'line', width: 40, sortable: false, align: 'center' },
13 | { display: '<%= h(misc.area) %>', name: 'area', width: 40, sortable: false, align: 'center' }
14 | ],
15 | searchitems: [
16 | { display: '<%= h(osm.key) %>/<%= h(osm.value) %>', name: 'key' }
17 | ],
18 | sortname: 'key',
19 | sortorder: 'asc',
20 | preProcess: function(data) {
21 | data.rows = jQuery.map(data.data, function(row, i) {
22 | return { 'cell': [
23 | link_to_key(row.key),
24 | fmt_josm_value(row.key, row.value, row.value_bool),
25 | fmt_josm_icon('standard', row.icon),
26 | fmt_josm_line(row.line_width, row.line_color),
27 | fmt_josm_area(row.area_color)
28 | ] };
29 | });
30 | return data;
31 | }
32 | });
33 | }
34 |
35 | function page_init() {
36 | up = function() { window.location = '/reports'; };
37 | page_init2();
38 | }
39 |
--------------------------------------------------------------------------------
/web/viewsjs/reports/languages.js.erb:
--------------------------------------------------------------------------------
1 | <% page = @trans.t.reports.languages %>
2 | function page_init() {
3 | up = function() { window.location = '/reports'; };
4 | create_flexigrid('grid-langs', {
5 | url: '/api/4/wiki/languages',
6 | colModel: [
7 | { display: '<%= h(page.code) %>', name: 'code', width: 60, sortable: true },
8 | { display: '<%= h(page.native_name) %>', name: 'native_name', width: 150, sortable: true },
9 | { display: '<%= h(page.english_name) %>', name: 'english_name', width: 150, sortable: true },
10 | { display: '<%= h(page.wiki_key_pages) %>', name: 'wiki_key_pages', width: 260, sortable: true, align: 'center' },
11 | { display: '<%= h(page.wiki_tag_pages) %>', name: 'wiki_tag_pages', width: 260, sortable: true, align: 'center' }
12 | ],
13 | sortname: 'code',
14 | sortorder: 'asc',
15 | showToggleBtn: false,
16 | usepager: false,
17 | useRp: false,
18 | preProcess: function(data) {
19 | return {
20 | total: data.total,
21 | page: 1,
22 | rows: jQuery.map(data.data, function(row, i) {
23 | return { 'cell': [
24 | span(row.code, 'lang'),
25 | row.native_name,
26 | row.english_name,
27 | fmt_value_with_percent(row.wiki_key_pages, row.wiki_key_pages_fraction),
28 | fmt_value_with_percent(row.wiki_tag_pages, row.wiki_tag_pages_fraction)
29 | ]};
30 | })
31 | };
32 | }
33 | });
34 | }
35 |
--------------------------------------------------------------------------------
/web/views/search.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= @title %>
3 |
<%= h(t.pages.search.you_were_searching_for) %>: <%= escape_html(@query) %>
4 |
5 |
6 |
13 |
14 |
<%= h(t.osm.keys) %>
15 |
17 |
18 |
19 |
<%= h(t.osm.values) %>
20 |
22 |
23 |
24 |
<%= h(t.osm.relation_types) %>
25 |
27 |
28 |
29 |
<%= h(t.osm.relation_member_roles) %>
30 |
32 |
33 |
34 |
<%= h(t.pages.search.fulltext) %>
35 |
This search is experimental. It shows keys and tags that might be related to the word you searched for. This doesn't work if there are several words.
36 |
38 |
39 |
40 | <% javascript do
41 | JS.raw(%Q{
42 | function page_init2() {
43 | init_tabs([#{ @query.to_json }]);
44 | }
45 | })
46 | end
47 | %>
48 |
--------------------------------------------------------------------------------
/web/lib/reports.rb:
--------------------------------------------------------------------------------
1 | # web/lib/reports.rb
2 | class Report
3 |
4 | @@reports = Array.new
5 |
6 | attr_reader :title, :sources
7 |
8 | def self.each
9 | @@reports.sort_by{ |report| report.title }.each do |report|
10 | yield report
11 | end
12 | end
13 |
14 | def self.each_visible
15 | @@reports.select{ |report| report.visible? }.sort_by{ |report| report.title }.each do |report|
16 | yield report
17 | end
18 | end
19 |
20 | def self.each_visible_with_index
21 | @@reports.select{ |report| report.visible? }.sort_by{ |report| report.title }.each_with_index do |report, idx|
22 | yield report, idx
23 | end
24 | end
25 |
26 | def initialize(title, *sources)
27 | @@reports << self
28 | @title = title
29 | @sources = Hash.new
30 | @visible = sources.size > 0
31 | sources.each do |id|
32 | @sources[id] = 1
33 | end
34 | end
35 |
36 | def uses_source?(id)
37 | sources.has_key? id
38 | end
39 |
40 | def name
41 | @title.gsub(/[\s-]/, '_').downcase
42 | end
43 |
44 | def url
45 | '/reports/' + name
46 | end
47 |
48 | def visible?
49 | @visible
50 | end
51 |
52 | end
53 |
54 | Report.new 'Database statistics', :db
55 | Report.new 'JOSM styles' # disabled
56 | Report.new 'Characters in keys', :db
57 | Report.new 'Frequently used keys without wiki page', :db, :wiki
58 | Report.new 'Key lengths', :db
59 | Report.new 'Language comparison table for keys in the wiki', :wiki
60 | Report.new 'Languages', :wiki
61 | Report.new 'Wiki pages about non-existing keys', :db, :wiki
62 | Report.new 'Name tags'
63 |
64 |
--------------------------------------------------------------------------------
/web/views/embed/key.erb:
--------------------------------------------------------------------------------
1 | <% if @key == '{{{key}}}' %>
2 | taginfo [More...]
3 | Statistics about the key will appear here.
4 | <% elsif @dbkey.nil? %>
5 | taginfo [More...]
6 | This key does not appear in the OSM database.
7 | <% else %>
8 | taginfo [More...]
9 |
10 |
11 |  |
12 | <%= @dbkey['count_nodes'].to_i.to_s_with_ts %> |
13 |
14 |
15 |  |
16 | <%= @dbkey['count_ways'].to_i.to_s_with_ts %> |
17 |
18 |
19 |  |
20 | <%= @dbkey['count_relations'].to_i.to_s_with_ts %> |
21 |
22 |
23 | <% end %>
24 |
--------------------------------------------------------------------------------
/web/views/reports/name_tags.erb:
--------------------------------------------------------------------------------
1 | <%
2 | @filter_type = BCP47.get_filter(params[:filter])
3 | @sel = Hash.new('')
4 | @sel[@filter_type] = ' selected="selected"'
5 | %>
6 |
7 |
<%= h(t.reports.name_tags.name) %>
8 | <%= t.reports.name_tags.intro %>
9 |
10 |
11 |
15 |
16 |
<%= h(t.reports.name_tags.overview.title) %>
17 |
18 |
Tag keys containing "name".
19 |
20 |
22 |
23 |
24 |
<%= h(t.reports.name_tags.bcp47.title) %>
25 |
26 | <%= t.reports.name_tags.bcp47.intro %>
27 |
36 |
37 |
39 |
40 |
41 | <% javascript do
42 | JS.raw(<<"JAVASCRIPT")
43 | function page_init2() {
44 | init_tabs([#{ @filter_type.to_json }]);
45 | }
46 | JAVASCRIPT
47 | end
48 | %>
49 |
--------------------------------------------------------------------------------
/examples/tapi:
--------------------------------------------------------------------------------
1 | #!/usr/bin/ruby
2 | #
3 | # tapi - Taginfo API
4 | #
5 | # Example utility for accessing the Taginfo API
6 | #
7 | # Usage: tapi PATH KEY=VAL KEY=VAL ...
8 | #
9 | # The tool will send the request to the server, get the JSON result and
10 | # print it out in an easier to read form.
11 | #
12 | # You can set the following environment variables (default in brackets):
13 | # TAGINFO_API_SERVER [taginfo.openstreetmap.org]
14 | # TAGINFO_API_PORT [80]
15 | # TAGINFO_API_VERSION [4]
16 | #
17 |
18 | require 'rubygems'
19 |
20 | require 'net/http'
21 | require 'uri'
22 | require 'json'
23 |
24 | API_SERVER = ENV['TAGINFO_API_SERVER'] || 'taginfo.openstreetmap.org'
25 | API_PORT = ENV['TAGINFO_API_PORT'] || 80
26 | API_VERSION = ENV['TAGINFO_API_VERSION'] || '4'
27 |
28 | def api_call(path, params)
29 | query = []
30 | params.each_pair do |k,v|
31 | query << k + '=' + v
32 | end
33 | uri = URI::HTTP.build({
34 | :host => API_SERVER,
35 | :port => API_PORT,
36 | :path => '/api/' + API_VERSION + '/' + path,
37 | :query => query.join('&')
38 | })
39 | STDERR.puts "URI=#{uri}"
40 |
41 | request = Net::HTTP::Get.new(uri.request_uri)
42 | request['User-Agent'] = 'tapi/1.0 (Taginfo)'
43 | result = Net::HTTP.start(uri.host, uri.port) do |http|
44 | http.request(request)
45 | end
46 | if result.code != '200'
47 | STDERR.puts "#{result.code} #{result.message}"
48 | STDERR.puts result.body
49 | exit 1
50 | end
51 |
52 | puts JSON.pretty_generate(JSON.parse(result.body))
53 | end
54 |
55 | path = ARGV.shift.sub(%r{^/}, '')
56 |
57 | options = {}
58 | ARGV.each do |arg|
59 | (k, v) = arg.split('=')
60 | options[k] = v;
61 | end
62 |
63 | api_call(path, options)
64 |
65 |
--------------------------------------------------------------------------------
/web/lib/api/v4/site.rb:
--------------------------------------------------------------------------------
1 | # web/lib/api/v4/site.rb
2 | class Taginfo < Sinatra::Base
3 |
4 | api(4, 'site/info', {
5 | :description => 'Get information about this taginfo site.',
6 | :result => [
7 | [:url, :STRING, 'URL'],
8 | [:name, :STRING, 'Name'],
9 | [:description, :STRING, 'Description'],
10 | [:icon, :STRING, 'Path to icon which appears on the lop left corner of all pages.'],
11 | [:contact, :STRING, 'Contact information to admin.'],
12 | [:area, :STRING, 'Description of area covered.']
13 | ],
14 | :example => { }
15 | }) do
16 | data = {}
17 | [:url, :name, :description, :icon, :contact, :area].each do |k|
18 | data[k] = TaginfoConfig.get("instance.#{k}")
19 | end
20 | return JSON.generate(data, json_opts(params[:format]))
21 | end
22 |
23 | api(4, 'site/sources', {
24 | :description => 'Get information about the data sources used.',
25 | :result => [
26 | [:name , :STRING, 'Name'],
27 | [:data_until , :STRING, 'All changes in the source until this date are reflected in taginfo.'],
28 | [:update_start, :STRING, 'Date/Timestamp when last update was started.'],
29 | [:update_end , :STRING, 'Date/Timestamp when last update was finished.']
30 | ],
31 | :example => { },
32 | :ui => '/sources'
33 | }) do
34 | return JSON.generate(Source.visible.map{ |source| {
35 | :name => source.name,
36 | :data_until => source.data_until,
37 | :update_start => source.update_start,
38 | :update_end => source.update_end
39 | }}, json_opts(params[:format]))
40 | end
41 |
42 | end
43 |
--------------------------------------------------------------------------------
/web/viewsjs/project.js.erb:
--------------------------------------------------------------------------------
1 | <%
2 | osm = @trans.t.osm
3 | misc = @trans.t.misc
4 | page = @trans.t.pages.project
5 | %>
6 | var create_flexigrid_for = {
7 | tags: function(project) {
8 | create_flexigrid('grid-tags', {
9 | url: '/api/4/project/tags?project=' + encodeURIComponent(project),
10 | colModel: [
11 | { display: '<%= h(osm.tag) %>', name: 'tag', width: 260, sortable: true },
12 | { display: '<%= h(osm.objects) %>', name: 'objects', width: 80, sortable: false },
13 | { display: '<%= h(page.tags.description) %>', name: 'description', width: 800, sortable: false, align: 'left' }
14 | ],
15 | searchitems: [
16 | { display: '<%= h(osm.key) %>/<%= h(osm.value) %>', name: 'key_value' }
17 | ],
18 | sortname: 'tag',
19 | sortorder: 'asc',
20 | preProcess: function(data) {
21 | data.rows = jQuery.map(data.data, function(row, i) {
22 | return { 'cell': [
23 | row.value ? link_to_tag(row.key, row.value) : (link_to_key(row.key) + '=*'),
24 | fmt_type_icon('node', row.on_node) +
25 | fmt_type_icon('way', row.on_way) +
26 | fmt_type_icon('area', row.on_area) +
27 | fmt_type_icon('relation', row.on_relation),
28 | project_tag_desc(row.description, row.icon_url, row.doc_url)
29 | ] };
30 | });
31 | delete data.data;
32 | return data;
33 | }
34 | });
35 | }
36 | };
37 |
38 | function page_init() {
39 | up = function() { window.location = '/projects'; }
40 | page_init2();
41 | }
42 |
--------------------------------------------------------------------------------
/sources/master/update.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Taginfo Master DB
4 | #
5 | # update.sh DIR
6 | #
7 |
8 | set -e
9 |
10 | DIR=$1
11 |
12 | DATECMD='date +%Y-%m-%dT%H:%M:%S'
13 |
14 | if [ "x" = "x$DIR" ]; then
15 | echo "Usage: update.sh DIR"
16 | exit 1
17 | fi
18 |
19 | echo "`$DATECMD` Start master..."
20 |
21 | MASTER_DB=$DIR/taginfo-master.db
22 | HISTORY_DB=$DIR/taginfo-history.db
23 | SELECTION_DB=$DIR/selection.db
24 |
25 | echo "`$DATECMD` Create search database..."
26 |
27 | rm -f $DIR/taginfo-search.db
28 | m4 --prefix-builtins -D __DIR__=$DIR search.sql | sqlite3 $DIR/taginfo-search.db
29 |
30 | echo "`$DATECMD` Create master database..."
31 |
32 | rm -f $MASTER_DB
33 | sqlite3 $MASTER_DB
2 | <%= h(t.taginfo.sources) %>
3 | <%= t.pages.sources.intro %>
4 |
5 |
6 |
7 | <%= h(t.pages.sources.list.title) %> |
8 | |
9 | <%= h(t.pages.sources.updates.title) %> |
10 |
11 |
12 | |
13 | <%= h(t.pages.sources.list.intro) %>
14 | <% Source.visible.each_with_index do |source, n| c = (n%2!=0) ? ' even' : '' %>
15 | <%= h(source.name) %>
16 | <%= t.pages.sources.description[source.id] %>
17 | <% end %>
18 | |
19 |
20 | <%= h(t.pages.sources.updates.intro) %>
21 |
22 |
23 | | <%= h(t.taginfo.source) %> |
24 | <%= h(t.pages.sources.data_until) %>* |
25 | <%= h(t.pages.sources.last_update_run) %> |
26 |
27 | <% Source.visible.each_with_index do |source, n| c = (n%2!=0) ? ' even' : '' %>
28 |
29 | <%= h(source.name) %>
30 | | <%= h(source.data_until) %> UTC |
31 | <%= h(source.update_start.to_s + ' ' + t.pages.sources.to + ' ' + source.update_end.to_s) %> UTC |
32 |
33 | <% end %>
34 |
35 | * <%= h(t.pages.sources.data_until_explanation) %>
36 | |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/web/lib/sources.rb:
--------------------------------------------------------------------------------
1 | # web/lib/sources.rb
2 | class Source
3 |
4 | @@sources = Array.new
5 |
6 | attr_reader :id, :name, :data_until, :update_start, :update_end, :visible, :dbsize, :dbpack
7 |
8 | # Enumerate all available sources
9 | def self.each
10 | @@sources.each do |source|
11 | yield source
12 | end
13 | end
14 |
15 | # The number of available sources
16 | def self.size
17 | @@sources.size
18 | end
19 |
20 | def self.visible
21 | @@sources.select{ |source| source.visible }
22 | end
23 |
24 | # Create new source
25 | # id - Symbol with id for this source
26 | # name - Name of this source
27 | def initialize(id, name, data_until, update_start, update_end, visible)
28 | @id = id.to_sym
29 | @name = name
30 | @data_until = data_until
31 | @update_start = update_start
32 | @update_end = update_end
33 | @visible = visible
34 |
35 | @dbsize = File.size("../../data/#{ dbname }").to_bytes rescue 0
36 | @dbpack = File.size("../../download/#{ dbname }.bz2").to_bytes rescue 0
37 |
38 | @@sources << self
39 | end
40 |
41 | # The URL where this source is described
42 | def url
43 | "/sources/#{ @id }"
44 | end
45 |
46 | # The img URL of this source
47 | def imgurl(size=16)
48 | "/img/sources/#{ @id }.#{ size }.png"
49 | end
50 |
51 | # Returns img tag for this source
52 | def img(size=16, title_prefix='')
53 | %Q{
}
54 | end
55 |
56 | def dbname
57 | "taginfo-#{ @id }.db"
58 | end
59 |
60 | def link_download
61 | %Q{#{ dbname }.bz2}
62 | end
63 |
64 | end
65 |
--------------------------------------------------------------------------------
/web/lib/api/v4/josm.rb:
--------------------------------------------------------------------------------
1 | # web/lib/api/v4/josm.rb
2 | class Taginfo < Sinatra::Base
3 |
4 | api(4, 'josm/style/image', {
5 | :superseded_by => '',
6 | :description => 'DEPRECATED. Access images for map features used in JOSM.',
7 | :parameters => {
8 | :style => 'JOSM style (required).',
9 | :image => 'Image path (required).'
10 | },
11 | :result => 'PNG image.',
12 | :example => { :style => 'standard', :image => 'transport/bus.png' },
13 | :ui => '/keys/landuse#josm'
14 | }) do
15 | style = params[:style]
16 | image = params[:image]
17 | content_type :png
18 | @db.select('SELECT png FROM josm.josm_style_images').
19 | condition('style = ?', style).
20 | condition('path = ?', image).
21 | get_first_value()
22 | end
23 |
24 | api(4, 'josm/style/rules', {
25 | :superseded_by => '',
26 | :description => 'List rules and symbols in JOSM styles.',
27 | :parameters => {
28 | :style => 'JOSM style (required).',
29 | :query => 'Only show results where the key or value matches this query (substring match, optional).'
30 | },
31 | :paging => :optional,
32 | :result => paging_results([
33 | [:key, :STRING, 'Key'],
34 | [:value, :STRING, 'Value'],
35 | [:value_bool, :STRING, '"yes" or "no". Null if the value is not boolean.'],
36 | [:rule, :STRING, 'JOSM style rule in XML format.'],
37 | [:area_color, :STRING, 'Fill color for area (if area rule).'],
38 | [:line_color, :STRING, 'Stroke color for line (if line rule).'],
39 | [:line_width, :INT, 'Line width (if line rule).'],
40 | [:icon, :STRING, 'Icon path (if icon rule).']
41 | ]),
42 | :example => { :style => 'standard', :page => 1, :rp => 10 },
43 | :ui => '/reports/josm_styles'
44 | }) do
45 | total = 0
46 | res = []
47 | return get_josm_style_rules_result(total, res);
48 | end
49 |
50 | end
51 |
--------------------------------------------------------------------------------
/web/viewsjs/relations.js.erb:
--------------------------------------------------------------------------------
1 | <%
2 | osm = @trans.t.osm
3 | page = @trans.t.pages.relations
4 | %>
5 | function page_init() {
6 | create_flexigrid('grid-relations', {
7 | url: '/api/4/relations/all',
8 | colModel: [
9 | { display: '<%= h(osm.relation_type) %>', name: 'rtype', width: 220, sortable: true },
10 | { display: '<%= h(osm.relations) %>', name: 'count', width: 250, sortable: true, align: 'center' },
11 | { display: '<%= h(osm.tag) %>', name: 'tag', width: 250, sortable: false },
12 | { display: '<%= h(page.prevalent_roles) %>', name: 'prevalent_roles', width: 550, sortable: false }
13 | ],
14 | searchitems: [
15 | { display: '<%= h(osm.relation_type) %>', name: 'rtype' }
16 | ],
17 | sortname: 'count',
18 | sortorder: 'desc',
19 | preProcess: function(data) {
20 | data.rows = jQuery.map(data.data, function(row, i) {
21 | return { 'cell': [
22 | link_to_rtype(row.rtype),
23 | fmt_value_with_percent(row.count, row.count_fraction),
24 | link_to_tag('type', row.rtype),
25 | fmt_prevalent_role_list(row.prevalent_roles)
26 | ] };
27 | });
28 | return data;
29 | }
30 | });
31 | };
32 |
33 | function fmt_prevalent_role_list(list) {
34 | if (list === null) {
35 | return empty('<%= h(page.no_information) %>');
36 | }
37 | if (list.length == 0) {
38 | return empty(page.roles_less_than_one_percent);
39 | }
40 | return jQuery.map(list, function(item, i) {
41 | if (item.role) {
42 | return tag('span', fmt_role(item.role), { tipsy: 'e', title: html_escape(item.role) + ' (' + fmt_as_percent(item.fraction) + ')' });
43 | } else {
44 | return tag('span', empty('<%= h(page.empty_role) %>'), { tipsy: 'e', title: '(' + fmt_as_percent(item.fraction) + ')' });
45 | }
46 | }).join(' • ');
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/web/views/taginfo/projects.erb:
--------------------------------------------------------------------------------
1 | <%= h(t.taginfo.projects) %>
2 |
3 |
4 |
5 | | Icon |
6 | Project ID Project Name |
7 | Fetch Date Updated | Code | Status |
8 | JSON URL Data URL Project URL Doc URL | Fmt Vers |
9 | Contact |
10 | Description |
11 |
12 | <% @projects.each_with_index do |project, n| c = (n%2!=0) ? ' even' : '' %>
13 |
14 |
15 |
16 | |
17 |
18 | <%= h(project['id']) %>
19 | <%= h(project['name']) %>
20 | |
21 |
22 | <%= h(project['fetch_date']) %>
23 | <%= h(project['data_updated']) %>
24 | |
25 | <%= h(project['fetch_status']) %> |
26 |
27 | <%= h(project['status']) %>
28 | <% if project['error_log'] != '' %>
29 |
30 | <% end %>
31 | |
32 |
33 | <%= h(project['json_url']) %>
34 | <%= h(project['data_url']) %>
35 | <%= h(project['project_url']) %>
36 | <%= h(project['doc_url']) %>
37 | |
38 | <%= h(project['data_format']) %> |
39 | <%= h(project['contact_name']) %> <%= h(project['contact_email']) %> |
40 | <%= h(project['description']) %> |
41 |
42 | <% end %>
43 |
44 |
--------------------------------------------------------------------------------
/web/public/js/customSelect.jquery.js:
--------------------------------------------------------------------------------
1 | /*! jQuery.customSelect() - v0.2.1 - 2012-12-17 */
2 |
3 | (function($){
4 | $.fn.extend({
5 |
6 | customSelect : function(options) {
7 | if(typeof document.body.style.maxHeight != "undefined"){ /* filter out <= IE6 */
8 | var defaults = {
9 | customClass: null,
10 | mapClass:true,
11 | mapStyle:true
12 | };
13 | var options = $.extend(defaults, options);
14 |
15 | return this.each(function() {
16 | var $this = $(this);
17 | var customSelectInnerSpan = $('');
18 | var customSelectSpan = $('').append(customSelectInnerSpan);
19 | $this.after(customSelectSpan);
20 |
21 | if(options.customClass) { customSelectSpan.addClass(options.customClass); }
22 | if(options.mapClass) { customSelectSpan.addClass($this.attr('class')); }
23 | if(options.mapStyle) { customSelectSpan.attr('style', $this.attr('style')); }
24 |
25 | $this.bind('update',function(){
26 | $this.change();
27 | var selectBoxWidth = parseInt($this.outerWidth()) - (parseInt(customSelectSpan.outerWidth()) - parseInt(customSelectSpan.width()) );
28 | customSelectSpan.css({display:'inline-block'});
29 | customSelectInnerSpan.css({width:selectBoxWidth, display:'inline-block'});
30 | var selectBoxHeight = customSelectSpan.outerHeight();
31 | $this.css({'-webkit-appearance':'menulist-button',width:customSelectSpan.outerWidth(),position:'absolute', opacity:0,height:selectBoxHeight,fontSize:customSelectSpan.css('font-size')});
32 | }).change(function(){
33 | var currentSelected = $this.find(':selected');
34 | var html = currentSelected.html() || ' ';
35 | customSelectInnerSpan.html(html).parent().addClass('customSelectChanged');
36 | setTimeout(function(){customSelectSpan.removeClass('customSelectOpen');},60);
37 | }).bind('mousedown',function(){
38 | customSelectSpan.toggleClass('customSelectOpen');
39 | }).focus(function(){
40 | customSelectSpan.addClass('customSelectFocus');
41 | }).blur(function(){
42 | customSelectSpan.removeClass('customSelectFocus customSelectOpen');
43 | }).trigger('update');
44 |
45 | });
46 | }
47 | }
48 | });
49 | })(jQuery);
50 |
--------------------------------------------------------------------------------
/web/viewsjs/reports/language_comparison_table_for_keys_in_the_wiki.js.erb:
--------------------------------------------------------------------------------
1 | <%
2 | osm = @trans.t.osm
3 |
4 | @languages = @db.execute('SELECT language FROM wiki_languages ORDER by language').map do |row|
5 | row['language']
6 | end
7 |
8 | lang_lookup = Hash.new
9 | @languages.each_with_index do |lang, idx|
10 | lang_lookup[lang] = idx + 1
11 | end
12 | @languages_lookup = @languages.map{ |lang| "'#{lang}': #{lang_lookup[lang]}" }.join(', ')
13 | %>
14 | function page_init() {
15 | up = function() { window.location = '/reports'; };
16 | var lang_to_idx = {
17 | <%= @languages_lookup %>
18 | };
19 | var rp = calculate_flexigrid_rp(jQuery('div.box')) - 1;
20 | current_grid = 'grid-keys';
21 | grids[current_grid] = jQuery('#grid-keys').flexigrid(jQuery.extend({}, flexigrid_defaults, texts.flexigrid, {
22 | url: '/api/4/keys/wiki_pages',
23 | colModel: [
24 | { display: '
<%= h(osm.key) %>', name: 'key', width: 200, sortable: true },
25 | <% @languages.each do |lang| %>
26 | { display: '<%= ::Language[lang].native_name %>
<%= h(lang) %>', name: '<%= h(lang) %>', align: 'center', width: 60, sortable: false },
27 | <% end %>
28 | ],
29 | searchitems: [
30 | { display: '<%= h(osm.key) %>', name: 'key' }
31 | ],
32 | sortname: 'key',
33 | sortorder: 'asc',
34 | showTableToggleBtn: false,
35 | rp: rp,
36 | onSuccess: function(grid) {
37 | grid.fixHeight();
38 | },
39 | preProcess: function(data) {
40 | return {
41 | total: data.total,
42 | page: data.page,
43 | rows: jQuery.map(data.data, function(row, i) {
44 | d = [link_to_key(row.key) <%= @languages.map{ ", ''"}.join() %>];
45 | for (var lang in row.lang) {
46 | ptype = row.lang[lang];
47 | d[lang_to_idx[lang]] = '
';
48 | }
49 | return { 'cell': d };
50 | })
51 | };
52 | }
53 | }));
54 | }
55 |
--------------------------------------------------------------------------------
/web/views/project.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= h(@project['name']) %>
3 |
<%= h(@project['description']) %>
4 |
5 |
6 |
10 |
11 |
12 | | <%= h(t.pages.project.overview.project_name) %>: | <%= h(@project['name']) %> |
13 | | <%= h(t.pages.project.overview.project_url) %>: | |
14 | | <%= h(t.pages.project.overview.description) %>: | <%= h(@project['description']) %> |
15 | <% if @project['doc_url'] %>
16 | | <%= h(t.pages.project.overview.documentation_url) %>: | |
17 | <% end %>
18 | | <%= h(t.pages.project.overview.last_update) %>: | <%= h(@project['data_updated']) %> |
19 | | <%= h(t.pages.project.overview.json_url) %>: | |
20 |
21 |
<%= t.pages.project.overview.info %>
22 |
23 |
29 |
30 | <% javascript do
31 | JS.raw(<<"JAVASCRIPT")
32 | function page_init2() {
33 | var project = #{ @project_id.to_json },
34 | project_url = #{ @project['project_url'].to_json },
35 | json_url = #{ @project['json_url'].to_json },
36 | icon_url = #{ @project['icon_url'].to_json },
37 | doc_url = #{ @project['doc_url'].to_json };
38 |
39 | if (project_url) {
40 | jQuery('#project_url').html(link_to_url(project_url));
41 | }
42 | if (icon_url) {
43 | jQuery('#icon_url').html(img({ src: icon_url, width: 16, height: 16, alt: ''}));
44 | }
45 | if (json_url) {
46 | jQuery('#json_url').html(link_to_url(json_url));
47 | }
48 | if (doc_url) {
49 | jQuery('#doc_url').html(link_to_url(doc_url));
50 | }
51 |
52 | init_tabs([project]);
53 | }
54 | JAVASCRIPT
55 | end
56 | %>
57 |
--------------------------------------------------------------------------------
/web/views/taginfo/apidoc.erb:
--------------------------------------------------------------------------------
1 | API Documentation
2 |
3 | See the OSM wiki for general information about the API.
4 |
5 | Table of Contents
6 |
7 |
8 | <% API.paths.keys.sort.each do |version|
9 | if version > 0
10 | API.paths[version].keys.sort.each do |path|
11 | doc = API.paths[version][path] %>
12 | - <%= doc.complete_path %><%= doc.deprecated? ? " Deprecated" : '' %>
13 | <% end
14 | end
15 | end %>
16 |
17 |
18 | <% API.paths.keys.sort.each do |version|
19 | if version > 0
20 | API.paths[version].keys.sort.each do |path|
21 | doc = API.paths[version][path]
22 | hashpath = doc.complete_path.tr('/', '_')[1,1000] %>
23 |
24 | <%= doc.complete_path %><%= doc.deprecated? ? " Deprecated" : '' %>
25 |
26 |
27 | | Path: |
28 | <%= doc.complete_path %> |
29 |
30 |
31 | | Description: |
32 | <%= doc.description %> |
33 |
34 |
35 | | Parameters: |
36 | <%= doc.show_parameters %> |
37 |
38 |
39 | | Paging: |
40 | <%= doc.show_paging %> |
41 |
42 |
43 | | Filter: |
44 | <%= doc.show_filter %> |
45 |
46 |
47 | | Sort: |
48 | <%= doc.show_sort %> |
49 |
50 |
51 | | Result: |
52 | <%= doc.show_result %> |
53 |
54 |
55 | | Example: |
56 | <%= h(doc.show_example) %> |
57 |
58 |
59 | | UI Example: |
60 | <%= h(doc.show_ui) %> |
61 |
62 | <% if doc.notes %>
63 |
64 | | Notes: |
65 | <%= doc.notes %> |
66 |
67 | <% end %>
68 |
69 | <% end
70 | end
71 | end %>
72 |
--------------------------------------------------------------------------------
/web/viewsjs/tags.js.erb:
--------------------------------------------------------------------------------
1 | <%
2 | osm = @trans.t.osm
3 | misc = @trans.t.misc
4 | %>
5 | function page_init() {
6 | create_flexigrid('grid-tags', {
7 | url: '/api/4/tags/popular',
8 | colModel: [
9 | { display: '<%= h(osm.tag) %>', name: 'tag', width: 300, sortable: true },
10 | { display: '
<%= h(osm.objects) %>', name: 'count_all', width: 220, sortable: true, align: 'center' },
11 | { display: '
<%= h(osm.nodes) %>', name: 'count_nodes', width: 220, sortable: true, align: 'center' },
12 | { display: '
<%= h(osm.ways) %>', name: 'count_ways', width: 220, sortable: true, align: 'center' },
13 | { display: '
<%= h(osm.relations) %>', name: 'count_relations', width: 220, sortable: true, align: 'center' },
14 | { display: '
', name: 'in_wiki', width: 20, sortable: true, align: 'center' }
15 | ],
16 | searchitems: [
17 | { display: '<%= h(osm.tag) %>', name: 'tag' }
18 | ],
19 | sortname: 'count_all',
20 | sortorder: 'desc',
21 | preProcess: function(data) {
22 | data.rows = jQuery.map(data.data, function(row, i) {
23 | return { 'cell': [
24 | hover_expand(link_to_tag(row.key, row.value, {}, { 'class': 'pref' })),
25 | fmt_value_with_percent(row.count_all, row.count_all_fraction),
26 | fmt_value_with_percent(row.count_nodes, row.count_nodes_fraction),
27 | fmt_value_with_percent(row.count_ways, row.count_ways_fraction),
28 | fmt_value_with_percent(row.count_relations, row.count_relations_fraction),
29 | fmt_checkmark(row.in_wiki)
30 | ] };
31 | });
32 | return data;
33 | }
34 | });
35 | }
36 |
--------------------------------------------------------------------------------
/sources/db/update.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Taginfo source: DB
4 | #
5 | # update.sh DIR [PLANETFILE]
6 | #
7 |
8 | set -e
9 |
10 | # uncomment this if you want to get a core file in case tagstats crashes
11 | #ulimit -c unlimited
12 |
13 | DIR=$1
14 | PLANETFILE=$2
15 |
16 | DATECMD='date +%Y-%m-%dT%H:%M:%S'
17 |
18 | if [ "x" = "x$DIR" ]; then
19 | echo "Usage: update.sh DIR [PLANETFILE]"
20 | exit 1
21 | fi
22 |
23 | if [ "x" = "x$PLANETFILE" ]; then
24 | PLANETFILE=`../../bin/taginfo-config.rb sources.db.planetfile`
25 | fi
26 |
27 | echo "`$DATECMD` Start db..."
28 |
29 | DATABASE=$DIR/taginfo-db.db
30 | SELECTION_DB=$DIR/../selection.db
31 |
32 | rm -f $DATABASE
33 |
34 | echo "`$DATECMD` Running init.sql..."
35 | sqlite3 $DATABASE <../init.sql
36 |
37 | echo "`$DATECMD` Running pre.sql..."
38 | sqlite3 $DATABASE 'Get list of all projects using OSM tags known to taginfo.',
6 | :parameters => { :status => 'Only show projects with given status (default is "OK")', :query => 'Only show projects matching this query (substring match, optional).' },
7 | :paging => :optional,
8 | :sort => %w( name ),
9 | :result => paging_results([
10 | [:id, :STRING, 'Project id'],
11 | [:name, :STRING, 'Project name'],
12 | [:project_url, :STRING, 'Project URL'],
13 | [:icon_url, :STRING, 'Icon URL'],
14 | [:doc_url, :STRING, 'Documentation URL'],
15 | [:description, :STRING, 'Project description']
16 | ]),
17 | :example => { :page => 1, :rp => 10, :sortname => 'name', :sortorder => 'asc' },
18 | :ui => '/projects'
19 | }) do
20 | if params[:status]
21 | status = params[:status]
22 | else
23 | status = 'OK'
24 | end
25 |
26 | q = like_contains(params[:query])
27 | total = @db.count('projects.projects').
28 | condition("status=?", status).
29 | condition_if("name LIKE ? ESCAPE '@' OR description LIKE ? ESCAPE '@'", q, q).
30 | get_first_value().to_i
31 |
32 | res = @db.select('SELECT * FROM projects.projects').
33 | condition("status=?", status).
34 | condition_if("name LIKE ? ESCAPE '@' OR description LIKE ? ESCAPE '@'", q, q).
35 | order_by(@ap.sortname, @ap.sortorder) { |o|
36 | o.name 'lower(name)'
37 | }.
38 | paging(@ap).
39 | execute()
40 |
41 | return JSON.generate({
42 | :page => @ap.page,
43 | :rp => @ap.results_per_page,
44 | :total => total,
45 | :url => request.url,
46 | :data => res.map{ |row| {
47 | :id => row['id'],
48 | :name => row['name'],
49 | :project_url => row['project_url'],
50 | :icon_url => row['icon_url'],
51 | :doc_url => row['doc_url'],
52 | :description => row['description'],
53 | }}
54 | }, json_opts(params[:format]))
55 | end
56 |
57 | end
58 |
--------------------------------------------------------------------------------
/web/viewsjs/reports/frequently_used_keys_without_wiki_page.js.erb:
--------------------------------------------------------------------------------
1 | <%
2 | osm = @trans.t.osm
3 | misc = @trans.t.misc
4 | page = @trans.t.reports.frequently_used_keys_without_wiki_page
5 | %>
6 | function create_flexigrid_with_option(english) {
7 | create_flexigrid('grid-keys', {
8 | url: '/api/4/keys/without_wiki_page?english=' + english,
9 | colModel: [
10 | { display: '<%= h(page.table.create_wiki_page) %>', name: 'create_wiki_page', width: 200, sortable: false },
11 | { display: '<%= h(osm.key) %>', name: 'key', width: 180, sortable: true },
12 | { display: '
<%= h(osm.objects) %>', name: 'count_all', width: 70, sortable: true, align: 'right' },
13 | { display: '<%= h(osm.users) %>', name: 'users_all', width: 44, sortable: true, align: 'right' },
14 | { display: '<%= h(osm.values) %>', name: 'values_all', width: 70, sortable: true, align: 'right' },
15 | { display: '<%= h(misc.prevalent_values) %>', name: 'prevalent_values', width: 500, sortable: true }
16 | ],
17 | searchitems: [
18 | { display: '<%= h(osm.key) %>', name: 'key' }
19 | ],
20 | sortname: 'count_all',
21 | sortorder: 'desc',
22 | preProcess: function(data) {
23 | data.rows = jQuery.map(data.data, function(row, i) {
24 | return { 'cell': [
25 | link_to_wiki('Key:' + row.key, { edit: true }),
26 | link_to_key(row.key),
27 | fmt_with_ts(row.count_all),
28 | fmt_with_ts(row.users_all),
29 | fmt_with_ts(row.values_all),
30 | fmt_prevalent_value_list(row.key, row.prevalent_values)
31 | ] };
32 | });
33 | return data;
34 | }
35 | });
36 | }
37 |
38 | function page_init() {
39 | up = function() { window.location = '/reports'; };
40 | page_init2();
41 | jQuery('#english').bind('click', function() {
42 | jQuery('#grid-keys').flexOptions({
43 | url: '/api/4/keys/without_wiki_page?english=' + (jQuery('#english')[0].checked ? '1' : '0')
44 | }).flexReload();
45 | });
46 | }
47 |
--------------------------------------------------------------------------------
/web/lib/api/v4/wiki.rb:
--------------------------------------------------------------------------------
1 | # web/lib/api/v4/wiki.rb
2 | class Taginfo < Sinatra::Base
3 |
4 | api(4, 'wiki/languages', {
5 | :description => 'List languages taginfo knows about and how many wiki pages describing keys and tags there are in these languages.',
6 | :paging => :no,
7 | :result => no_paging_results([
8 | [:code , :STRING, 'Language code.'],
9 | [:native_name , :STRING, 'Name of language in this language.'],
10 | [:english_name , :STRING, 'Name of language in English.'],
11 | [:wiki_key_pages , :INT, 'Number of "Key" wiki pages in this language.'],
12 | [:wiki_key_pages_fraction, :FLOAT, 'Number of "Key" wiki pages in this language in relation to the number of keys described in any language in the wiki.'],
13 | [:wiki_tag_pages , :INT, 'Number of "Tag" wiki pages in this language.'],
14 | [:wiki_tag_pages_fraction, :FLOAT, 'Number of "Tag" wiki pages in this language in relation to the number of tags described in any language in the wiki.']
15 | ]),
16 | :sort => %w( code native_name english_name wiki_key_pages wiki_tag_pages ),
17 | :example => { :sortname => 'wiki_key_pages', :sortorder => 'desc' },
18 | :ui => '/reports/languages'
19 | }) do
20 | res = @db.select('SELECT * FROM languages').
21 | order_by(@ap.sortname, @ap.sortorder) { |o|
22 | o.code
23 | o.native_name
24 | o.english_name
25 | o.wiki_key_pages
26 | o.wiki_tag_pages
27 | }.
28 | execute()
29 |
30 | return JSON.generate({
31 | :total => res.size,
32 | :url => request.url,
33 | :data => res.map{ |row| {
34 | :code => row['code'],
35 | :native_name => row['native_name'],
36 | :english_name => row['english_name'],
37 | :wiki_key_pages => row['wiki_key_pages'].to_i,
38 | :wiki_key_pages_fraction => row['wiki_key_pages'].to_f / @db.stats('wiki_keys_described'),
39 | :wiki_tag_pages => row['wiki_tag_pages'].to_i,
40 | :wiki_tag_pages_fraction => row['wiki_tag_pages'].to_f / @db.stats('wiki_tags_described'),
41 | } }
42 | }, json_opts(params[:format]))
43 | end
44 |
45 | end
46 |
--------------------------------------------------------------------------------
/sources/db/update_characters.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/ruby
2 | #------------------------------------------------------------------------------
3 | #
4 | # Taginfo source: DB
5 | #
6 | # update_characters.rb
7 | #
8 | #------------------------------------------------------------------------------
9 | #
10 | # Copyright (C) 2013 Jochen Topf
11 | #
12 | # This program is free software; you can redistribute it and/or modify
13 | # it under the terms of the GNU General Public License as published by
14 | # the Free Software Foundation; either version 2 of the License, or
15 | # (at your option) any later version.
16 | #
17 | # This program is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | # GNU General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU General Public License along
23 | # with this program; if not, write to the Free Software Foundation, Inc.,
24 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 | #
26 | #------------------------------------------------------------------------------
27 |
28 | require 'sqlite3'
29 |
30 | dir = ARGV[0] || '.'
31 | db = SQLite3::Database.new(dir + '/taginfo-db.db')
32 | db.results_as_hash = true
33 |
34 | db.execute("PRAGMA journal_mode = OFF");
35 | db.execute("PRAGMA synchronous = OFF");
36 | db.execute("PRAGMA count_changes = OFF");
37 | db.execute("PRAGMA temp_store = MEMORY;");
38 | db.execute("PRAGMA cache_size = 5000000;");
39 |
40 | #------------------------------------------------------------------------------
41 |
42 | regexes = [
43 | [ 'plain', %r{^[a-z]([a-z_]*[a-z])?$} ],
44 | [ 'colon', %r{^[a-z][a-z_:]*[a-z]$} ],
45 | [ 'letters', %r{^[\p{L}\p{M}]([\p{L}\p{M}\p{N}_:]*[\p{L}\p{M}\p{N}])?$}u ],
46 | [ 'space', %r{[\s\p{Z}]}u ],
47 | [ 'problem', %r{[=+/&<>;\@'"?%#\\,\p{C}]}u ]
48 | ];
49 |
50 | keys = {}
51 | db.execute("SELECT key FROM keys").map{ |row| row['key'] }.each do |key|
52 | keys[key] = 'rest'
53 | regexes.each do |type, regex|
54 | if key.match(regex)
55 | keys[key] = type
56 | break
57 | end
58 | end
59 | end
60 |
61 | db.transaction do |db|
62 | keys.each do |key, type|
63 | db.execute("UPDATE keys SET characters=? WHERE key=?", type, key);
64 | end
65 | end
66 |
67 | #-- THE END -------------------------------------------------------------------
68 |
--------------------------------------------------------------------------------
/sources/languages/update.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Taginfo source: Languages
4 | #
5 | # update.sh DIR
6 | #
7 |
8 | set -e
9 |
10 | DIR=$1
11 | REGISTRY_URL="http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry"
12 | REGISTRY_FILE="$DIR/language-subtag-registry"
13 | CLDR_URL="http://unicode.org/Public/cldr/latest/core.zip"
14 | CLDR_FILE="$DIR/cldr-core.zip"
15 | CLDR_DIR="$DIR/cldr"
16 | UNICODE_SCRIPTS_URL="http://www.unicode.org/Public/UNIDATA/Scripts.txt"
17 | UNICODE_SCRIPTS_FILE="$DIR/Scripts.txt"
18 | PROPERTY_ALIASES_URL="http://www.unicode.org/Public/UNIDATA/PropertyValueAliases.txt"
19 | PROPERTY_ALIASES_FILE="$DIR/PropertyValueAliases.txt"
20 |
21 | DATECMD='date +%Y-%m-%dT%H:%M:%S'
22 |
23 | update_file() {
24 | file=$1
25 | url=$2
26 |
27 | if curl --silent --fail --location --time-cond $file --output $file $url; then
28 | return 0
29 | else
30 | error=$?
31 | if [ "$error" = "22" ]; then
32 | echo "WARNING: Getting ${url} failed. Using old version."
33 | else
34 | echo "ERROR: Could not get ${url}: curl error: $error"
35 | exit 1
36 | fi
37 | fi
38 | }
39 |
40 | if [ "x" = "x$DIR" ]; then
41 | echo "Usage: update.sh DIR"
42 | exit 1
43 | fi
44 |
45 | echo "`$DATECMD` Start languages..."
46 |
47 | EXEC_RUBY="$TAGINFO_RUBY"
48 | if [ "x$EXEC_RUBY" = "x" ]; then
49 | EXEC_RUBY=ruby
50 | fi
51 | echo "Running with ruby set as '${EXEC_RUBY}'"
52 |
53 | DATABASE=$DIR/taginfo-languages.db
54 |
55 | rm -f $DATABASE
56 |
57 | echo "`$DATECMD` Running init.sql..."
58 | sqlite3 $DATABASE <../init.sql
59 |
60 | echo "`$DATECMD` Running pre.sql..."
61 | sqlite3 $DATABASE
2 |
3 | | <%= h(t.help.keyboard.site_navigation) %> |
4 | <%= h(t.help.keyboard.page_navigation) %> |
5 | <%= h(t.help.keyboard.table_navigation) %> |
6 |
7 |
8 | | h - <%= h(t.help.keyboard.home_page) %> |
9 | ? - <%= h(t.help.keyboard.help_page) %> |
10 | <%= h(t.help.keyboard.keys.home) %> - <%= h(t.help.keyboard.first_page) %> |
11 |
12 | k - <%= h(t.help.keyboard.keys_page) %> |
13 | s - <%= h(t.help.keyboard.activate_search) %> |
14 | <%= h(t.help.keyboard.keys.pageup) %> - <%= h(t.help.keyboard.prev_page) %> |
15 |
16 | | t - <%= h(t.help.keyboard.tags_page) %> |
17 | <%= h(t.help.keyboard.keys.tab) %> - <%= h(t.help.keyboard.switch_input) %> |
18 | <%= h(t.help.keyboard.keys.pagedown) %> - <%= h(t.help.keyboard.next_page) %> |
19 |
20 |
21 | | r - <%= h(t.help.keyboard.relations_page) %> |
22 | 1 - 9 - <%= h(t.help.keyboard.switch_tab) %> |
23 | <%= h(t.help.keyboard.keys.end) %> - <%= h(t.help.keyboard.last_page) %> |
24 |
25 |
26 | | p - <%= h(t.help.keyboard.projects_page) %> |
27 | <%= h(t.help.keyboard.keys.esc) %> - <%= h(t.help.keyboard.deactivate) %> |
28 | ↑ - <%= h(t.help.keyboard.prev_entry) %> |
29 |
30 |
31 | | c - <%= h(t.help.keyboard.compare_page) %> |
32 | |
33 | ↓ - <%= h(t.help.keyboard.next_entry) %> |
34 |
35 |
36 | | ← - <%= h(t.help.keyboard.up) %> |
37 | |
38 | → - <%= h(t.help.keyboard.enter_entry) %> |
39 |
40 |
41 | |
42 | |
43 | f - <%= h(t.help.keyboard.activate_filter) %> |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/sources/master/selection.sql:
--------------------------------------------------------------------------------
1 | -- ============================================================================
2 | --
3 | -- Taginfo
4 | --
5 | -- selection.sql
6 | --
7 | -- This database contains a selection of often used tags etc.
8 | --
9 | -- It is used in the next taginfo run to create some statistics, maps, etc.
10 | -- only for those selected data.
11 | --
12 | -- ============================================================================
13 |
14 | .bail ON
15 |
16 | -- ============================================================================
17 |
18 | ATTACH DATABASE '__DIR__/db/taginfo-db.db' AS db;
19 | ATTACH DATABASE '__DIR__/wiki/taginfo-wiki.db' AS wiki;
20 |
21 | -- ============================================================================
22 |
23 | DROP TABLE IF EXISTS interesting_tags;
24 | CREATE TABLE interesting_tags (
25 | key TEXT,
26 | value TEXT
27 | );
28 |
29 | -- MIN_COUNT_TAGS setting: sources.master.min_count_tags
30 | INSERT INTO interesting_tags (key, value)
31 | SELECT DISTINCT key, NULL FROM db.keys WHERE count_all > __MIN_COUNT_TAGS__
32 | UNION
33 | SELECT key, value FROM db.tags WHERE count_all > __MIN_COUNT_TAGS__;
34 |
35 | DELETE FROM interesting_tags WHERE key IN ('created_by', 'ele', 'height', 'is_in', 'lanes', 'layer', 'maxspeed', 'name', 'ref', 'width') AND value IS NOT NULL;
36 | DELETE FROM interesting_tags WHERE value IS NOT NULL AND key LIKE '%:%';
37 | DELETE FROM interesting_tags WHERE value IS NOT NULL AND key LIKE 'fresno_%';
38 |
39 | ANALYZE interesting_tags;
40 |
41 | -- ============================================================================
42 |
43 | DROP TABLE IF EXISTS frequent_tags;
44 | CREATE TABLE frequent_tags (
45 | key TEXT,
46 | value TEXT
47 | );
48 |
49 | -- MIN_COUNT_FOR_MAP setting: sources.master.min_count_for_map
50 | INSERT INTO frequent_tags (key, value) SELECT key, value FROM db.tags WHERE count_all > __MIN_COUNT_FOR_MAP__;
51 |
52 | ANALYZE frequent_tags;
53 |
54 | -- ============================================================================
55 |
56 | DROP TABLE IF EXISTS interesting_relation_types;
57 | CREATE TABLE interesting_relation_types (
58 | rtype TEXT
59 | );
60 |
61 | -- MIN_COUNT_RELATIONS_PER_TYPE setting: sources.master.min_count_relations_per_type
62 | INSERT INTO interesting_relation_types (rtype)
63 | SELECT value FROM db.tags WHERE key='type' AND count_relations > __MIN_COUNT_RELATIONS_PER_TYPE__;
64 |
65 | ANALYZE interesting_relation_types;
66 |
67 | -- ============================================================================
68 |
--------------------------------------------------------------------------------
/web/lib/api/v4/project.rb:
--------------------------------------------------------------------------------
1 | # web/lib/api/v4/project.rb
2 | class Taginfo < Sinatra::Base
3 |
4 | api(4, 'project/tags', {
5 | :description => 'Get list of all keys/tags used by a project.',
6 | :parameters => { :project => 'Project ID' },
7 | :paging => :optional,
8 | :sort => %w( tag ),
9 | :result => paging_results([
10 | [:key, :STRING, 'Key'],
11 | [:value, :STRING, 'Value'],
12 | [:on_node, :BOOL, 'For nodes?'],
13 | [:on_way, :BOOL, 'For ways?'],
14 | [:on_relation, :BOOL, 'For relations?'],
15 | [:on_area, :BOOL, 'For areas?'],
16 | [:description, :STRING, 'Description'],
17 | [:doc_url, :STRING, 'Documentation URL'],
18 | [:icon_url, :STRING, 'Icon URL']
19 | ]),
20 | :example => { :page => 1, :rp => 10, :sortname => 'key', :sortorder => 'asc' },
21 | :ui => '/projects/id_editor'
22 | }) do
23 | project_id = params[:project]
24 |
25 | q = like_contains(params[:query])
26 | total = @db.count('projects.project_tags').
27 | condition("project_id=?", project_id).
28 | condition_if("key LIKE ? ESCAPE '@' OR value LIKE ? ESCAPE '@'", q, q).
29 | get_first_value().to_i
30 |
31 | res = @db.select('SELECT * FROM projects.project_tags').
32 | condition("project_id=?", project_id).
33 | condition_if("key LIKE ? ESCAPE '@' OR value LIKE ? ESCAPE '@'", q, q).
34 | order_by(@ap.sortname, @ap.sortorder) { |o|
35 | o.tag :key
36 | o.tag :value
37 | }.
38 | paging(@ap).
39 | execute()
40 |
41 | return JSON.generate({
42 | :page => @ap.page,
43 | :rp => @ap.results_per_page,
44 | :total => total,
45 | :url => request.url,
46 | :data => res.map{ |row| {
47 | :key => row['key'],
48 | :value => row['value'],
49 | :on_node => row['on_node'].to_i == 1,
50 | :on_way => row['on_way'].to_i == 1,
51 | :on_relation => row['on_relation'].to_i == 1,
52 | :on_area => row['on_area'].to_i == 1,
53 | :description => row['description'],
54 | :doc_url => row['doc_url'],
55 | :icon_url => row['icon_url']
56 | }}
57 | }, json_opts(params[:format]))
58 | end
59 |
60 | end
61 |
--------------------------------------------------------------------------------
/sources/wiki/lib/mediawikiapi.rb:
--------------------------------------------------------------------------------
1 | #------------------------------------------------------------------------------
2 | #
3 | # MediaWikiAPI
4 | #
5 | #------------------------------------------------------------------------------
6 | #
7 | # Simple helper class to access the Mediawiki API.
8 | #
9 | #------------------------------------------------------------------------------
10 | #
11 | # Copyright (C) 2013 Jochen Topf
12 | #
13 | # This program is free software; you can redistribute it and/or modify
14 | # it under the terms of the GNU General Public License as published by
15 | # the Free Software Foundation; either version 2 of the License, or
16 | # (at your option) any later version.
17 | #
18 | # This program is distributed in the hope that it will be useful,
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | # GNU General Public License for more details.
22 | #
23 | # You should have received a copy of the GNU General Public License along
24 | # with this program; if not, write to the Free Software Foundation, Inc.,
25 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 | #
27 | #------------------------------------------------------------------------------
28 |
29 | require 'cgi'
30 |
31 | module MediaWikiAPI
32 |
33 | class API
34 |
35 | def initialize(host, port=80, path='/w/api.php?')
36 | @host = host
37 | @port = port
38 | @path = path
39 | @headers = {}
40 | add_header('User-agent', 'taginfo/1.0 (http://wiki.osm.org/wiki/Taginfo)')
41 | end
42 |
43 | def add_header(name, value)
44 | @headers[name] = value
45 | end
46 |
47 | def build_path(params)
48 | @path + params.to_a.map{ |el| CGI::escape(el[0].to_s) + '=' + CGI::escape(el[1].to_s) }.join('&')
49 | end
50 |
51 | def get(params)
52 | path = build_path(params)
53 | http = Net::HTTP.start(@host, @port)
54 | # puts "Getting path [#{path}]"
55 | result = http.get(path, @headers)
56 | result.body.force_encoding('UTF-8')
57 | result
58 | end
59 |
60 | def query(params)
61 | params[:action] = 'query'
62 | params[:format] = 'json'
63 | result = get(params)
64 | JSON.parse(result.body, { :create_additions => false })
65 | end
66 |
67 | end
68 |
69 | end
70 |
71 | #-- THE END -------------------------------------------------------------------
72 |
--------------------------------------------------------------------------------
/tagstats/Makefile:
--------------------------------------------------------------------------------
1 | #------------------------------------------------------------------------------
2 | #
3 | # Tagstats Makefile
4 | #
5 | #------------------------------------------------------------------------------
6 | #
7 | # You can set several environment variables before running make if you don't
8 | # like the defaults:
9 | #
10 | # CXX - Your C++ compiler.
11 | # CPLUS_INCLUDE_PATH - Include file search path. This should include the
12 | # directory where Osmium is.
13 | # CXXFLAGS - Extra compiler flags.
14 | # LDFLAGS - Extra linker flags.
15 | #
16 | #------------------------------------------------------------------------------
17 |
18 | CXXFLAGS += -O3
19 | #CXXFLAGS += -g
20 | #CXXFLAGS += -g -pg
21 | #CXXFLAGS += -g -fprofile-arcs -ftest-coverage
22 | CXXFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
23 | CXXFLAGS += `../bin/taginfo-config.rb tagstats.cxxflags`
24 |
25 | GEODISTRIBUTION_TYPE := $(shell ../bin/taginfo-config.rb tagstats.geodistribution_int uint16_t)
26 | BYID := $(shell ../bin/taginfo-config.rb tagstats.geodistribution)
27 | #BYID := SparseTable
28 | #BYID := MmapFile
29 | #BYID := MmapAnon
30 | BYID_LC := $(shell echo $(BYID) | sed -e 's/\([A-Z]\)/_\1/g' | cut -c2- | tr 'A-Z' 'a-z')
31 | BYID_INCL := ""
32 |
33 | CXXFLAGS_FEATURES += -DTAGSTATS_GEODISTRIBUTION_INT=$(GEODISTRIBUTION_TYPE)
34 | CXXFLAGS_FEATURES += -DTAGSTATS_GEODISTRIBUTION_FOR_WAYS=$(BYID)
35 | CXXFLAGS_FEATURES += -DTAGSTATS_GEODISTRIBUTION_INCLUDE=$(BYID_INCL)
36 |
37 | CXXFLAGS_WARNINGS := -Wall -Wextra -Wredundant-decls -Wdisabled-optimization -pedantic
38 |
39 | LIB_EXPAT := -lexpat
40 | LIB_PBF := -pthread -lz -lprotobuf-lite -losmpbf
41 | LIB_GD := -lgd -lz -lm
42 | LIB_SQLITE := -lsqlite3
43 |
44 | .PHONY: all check indent install clean
45 |
46 | all: tagstats osmstats
47 |
48 | osmstats: osmstats.cpp statistics_handler.hpp
49 | $(CXX) $(CXXFLAGS) $(CXXFLAGS_WARNINGS) -o $@ $< $(LDFLAGS) $(LIB_EXPAT) $(LIB_PBF) $(LIB_SQLITE)
50 |
51 | tagstats: tagstats.cpp tagstats_handler.hpp statistics_handler.hpp string_store.hpp geodistribution.hpp sqlite.hpp
52 | $(CXX) $(CXXFLAGS) $(CXXFLAGS_WARNINGS) $(CXXFLAGS_FEATURES) -o $@ $< $(LDFLAGS) $(LIB_EXPAT) $(LIB_PBF) $(LIB_SQLITE) $(LIB_GD)
53 |
54 | check:
55 | cppcheck --enable=all tagstats.cpp osmstats.cpp
56 |
57 | indent:
58 | astyle --style=java --indent-namespaces --indent-switches --pad-header --suffix=none \*.hpp \*.cpp
59 |
60 | install:
61 | install -m 755 tagstats ../sources/db/tagstats
62 |
63 | clean:
64 | rm -f *.o *.gcno *.gcda *.gcov gmon.out core tagstats osmstats
65 |
66 |
--------------------------------------------------------------------------------
/web/views/embed/tag.erb:
--------------------------------------------------------------------------------
1 | <% if @key == '{{{key}}}' && @value == '{{{value}}}' %>
2 | taginfo [More...]
3 | Statistics about the tag will appear here.
4 | <% elsif @dbtag.nil? %>
5 | taginfo [More...]
6 | This tag does not appear in the OSM database.
7 | <% else %>
8 | taginfo [More...]
9 |
10 |
11 |  |
12 | <%= @dbtag['count_nodes'].to_i.to_s_with_ts %> |
13 | <%= @dbkey['count_nodes'] == 0 ? '0.00' : ('%.2f' % (@dbtag['count_nodes'].to_f / @dbkey['count_nodes'].to_f * 100)) %> % |
14 |
15 |
16 |  |
17 | <%= @dbtag['count_ways'].to_i.to_s_with_ts %> |
18 | <%= @dbkey['count_ways'] == 0 ? '0.00' : ('%.2f' % (@dbtag['count_ways'].to_f / @dbkey['count_ways'].to_f * 100)) %> % |
19 |
20 |
21 |  |
22 | <%= @dbtag['count_relations'].to_i.to_s_with_ts %> |
23 | <%= @dbkey['count_relations'] == 0 ? '0.00' : ('%.2f' % (@dbtag['count_relations'].to_f / @dbkey['count_relations'].to_f * 100)) %> % |
24 |
25 |
26 | <% end %>
27 |
--------------------------------------------------------------------------------
/sources/languages/import_unicode_scripts.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/ruby
2 | #------------------------------------------------------------------------------
3 | #
4 | # Taginfo source: Languages
5 | #
6 | # import_unicode_scripts.rb
7 | #
8 | #------------------------------------------------------------------------------
9 | #
10 | # Copyright (C) 2013 Jochen Topf
11 | #
12 | # This program is free software; you can redistribute it and/or modify
13 | # it under the terms of the GNU General Public License as published by
14 | # the Free Software Foundation; either version 2 of the License, or
15 | # (at your option) any later version.
16 | #
17 | # This program is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | # GNU General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU General Public License along
23 | # with this program; if not, write to the Free Software Foundation, Inc.,
24 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 | #
26 | #------------------------------------------------------------------------------
27 |
28 | require 'sqlite3'
29 |
30 | dir = ARGV[0] || '.'
31 | db = SQLite3::Database.new(dir + '/taginfo-languages.db')
32 |
33 | #------------------------------------------------------------------------------
34 |
35 | property_value_alias_file = "#{dir}/PropertyValueAliases.txt"
36 | codepoint_script_mapping_file = "#{dir}/Scripts.txt"
37 |
38 | db.transaction do |db|
39 | open(property_value_alias_file) do |file|
40 | file.each do |line|
41 | line.chomp!
42 | if line.match(%r{^sc ;})
43 | (sc, script, name) = line.split(%r{\s*;\s*})
44 | db.execute("INSERT INTO unicode_scripts (script, name) VALUES (?, ?)", script, name)
45 | end
46 | end
47 | end
48 |
49 | open(codepoint_script_mapping_file) do |file|
50 | file.each do |line|
51 | line.chomp!
52 | line.sub!(%r{\s*#.*}, '')
53 | next if line.match(%r{^$})
54 | (codes, script) = line.split(%r{\s+;\s+})
55 | if codes.match(%r{^[0-9A-F]{4,5}$})
56 | from = codes
57 | to = codes
58 | elsif codes.match(%r{^([0-9A-F]{4,5})..([0-9A-F]{4,5})$})
59 | from = $1
60 | to = $2
61 | else
62 | puts "Line does not match: #{line}"
63 | next
64 | end
65 | db.execute("INSERT INTO unicode_codepoint_script_mapping (codepoint_from, codepoint_to, name) VALUES (?, ?, ?)", from, to, script)
66 | end
67 | end
68 | end
69 |
70 |
71 | #-- THE END -------------------------------------------------------------------
72 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Taginfo
2 |
3 | Brings together information about OpenStreetMap tags and makes it searchable
4 | and browsable.
5 |
6 | **Documentation:** See the
7 | [Taginfo](http://wiki.openstreetmap.org/wiki/Taginfo) page at the OpenStreetMap
8 | wiki.
9 |
10 | **Live System:** [taginfo.openstreetmap.org](http://taginfo.openstreetmap.org/)
11 |
12 |
13 | ## Files
14 |
15 | * `/sources` - import scripts
16 | * `/web` - web user interface and API
17 | * `/examples` - some misc example stuff
18 | * `/tagstats` - C++ program to create database statistics
19 |
20 |
21 | ## Prerequisites
22 |
23 | It uses:
24 |
25 | * Ruby (must be at least 1.9.1)
26 | * Mongrel or Apache2 mod_passenger
27 | * [Sinatra web framework](http://www.sinatrarb.com/)
28 | * Rack Contrib Gem (for `Rack::JSONP`)
29 | * JSON gem (install with gem, Debian/Ubuntu packages are too old and buggy)
30 | * curl binary
31 | * sqlite3 binary and ruby libs
32 | * m4 binary
33 |
34 | Install the Debian/Ubuntu packages:
35 | ```sh
36 | $ sudo apt-get install curl m4 sqlite3 ruby-sqlite3
37 | $ sudo apt-get install ruby-passenger libapache2-mod-passenger
38 | ```
39 |
40 | Install the Gems:
41 | ```sh
42 | $ sudo gem install rack rack-contrib sinatra sinatra-r18n json
43 | ```
44 |
45 | There is a developer mailing list:
46 | [taginfo-dev](http://lists.openstreetmap.org/listinfo/taginfo-dev)
47 |
48 |
49 | ## Data Import
50 |
51 | See [Taginfo/Running](http://wiki.openstreetmap.org/wiki/Taginfo/Running) at
52 | OpenStreetMap's wiki.
53 |
54 |
55 | ## Web User Interface
56 |
57 | You need a `/data` directory (in the parent directory of the directory where
58 | this `README.md` is). It must contain the sqlite database files created in the
59 | data import step or downloaded from page
60 | [taginfo.openstreetmap.org/download](http://taginfo.openstreetmap.org/download).
61 |
62 | To start the web user interface:
63 | ```sh
64 | $ cd web
65 | $ ./taginfo.rb
66 | ```
67 |
68 | ## Javascript
69 |
70 | Taginfo uses the following Javascript libraries:
71 | * jQuery 1.9.0
72 | * jQuery UI 1.9.2
73 | * [customSelect](http://adam.co/lab/jquery/customselect/)
74 | * [tipsy](http://onehackoranother.com/projects/jquery/tipsy/)
75 | * [jQuery Cookie](https://github.com/carhartl/jquery-cookie/)
76 | * Flexigrid (from [Google Code](http://code.google.com/p/flexigrid/) and
77 | [flexigrid.info](http://www.flexigrid.info/), but with changes and bugfixes)
78 |
79 | All the Javascript and CSS needed is already included.
80 |
81 |
82 | ## Thanks
83 |
84 | * Stefano Tampieri, for the Italian translation
85 | * Ilya Zverev (zverik@textual.ru), for the Russion translation
86 | * Jocelyn Jaubert (jocelyn.jaubert@gmail.com), for the French translation
87 | * Jacek Buczyński (jacekzlodzi@gmail.com), for the Polish translation
88 |
89 |
90 | ## Author
91 |
92 | Jochen Topf (jochen@remote.org) - [Joto](http://wiki.openstreetmap.org/wiki/User:Joto)
93 |
94 |
--------------------------------------------------------------------------------
/web/views/index.erb:
--------------------------------------------------------------------------------
1 |
57 | <% javascript_for(:d3, :d3_cloud) %>
58 |
--------------------------------------------------------------------------------
/web/lib/ui/relation.rb:
--------------------------------------------------------------------------------
1 | # web/lib/ui/relations.rb
2 | class Taginfo < Sinatra::Base
3 |
4 | get %r{^/relations/(.*)} do |rtype|
5 | if params[:rtype].nil?
6 | @rtype = rtype
7 | else
8 | @rtype = params[:rtype]
9 | end
10 |
11 | @rtype_uri = escape(@rtype)
12 |
13 | @title = [escape_html(@rtype), t.osm.relations]
14 | section :relations
15 |
16 | @wiki_count = @db.count('wiki.relation_pages').condition('rtype=?', @rtype).get_first_i
17 | @count_all_values = @db.select("SELECT count FROM db.relation_types").condition('rtype = ?', @rtype).get_first_i
18 |
19 | @desc = h(@db.select("SELECT description FROM wiki.relation_pages WHERE lang=? AND rtype=?", r18n.locale.code, @rtype).get_first_value())
20 | @desc = h(@db.select("SELECT description FROM wiki.relation_pages WHERE lang='en' AND rtype=?", @rtype).get_first_value()) if @desc == ''
21 | if @desc == ''
22 | @desc = "#{ t.pages.relation.no_description_in_wiki }"
23 | else
24 | @desc = "#{ @desc }"
25 | end
26 |
27 | @db.select("SELECT width, height, image_url, thumb_url_prefix, thumb_url_suffix FROM wiki.relation_pages LEFT OUTER JOIN wiki.wiki_images USING(image) WHERE lang=? AND rtype=? UNION SELECT width, height, image_url, thumb_url_prefix, thumb_url_suffix FROM wiki.relation_pages LEFT OUTER JOIN wiki.wiki_images USING(image) WHERE lang='en' AND rtype=? LIMIT 1", r18n.locale.code, @rtype, @rtype).
28 | execute() do |row|
29 | @image_url = build_image_url(row)
30 | end
31 |
32 | @count_relation_roles = @db.count('relation_roles').condition("rtype=?", @rtype).get_first_i
33 |
34 | sum_count_all = @db.select("SELECT members_all FROM db.relation_types WHERE rtype=?", @rtype).get_first_i
35 |
36 | @roles = []
37 | sum = { 'nodes' => 0, 'ways' => 0, 'relations' => 0 }
38 | @db.select("SELECT * FROM db.relation_roles WHERE rtype=? ORDER BY count_all DESC", @rtype).execute() do |row|
39 | %w( nodes ways relations ).each do |type|
40 | count = row["count_#{ type }"].to_i
41 | if row['count_all'].to_i < sum_count_all * 0.01
42 | sum[type] += count
43 | else
44 | @roles << { :role => row['role'], :type => type, :value => count }
45 | end
46 | end
47 | end
48 | if sum['nodes'] > 0 || sum['ways'] > 0 || sum['relations'] > 0
49 | %w( nodes ways relations ).each do |type|
50 | @roles << { :role => '...', :type => type, :value => sum[type] }
51 | end
52 | end
53 |
54 | javascript_for(:flexigrid, :d3)
55 | javascript "#{ r18n.locale.code }/relation"
56 | erb :relation
57 | end
58 |
59 | end
60 |
--------------------------------------------------------------------------------
/sources/wiki/pre.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Taginfo source: Wiki
3 | --
4 | -- pre.sql
5 | --
6 |
7 | .bail ON
8 |
9 | INSERT INTO source (id, name, update_start, data_until) SELECT 'wiki', 'Wiki', datetime('now'), datetime('now');
10 |
11 | DROP TABLE IF EXISTS wikipages;
12 |
13 | CREATE TABLE wikipages (
14 | lang TEXT,
15 | tag TEXT,
16 | key TEXT,
17 | value TEXT,
18 | title TEXT,
19 | body TEXT,
20 | tgroup TEXT,
21 | type TEXT,
22 | has_templ INTEGER,
23 | parsed INTEGER,
24 | description TEXT,
25 | image TEXT,
26 | on_node INTEGER,
27 | on_way INTEGER,
28 | on_area INTEGER,
29 | on_relation INTEGER,
30 | tags_implies TEXT,
31 | tags_combination TEXT,
32 | tags_linked TEXT,
33 | status TEXT
34 | );
35 |
36 | DROP TABLE IF EXISTS relation_pages;
37 |
38 | CREATE TABLE relation_pages (
39 | lang TEXT,
40 | rtype TEXT,
41 | title TEXT,
42 | body TEXT,
43 | tgroup TEXT,
44 | type TEXT,
45 | has_templ INTEGER,
46 | parsed INTEGER,
47 | description TEXT,
48 | image TEXT,
49 | tags_linked TEXT,
50 | status TEXT
51 | );
52 |
53 | DROP TABLE IF EXISTS wiki_images;
54 |
55 | CREATE TABLE wiki_images (
56 | image TEXT,
57 | width INTEGER,
58 | height INTEGER,
59 | size INTEGER,
60 | mime TEXT,
61 | image_url TEXT,
62 | thumb_url_prefix TEXT,
63 | thumb_url_suffix TEXT
64 | );
65 |
66 | DROP TABLE IF EXISTS wikipages_keys;
67 |
68 | CREATE TABLE wikipages_keys (
69 | key TEXT,
70 | langs TEXT,
71 | lang_count INTEGER
72 | );
73 |
74 | DROP TABLE IF EXISTS wikipages_tags;
75 |
76 | CREATE TABLE wikipages_tags (
77 | key TEXT,
78 | value TEXT,
79 | langs TEXT,
80 | lang_count INTEGER
81 | );
82 |
83 | DROP TABLE IF EXISTS wiki_languages;
84 |
85 | CREATE TABLE wiki_languages (
86 | language TEXT,
87 | count_pages INTEGER
88 | );
89 |
90 | DROP TABLE IF EXISTS invalid_page_title;
91 |
92 | CREATE TABLE invalid_page_titles (
93 | reason TEXT,
94 | title TEXT
95 | );
96 |
97 | DROP TABLE IF EXISTS invalid_image_titles;
98 |
99 | CREATE TABLE invalid_image_titles (
100 | reason TEXT,
101 | page_title TEXT,
102 | image_title TEXT
103 | );
104 |
105 | DROP TABLE IF EXISTS words;
106 |
107 | CREATE TABLE words (
108 | key TEXT,
109 | value TEXT,
110 | words TEXT
111 | );
112 |
113 | DROP TABLE IF EXISTS stats;
114 |
115 | CREATE TABLE stats (
116 | key TEXT,
117 | value INT64
118 | );
119 |
120 |
--------------------------------------------------------------------------------
/web/viewsjs/keys.js.erb:
--------------------------------------------------------------------------------
1 | <%
2 | osm = @trans.t.osm
3 | misc = @trans.t.misc
4 | %>
5 | function page_init() {
6 | create_flexigrid('grid-keys', {
7 | url: '/api/4/keys/all?include=prevalent_values',
8 | colModel: [
9 | { display: '<%= h(osm.key) %>', name: 'key', width: 160, sortable: true },
10 | { display: '
<%= h(osm.objects) %>', name: 'count_all', width: 160, sortable: true, align: 'center' },
11 | { display: '
<%= h(osm.nodes) %>', name: 'count_nodes', width: 250, sortable: true, align: 'center' },
12 | { display: '
<%= h(osm.ways) %>', name: 'count_ways', width: 250, sortable: true, align: 'center' },
13 | { display: '
<%= h(osm.relations) %>', name: 'count_relations', width: 250, sortable: true, align: 'center' },
14 | { display: '<%= h(osm.users) %>', name: 'users_all', width: 44, sortable: true, align: 'right' },
15 | { display: '
', name: 'in_wiki', width: 20, sortable: true, align: 'center' },
16 | { display: '<%= h(osm.values) %>', name: 'values_all', width: 70, sortable: true, align: 'right' },
17 | { display: '<%= h(misc.prevalent_values) %>', name: 'prevalent_values', width: 500, sortable: true }
18 | ],
19 | searchitems: [
20 | { display: '<%= h(osm.key) %>', name: 'key' }
21 | ],
22 | sortname: 'count_all',
23 | sortorder: 'desc',
24 | preProcess: function(data) {
25 | data.rows = jQuery.map(data.data, function(row, i) {
26 | return { 'cell': [
27 | link_to_key(row.key),
28 | fmt_value_with_percent(row.count_all, row.count_all_fraction),
29 | fmt_value_with_percent(row.count_nodes, row.count_nodes_fraction),
30 | fmt_value_with_percent(row.count_ways, row.count_ways_fraction),
31 | fmt_value_with_percent(row.count_relations, row.count_relations_fraction),
32 | fmt_with_ts(row.users_all),
33 | fmt_checkmark(row.in_wiki),
34 | fmt_with_ts(row.values_all),
35 | fmt_prevalent_value_list(row.key, row.prevalent_values)
36 | ] };
37 | });
38 | return data;
39 | }
40 | });
41 | }
42 |
--------------------------------------------------------------------------------
/web/lib/ui/keys.rb:
--------------------------------------------------------------------------------
1 | # web/lib/ui/keys.rb
2 | class Taginfo < Sinatra::Base
3 |
4 | get %r{^/keys/(.*)} do |key|
5 | if params[:key].nil?
6 | @key = key
7 | else
8 | @key = params[:key]
9 | end
10 |
11 | @key_uri = escape(@key)
12 |
13 | @title = [@key, t.osm.keys]
14 | section :keys
15 |
16 | @filter_type = get_filter()
17 | @sel = Hash.new('')
18 | @sel[@filter_type] = ' selected="selected"'
19 | @filter_xapi = { 'all' => '*', nil => '*', 'nodes' => 'node', 'ways' => 'way', 'relations' => 'relation' }[@filter_type];
20 |
21 | @count_all_values = @db.select("SELECT count_#{@filter_type} FROM db.keys").condition('key = ?', @key).get_first_i
22 |
23 | @desc = h(@db.select("SELECT description FROM wiki.wikipages WHERE lang=? AND key=? AND value IS NULL", r18n.locale.code, @key).get_first_value())
24 | @desc = h(@db.select("SELECT description FROM wiki.wikipages WHERE lang='en' AND key=? AND value IS NULL", @key).get_first_value()) if @desc == ''
25 | if @desc == ''
26 | @desc = "#{ t.pages.key.no_description_in_wiki }"
27 | else
28 | @desc = "#{ @desc }"
29 | end
30 |
31 | @db.select("SELECT width, height, image_url, thumb_url_prefix, thumb_url_suffix FROM wiki.wikipages LEFT OUTER JOIN wiki.wiki_images USING(image) WHERE lang=? AND key=? AND value IS NULL UNION SELECT width, height, image_url, thumb_url_prefix, thumb_url_suffix FROM wiki.wikipages LEFT OUTER JOIN wiki.wiki_images USING(image) WHERE lang='en' AND key=? AND value IS NULL LIMIT 1", r18n.locale.code, @key, @key).
32 | execute() do |row|
33 | @image_url = build_image_url(row)
34 | end
35 |
36 | @prevalent_values = @db.select("SELECT value, count_#{@filter_type} AS count FROM tags").
37 | condition('key=?', @key).
38 | condition('count > ?', @count_all_values * 0.02).
39 | order_by([:count], 'DESC').
40 | execute().map{ |row| { 'value' => row['value'], 'count' => row['count'].to_i } }
41 |
42 | # add "(other)" label for the rest of the values
43 | sum = @prevalent_values.inject(0){ |sum, x| sum += x['count'] }
44 | if sum < @count_all_values
45 | @prevalent_values << { 'value' => '(other)', 'count' => @count_all_values - sum }
46 | end
47 |
48 | @wiki_count = @db.count('wiki.wikipages').condition('key=? AND value IS NULL', @key).get_first_i
49 | @user_count = @db.select('SELECT users_all FROM db.keys').condition('key=?', @key).get_first_i
50 |
51 | @img_width = TaginfoConfig.get('geodistribution.width') * TaginfoConfig.get('geodistribution.scale_image')
52 | @img_height = TaginfoConfig.get('geodistribution.height') * TaginfoConfig.get('geodistribution.scale_image')
53 |
54 | javascript_for(:flexigrid, :d3)
55 | javascript "#{ r18n.locale.code }/key"
56 | erb :key
57 | end
58 |
59 | end
60 |
61 |
--------------------------------------------------------------------------------
/sources/update_all.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #------------------------------------------------------------------------------
3 | #
4 | # Taginfo
5 | #
6 | # update_all.sh DIR
7 | #
8 | # Call this to update your Taginfo databases. All data will be store in the
9 | # directory DIR. Create an empty directory before starting for the first time!
10 | #
11 | # In this directory you will find:
12 | # log - directory with log files from running the update script
13 | # download - directory with bzipped databases for download
14 | # ... - a directory for each source with database and possible some
15 | # temporary files
16 | #
17 | #------------------------------------------------------------------------------
18 |
19 | # These sources will be downloaded from http://taginfo.openstreetmap.org/download/
20 | # Note that this will NOT work for the "db" source! Well, you can download it,
21 | # but it will fail later, because the database is changed by the master.sql
22 | # scripts.
23 | SOURCES_DOWNLOAD=`../bin/taginfo-config.rb sources.download`
24 |
25 | # These sources will be created from the actual sources
26 | SOURCES_CREATE=`../bin/taginfo-config.rb sources.create`
27 |
28 | #------------------------------------------------------------------------------
29 |
30 | set -e
31 |
32 | DATECMD='date +%Y-%m-%dT%H:%M:%S'
33 |
34 | DIR=$1
35 |
36 | if [ "x" = "x$DIR" ]; then
37 | echo "Usage: update_all.sh DIR"
38 | exit 1
39 | fi
40 |
41 | LOGFILE=`date +%Y%m%dT%H%M`
42 | mkdir -p $DIR/log
43 | exec >$DIR/log/$LOGFILE.log 2>&1
44 |
45 | echo "`$DATECMD` Start update_all..."
46 |
47 | mkdir -p $DIR/download
48 |
49 | for source in $SOURCES_DOWNLOAD; do
50 | echo "====================================="
51 | echo "Downloading $source..."
52 | mkdir -p $DIR/$source
53 | curl --silent --fail --output $DIR/download/taginfo-$source.db.bz2 http://taginfo.openstreetmap.org/download/taginfo-$source.db.bz2
54 | bzcat $DIR/download/taginfo-$source.db.bz2 >$DIR/$source/taginfo-$source.db
55 | echo "Done."
56 | done
57 |
58 | for source in $SOURCES_CREATE; do
59 | echo "====================================="
60 | echo "Running $source/update.sh..."
61 | mkdir -p $DIR/$source
62 | cd $source
63 | ./update.sh $DIR/$source
64 | cd ..
65 | echo "Done."
66 | done
67 |
68 | echo "====================================="
69 | echo "Running master/update.sh..."
70 | cd master
71 | ./update.sh $DIR
72 | cd ..
73 |
74 | echo "====================================="
75 | echo "`$DATECMD` Running bzip2 on all databases..."
76 | for source in $SOURCES_CREATE; do
77 | bzip2 -9 -c $DIR/$source/taginfo-$source.db >$DIR/download/taginfo-$source.db.bz2 &
78 | done
79 | sleep 5 # wait for bzip2 on the smaller dbs to finish
80 | bzip2 -9 -c $DIR/taginfo-master.db >$DIR/download/taginfo-master.db.bz2 &
81 | bzip2 -9 -c $DIR/taginfo-search.db >$DIR/download/taginfo-search.db.bz2 &
82 |
83 | wait
84 | echo "Done."
85 |
86 | echo "====================================="
87 | echo "`$DATECMD` Done update_all."
88 |
89 |
90 | #-- THE END -------------------------------------------------------------------
91 |
--------------------------------------------------------------------------------
/web/views/reports/characters_in_keys.erb:
--------------------------------------------------------------------------------
1 |
2 |
<%= h(t.reports.characters_in_keys.name) %>
3 | <%= t.reports.characters_in_keys.intro %>
4 |
5 |
6 |
11 |
12 |
<%= h(t.reports.characters_in_keys.statistics.title) %>
13 |
14 |
15 |
16 | | |
17 | <%= h(t.misc.count) %> |
18 | <%= h(t.reports.characters_in_keys.statistics.fraction) %> |
19 | <%= h(t.reports.characters_in_keys.statistics.characters) %> |
20 |
21 | <% letter='A'
22 | colors = { :A => '#2ca02c', :B => '#98df8a', :C => '#dbdb8d', :D => '#d62728', :E => '#ff9896', :F => '#aec7e8' }
23 | %w(plain colon letters space problem rest).each_with_index do |type, n| c = (n%2!=0) ? ' even' : '' %>
24 |
25 | | <%= letter %> |
26 | <%= @db.stats('characters_in_keys_' + type) %> |
27 | <%= sprintf '%.2f', @db.stats('characters_in_keys_' + type) * 100.0 / @db.stats('num_keys') %>% |
28 | <%= t.reports.characters_in_keys.statistics.characters_in_keys[type] %> |
29 |
30 | <% letter = letter.succ; end %>
31 |
32 | |
33 | <%= @db.stats('num_keys') %> |
34 | 100% |
35 | <%= t.reports.characters_in_keys.statistics.characters_in_keys.total %> |
36 |
37 |
38 |
39 |
40 |
<%= h(t.reports.characters_in_keys.whitespace.title) %>
41 |
42 | <%= t.reports.characters_in_keys.whitespace.intro %>
43 |
44 |
46 |
47 |
48 |
<%= h(t.reports.characters_in_keys.problematic.title) %>
49 |
50 | <%= t.reports.characters_in_keys.problematic.intro %>
51 |
52 |
54 |
55 |
56 | <% javascript_for(:d3) %>
57 |
--------------------------------------------------------------------------------
/tagstats/string_store.hpp:
--------------------------------------------------------------------------------
1 | #ifndef TAGSTATS_STRING_STORE_HPP
2 | #define TAGSTATS_STRING_STORE_HPP
3 |
4 | /*
5 |
6 | Copyright 2012, 2014 Jochen Topf .
7 |
8 | This file is part of Tagstats.
9 |
10 | Tagstats is free software: you can redistribute it and/or modify
11 | it under the terms of the GNU General Public License as published by
12 | the Free Software Foundation, either version 3 of the License, or
13 | (at your option) any later version.
14 |
15 | Tagstats is distributed in the hope that it will be useful,
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | GNU General Public License for more details.
19 |
20 | You should have received a copy of the GNU General Public License
21 | along with Tagstats. If not, see .
22 |
23 | */
24 |
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | /**
33 | * class StringStore
34 | *
35 | * Storage of lots of strings (const char *). Memory is allocated in chunks.
36 | * If a string is added and there is no space in the current chunk, a new
37 | * chunk will be allocated. Strings added to the store must not be larger
38 | * than the chunk size.
39 | *
40 | * All memory is released when the destructor is called. There is no other way
41 | * to release all or part of the memory.
42 | *
43 | */
44 | class StringStore {
45 |
46 | size_t m_chunk_size;
47 |
48 | std::list m_chunks;
49 |
50 | void add_chunk() {
51 | m_chunks.push_front(std::string());
52 | m_chunks.front().reserve(m_chunk_size);
53 | }
54 |
55 | public:
56 |
57 | StringStore(size_t chunk_size) :
58 | m_chunk_size(chunk_size),
59 | m_chunks() {
60 | add_chunk();
61 | }
62 |
63 | /**
64 | * Add a null terminated string to the store. This will
65 | * automatically get more memory if we are out.
66 | * Returns a pointer to the copy of the string we have
67 | * allocated.
68 | */
69 | const char* add(const char* string) {
70 | size_t len = std::strlen(string) + 1;
71 |
72 | assert(len <= m_chunk_size);
73 |
74 | size_t chunk_len = m_chunks.front().size();
75 | if (chunk_len + len > m_chunks.front().capacity()) {
76 | add_chunk();
77 | chunk_len = 0;
78 | }
79 |
80 | m_chunks.front().append(string);
81 | m_chunks.front().append(1, '\0');
82 |
83 | return m_chunks.front().c_str() + chunk_len;
84 | }
85 |
86 | // These functions get you some idea how much memory was
87 | // used.
88 | int get_chunk_size() const {
89 | return m_chunk_size;
90 | }
91 |
92 | int get_chunk_count() const {
93 | return m_chunks.size();
94 | }
95 |
96 | int get_used_bytes_in_last_chunk() const {
97 | return m_chunks.front().size();
98 | }
99 |
100 | };
101 |
102 | #endif // TAGSTATS_STRING_STORE_HPP
103 |
--------------------------------------------------------------------------------
/sources/projects/import.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/ruby
2 | #------------------------------------------------------------------------------
3 | #
4 | # Taginfo source: Projects
5 | #
6 | # import.rb
7 | #
8 | #------------------------------------------------------------------------------
9 | #
10 | # Copyright (C) 2014 Jochen Topf
11 | #
12 | # This program is free software; you can redistribute it and/or modify
13 | # it under the terms of the GNU General Public License as published by
14 | # the Free Software Foundation; either version 2 of the License, or
15 | # (at your option) any later version.
16 | #
17 | # This program is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | # GNU General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU General Public License along
23 | # with this program; if not, write to the Free Software Foundation, Inc.,
24 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 | #
26 | #------------------------------------------------------------------------------
27 |
28 | require 'net/https'
29 | require 'uri'
30 | require 'sqlite3'
31 | require 'time'
32 |
33 | #------------------------------------------------------------------------------
34 |
35 | dir = ARGV[0] || '.'
36 | db = SQLite3::Database.new(dir + '/taginfo-projects.db')
37 |
38 | project_list = ARGV[1] || 'project_list.txt'
39 |
40 | #------------------------------------------------------------------------------
41 |
42 | projects = []
43 | open(project_list) do |file|
44 | file.each do |line|
45 | projects << line.chomp.split(' ')
46 | end
47 | end
48 |
49 | projects.each do |id, url|
50 | puts " #{id} #{url}"
51 | uri = URI(url)
52 | http = Net::HTTP.new(uri.host, uri.port)
53 | if uri.scheme == 'https'
54 | http.use_ssl = true
55 | http.verify_mode = OpenSSL::SSL::VERIFY_NONE
56 | end
57 | begin
58 | request = Net::HTTP::Get.new(uri.request_uri)
59 | response = http.request(request)
60 | begin
61 | last_modified = Time.parse(response['Last-Modified'] || response['Date']).utc.iso8601
62 | rescue
63 | last_modified = Time.now.utc
64 | end
65 | db.execute("INSERT INTO projects (id, json_url, last_modified, fetch_date, fetch_status, fetch_json, status, data_updated) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
66 | id,
67 | url,
68 | last_modified,
69 | Time.now.utc.iso8601,
70 | response.code,
71 | response.body,
72 | (response.code == '200' ? 'OK' : 'FETCH ERROR'),
73 | last_modified
74 | );
75 | rescue
76 | db.execute("INSERT INTO projects (id, json_url, fetch_date, fetch_status, status) VALUES (?, ?, ?, ?, ?)",
77 | id,
78 | url,
79 | Time.now.utc.iso8601,
80 | 500,
81 | 'FETCH ERROR'
82 | );
83 | end
84 | end
85 |
86 |
87 | #-- THE END -------------------------------------------------------------------
88 |
--------------------------------------------------------------------------------
/web/lib/ui/tags.rb:
--------------------------------------------------------------------------------
1 | # web/lib/ui/tags.rb
2 | class Taginfo < Sinatra::Base
3 |
4 | get %r{^/tags/(.*)} do |tag|
5 | if tag.match(/=/)
6 | kv = tag.split('=', 2)
7 | else
8 | kv = [ tag, '' ]
9 | end
10 | if params[:key].nil?
11 | @key = kv[0]
12 | else
13 | @key = params[:key]
14 | end
15 | if params[:value].nil?
16 | @value = kv[1]
17 | else
18 | @value = params[:value]
19 | end
20 | @tag = @key + '=' + @value
21 |
22 | @key_uri = escape(@key)
23 | @value_uri = escape(@value)
24 |
25 | @title = [@key + '=' + @value, t.osm.tags]
26 | section :tags
27 |
28 | @filter_type = get_filter()
29 | @sel = Hash.new('')
30 | @sel[@filter_type] = ' selected="selected"'
31 | @filter_xapi = { 'all' => '*', nil => '*', 'nodes' => 'node', 'ways' => 'way', 'relations' => 'relation' }[@filter_type];
32 |
33 | @wiki_count = @db.count('wiki.wikipages').condition('key=? AND value=?', @key, @value).get_first_i
34 | if @wiki_count == 0
35 | @wiki_count_key = @db.count('wiki.wikipages').condition('key=? AND value IS NULL', @key).get_first_i
36 | end
37 | @count_all = @db.select("SELECT count_#{@filter_type} FROM db.tags").condition('key = ? AND value = ?', @key, @value).get_first_i
38 |
39 | @desc = h(@db.select("SELECT description FROM wiki.wikipages WHERE lang=? AND key=? AND value=?", r18n.locale.code, @key, @value).get_first_value())
40 | @desc = h(@db.select("SELECT description FROM wiki.wikipages WHERE lang='en' AND key=? AND value=?", @key, @value).get_first_value()) if @desc == ''
41 | if @desc == ''
42 | @desc = "#{ t.pages.tag.no_description_in_wiki }"
43 | else
44 | @desc = "#{ @desc }"
45 | end
46 |
47 | @db.select("SELECT width, height, image_url, thumb_url_prefix, thumb_url_suffix FROM wiki.wikipages LEFT OUTER JOIN wiki.wiki_images USING(image) WHERE lang=? AND key=? AND value=? UNION SELECT width, height, image_url, thumb_url_prefix, thumb_url_suffix FROM wiki.wikipages LEFT OUTER JOIN wiki.wiki_images USING(image) WHERE lang='en' AND key=? AND value=? LIMIT 1", r18n.locale.code, @key, @value, @key, @value).
48 | execute() do |row|
49 | @image_url = build_image_url(row)
50 | end
51 |
52 | @has_rtype_link = false
53 | if @key == 'type' && @db.count('relation_types').condition('rtype = ?', @value).get_first_i > 0
54 | @has_rtype_link = true
55 | end
56 |
57 | @has_map = @db.count('tag_distributions').condition('key=? AND value=?', @key, @value).get_first_i > 0
58 |
59 | @img_width = TaginfoConfig.get('geodistribution.width') * TaginfoConfig.get('geodistribution.scale_image')
60 | @img_height = TaginfoConfig.get('geodistribution.height') * TaginfoConfig.get('geodistribution.scale_image')
61 |
62 | javascript_for(:flexigrid)
63 | javascript "#{ r18n.locale.code }/tag"
64 | erb :tag
65 | end
66 |
67 | end
68 |
69 |
--------------------------------------------------------------------------------
/web/test/test_sql.rb:
--------------------------------------------------------------------------------
1 | $: << 'lib'
2 | require File.join(File.dirname(__FILE__), '..', 'lib', 'sql.rb')
3 | require 'test/unit'
4 |
5 | class TestSql < Test::Unit::TestCase
6 |
7 | def setup
8 | @select = SQL::Select.new('test', 'test')
9 | end
10 |
11 | def test_order_by_no_block
12 | assert_kind_of SQL::Select, @select
13 | @select.order_by(:foo, 'ASC')
14 | assert_equal 'test ORDER BY foo ASC', @select.build_query
15 | end
16 |
17 | def test_order_by_no_block_desc
18 | assert_kind_of SQL::Select, @select
19 | @select.order_by(:foo, 'DESC')
20 | assert_equal 'test ORDER BY foo DESC', @select.build_query
21 | end
22 |
23 | def test_order_by_simple
24 | assert_kind_of SQL::Select, @select
25 | @select.order_by(:foo, 'ASC') do |o|
26 | o.foo
27 | end
28 | assert_equal 'test ORDER BY foo ASC', @select.build_query
29 | end
30 |
31 | def test_order_by_desc
32 | @select.order_by(:foo, 'DESC') do |o|
33 | o.foo
34 | end
35 | assert_equal 'test ORDER BY foo DESC', @select.build_query
36 | end
37 |
38 | def test_order_by_unused
39 | @select.order_by([:foo], 'ASC') do |o|
40 | o.foo
41 | o.bar! 'baz'
42 | end
43 | assert_equal 'test ORDER BY foo ASC', @select.build_query
44 | end
45 |
46 | def test_order_by_reverse
47 | @select.order_by(:bar, 'ASC') do |o|
48 | o.foo
49 | o.bar! 'baz'
50 | end
51 | assert_equal 'test ORDER BY baz DESC', @select.build_query
52 | end
53 |
54 | def test_order_by_array
55 | @select.order_by([:foo, 'bar'], 'ASC') do |o|
56 | o.bar! 'baz'
57 | o.foo
58 | end
59 | assert_equal 'test ORDER BY foo ASC,baz DESC', @select.build_query
60 | end
61 |
62 | def test_order_by_array_reverse
63 | @select.order_by([:bar, :foo], 'DESC') do |o|
64 | o.foo
65 | o.bar!
66 | end
67 | assert_equal 'test ORDER BY bar ASC,foo DESC', @select.build_query
68 | end
69 |
70 | def test_order_by_array_multiple
71 | @select.order_by([:bar, :foo], 'DESC') do |o|
72 | o.foo 'f1'
73 | o.foo! :f2
74 | o.bar :baz
75 | end
76 | assert_equal 'test ORDER BY baz DESC,f1 DESC,f2 ASC', @select.build_query
77 | end
78 |
79 | def test_order_by_map
80 | @select.order_by(:length, 'ASC') do |o|
81 | o.length 'length(foo)'
82 | o.length :foo
83 | end
84 | assert_equal 'test ORDER BY length(foo) ASC,foo ASC', @select.build_query
85 | end
86 |
87 | def test_order_by_asc_or_desc
88 | assert_raise ArgumentError do
89 | @select.order_by(:foo, 'blub') do |o|
90 | o.foo
91 | end
92 | end
93 | end
94 |
95 | def test_order_by_no_def
96 | assert_raise ArgumentError do
97 | @select.order_by(:foo) do |o|
98 | o.bar
99 | end
100 | end
101 | end
102 |
103 | end
104 |
--------------------------------------------------------------------------------
/web/lib/api/v4/relations.rb:
--------------------------------------------------------------------------------
1 | # web/lib/api/v4/relations.rb
2 |
3 | class Taginfo < Sinatra::Base
4 |
5 | api(4, 'relations/all', {
6 | :description => 'Information about the different relation types.',
7 | :parameters => {
8 | :query => 'Only show results where the relation type matches this query (substring match, optional).'
9 | },
10 | :paging => :optional,
11 | :sort => %w( rtype count ),
12 | :result => paging_results([
13 | [:rtype, :STRING, 'Relation type'],
14 | [:count, :INT, 'Number of relations with this type.'],
15 | [:count_fraction, :INT, 'Number of relations with this type divided by the overall number of relations.'],
16 | [:prevalent_roles, :ARRAY, 'Prevalent member roles.', [
17 | [:role, :STRING, 'Member role'],
18 | [:count, :INT, 'Number of members with this role.'],
19 | [:fraction, :FLOAT, 'Number of members with this role divided by all members.']
20 | ]]
21 | ]),
22 | :notes => "prevalent_roles can be null if taginfo doesn't have role information for this relation type, or an empty array when there are no roles with more than 1% of members",
23 | :example => { :page => 1, :rp => 10 },
24 | :ui => '/relations'
25 | }) do
26 | total = @db.count('relation_types').
27 | condition_if("rtype LIKE ? ESCAPE '@'", like_contains(params[:query])).
28 | get_first_value().to_i
29 |
30 | res = @db.select('SELECT * FROM relation_types').
31 | condition_if("rtype LIKE ? ESCAPE '@'", like_contains(params[:query])).
32 | order_by(@ap.sortname, @ap.sortorder) { |o|
33 | o.rtype
34 | o.count
35 | }.
36 | paging(@ap).
37 | execute()
38 |
39 | all_relations = @db.stats('relations').to_i
40 |
41 | prevroles = @db.select('SELECT rtype, role, count, fraction FROM db.prevalent_roles').
42 | condition("rtype IN (#{ res.map{ |row| "'" + SQLite3::Database.quote(row['rtype']) + "'" }.join(',') })").
43 | order_by([:count], 'DESC').
44 | execute()
45 |
46 | pr = {}
47 | res.each do |row|
48 | pr[row['rtype']] = []
49 | end
50 |
51 | prevroles.each do |pv|
52 | rtype = pv['rtype']
53 | pv.delete_if{ |k,v| k.is_a?(Integer) || k == 'rtype' }
54 | pv['count'] = pv['count'].to_i
55 | pv['fraction'] = pv['fraction'].to_f
56 | pr[rtype] << pv
57 | end
58 |
59 | return JSON.generate({
60 | :page => @ap.page,
61 | :rp => @ap.results_per_page,
62 | :total => total,
63 | :url => request.url,
64 | :data => res.map{ |row| {
65 | :rtype => row['rtype'],
66 | :count => row['count'].to_i,
67 | :count_fraction => row['count'].to_f / all_relations,
68 | :prevalent_roles => row['members_all'] ? pr[row['rtype']][0,10] : nil
69 | } }
70 | }, json_opts(params[:format]))
71 | end
72 |
73 | end
74 |
--------------------------------------------------------------------------------
/web/lib/javascript.rb:
--------------------------------------------------------------------------------
1 | # web/lib/javascript.rb
2 |
3 | def javascript(url=nil, &block)
4 | @javascript ||= Array.new
5 | @javascript << Javascript.new(url, &block)
6 | end
7 |
8 | def javascript_tags
9 | @javascript.flatten.uniq.map{ |js| js.to_html }.join("\n")
10 | end
11 |
12 | def javascript_for(*ids)
13 | (@javascript ||= [] ) << Javascript.init(ids)
14 | end
15 |
16 | class Javascript
17 |
18 | @@js_files = {
19 | # :common => [ 'jquery-1.11.1.min', 'jquery-ui-1.9.2.custom.min', 'customSelect.jquery.min', 'jquery.tipsy-minified', 'jquery.cookie-minified' ],
20 | :common => [ 'common' ],
21 | :taginfo => [ 'taginfo' ],
22 | :flexigrid => [ 'jquery-migrate-1.2.1.min', 'flexigrid-minified' ],
23 | :d3 => [ 'd3/d3.v3.min' ],
24 | :d3_cloud => [ 'd3/d3.layout.cloud' ],
25 | }
26 |
27 | def self.init(ids)
28 | js = []
29 | ids.each do |id|
30 | @@js_files[id].each do |file|
31 | js << self.new(file)
32 | end
33 | end
34 | js
35 | end
36 |
37 | def initialize(file)
38 | if file.nil?
39 | c = ''
40 | r = yield c
41 | @content = (c == '' ? r : c)
42 | else
43 | @file = file
44 | end
45 | end
46 |
47 | def to_html
48 | if @file.nil?
49 | %Q{ }
50 | else
51 | %Q{ }
52 | end
53 | end
54 |
55 | end
56 |
57 | class JQuery
58 |
59 | # "include" the convenience methods from R18n::Helpers.
60 | # Uses extend instead of include, because we want this
61 | # to work not with instances of JQuery but they should
62 | # show up as JQuery class methods.
63 | extend R18n::Helpers
64 |
65 | def self.flexigrid(id, options)
66 | defaults = {
67 | :method => 'GET',
68 | :dataType => 'json',
69 | :pagetext => t.flexigrid.pagetext,
70 | :pagestat => t.flexigrid.pagestat,
71 | :outof => t.flexigrid.outof,
72 | :findtext => t.flexigrid.findtext,
73 | :procmsg => t.flexigrid.procmsg,
74 | :nomsg => t.flexigrid.nomsg,
75 | :errormsg => t.flexigrid.errormsg,
76 | :showToggleBtn => false,
77 | :usepager => true,
78 | :useRp => true,
79 | :rp => 15,
80 | :rpOptions => [10,15,20,25,50,100],
81 | }
82 | "jQuery('##{id}').flexigrid(" + defaults.merge(options).to_json + ");\n"
83 | end
84 |
85 | end
86 |
87 | class JS
88 |
89 | #
90 | # Careful, deep magic!
91 | #
92 | # We redefine the to_json method of the String argument to return
93 | # the raw string. This way we can do JS.raw("foo").to_json and get "foo".
94 | #
95 | def self.raw(code)
96 | code.instance_eval do
97 | def to_json(state=nil)
98 | to_s
99 | end
100 | end
101 | code
102 | end
103 |
104 | end
105 |
106 |
--------------------------------------------------------------------------------
/web/views/relation.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 | <% if @count_all_values <= TaginfoConfig.get('xapi.max_results', 1000) %>
4 | <%= xapi_link('relation', 'type', @rtype) %> <%= josm_link('relation', 'type', @rtype) %>
5 | <% else %>
6 | XAPI
7 | JOSM
8 | <% end %>
9 | <%= turbo_link(@count_all_values, 'relations', 'type', @rtype) %>
10 |
11 |
12 |
<%= @desc %>
13 |
14 |
15 |
22 |
23 | <% if @image_url %>
24 |
25 |
 %>)
26 |
27 | <% end %>
28 |
<%= h(t.pages.relation.overview.title) %>
29 |
31 |
<%= h(t.pages.relation.overview.see_also) %>: type=
32 |
33 |
34 |
<%= h(t.pages.relation.roles.title) %>
35 | <% if @count_relation_roles > 0 %>
36 |
38 | <% else %>
39 |
<%= h(t.pages.relation.roles.no_roles_info) %>
40 | <% end %>
41 |
42 |
43 |
<%= h(t.pages.relation.graph.title) %>
44 | <% if @count_relation_roles > 0 %>
45 |
46 |
47 | <% else %>
48 |
<%= h(t.pages.relation.roles.no_roles_info) %>
49 | <% end %>
50 |
51 |
52 |
<%= h(t.pages.relation.wiki_pages.title) %>
53 | <% if @wiki_count > 0 %>
54 |
56 | <% else %>
57 |
<%= h(t.pages.relation.wiki_pages.none_found) %>
58 |
<%= h(t.pages.relation.wiki_pages.create) %>
59 | <% end %>
60 |
61 |
62 |
<%= h(t.pages.relation.projects.title) %>
63 |
65 |
66 |
67 |
68 | <% javascript do
69 | JS.raw(<<"JAVASCRIPT")
70 | function page_init2() {
71 | var rtype = #{ @rtype.to_json },
72 | roles = #{ @roles.to_json.gsub(/\},/, "},\n") };
73 | jQuery('h1').html("#{ t.pages.relation.name } '" + fmt_rtype(rtype) + "'");
74 | jQuery('span#taglink').html(link_to_value('type', rtype));
75 | init_tabs([rtype]);
76 | create_role_chart(roles);
77 | }
78 | JAVASCRIPT
79 | end
80 | %>
81 |
--------------------------------------------------------------------------------
/web/lib/ui/search.rb:
--------------------------------------------------------------------------------
1 | # web/lib/ui/search.rb
2 | class Taginfo < Sinatra::Base
3 |
4 | # The search results page
5 | get '/search' do
6 | @title = t.pages.search.title
7 |
8 | javascript "#{ r18n.locale.code }/search"
9 | @query = params[:q]
10 | javascript_for(:flexigrid)
11 | if @query =~ /(.*)=(.*)/
12 | erb :search_tags
13 | else
14 | erb :search
15 | end
16 | end
17 |
18 | # Return opensearch description (see www.opensearch.org)
19 | get '/search/opensearch.xml' do
20 | content_type :opensearch
21 | opensearch = <
23 |
24 | #{ TaginfoConfig.get('opensearch.shortname') }
25 | #{ TaginfoConfig.get('opensearch.description') }
26 | #{ TaginfoConfig.get('opensearch.tags') }
27 | #{ TaginfoConfig.get('opensearch.contact') }
28 |
29 |
30 |
31 | __URL__/favicon.ico
32 |
33 | END_XML
34 | return opensearch.gsub(/__URL__/, TaginfoConfig.get('instance.url'))
35 | end
36 |
37 | # Returns search suggestions as per OpenSearch standard
38 | get '/search/suggest' do
39 | query = params[:term]
40 | format = params[:format]
41 |
42 | sel = @db.select('SELECT * FROM suggestions').
43 | order_by([:score], 'DESC').
44 | limit(10)
45 |
46 | if query =~ /^=(.*)/
47 | value = $1
48 | res = sel.
49 | condition_if("value LIKE ? ESCAPE '@'", like_prefix(value)).
50 | execute().
51 | map{ |row| row['key'] + '=' + row['value'].to_s }
52 | elsif query =~ /^([^=]+)=(.*)/
53 | key = $1
54 | value = $2
55 | res = sel.
56 | condition_if("key LIKE ? ESCAPE '@'", like_prefix(key)).
57 | condition_if("value LIKE ? ESCAPE '@'", like_prefix(value)).
58 | execute().
59 | map{ |row| row['key'] + '=' + row['value'].to_s }
60 | else
61 | res = sel.
62 | condition_if("key LIKE ? ESCAPE '@'", like_prefix(query)).
63 | is_null('value').
64 | execute().
65 | map{ |row| row['key'] }
66 | end
67 |
68 | content_type :json
69 | if format == 'simple'
70 | # simple format is used by the search box on the website itself,
71 | # it is just a list of suggestions
72 | return res.to_json + "\n";
73 | else
74 | # this is the OpenSearch standard format
75 | return [
76 | query, # the query string
77 | res, # the list of suggestions
78 | res.map{ |item| '' }, # the standard says this is for descriptions, we don't have any so this is empty
79 | res.map{ |item| TaginfoConfig.get('instance.url') + '/tags/' + item } # the page this search should got to (ignored by FF, Chrome)
80 | ].to_json + "\n"
81 | end
82 | end
83 |
84 | end
85 |
--------------------------------------------------------------------------------
/sources/potlatch/import_potlatch.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/ruby
2 | #------------------------------------------------------------------------------
3 | #
4 | # Taginfo source: Potlatch
5 | #
6 | # import_potlatch.rb
7 | #
8 | #------------------------------------------------------------------------------
9 | #
10 | # Copyright (C) 2013 Jochen Topf
11 | #
12 | # This program is free software; you can redistribute it and/or modify
13 | # it under the terms of the GNU General Public License as published by
14 | # the Free Software Foundation; either version 2 of the License, or
15 | # (at your option) any later version.
16 | #
17 | # This program is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | # GNU General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU General Public License along
23 | # with this program; if not, write to the Free Software Foundation, Inc.,
24 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 | #
26 | #------------------------------------------------------------------------------
27 |
28 | require 'sqlite3'
29 | require 'rexml/document'
30 |
31 | dir = ARGV[0] || '.'
32 | db = SQLite3::Database.new(dir + '/taginfo-potlatch.db')
33 |
34 | #------------------------------------------------------------------------------
35 |
36 | db.transaction do |db|
37 | file = File.new(dir + '/git-source/resources/map_features.xml')
38 | doc = REXML::Document.new(file)
39 |
40 | doc.elements.each('/mapFeatures/category') do |category_element|
41 | db.execute('INSERT INTO categories (id, name) VALUES (?, ?)', category_element.attributes['id'], category_element.attributes['name'])
42 | end
43 |
44 | doc.elements.each('/mapFeatures/feature') do |feature_element|
45 | feature_name = feature_element.attributes['name']
46 |
47 | on = { :point => 0, :line => 0, :area => 0, :relation => 0 }
48 |
49 | fields = Hash.new
50 | feature_element.elements.each do |element|
51 | case element.name
52 | when 'tag'
53 | value = element.attributes['v'] == '*' ? nil : element.attributes['v']
54 | db.execute('INSERT INTO tags (key, value, feature_name) VALUES (?, ?, ?)', element.attributes['k'], value, feature_name)
55 | when /^(point|line|area|relation)$/
56 | on[$1.to_sym] = 1
57 | when /^(category|help)$/
58 | fields[element.name] = element.text.strip
59 | when 'icon'
60 | fields['icon_image'] = element.attributes['image']
61 | fields['icon_background'] = element.attributes['background']
62 | fields['icon_foreground'] = element.attributes['foreground']
63 | end
64 | end
65 |
66 | if on[:point] + on[:line] + on[:area] + on[:relation] == 0
67 | on = { :point => 1, :line => 1, :area => 1, :relation => 1 }
68 | end
69 |
70 | db.execute('INSERT INTO features (name, category_id, help, on_point, on_line, on_area, on_relation, icon_image, icon_background, icon_foreground) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
71 | feature_name, fields['category'], fields['help'], on[:point], on[:line], on[:area], on[:relation], fields['icon_image'], fields['icon_background'], fields['icon_foreground'])
72 | end
73 |
74 | end
75 |
76 |
77 | #-- THE END -------------------------------------------------------------------
78 |
--------------------------------------------------------------------------------