aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2011-12-28 23:31:27 +0100
committerJochen Topf <jochen@topf.org>2011-12-28 23:31:27 +0100
commit9f7eecc2d5c34fd71fae022ed8ef37a176898686 (patch)
tree1e1de8bb91405ebb30a4424c6d9debebd2cc28d0
parent64d4f868ebdf36f96fe08fca9928a9d95c12cdc8 (diff)
downloadtaginfo-9f7eecc2d5c34fd71fae022ed8ef37a176898686.tar
taginfo-9f7eecc2d5c34fd71fae022ed8ef37a176898686.tar.gz
Show icons/map symbols in JOSM tab.
-rwxr-xr-xsources/josm/import_josm.rb10
-rw-r--r--sources/josm/pre.sql2
-rw-r--r--web/lib/api/josm.rb6
-rw-r--r--web/public/js/taginfo.js14
4 files changed, 28 insertions, 4 deletions
diff --git a/sources/josm/import_josm.rb b/sources/josm/import_josm.rb
index 6851cb0..52ad3b2 100755
--- a/sources/josm/import_josm.rb
+++ b/sources/josm/import_josm.rb
@@ -37,7 +37,8 @@ class Rule
attr_accessor :k, :v, :b
attr_accessor :scale_min, :scale_max
attr_accessor :icon_source
- attr_accessor :line_width, :line_realwidth
+ attr_accessor :line_color, :line_width, :line_realwidth
+ attr_accessor :area_color
attr_reader :rule
@@ -47,15 +48,17 @@ class Rule
def insert(db)
db.execute(
- 'INSERT INTO josm_style_rules (k, v, b, scale_min, scale_max, icon_source, line_width, line_realwidth, rule) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)',
+ 'INSERT INTO josm_style_rules (k, v, b, scale_min, scale_max, icon_source, line_color, line_width, line_realwidth, area_color, rule) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
k,
v,
b,
scale_min,
scale_max,
icon_source,
+ line_color,
line_width,
line_realwidth,
+ area_color,
rule
)
end
@@ -85,7 +88,10 @@ doc.elements.each('/rules/rule') do |rule_element|
rule.scale_max = element.text
when 'icon'
rule.icon_source = element.attributes['src']
+ when 'area'
+ rule.area_color = element.attributes['colour']
when 'line'
+ rule.line_color = element.attributes['colour']
rule.line_width = element.attributes['width']
rule.line_realwidth = element.attributes['realwidth']
end
diff --git a/sources/josm/pre.sql b/sources/josm/pre.sql
index 9335ecf..3bf48a7 100644
--- a/sources/josm/pre.sql
+++ b/sources/josm/pre.sql
@@ -36,8 +36,10 @@ CREATE TABLE josm_style_rules (
scale_min INTEGER,
scale_max INTEGER,
icon_source VARCHAR,
+ line_color VARCHAR,
line_width INTEGER,
line_realwidth INTEGER,
+ area_color VARCHAR,
rule VARCHAR
);
diff --git a/web/lib/api/josm.rb b/web/lib/api/josm.rb
index 70a0099..ff85f31 100644
--- a/web/lib/api/josm.rb
+++ b/web/lib/api/josm.rb
@@ -33,7 +33,11 @@ class Taginfo < Sinatra::Base
:k => row['k'],
:v => row['v'],
:b => row['b'],
- :rule => h(row['rule'])
+ :rule => h(row['rule']),
+ :area_color => row['area_color'] ? h(row['area_color'].sub(/^.*#/, '#')) : '',
+ :line_color => row['line_color'] ? h(row['line_color'].sub(/^.*#/, '#')) : '',
+ :line_width => row['line_width'] ? h(row['line_width']) : 0,
+ :icon => row['icon_source'] && row['icon_source'] != 'misc/deprecated.png' ? h(row['icon_source']) : ''
} }
}.to_json
end
diff --git a/web/public/js/taginfo.js b/web/public/js/taginfo.js
index 0451d2f..47b4ca0 100644
--- a/web/public/js/taginfo.js
+++ b/web/public/js/taginfo.js
@@ -393,6 +393,9 @@ var create_flexigrid_for = {
url: '/api/2/josm/styles/standard/tags?key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value),
colModel: [
{ display: texts.osm.value, name: 'v', width: 200, sortable: false },
+ { display: 'Icon', name: 'icon', width: 30, sortable: false, align: 'center' },
+ { display: 'Line', name: 'line', width: 30, sortable: false, align: 'center' },
+ { display: 'Area', name: 'area', width: 30, sortable: false, align: 'center' },
{ display: 'Rule XML', name: 'rule', width: 100, sortable: false }
],
/* searchitems: [
@@ -405,6 +408,9 @@ var create_flexigrid_for = {
data.rows = jQuery.map(data.data, function(row, i) {
return { 'cell': [
row.v ? link_to_value(row.k, row.v) : row.b ? (row.b + ' (Boolean)') : '*',
+ row.icon ? '<img src="/api/2/josm/styles/images?style=standard&image=' + row.icon + '" title="' + row.icon + '" alt=""/>' : '',
+ '<div>' + (row.line_width > 0 ? '<div title="' + row.line_color + '" style="height: ' + row.line_width + 'px; margin-top: ' + (6 - Math.round(row.line_width/2)) + 'px; padding: 0; background-color: ' + row.line_color + '"></div>' : '') + '</div>',
+ row.area_color ? '<div title="' + row.area_color + '" style="height: 8px; background-color: ' + row.area_color + '"></div>' : '',
'<span title="' + row.rule + '">XML</span>'
] };
});
@@ -469,7 +475,10 @@ var create_flexigrid_for = {
create_flexigrid('grid-josm', {
url: '/api/2/josm/styles/standard/keys?key=' + encodeURIComponent(key),
colModel: [
- { display: texts.osm.value, name: 'v', width: 200, sortable: true },
+ { display: texts.osm.value, name: 'v', width: 200, sortable: true },
+ { display: 'Icon', name: 'icon', width: 30, sortable: false, align: 'center' },
+ { display: 'Line', name: 'line', width: 30, sortable: false, align: 'center' },
+ { display: 'Area', name: 'area', width: 30, sortable: false, align: 'center' },
{ display: 'Rule XML', name: 'rule', width: 100, sortable: false }
],
searchitems: [
@@ -482,6 +491,9 @@ var create_flexigrid_for = {
data.rows = jQuery.map(data.data, function(row, i) {
return { 'cell': [
row.v ? link_to_value(row.k, row.v) : row.b ? (row.b + ' (Boolean)') : '*',
+ row.icon ? '<img src="/api/2/josm/styles/images?style=standard&image=' + row.icon + '" title="' + row.icon + '" alt=""/>' : '',
+ '<div>' + (row.line_width > 0 ? '<div title="' + row.line_color + '" style="height: ' + row.line_width + 'px; margin-top: ' + (6 - Math.round(row.line_width/2)) + 'px; padding: 0; background-color: ' + row.line_color + '"></div>' : '') + '</div>',
+ row.area_color ? '<div title="' + row.area_color + '" style="height: 8px; background-color: ' + row.area_color + '"></div>' : '',
'<span title="' + row.rule + '">XML</span>'
] };
});