Skip to content

Commit

Permalink
Organize GJ output, clearly separating OSM tags. Also cutover to LTS
Browse files Browse the repository at this point in the history
from Rust. #10
  • Loading branch information
dabreegster committed Sep 8, 2023
1 parent fcdd265 commit e91e502
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 775 deletions.
8 changes: 6 additions & 2 deletions aggregate_routes/src/osm2network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,11 @@ impl Edge {
));
let mut properties = JsonObject::new();
if output_osm_tags {
let mut tags = JsonObject::new();
for (key, value) in &self.tags {
properties.insert(key.to_string(), JsonValue::from(value.to_string()));
tags.insert(key.to_string(), JsonValue::from(value.to_string()));
}
properties.insert("osm_tags".to_string(), tags.into());
}
properties.insert("node1".to_string(), JsonValue::from(node1));
properties.insert("node2".to_string(), JsonValue::from(node2));
Expand Down Expand Up @@ -202,9 +204,11 @@ impl Edge {
let geometry = Geometry::new(Value::LineString(pts));

let mut properties = JsonObject::new();
let mut tags = JsonObject::new();
for (key, value) in &self.tags {
properties.insert(key.to_string(), JsonValue::from(value.to_string()));
tags.insert(key.to_string(), JsonValue::from(value.to_string()));
}
properties.insert("osm_tags".to_string(), tags.into());
properties.insert("node1".to_string(), JsonValue::from(node1));
properties.insert("node2".to_string(), JsonValue::from(node2));
properties.insert("way".to_string(), JsonValue::from(self.way_id));
Expand Down
5 changes: 0 additions & 5 deletions viewer/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import Histogram from "./Histogram.svelte";
import Layout from "./Layout.svelte";
import Legend from "./Legend.svelte";
import { evaluateLTS } from "./lts";
import PropertiesTable from "./PropertiesTable.svelte";
import ToggleLayer from "./ToggleLayer.svelte";
Expand Down Expand Up @@ -83,10 +82,6 @@
if (f.geometry.type == "LineString") {
min = Math.min(min, f.properties.count);
max = Math.max(max, f.properties.count);
// Add in LTS
let result = evaluateLTS({ tags: f.properties });
f.properties.lts = result.lts;
rnetGj.features.push(f);
} else if (f.properties.origin_count) {
originsGj.features.push(f);
Expand Down
18 changes: 6 additions & 12 deletions viewer/src/PropertiesTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,24 @@
export let properties: { [name: string]: any };
let tags = structuredClone(properties);
// TODO Organize the GJ output better in the first-place, nest OSM tags elsewhere
delete tags.count;
delete tags.lts;
delete tags.node1;
delete tags.node2;
delete tags.way;
let ltsResult = calculate({
// Get detailed messages. Remember maplibre compacts nested feature properties, so we have to parse as JSON!
let tags = JSON.parse(properties.osm_tags);
let { messages } = calculate({
method: "bike_ottawa",
tags,
});
</script>

<b>Count: {properties.count.toFixed(2)}</b>
<b>LTS (Rust): {ltsResult.lts}</b>
<b>LTS: {properties.lts}</b>
<ul>
{#each ltsResult.messages as msg}
{#each messages as msg}
<li>{msg}</li>
{/each}
</ul>
<table>
<tbody>
{#each Object.entries(properties) as [key, value]}
{#each Object.entries(tags) as [key, value]}
<tr><td>{key}</td><td>{value}</td></tr>
{/each}
</tbody>
Expand Down
Loading

0 comments on commit e91e502

Please sign in to comment.