Files
iD/js/id/svg.js
T
John Firebaugh f64c2df17f Return null rather than empty string
Empty string still generates the error 'Problem parsing d=""',
while null results in no 'd' attribute at all.
2013-01-17 11:57:29 -08:00

30 lines
794 B
JavaScript

iD.svg = {
RoundProjection: function (projection) {
return function (d) {
return iD.util.geo.roundCoords(projection(d));
};
},
PointTransform: function (projection) {
return function (entity) {
return 'translate(' + projection(entity.loc) + ')';
};
},
LineString: function (projection) {
var cache = {};
return function (entity) {
if (cache[entity.id] !== undefined) {
return cache[entity.id];
}
if (entity.nodes.length === 0) {
return (cache[entity.id] = null);
}
return (cache[entity.id] =
'M' + entity.nodes.map(function (n) { return projection(n.loc); }).join('L'));
}
}
};