From e83097f2cfc6e3663adc009179c27bf9485c14f5 Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Sat, 30 Oct 2010 22:20:30 +0200 Subject: More Potlatch2 support --- sources/potlatch/import_potlatch.rb | 8 ++++++-- sources/potlatch/pre.sql | 20 +++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) (limited to 'sources') diff --git a/sources/potlatch/import_potlatch.rb b/sources/potlatch/import_potlatch.rb index b939cc6..61832e3 100755 --- a/sources/potlatch/import_potlatch.rb +++ b/sources/potlatch/import_potlatch.rb @@ -57,6 +57,10 @@ doc.elements.each('/mapFeatures/feature') do |feature_element| on[$1.to_sym] = 1 when /^(category|help)$/ fields[element.name] = element.text.strip + when 'icon' + fields['icon_image'] = element.attributes['image'] + fields['icon_background'] = element.attributes['background'] + fields['icon_foreground'] = element.attributes['foreground'] end end @@ -64,8 +68,8 @@ doc.elements.each('/mapFeatures/feature') do |feature_element| on = { :point => 1, :line => 1, :area => 1, :relation => 1 } end - db.execute('INSERT INTO features (name, category_id, help, on_point, on_line, on_area, on_relation) VALUES (?, ?, ?, ?, ?, ?, ?)', - feature_name, fields['category'], fields['help'], on[:point], on[:line], on[:area], on[:relation]) + db.execute('INSERT INTO features (name, category_id, help, on_point, on_line, on_area, on_relation, icon_image, icon_background, icon_foreground) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', + feature_name, fields['category'], fields['help'], on[:point], on[:line], on[:area], on[:relation], fields['icon_image'], fields['icon_background'], fields['icon_foreground']) end db.execute('COMMIT'); diff --git a/sources/potlatch/pre.sql b/sources/potlatch/pre.sql index 7f3a40b..9f79445 100644 --- a/sources/potlatch/pre.sql +++ b/sources/potlatch/pre.sql @@ -36,7 +36,6 @@ CREATE TABLE categories ( name TEXT ); - -- -- features -- @@ -44,14 +43,17 @@ CREATE TABLE categories ( DROP TABLE IF EXISTS features; CREATE TABLE features ( - name TEXT, - category_id TEXT REFERENCES categories (id), - category_name TEXT, - help TEXT, - on_point INTEGER, - on_line INTEGER, - on_area INTEGER, - on_relation INTEGER + name TEXT, + category_id TEXT REFERENCES categories (id), + category_name TEXT, + help TEXT, + on_point INTEGER, + on_line INTEGER, + on_area INTEGER, + on_relation INTEGER, + icon_image TEXT, + icon_foreground TEXT, + icon_background TEXT ); -- -- cgit v1.2.3