Documentation
¶
Overview ¶
Package mapfile reads a map kept in files, in metres: a manifest, the ground's heights as an image and what lies on the ground as GeoJSON, whole or cut into tiles. It is the geography a board lays itself by, whichever its grid; the format is README.md's.
File ¶
Load reads a File: its Heights, its [Feature]s with their places turned to the world's, y down, the parts of the manifest that are a reader's own (File.Part) and its lines tagged highway as [Road]s from Meeting to meeting (File.Network).
Tiles ¶
Cut writes a map as tiles of two tiers, the map as it is and its Overview, which Load reads alike: heights as a place is asked for, features by File.Within.
Index ¶
- Constants
- func Cut(fsys fs.FS, name, out string, c Cutting) error
- type Cutting
- type Feature
- type File
- func (l *File) Grounded() bool
- func (l *File) HeightAt(x, y float32) float32
- func (l *File) HeightAtTier(x, y float32, tier int) float32
- func (l *File) Network() ([]Road, []Meeting)
- func (l *File) Part(name string, into any) (bool, error)
- func (l *File) Whole() error
- func (l *File) Within(box geom.AABB, tier int) ([]Feature, error)
- type Heights
- type Meeting
- type Road
- type Section
- type Shape
Constants ¶
const DefaultCorner = 8
DefaultCorner is the radius of a junction's corners where the manifest sets none.
const Overview = 3
Overview is the tier of the tiles that is drawn from far off: tiles eight times the side, heights every eighth pixel.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cutting ¶
type Cutting struct {
// Tile is a tile's side in metres, a power of two; Margin how far past a tile a feature
// may lie and still be the tile's.
Tile float32
Margin float32
// Overview says whether a feature of these tags, extent metres across, is drawn from far
// off: it lies in the overview tier too.
Overview func(tags map[string]string, extent float32) bool
}
Cutting is how a level is cut into tiles.
type Feature ¶
type Feature struct {
// ID is the feature's own name in its file, empty where it has none.
ID string
Tags map[string]string
Shape Shape
// Path is the place, the line's points or the area's outline, Holes the outlines cut out
// of an area.
Path []geom.Vec
Holes [][]geom.Vec
}
Feature is a thing lying on the ground: what it is by its tags, named as OpenStreetMap's, and where, in the world's places.
type File ¶
type File struct {
// Width and Height are the level's size, metres.
Width float32
Height float32
// Seed is what a reader scatters from where it must.
Seed uint64
// Heights is the ground's heights of a level in one piece; nil, a level in tiles or a
// ground level at zero.
Heights *Heights
// Features is what lies on a level in one piece; a level in tiles gives its own by Within.
Features []Feature
// Sections is how a road of each highway lies across, Corner the radius the kerbs round
// a junction's corners at.
Sections map[string]Section
Corner float32
// contains filtered or unexported fields
}
File is a level read: its ground and what lies on it, whole or in tiles read as asked for.
func Load ¶
Load is the level whose manifest is name in fsys, the files it names beside it; of a level in tiles nothing but the manifest is read yet.
func (*File) HeightAtTier ¶
HeightAtTier is the ground's height at a place as a tier of the tiles has it; a level in one piece has one ground.
func (*File) Network ¶
Network is the level's lines tagged highway as roads and the meetings they end at: a line cut where another shares a point within it, two of one highway joined where they alone end.
func (*File) Part ¶
Part decodes the manifest's part of a name, a reader's own, into what into points at, and says whether the manifest has one.
type Heights ¶
type Heights struct {
Columns int
Rows int
Pixel float32
// Lowest is the height of the value 0, Step the metres a step of the value.
Lowest float32
Step float32
// contains filtered or unexported fields
}
Heights is a ground's heights a corner a pixel: Columns by Rows of them, Pixel metres apart, the first row the north edge.
type Meeting ¶
Meeting is where three or more roads end: the ways they leave it, in the order that turns left as the world lies.