diff options
author | Jochen Topf <jochen@topf.org> | 2011-10-12 19:34:19 +0200 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2011-10-12 19:34:19 +0200 |
commit | 37cdf05ea821f39f69ca023e9a4c02680bb772e4 (patch) | |
tree | c078ef3c7300f4969d1b9b92414989e2ea4c48fe /web | |
parent | e6ba7db9ef8f4f02415b6bcc90f0e8acc7c6ba04 (diff) | |
download | taginfo-37cdf05ea821f39f69ca023e9a4c02680bb772e4.tar taginfo-37cdf05ea821f39f69ca023e9a4c02680bb772e4.tar.gz |
Change API and UI to show way distribution map also
Diffstat (limited to 'web')
-rw-r--r-- | web/lib/api/db.rb | 28 | ||||
-rw-r--r-- | web/views/key.erb | 18 |
2 files changed, 44 insertions, 2 deletions
diff --git a/web/lib/api/db.rb b/web/lib/api/db.rb index aafb763..1245a4e 100644 --- a/web/lib/api/db.rb +++ b/web/lib/api/db.rb @@ -206,6 +206,34 @@ class Taginfo < Sinatra::Base get_first_value() end + api(3, 'db/keys/distribution/nodes', { + :description => 'Get map with distribution of this key in the database (nodes only).', + :parameters => { :key => 'Tag key (required).' }, + :result => 'PNG image.', + :example => { :key => 'amenity' }, + :ui => '/keys/amenity#map' + }) do + key = params[:key] + content_type :png + @db.select('SELECT nodes FROM db.key_distributions'). + condition('key = ?', key). + get_first_value() + end + + api(3, 'db/keys/distribution/ways', { + :description => 'Get map with distribution of this key in the database (ways only).', + :parameters => { :key => 'Tag key (required).' }, + :result => 'PNG image.', + :example => { :key => 'highway' }, + :ui => '/keys/highway#map' + }) do + key = params[:key] + content_type :png + @db.select('SELECT ways FROM db.key_distributions'). + condition('key = ?', key). + get_first_value() + end + api(2, 'db/keys/values', { :description => 'Get values used with a given key.', :parameters => { diff --git a/web/views/key.erb b/web/views/key.erb index 2bf42b0..57d6de8 100644 --- a/web/views/key.erb +++ b/web/views/key.erb @@ -49,8 +49,22 @@ </div> <div id="map"> <h2>Geographical distribution of this key</h2> - <p><i>Currently only tags on nodes are shown.</i></p> - <div style="background-image: url(<%= TaginfoConfig.get('geodistribution.background_image') %>); background-repeat: no-repeat;"/><img src="/api/2/db/keys/distribution?key=<%= @key_uri %>" alt="" width="<%= TaginfoConfig.get('geodistribution.width') %>" height="<%= TaginfoConfig.get('geodistribution.height') %>"/></div> + <% if @filter_type == 'all' %> + <div style="background-image: url(<%= TaginfoConfig.get('geodistribution.background_image') %>); background-repeat: no-repeat;"/> + <img src="/api/3/db/keys/distribution/nodes?key=<%= @key_uri %>" alt="" width="<%= TaginfoConfig.get('geodistribution.width') %>" height="<%= TaginfoConfig.get('geodistribution.height') %>" style="position: absolute;"/> + <img src="/api/3/db/keys/distribution/ways?key=<%= @key_uri %>" alt="" width="<%= TaginfoConfig.get('geodistribution.width') %>" height="<%= TaginfoConfig.get('geodistribution.height') %>"/> + </div> + <% elsif @filter_type == 'nodes' %> + <div style="background-image: url(<%= TaginfoConfig.get('geodistribution.background_image') %>); background-repeat: no-repeat;"/> + <img src="/api/3/db/keys/distribution/nodes?key=<%= @key_uri %>" alt="" width="<%= TaginfoConfig.get('geodistribution.width') %>" height="<%= TaginfoConfig.get('geodistribution.height') %>"/> + </div> + <% elsif @filter_type == 'ways' %> + <div style="background-image: url(<%= TaginfoConfig.get('geodistribution.background_image') %>); background-repeat: no-repeat;"/> + <img src="/api/3/db/keys/distribution/ways?key=<%= @key_uri %>" alt="" width="<%= TaginfoConfig.get('geodistribution.width') %>" height="<%= TaginfoConfig.get('geodistribution.height') %>"/> + </div> + <% elsif @filter_type == 'relations' %> + <p><i>Relations do not have a geographical location, so no map can be shown.</i></p> + <% end %> </div> <div id="wiki"> <h2>Wiki pages about this key</h2> |