Skip to content

Commit

Permalink
update external fetch line list process
Browse files Browse the repository at this point in the history
add prism csv format
  • Loading branch information
nlehuby committed Nov 12, 2021
1 parent edb24ae commit 3399387
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ projects = {
"qa": true
},
"Kochi":{
"line_list":"https://raw.githubusercontent.com/Jungle-Bus/KochiTransport_geom_ci/gh-pages/lines.csv",
"format": "osm-transit-extractor",
"line_list":"https://raw.githubusercontent.com/Jungle-Bus/KochiTransport_exports_ci/gh-pages/lines_for_unroll.csv",
"format": "prism",
"qa": true
}
}
Expand All @@ -24,6 +24,9 @@ async function on_load(){
if (projects[project_id]["format"] == "osm-transit-extractor"){
display_from_osm_transit_extractor_csv_list(projects[project_id]["line_list"], projects[project_id]["qa"])
}
if (projects[project_id]["format"] == "prism"){
display_from_prism_csv_list(projects[project_id]["line_list"], projects[project_id]["qa"])
}
}
}

Expand Down Expand Up @@ -191,6 +194,31 @@ function display_from_osm_transit_extractor_csv_list(url, add_qa_to_url){
});
}

function display_from_prism_csv_list(url, add_qa_to_url){
Papa.parse(url, {
download: true,
header: true,
dynamicTyping: true,
complete: function(results) {
results.data.splice(-1, 1);
for (var line of results.data){
line['id'] = line['line_id'].slice(1);
line["thumbnail"] = `
<transport-thumbnail
data-transport-mode="${line['mode']}"
data-transport-line-code="${line['code'] ||' '}"
data-transport-line-color="${line['colour'] || 'grey'}">
</transport-thumbnail>`
}
display_table(results.data, lines_table, add_qa_to_url)

var lines_stats = document.getElementById("lines_stats");
lines_stats.innerHTML = display_stats(results.data);
lines_stats.scrollIntoView();
}
});
}

function display_stats(lines){
var line_nb = lines.length;
if (line_nb > 10){
Expand Down

0 comments on commit 3399387

Please sign in to comment.