street_index
This library contains utility functions for generating a street index.
How it works is fairly simple: You give it a grid (right now limited
to a rectangular grid) on a page, and add StreetNameRect
s. Each
StreetNameRect
contains the String for the street / road name as well
as the extents of the laid out String on the map.
The Grid
takes care of assigning a grid position to your street name
such as "Canterbury Road => A2"
. Since usually maps have the problem
of having duplicated road names (which is not what you'd want in a street
index), you can create a DeduplicatedRoadNames::from_streets
, which will
deduplicate all road names.
The problem generally arises when street names are ambigouus. For example, a street that appears in two locations on the map (such as a city having the same street name as a neighbouring city). Because of this, street name processing can't be fully automated, since there are always weird edge cases to worry about. However, 90% of roads aren't like that.
Because of this limitation DeduplicatedRoadNames::process()
gives you
two types of roads back: ProcessedRoadName
is for roads that span only
1 or 2 grid cells (i.e. "Canterbury Road" => A9
, "Canterbury Road" => A9-A10
).
In these cases (which cover 90% of street index names), the mapping is not
ambigouus.
UnprocessedRoadName
is for anything else (e.g. "Canterbury Road" => [A9, A10, E1, E2]
.
Usually these roads need to be manually reviewed - it could likely be that
there are two roads "Canterbury Road" => A9-10;E1-E2
, but it could also
be that the road is just one road and part of it is just clipped off the map,
in which case you'd write "Canterbury Road" => A9-E2
.
For cartographic purposes, usually you want the output in CSV format, so
that your graphic designer can paste the street index into InDesign /
Illustrator for the final map layout. Both UnprocessedRoads
and
ProcessedRoads
have a simple .to_csv
function for easy export.
Example
extern crate street_index;
use *;
License
This library is licensed under the MIT license.