five-on-it / packages/catalogue/src/region/roads
packages/catalogue/src/region/roads
A region's roads, routed over its tiles: each road of the spec, of a class of tiles.json (a dirt track, a country road, a street, an avenue, a highway), from where it starts (the spawn apron, an edge of the region, a tile, a feature) to where it goes, through the middles of the tiles' edges, the sockets, as RollerCoaster Tycoon's paths go: straight across a tile, or round a quarter bend of 32 m to the next side. The route is the cheapest over the tiles (A* over a tile and the way it was entered): a step costs one, a turn more, climbing more than the class may costs more again, a tile under water or lava is never entered (water.ts), a tile another road holds can be crossed straight over, at right angles, or joined at the end. Its heights follow the land at every socket, then are levelled to the class's grade (a level a tile, two for a track, half for a highway, a highway's and an avenue's closed over dips of a few tiles first) and pinned at their ends and where they meet another road; where a road runs more than 4 m over the land, it is a bridge. A road with tunnels: "auto" may go straight through a hill (its climb costs the search little) and holds its grade under the humps a few tiles wide; where the land then stands TUNNEL.clear and more over it, across its whole cutting, for TUNNEL.minLength and more, it is a tunnel (tunnels.ts builds its roof and portals), elsewhere a cutting. The ground is graded to the roads (terrain.ts).