summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web/lib/api/db.rb28
-rw-r--r--web/views/key.erb18
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>