mapclient

package
v0.0.0-...-2bb1cf3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2021 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToolDot

func ToolDot() error

ToolDot consumes a MapRaw on os.Stdin, parses it and dumps to os.Stdout a dot representation (cf. graphviz.org) of it.

func ToolInit

func ToolInit() error

ToolInit consumes a MapSeed on os.Stdin, parses it, extrapolates the MapRaw from it and then dumps that MapRaw to os.Stdout.

func ToolNoise

func ToolNoise(noise float64) error

ToolNoise consumes a MapRaw on os.Stdin, parses it then alter each node position (with a configurable statistical noise) and the dumps the new MapRaw on os.Stdout.

func ToolNormalize

func ToolNormalize() error

ToolNormalize consumes a MapRaw on os.Stdin, parses it a remap each node position (keeping the same aspect ratio to fit the whole map into a given bounded box.

func ToolSplit

func ToolSplit(maxDist float64) error

ToolSplit consumes a MapRaw on os.Stdin, parses it then adds nodes until each road (edge) is shorter than a threshold (given by maxDist)

func ToolSvg

func ToolSvg() error

ToolSvg consumes a MapRaw on os.Stdin, parses it and dumps a SVG representation of it to os.Stdout.

Types

type ClientCLI

type ClientCLI struct{}

ClientCLI gathers the command line interface actions related to the Map API service. It wraps the main gRPC client calls and dumps all the output as JSON on os.Stdout.

func (*ClientCLI) GetCities

func (c *ClientCLI) GetCities(ctx context.Context, args PathArgs) error

GetCities produces to os.Stdout a JSON array of cities, where each City is an <id,name> tuple.

func (*ClientCLI) GetPath

func (c *ClientCLI) GetPath(ctx context.Context, args PathArgs) error

GetPath produces to os.Stdout a JSON array of integers, all fields being the unique ID of a position involved in the path from the given source to the given destination.

func (*ClientCLI) GetPositions

func (c *ClientCLI) GetPositions(ctx context.Context, args PathArgs) error

GetPositions produces to os.Stdout a JSON array of <id,x,y> tuples, all fields being integers, with one tuple for each position on the map, i.e. one tuple per vertex in the graph.

func (*ClientCLI) GetRoads

func (c *ClientCLI) GetRoads(ctx context.Context, args PathArgs) error

GetRoads produces to os.Stdout a JSON stream of <int,int> pairs objects, with one pair for a road in place on the given map.

func (*ClientCLI) GetStep

func (c *ClientCLI) GetStep(ctx context.Context, args PathArgs) error

GetStep produces to os.Stdout a JSON singleton array of integers, with the unique value equals to the ID of the position that is the next step in the path from the given source to the given destination.

func (*ClientCLI) ListMaps

func (c *ClientCLI) ListMaps(ctx context.Context, args PathArgs) error

ListMaps produces to os.Stdout a JSON stream of objects, each object describing a Map registered in the repository.

type MapRaw

type MapRaw struct {
	ID    string    `json:"id"`
	Sites []SiteRaw `json:"sites"`
	Roads []RoadRaw `json:"roads"`
}

MapRaw is a human-unfriendly representation of a Map - The Sites are indexed by a unique number - The presence of a non-empty name on the site makes it an established City when the map is instantiated. - The roads are unidirectional (the MapRaw is a digraph). - A road might be duplicated, without effect

type MapSeed

type MapSeed struct {
	ID    string     `json:"id"`
	Sites []SiteSeed `json:"sites"`
	Roads []RoadSeed `json:"roads"`
}

MapSeed is a handy representation of a map where nearly each node of the graph carries a city. - The sites are identified by a textual name, typically decided by a content creator that will name the cities in a meaningful way. - Each site name MUST be unique - The reads bidirectional. - Duplicated roads are treated as is, no simplification is done.

type PathArgs

type PathArgs struct {
	MapName  string
	Src, Dst uint64
	Max      uint32
}

PathArgs gathers the possible arguments for the map-related calls. Hopefully they are always the same.

func (*PathArgs) Parse

func (pa *PathArgs) Parse(args []string) (err error)

Parse extracts the elements of the PathArgs from the array of command line positional arguments.

type RoadRaw

type RoadRaw struct {
	Src uint64 `json:"src"`
	Dst uint64 `json:"dst"`
}

RoadRaw is a minimal repreentation of a directional road on the map.

type RoadSeed

type RoadSeed struct {
	Src string `json:"src"`
	Dst string `json:"dst"`
}

RoadSeed is the minimal representation of a diriectional graph edge in a map for Hegemonie.

type SiteRaw

type SiteRaw struct {
	ID uint64 `json:"id"`
	X  uint64 `json:"x"`
	Y  uint64 `json:"y"`
	// City is the name of the city that should exist at the instanciation a region based on the current map.
	// The presence of a City is achieved by a non-empty string in the City field, that will be the name of the city
	City string `json:"city"`
}

SiteRaw is the information of a node in the graph representation on a map by MapRaw.

type SiteSeed

type SiteSeed struct {
	ID   string `json:"id"`
	X    uint64 `json:"x"`
	Y    uint64 `json:"y"`
	City bool   `json:"city"`
}

SiteSeed is the minimal representation of a graph node in a map for Hegemonie.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL