<buttonid="sidebar-toggle"class="icon-button"type="button"title="Toggle Table of Contents"aria-label="Toggle Table of Contents"aria-controls="sidebar">
<ahref="../../print.html"title="Print this book"aria-label="Print this book">
<iid="print-button"class="fa fa-print"></i>
</a>
</div>
</div>
<divid="search-wrapper"class="hidden">
<formid="searchbar-outer"class="searchbar-outer">
<inputtype="search"name="search"id="searchbar"name="searchbar"placeholder="Search this book ..."aria-controls="searchresults-outer"aria-describedby="searchresults-header">
<h1><aclass="header"href="#from-osm-to-rawmap-convert_osm-crate"id="from-osm-to-rawmap-convert_osm-crate">From OSM to RawMap (<code>convert_osm</code> crate)</a></h1>
<p>The first phase of map building reads in data from OSM files and a few others,
producing a serialized <code>RawMap</code>. Importing all maps (one for each pre-defined
bounding polygon) takes a few minutes. Players don't see this cost; it only
takes a few seconds to load a serialized map.</p>
<ul>
<li><code>osm.rs</code>: Read .osm, extracting the points for road-like ways, buildings, and
areas
<ul>
<li>Areas usually come from a relation of multiple ways, with the points out of
order. Gluing all the points together fails when the .osm has some ways
clipped out. In that case, try to trace along the map boundary if the
partial area intersects the boundary in a clear way. Otherwise, just use a
straight line to try to close off the polygon.</li>
<li>Also read traffic signal locations and turn restrictions between OSM ways</li>
</ul>
</li>
<li><code>split_ways.rs</code>: Split OSM ways into road segments
<ul>
<li>OSM ways cross many intersections, so treat points with multiple ways and
the points at the beginning and end of a way as intersections, then split
the way into road segments between two intersections.</li>
<li>This phase remembers which road segment is the beginning and end of the OSM
way, for per-lane turn restrictions later</li>
<li>Apply turn restrictions between roads here. Since OSM ways cross many
intersections, the turn restrictions only apply to one particular road
segment that gets created from the way. Make sure the destination of the
restriction is actually incident to a particular source road.</li>
</ul>
</li>
<li><code>clip.rs</code>: Clip the map to the boundary polygon
<ul>
<li>Osmosis options in <code>import.sh</code> preserve ways that cross the boundary</li>
<li>Trim roads that cross the boundary. There may be cases where a road dips out
of bounds, then immediately comes back in. Disconnecting it isn't ideal, but
it's better to manually tune the boundary polygon when this happens than try
to preserve lots of out-of-bounds geometry.</li>
<li>Area polygons are intersected with the boundary polygon using the <code>clipping</code>
crate</li>
</ul>
</li>
<li><code>lib.rs</code>: Remove cul-de-sacs (roads that begin and end at the same
intersection), because they mess up parking hints and pathfinding.</li>
<li><code>lib.rs</code>: Apply parking hints from a King County GIS blockface dataset
<ul>
<li>Match each blockface to the nearest edge of a road</li>
<li>Interpret the metadata to assign on-street parking there or not</li>
</ul>
</li>
<li><code>lib.rs</code>: Apply offstreet parking hints from a King County GIS dataset
<ul>
<li>Match each point to the building containing it, plumbing through the number
of spots</li>
</ul>
</li>
<li><code>lib.rs</code>: <strong>Disabled</strong>: Apply sidewalk presence hints from a King County GIS
dataset
<ul>
<li>Match each sidewalk line to the nearest edge of a road</li>
<li>Update the road to have a sidewalk on none, one, or both sides</li>
</ul>
</li>
<li><code>lib.rs</code> using the <code>srtm</code> module: Load (extremely poor quality) elevation data</li>