summaryrefslogtreecommitdiff
path: root/sources/josm
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2011-12-28 19:36:42 +0100
committerJochen Topf <jochen@topf.org>2011-12-28 19:36:42 +0100
commit64d4f868ebdf36f96fe08fca9928a9d95c12cdc8 (patch)
tree4e8731da6f5081be0534ec5a46540ebf11142f57 /sources/josm
parentafe1e7dacd7de22ea298a012f630acd883216063 (diff)
downloadtaginfo-64d4f868ebdf36f96fe08fca9928a9d95c12cdc8.tar
taginfo-64d4f868ebdf36f96fe08fca9928a9d95c12cdc8.tar.gz
JOSM images support improved
Add JOSM map feature images to taginfo-josm.db database and make accessible via API.
Diffstat (limited to 'sources/josm')
-rwxr-xr-xsources/josm/import_josm.rb21
-rw-r--r--sources/josm/pre.sql14
-rwxr-xr-xsources/josm/update.sh9
3 files changed, 44 insertions, 0 deletions
diff --git a/sources/josm/import_josm.rb b/sources/josm/import_josm.rb
index 26d5e71..6851cb0 100755
--- a/sources/josm/import_josm.rb
+++ b/sources/josm/import_josm.rb
@@ -27,6 +27,7 @@
require 'rubygems'
+require 'find'
require 'pp'
require 'sqlite3'
require 'rexml/document'
@@ -95,5 +96,25 @@ end
db.execute('COMMIT');
+db.execute('BEGIN TRANSACTION');
+
+Dir.chdir(dir + '/svn-source') do
+ Dir.foreach(dir + '/svn-source') do |style|
+ Find.find(style) do |path|
+ if FileTest.directory?(path) && File.basename(path) =~ /^\./
+ Find.prune
+ elsif FileTest.file?(path)
+ File.open(path) do |file|
+ png = file.read
+ pathwostyle = path.sub(%r(^#{style}/), '')
+ db.execute('INSERT INTO josm_style_images (style, path, png) VALUES (?, ?, ?)', style, pathwostyle, png)
+ end
+ end
+ end
+ end
+end
+
+db.execute('COMMIT');
+
#-- THE END -------------------------------------------------------------------
diff --git a/sources/josm/pre.sql b/sources/josm/pre.sql
index 5c2975d..9335ecf 100644
--- a/sources/josm/pre.sql
+++ b/sources/josm/pre.sql
@@ -41,3 +41,17 @@ CREATE TABLE josm_style_rules (
rule VARCHAR
);
+--
+-- josm_style_images
+--
+-- Images/Icons used in JOSM style rules
+--
+
+DROP TABLE IF EXISTS josm_style_images;
+
+CREATE TABLE josm_style_images (
+ style VARCHAR,
+ path VARCHAR,
+ png BLOB
+);
+
diff --git a/sources/josm/update.sh b/sources/josm/update.sh
index abfb7e9..c8507fd 100755
--- a/sources/josm/update.sh
+++ b/sources/josm/update.sh
@@ -27,6 +27,15 @@ rm -f $ELEMSTYLES
echo "`$DATECMD` Getting styles..."
wget -O $ELEMSTYLES http://josm.openstreetmap.de/svn/trunk/styles/standard/elemstyles.xml
+echo "`$DATECMD` Updating images..."
+if [ -d $DIR/svn-source ]; then
+ cd $DIR/svn-source
+ svn update
+ cd -
+else
+ svn checkout http://josm.openstreetmap.de/svn/trunk/images/styles $DIR/svn-source
+fi
+
echo "`$DATECMD` Running init.sql..."
sqlite3 $DATABASE <../init.sql