aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sources/master/master.sql3
-rwxr-xr-xsources/merkaartor/import_merkaartor.rb66
-rw-r--r--sources/merkaartor/post.sql8
-rw-r--r--sources/merkaartor/pre.sql92
-rwxr-xr-xsources/merkaartor/update.sh42
-rw-r--r--web/lib/sql.rb2
-rw-r--r--web/public/img/sources/merkaartor.100.pngbin0 -> 21072 bytes
-rw-r--r--web/public/img/sources/merkaartor.16.pngbin0 -> 870 bytes
-rw-r--r--web/public/img/sources/merkaartor.24.pngbin0 -> 1621 bytes
-rw-r--r--web/public/img/sources/merkaartor.32.pngbin0 -> 2780 bytes
-rw-r--r--web/public/img/sources/merkaartor.64.pngbin0 -> 9706 bytes
-rwxr-xr-xweb/taginfo.rb19
-rw-r--r--web/views/key.erb18
-rw-r--r--web/views/keys.erb8
-rw-r--r--web/views/sources/merkaartor/index.erb4
15 files changed, 258 insertions, 4 deletions
diff --git a/sources/master/master.sql b/sources/master/master.sql
index eeaf93a..e71f81c 100644
--- a/sources/master/master.sql
+++ b/sources/master/master.sql
@@ -38,10 +38,13 @@ INSERT INTO master_stats SELECT * FROM db.stats
INSERT INTO db.keys (key) SELECT DISTINCT key FROM wiki.wikipages WHERE key NOT IN (SELECT key FROM db.keys);
INSERT INTO db.keys (key) SELECT DISTINCT k FROM josm.josm_style_rules WHERE k NOT IN (SELECT key FROM db.keys);
-- potlatch XXX
+-- INSERT INTO db.keys (key) SELECT DISTINCT key FROM merkaartor.keys WHERE key NOT IN (SELECT key FROM db.keys);
+
UPDATE db.keys SET in_wiki=1 WHERE key IN (SELECT distinct key FROM wiki.wikipages);
UPDATE db.keys SET in_wiki_en=1 WHERE key IN (SELECT distinct key FROM wiki.wikipages WHERE lang='en');
UPDATE db.keys SET in_josm=1 WHERE key IN (SELECT distinct k FROM josm.josm_style_rules);
-- potlatch XXX
+UPDATE db.keys SET in_merkaartor=1 WHERE key IN (SELECT key FROM merkaartor.keys);
-- too slow, so we drop it for now
-- INSERT INTO db.tags (key, value) SELECT DISTINCT key, value FROM wiki.wikipages WHERE key || '=XX=' || value NOT IN (SELECT key || '=XX=' || value FROM db.tags);
diff --git a/sources/merkaartor/import_merkaartor.rb b/sources/merkaartor/import_merkaartor.rb
new file mode 100755
index 0000000..52af543
--- /dev/null
+++ b/sources/merkaartor/import_merkaartor.rb
@@ -0,0 +1,66 @@
+#!/usr/bin/ruby
+#------------------------------------------------------------------------------
+#
+# Taginfo source: Merkaartor
+#
+# import_merkaartor.rb
+#
+#------------------------------------------------------------------------------
+#
+# Copyright (C) 2010 Jochen Topf <jochen@remote.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+#------------------------------------------------------------------------------
+
+require 'pp'
+require 'sqlite3'
+require 'rexml/document'
+
+dir = ARGV[0] || '.'
+
+db = SQLite3::Database.new(dir + '/taginfo-merkaartor.db')
+
+db.execute('BEGIN TRANSACTION');
+
+template = 'default'
+db.execute('INSERT INTO templates (name) VALUES (?)', template)
+
+file = File.new(dir + '/git-source/Templates/' + template + '.mat')
+doc = REXML::Document.new(file)
+
+doc.elements.each('/templates/widgets/widget') do |widget|
+ key = widget.attributes['tag']
+ link = widget.elements['link'].attributes['src'] if widget.elements['link']
+ selector = widget.elements['selector'].attributes['expr'] if widget.elements['selector']
+ db.execute('INSERT INTO keys (template, key, tag_type, link, selector) VALUES (?, ?, ?, ?, ?)', template, key, widget.attributes['type'], link, selector)
+ widget.elements.each('description') do |desc|
+ db.execute('INSERT INTO key_descriptions (template, key, lang, description) VALUES (?, ?, ?, ?)', template, key, desc.attributes['locale'], desc.text)
+ end
+ widget.elements.each('value') do |valelement|
+ value = valelement.attributes['tag']
+ vlink = valelement.elements['link'].attributes['src'] if valelement.elements['link']
+ db.execute('INSERT INTO tags (template, key, value, link) VALUES (?, ?, ?, ?)', template, key, value, vlink)
+ widget.elements.each('description') do |desc|
+ db.execute('INSERT INTO tag_descriptions (template, key, value, lang, description) VALUES (?, ?, ?, ?, ?)', template, key, value, desc.attributes['locale'], desc.text)
+ end
+ end
+end
+
+
+db.execute('COMMIT');
+
+
+#-- THE END -------------------------------------------------------------------
diff --git a/sources/merkaartor/post.sql b/sources/merkaartor/post.sql
new file mode 100644
index 0000000..9e7fea9
--- /dev/null
+++ b/sources/merkaartor/post.sql
@@ -0,0 +1,8 @@
+--
+-- Taginfo source: Merkaartor
+--
+-- post.sql
+--
+
+.bail ON
+
diff --git a/sources/merkaartor/pre.sql b/sources/merkaartor/pre.sql
new file mode 100644
index 0000000..60ba309
--- /dev/null
+++ b/sources/merkaartor/pre.sql
@@ -0,0 +1,92 @@
+--
+-- Taginfo source: Merkaartor
+--
+-- pre.sql
+--
+
+.bail ON
+
+DROP TABLE IF EXISTS meta;
+
+CREATE TABLE meta (
+ source_id TEXT,
+ source_name TEXT,
+ update_start TEXT,
+ update_end TEXT,
+ data_until TEXT
+);
+
+INSERT INTO meta (source_id, source_name, update_start, data_until) SELECT 'potlatch', 'Potlatch', datetime('now'), datetime('now');
+
+DROP TABLE IF EXISTS stats;
+
+CREATE TABLE stats (
+ key TEXT,
+ value INT64
+);
+
+
+--
+-- templates
+--
+
+DROP TABLE IF EXISTS templates;
+
+CREATE TABLE templates (
+ name TEXT
+);
+
+--
+-- keys
+--
+
+DROP TABLE IF EXISTS keys;
+
+CREATE TABLE keys (
+ template TEXT,
+ key TEXT,
+ tag_type TEXT,
+ link TEXT,
+ selector TEXT
+);
+
+--
+-- key_descriptions
+--
+
+DROP TABLE IF EXISTS key_descriptions;
+
+CREATE TABLE key_descriptions (
+ template TEXT,
+ key TEXT,
+ lang TEXT,
+ description TEXT
+);
+
+--
+-- tags
+--
+
+DROP TABLE IF EXISTS tags;
+
+CREATE TABLE tags (
+ template TEXT,
+ key TEXT,
+ value TEXT,
+ link TEXT
+);
+
+--
+-- tag_descriptions
+--
+
+DROP TABLE IF EXISTS tag_descriptions;
+
+CREATE TABLE tag_descriptions (
+ template TEXT,
+ key TEXT,
+ value TEXT,
+ lang TEXT,
+ description TEXT
+);
+
diff --git a/sources/merkaartor/update.sh b/sources/merkaartor/update.sh
new file mode 100755
index 0000000..ae97d45
--- /dev/null
+++ b/sources/merkaartor/update.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# Taginfo source: Merkaartor
+#
+# update.sh DIR
+#
+
+set -e
+
+DIR=$1
+
+if [ "x" = "x$DIR" ]; then
+ echo "Usage: update.sh DIR"
+ exit 1
+fi
+
+echo -n "Start merkaartor: "; date
+
+DATABASE=$DIR/taginfo-merkaartor.db
+
+rm -f $DATABASE
+
+echo "Getting resources..."
+if [ -d $DIR/git-source ]; then
+ cd $DIR/git-source
+ git pull
+ cd -
+else
+ git clone http://git.gitorious.org/merkaartor/main.git $DIR/git-source
+fi
+
+echo "Running pre.sql..."
+sqlite3 $DATABASE <pre.sql
+
+echo "Running import..."
+./import_merkaartor.rb $DIR
+
+echo "Running post.sql..."
+sqlite3 $DATABASE <post.sql
+
+echo -n "Done merkaartor: "; date
+
diff --git a/web/lib/sql.rb b/web/lib/sql.rb
index 514dedf..c2487c0 100644
--- a/web/lib/sql.rb
+++ b/web/lib/sql.rb
@@ -11,7 +11,7 @@ module SQL
@db = SQLite3::Database.new(filename)
@db.results_as_hash = true
- [:db, :wiki, :josm].each do |dbname|
+ [:db, :wiki, :josm, :merkaartor].each do |dbname|
@db.execute("ATTACH DATABASE '#{dir}/taginfo-#{dbname}.db' AS #{dbname}")
end
diff --git a/web/public/img/sources/merkaartor.100.png b/web/public/img/sources/merkaartor.100.png
new file mode 100644
index 0000000..60bdfdf
--- /dev/null
+++ b/web/public/img/sources/merkaartor.100.png
Binary files differ
diff --git a/web/public/img/sources/merkaartor.16.png b/web/public/img/sources/merkaartor.16.png
new file mode 100644
index 0000000..c1b561c
--- /dev/null
+++ b/web/public/img/sources/merkaartor.16.png
Binary files differ
diff --git a/web/public/img/sources/merkaartor.24.png b/web/public/img/sources/merkaartor.24.png
new file mode 100644
index 0000000..4a71e27
--- /dev/null
+++ b/web/public/img/sources/merkaartor.24.png
Binary files differ
diff --git a/web/public/img/sources/merkaartor.32.png b/web/public/img/sources/merkaartor.32.png
new file mode 100644
index 0000000..052f08f
--- /dev/null
+++ b/web/public/img/sources/merkaartor.32.png
Binary files differ
diff --git a/web/public/img/sources/merkaartor.64.png b/web/public/img/sources/merkaartor.64.png
new file mode 100644
index 0000000..019c92a
--- /dev/null
+++ b/web/public/img/sources/merkaartor.64.png
Binary files differ
diff --git a/web/taginfo.rb b/web/taginfo.rb
index 0980c5f..ef08bf0 100755
--- a/web/taginfo.rb
+++ b/web/taginfo.rb
@@ -171,6 +171,16 @@ class Taginfo < Sinatra::Base
end
@wiki_count = @db.count('wiki.wikipages').condition('value IS NULL').condition('key=?', @key).get_first_value().to_i
+
+ (@merkaartor_type, @merkaartor_link, @merkaartor_selector) = @db.select('SELECT tag_type, link, selector FROM merkaartor.keys').condition('key=?', @key).get_columns(:tag_type, :link, :selector)
+ @merkaartor_images = [:node, :way, :area, :relation].map{ |type|
+ name = type.to_s.capitalize
+ '<img src="/img/types/' + (@merkaartor_selector =~ /Type is #{name}/ ? type.to_s : 'none') + '.16.png" alt="' + name + '" title="' + name + '"/>'
+ }.join('&nbsp;')
+
+ @merkaartor_values = @db.select('SELECT value FROM merkaartor.tags').condition('key=?', @key).order_by([:value], :value, 'ASC').execute().map{ |row| row['value'] }
+
+ @merkaartor_desc = @db.select('SELECT lang, description FROM key_descriptions').condition('key=?', @key).order_by([:lang], :lang, 'ASC').execute()
erb :key
end
@@ -307,6 +317,15 @@ class Taginfo < Sinatra::Base
#--------------------------------------------------------------------------
+ get '/sources/merkaartor/?' do
+ @title = 'Merkaartor'
+ @breadcrumbs << ['Sources', '/sources']
+ @breadcrumbs << ['Merkaartor']
+ erb :'sources/merkaartor/index'
+ end
+
+ #--------------------------------------------------------------------------
+
load 'lib/api/db.rb'
load 'lib/api/wiki.rb'
load 'lib/api/josm.rb'
diff --git a/web/views/key.erb b/web/views/key.erb
index 8b8fbe7..7c40892 100644
--- a/web/views/key.erb
+++ b/web/views/key.erb
@@ -32,6 +32,7 @@
<li><a href="#tabs-map">Map</a></li>
<li><a href="#tabs-wiki">Wiki</a></li>
<li><a href="#tabs-josm">JOSM</a></li>
+ <li><a href="#tabs-merkaartor">Merkaartor</a></li>
</ul>
<div id="tabs-values">
<h2>Values used with this key</h2>
@@ -72,6 +73,23 @@
<table id="grid-josm">
</table>
</div>
+ <div id="tabs-merkaartor">
+ <p>Type: <%= @merkaartor_type %></p>
+ <% if @merkaartor_link %>
+ <p>Link: XXX</p>
+ <% end %>
+ <p>
+ <%= @merkaartor_images %>
+ </p>
+ <h3>Values</h3>
+ <%= @merkaartor_values.map{ |value| link_to_value(@key, value) }.join(', ') %>
+ <h3>Descriptions</h3>
+ <table>
+ <% @merkaartor_desc.each do |desc| %>
+ <tr><td><%= desc['lang'] %></td><td><%= desc['description'] %></td></tr>
+ <% end %>
+ </table>
+ </div>
</div>
<iframe id="josmiframe" name="josmiframe"></iframe>
diff --git a/web/views/keys.erb b/web/views/keys.erb
index 5eaaaf1..ad8697d 100644
--- a/web/views/keys.erb
+++ b/web/views/keys.erb
@@ -19,6 +19,7 @@
{ display: '<img src="/img/sources/wiki.16.png" alt="Wiki" title="Wiki"/>', name: 'in_wiki', width: 20, sortable: true, align: 'center' },
{ display: '<img src="/img/sources/josm.16.png" alt="JOSM" title="JOSM"/>', name: 'in_josm', width: 20, sortable: true, align: 'center' },
// { display: '<img src="/img/sources/potlatch.16.png" alt="Potlatch 2" title="Potlatch 2"/>', name: 'in_potlatch', width: 20, sortable: true, align: 'center' },
+ // { display: '<img src="/img/sources/merkaartor.16.png" alt="Merkaartor" title="Merkaartor"/>', name: 'in_merkaartor', width: 20, sortable: true, align: 'center' },
{ display: '<span title="Number of different values for this key">Values</span>', name: 'values_all', width: 70, sortable: true, align: 'right' },
{ display: 'Prevalent Values', name: 'prevalent_values', width: 500, sortable: true, align: 'left' }
],
@@ -42,9 +43,10 @@
print_value_with_percent(row.count_ways, row.count_ways_fraction),
print_value_with_percent(row.count_relations, row.count_relations_fraction),
print_with_ts(row.users_all),
- row.in_wiki ? '&#x2714;' : '-',
- row.in_josm ? '&#x2714;' : '-',
- // row.in_potlatch ? '&#x2714;' : '-',
+ row.in_wiki ? '&#x2714;' : '-',
+ row.in_josm ? '&#x2714;' : '-',
+ // row.in_potlatch ? '&#x2714;' : '-',
+ // row.in_merkaartor ? '&#x2714;' : '-',
print_with_ts(row.values_all),
print_tag_list(row.key, row.prevalent_values)
] };
diff --git a/web/views/sources/merkaartor/index.erb b/web/views/sources/merkaartor/index.erb
new file mode 100644
index 0000000..c33f0f0
--- /dev/null
+++ b/web/views/sources/merkaartor/index.erb
@@ -0,0 +1,4 @@
+<h1><img src="/img/sources/merkaartor.32.png" alt="" title="Merkaartor"/> Merkaartor</h1>
+
+<p>&rarr; <a class="extlink" href="http://merkaartor.be/">Merkaartor</a> is an OSM editor.</p>
+