Format CSV
This commit is contained in:
parent
00f2cead36
commit
0fc468a682
2 changed files with 16 additions and 0 deletions
|
|
@ -86,6 +86,8 @@ BR.Export = L.Class.extend({
|
||||||
return BR.Kml.format(track);
|
return BR.Kml.format(track);
|
||||||
case 'geojson':
|
case 'geojson':
|
||||||
return JSON.stringify(track, null, 2);
|
return JSON.stringify(track, null, 2);
|
||||||
|
case 'csv':
|
||||||
|
return BR.Csv.format(track);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
js/format/Csv.js
Normal file
14
js/format/Csv.js
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
BR.Csv = {
|
||||||
|
format: function (geoJson) {
|
||||||
|
const separator = '\t';
|
||||||
|
const newline = '\n';
|
||||||
|
const messages = geoJson.features[0].properties.messages;
|
||||||
|
let csv = '';
|
||||||
|
|
||||||
|
for (const entries of messages) {
|
||||||
|
csv += entries.join(separator) + newline;
|
||||||
|
}
|
||||||
|
|
||||||
|
return csv;
|
||||||
|
},
|
||||||
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue