Start osmChange work, be a little bit more compact

This commit is contained in:
Tom MacWright
2012-11-19 20:46:29 -05:00
parent cedc714e2d
commit 48196a7a8d
3 changed files with 42 additions and 39 deletions

View File

@@ -5,25 +5,41 @@ iD.format.XML = {
}
},
decode: function(s) {
return s.replace(/>/g,'>').
replace(/</g,'&lt;').
replace(/"/g,'&quot;');
return s.replace(/>/g,'&gt;').replace(/</g,'&lt;').replace(/"/g,'&quot;');
},
changeset: function(comment) {
return (new XMLSerializer()).serializeToString(
JXON.unbuild({
osm: {
changeset: {
tag: [
{ '@k': 'created_by', '@v': 'iD' },
{ '@k': 'comment', '@v': comment || '' }
],
'@version': 0.3,
'@generator': 'iD'
}
}
}));
},
osmChange: function() {
return (new XMLSerializer()).serializeToString(
JXON.unbuild({
osmChange: {
'@version': 0.3,
'@generator': 'iD'
}
}));
},
mappings: {
node: function(entity) {
return iD.XML.decode((new XMLSerializer()).serializeToString(
return iD.format.XML.decode((new XMLSerializer()).serializeToString(
JXON.unbuild({
node: {
'@id': entity.id,
'@lat': entity.lat,
'@lon': entity.lon,
'tag': _.map(entity.tags, function(k, v) {
return {
keyAttributes: {
k: k,
v: v
}
};
'@lat': entity.lat, '@lon': entity.lon,
tag: _.map(entity.tags, function(k, v) {
return { keyAttributes: { k: k, v: v } };
})
}
})
@@ -35,19 +51,12 @@ iD.format.XML = {
JXON.unbuild({
way: {
'@id': entity.id,
'nd': entity.nodes.map(function(e) {
return {
keyAttributes: {
ref: e.id
}
};
nd: entity.nodes.map(function(e) {
return { keyAttributes: { ref: e.id } };
}),
'tag': _.map(entity.tags, function(k, v) {
tag: _.map(entity.tags, function(k, v) {
return {
keyAttributes: {
k: k,
v: v
}
keyAttributes: { k: k, v: v }
};
})
}

View File

@@ -205,7 +205,6 @@ iD.Map = function(elem) {
.classed('active', classActive);
}
function drawMarkers(points, filter) {
var markers = hit_g.selectAll('g.marker')
.filter(filter)
@@ -219,8 +218,7 @@ iD.Map = function(elem) {
marker.append('circle')
.attr({ r: 10, cx: 8, cy: 8 });
marker.append('image')
.attr({ width: 16, height: 16 })
.attr('xlink:href', iD.Style.markerimage);
.attr({ width: 16, height: 16, 'xlink:href': iD.Style.markerimage });
markers.attr('transform', function(d) {
var pt = projection([d.lon, d.lat]);
return 'translate(' + [~~pt[0], ~~pt[1]] + ') transform(-8, -8)';