diff options
author | Jochen Topf <jochen@topf.org> | 2014-05-12 11:55:12 +0200 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2014-05-12 11:55:12 +0200 |
commit | e37df4e561bb43bcef978c3ad8bbd6dc5f414c00 (patch) | |
tree | 76b225dbe1243ba04cadfa0462173d32d800bb6a /web/lib | |
parent | 213741fd9bb5493112634dcc1dc14c41b7182399 (diff) | |
download | taginfo-e37df4e561bb43bcef978c3ad8bbd6dc5f414c00.tar taginfo-e37df4e561bb43bcef978c3ad8bbd6dc5f414c00.tar.gz |
Add API call to get maps of tag distributions.
Diffstat (limited to 'web/lib')
-rw-r--r-- | web/lib/api/v4/tag.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/web/lib/api/v4/tag.rb b/web/lib/api/v4/tag.rb index 5a1e637..08626d4 100644 --- a/web/lib/api/v4/tag.rb +++ b/web/lib/api/v4/tag.rb @@ -83,6 +83,46 @@ class Taginfo < Sinatra::Base }.to_json end + api(4, 'tag/distribution/nodes', { + :description => 'Get map with distribution of this tag in the database (nodes only). Will return empty image if there is no map available for this tag.', + :parameters => { :key => 'Tag key (required).', :value => 'Tag value (required).' }, + :result => 'PNG image.', + :example => { :key => 'amenity', :value => 'post_box' }, + :ui => '/tags/amenit=post_boxy#map' + }) do + key = params[:key] + value = params[:value] + content_type :png + @db.select('SELECT png FROM db.tag_distributions'). + condition("object_type='n'"). + condition('key = ?', key). + condition('value = ?', value). + get_first_value() || + @db.select('SELECT png FROM db.key_distributions'). + condition('key IS NULL'). + get_first_value() + end + + api(4, 'tag/distribution/ways', { + :description => 'Get map with distribution of this tag in the database (ways only). Will return empty image if there is no map available for this tag.', + :parameters => { :key => 'Tag key (required).', :value => 'Tag value (required).' }, + :result => 'PNG image.', + :example => { :key => 'highway', :value => 'residential' }, + :ui => '/tags/highway=residential#map' + }) do + key = params[:key] + value = params[:value] + content_type :png + @db.select('SELECT png FROM db.tag_distributions'). + condition("object_type='w'"). + condition('key = ?', key). + condition('value = ?', value). + get_first_value() || + @db.select('SELECT png FROM db.key_distributions'). + condition('key IS NULL'). + get_first_value() + end + api(4, 'tag/josm/style/rules', { :description => 'List rules and symbols for the given tag in JOSM styles.', :parameters => { |