Skip to content

Commit

Permalink
deploy: 17da1bb
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Oct 25, 2024
1 parent 2c678b8 commit 7f6fa41
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 18 deletions.
Binary file modified assets/backend_bg.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions assets/main-1d698b2f.js → assets/main-b19490ab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/worker-8453143b.js → assets/worker-5c936af5.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions doc/graph/struct.Graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,18 @@
) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.81.0/std/collections/hash/map/struct.HashMap.html" title="struct std::collections::hash::map::HashMap">HashMap</a>&lt;<a class="struct" href="struct.RoadID.html" title="struct graph::RoadID">RoadID</a>, <a class="struct" href="https://doc.rust-lang.org/1.81.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>&gt;</h4></section></summary><div class="docblock"><p>From a list of start intersections, floods out the graph for a profile until <code>end_time</code> is
reached. Returns the time needed to reach each road within that range. This query is not
precise about positions along a road.</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Graph-1" class="impl"><a class="src rightside" href="../src/graph/scrape.rs.html#11-134">source</a><a href="#impl-Graph-1" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Graph.html" title="struct graph::Graph">Graph</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../src/graph/scrape.rs.html#18-105">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>&lt;R: OsmReader&gt;(
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Graph-1" class="impl"><a class="src rightside" href="../src/graph/scrape.rs.html#12-147">source</a><a href="#impl-Graph-1" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Graph.html" title="struct graph::Graph">Graph</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../src/graph/scrape.rs.html#20-118">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>&lt;R: OsmReader&gt;(
input_bytes: &amp;[<a class="primitive" href="https://doc.rust-lang.org/1.81.0/std/primitive.u8.html">u8</a>],
osm_reader: <a class="primitive" href="https://doc.rust-lang.org/1.81.0/std/primitive.reference.html">&amp;mut R</a>,
profiles: <a class="struct" href="https://doc.rust-lang.org/1.81.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;(<a class="struct" href="https://doc.rust-lang.org/1.81.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>, <a class="struct" href="https://doc.rust-lang.org/1.81.0/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a>&lt;dyn <a class="trait" href="https://doc.rust-lang.org/1.81.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;<a class="struct" href="struct.Road.html" title="struct graph::Road">Road</a>) -&gt; (<a class="enum" href="enum.Direction.html" title="enum graph::Direction">Direction</a>, <a class="struct" href="https://doc.rust-lang.org/1.81.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>)&gt;)&gt;,
profiles: <a class="struct" href="https://doc.rust-lang.org/1.81.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;(<a class="struct" href="https://doc.rust-lang.org/1.81.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>, <a class="struct" href="https://doc.rust-lang.org/1.81.0/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a>&lt;dyn <a class="trait" href="https://doc.rust-lang.org/1.81.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;Tags, &amp;LineString) -&gt; (<a class="enum" href="enum.Direction.html" title="enum graph::Direction">Direction</a>, <a class="struct" href="https://doc.rust-lang.org/1.81.0/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>)&gt;)&gt;,
timer: &amp;mut <a class="struct" href="struct.Timer.html" title="struct graph::Timer">Timer</a>,
) -&gt; <a class="type" href="https://docs.rs/anyhow/1.0.91/anyhow/type.Result.html" title="type anyhow::Result">Result</a>&lt;<a class="struct" href="struct.Graph.html" title="struct graph::Graph">Graph</a>&gt;</h4></section></summary><div class="docblock"><p>Constructs a graph from OpenStreetMap data.</p>
<ul>
<li><code>input_bytes</code>: Bytes of an osm.pbf or osm.xml file</li>
<li><code>osm_reader</code>: A callback for every OSM element read, to extract non-graph data</li>
<li><code>profiles</code>: A list of named profiles. Each one assigns an access direction and cost to
each Road.</li>
<li><code>profiles</code>: A list of named profiles. Each one assigns an access direction and cost,
given OSM tags and a Euclidean center-line. If every profile assigns <code>Direction::None</code>,
then the Road is completely excluded from the graph.</li>
</ul>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Graph-2" class="impl"><a class="src rightside" href="../src/graph/snap.rs.html#9-106">source</a><a href="#impl-Graph-2" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Graph.html" title="struct graph::Graph">Graph</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.snap_route" class="method"><a class="src rightside" href="../src/graph/snap.rs.html#11-17">source</a><h4 class="code-header">pub fn <a href="#method.snap_route" class="fn">snap_route</a>(
&amp;self,
Expand Down
46 changes: 36 additions & 10 deletions doc/src/graph/scrape.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,25 @@
<a href="#164" id="164">164</a>
<a href="#165" id="165">165</a>
<a href="#166" id="166">166</a>
<a href="#167" id="167">167</a>
<a href="#168" id="168">168</a>
<a href="#169" id="169">169</a>
<a href="#170" id="170">170</a>
<a href="#171" id="171">171</a>
<a href="#172" id="172">172</a>
<a href="#173" id="173">173</a>
<a href="#174" id="174">174</a>
<a href="#175" id="175">175</a>
<a href="#176" id="176">176</a>
<a href="#177" id="177">177</a>
<a href="#178" id="178">178</a>
<a href="#179" id="179">179</a>
</pre></div><pre class="rust"><code><span class="kw">use </span>std::collections::BTreeMap;
<span class="kw">use </span>std::time::Duration;

<span class="kw">use </span>anyhow::Result;
<span class="kw">use </span>geo::EuclideanLength;
<span class="kw">use </span>geo::{EuclideanLength, LineString};
<span class="kw">use </span>utils::Tags;

<span class="kw">use </span><span class="kw">crate</span>::gtfs::GtfsModel;
<span class="kw">use </span><span class="kw">crate</span>::route::Router;
Expand All @@ -179,23 +193,34 @@
///
/// - `input_bytes`: Bytes of an osm.pbf or osm.xml file
/// - `osm_reader`: A callback for every OSM element read, to extract non-graph data
/// - `profiles`: A list of named profiles. Each one assigns an access direction and cost to
/// each Road.
/// - `profiles`: A list of named profiles. Each one assigns an access direction and cost,
/// given OSM tags and a Euclidean center-line. If every profile assigns `Direction::None`,
/// then the Road is completely excluded from the graph.
</span><span class="kw">pub fn </span>new&lt;R: utils::osm2graph::OsmReader&gt;(
input_bytes: <span class="kw-2">&amp;</span>[u8],
osm_reader: <span class="kw-2">&amp;mut </span>R,
profiles: Vec&lt;(String, Box&lt;<span class="kw">dyn </span>Fn(<span class="kw-2">&amp;</span>Road) -&gt; (Direction, Duration)&gt;)&gt;,
profiles: Vec&lt;(
String,
Box&lt;<span class="kw">dyn </span>Fn(<span class="kw-2">&amp;</span>Tags, <span class="kw-2">&amp;</span>LineString) -&gt; (Direction, Duration)&gt;,
)&gt;,
timer: <span class="kw-2">&amp;mut </span>Timer,
) -&gt; <span class="prelude-ty">Result</span>&lt;Graph&gt; {
timer.step(<span class="string">"parse OSM and split graph"</span>);

<span class="kw">let </span>graph = utils::osm2graph::Graph::new(
input_bytes,
<span class="comment">// Don't do any filtering by profile yet
// TODO Actually, see if any profile accepts it. But can we avoid calling the profiles
// twice?
</span>|tags| {
tags.has(<span class="string">"highway"</span>) &amp;&amp; !tags.is(<span class="string">"highway"</span>, <span class="string">"proposed"</span>) &amp;&amp; !tags.is(<span class="string">"area"</span>, <span class="string">"yes"</span>)
|tags| {
<span class="kw">if </span>!tags.has(<span class="string">"highway"</span>) || tags.is(<span class="string">"highway"</span>, <span class="string">"proposed"</span>) || tags.is(<span class="string">"area"</span>, <span class="string">"yes"</span>)
{
<span class="kw">return </span><span class="bool-val">false</span>;
}
<span class="comment">// Make sure at least one profile allows access
// TODO It's weird to pass in an empty linestring
// TODO It's inefficient to call the profiles twice
</span><span class="kw">let </span>empty = LineString::new(Vec::new());
profiles
.iter()
.any(|(<span class="kw">_</span>, profile)| profile(tags, <span class="kw-2">&amp;</span>empty).<span class="number">0 </span>!= Direction::None)
},
osm_reader,
)<span class="question-mark">?</span>;
Expand Down Expand Up @@ -239,7 +264,7 @@
<span class="kw">let </span><span class="kw-2">mut </span>access = Vec::new();
<span class="kw">let </span><span class="kw-2">mut </span>cost = Vec::new();
<span class="kw">for </span>(<span class="kw">_</span>, profile) <span class="kw">in </span><span class="kw-2">&amp;</span>profiles {
<span class="kw">let </span>(dir, c) = profile(road);
<span class="kw">let </span>(dir, c) = profile(<span class="kw-2">&amp;</span>road.osm_tags, <span class="kw-2">&amp;</span>road.linestring);
access.push(dir);
cost.push(c);
}
Expand All @@ -256,6 +281,7 @@

profile_names.insert(name, ProfileID(idx));
}
timer.pop();

<span class="prelude-val">Ok</span>(Graph {
roads,
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>15-minute neighborhood tool</title>
<script type="module" crossorigin src="/15m/assets/main-1d698b2f.js"></script>
<script type="module" crossorigin src="/15m/assets/main-b19490ab.js"></script>
<link rel="stylesheet" href="/15m/assets/index-4f769499.css">
</head>
<body>
Expand Down

0 comments on commit 7f6fa41

Please sign in to comment.