Add josm converter and converted, switch to it.

This commit is contained in:
Tom MacWright
2013-01-31 12:18:06 -05:00
parent bc59070ff3
commit 4e7ed7250b
5 changed files with 12328 additions and 3 deletions

View File

@@ -136,7 +136,7 @@
<div id="iD"></div><script>
locale.current = 'en';
d3.json('keys.json', function(err, keys) {
d3.json('presets/presets.json', function(err, presets_data) {
d3.json('presets/presets_josm.json', function(err, presets_data) {
var id = iD();
id.connection().keys(keys)
.presetData(iD.presetData().data(presets_data))

View File

@@ -16,7 +16,7 @@ iD.presetData = function() {
presets.match = function(entity) {
return data.filter(function(d) {
return _.contains(d.match.type, entity.type);
return _.contains(d.type, entity.type);
});
};

View File

@@ -38,7 +38,7 @@ iD.ui.preset = function() {
function presets(selection) {
var sections = selection.selectAll('div.preset-section')
.data(preset.form)
.data(preset.main)
.enter()
.append('div')
.attr('class', 'preset-section');

44
presets/convert_josm.py Normal file
View File

@@ -0,0 +1,44 @@
from xml.dom.minidom import parse
import os
dirr = os.path.dirname(__file__)
import json
def relative(x):
return os.path.join(dirr, x)
dom1 = parse(relative('./josm.xml'))
items = dom1.getElementsByTagName('item')
jsonOutput = []
for item in items:
jitem = {
"name": item.getAttribute('name'),
"type": item.getAttribute('type').split(','),
"main": []
}
for n in item.childNodes:
if n.nodeType != n.TEXT_NODE and n.nodeType != n.COMMENT_NODE:
if n.tagName == 'text':
jitem['main'].append({
'type': 'text',
'key': n.getAttribute('key'),
'text': n.getAttribute('text')
})
if n.tagName == 'combo':
jitem['main'].append({
'type': 'select',
'key': n.getAttribute('key'),
'text': n.getAttribute('text'),
'values': n.getAttribute('values').split(',')
})
if n.tagName == 'check':
jitem['main'].append({
'type': 'check',
'key': n.getAttribute('key'),
'text': n.getAttribute('text'),
'default': (n.getAttribute('check') == 'true')
})
jsonOutput.append(jitem)
json.dump(jsonOutput, open(relative('presets_josm.json'), 'w'), indent=4)

12281
presets/presets_josm.json Normal file

File diff suppressed because it is too large Load Diff