aboutsummaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2010-11-04 20:48:20 +0100
committerJochen Topf <jochen@topf.org>2010-11-04 20:48:20 +0100
commit1292fe579b19061a0b5f69014b3635a1a2e9f9e1 (patch)
tree551fe909de25d2520b2aee65f48d3688fc21c77e /sources
parent0bf8b3ea8c9524a4a8666e5dcb5276c9729d45f6 (diff)
parent10f53cfe47f11629b26d550c7deabba4cc427fb3 (diff)
downloadtaginfo-1292fe579b19061a0b5f69014b3635a1a2e9f9e1.tar
taginfo-1292fe579b19061a0b5f69014b3635a1a2e9f9e1.tar.gz
added merkaartor branch
Diffstat (limited to 'sources')
-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
5 files changed, 211 insertions, 0 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
+