dotworld

package module
v0.0.0-...-0d11aec Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: AGPL-3.0 Imports: 3 Imported by: 2

README

dotworld

dotworld is for creating dot maps that look like:

example map graph

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Reference = PlateCarre{
	Width:  8192,
	Height: 4096,
}

Reference defines the coordinates for default reference image.

Functions

func AvgY

func AvgY(m *image.Gray, b image.Rectangle) float32

AvgY calculates average Y (luminosity) for a grayscale image.

Types

type Grid

type Grid struct {
	// CountX defines number of dots in X dimension.
	CountX int
	// Thshold defines minimum average Y value, where dot should be placed.
	Threshold float32

	// Coord define image coordinate system.
	Coord PlateCarre
}

Grid defines arguments for deriving a Map from an image.

func (*Grid) MapFromImage

func (grid *Grid) MapFromImage(m *image.Gray) *Map

MapFromImage derives a Map from an image.

type GridPosition

type GridPosition struct {
	Row int
	Col int
}

GridPosition represents the integer row and column of a location on a grid.

type Location

type Location struct {
	S2
	Land float32 // 0 to 1
	Load float32
}

Location defines a location in LatLong coordinates.

type Map

type Map struct {
	CountX, CountY int
	Grid           *Grid
	Bounds         image.Rectangle
	Locations      map[GridPosition]*Location
}

Map defines a location map with dots.

func (*Map) Copy

func (m *Map) Copy() *Map

Copy returns a new Map with the same data

func (*Map) EncodeSVG

func (m *Map) EncodeSVG(w io.Writer, width, height int) (err error)

EncodeSVG encodes map as a svg.

func (*Map) Lookup

func (m *Map) Lookup(pos S2) GridPosition

Lookup finds the appropriate row and column in the grid for the given S2 location.

func (*Map) Nearest

func (m *Map) Nearest(pos GridPosition) *Location

Nearest returns the requested grid position, or a close by neighbor if the requested one isn't found. Returns nil if nothing is found.

type P2

type P2 struct {
	X float32
	Y float32
}

P2 defines a pixel coordinate.

type PlateCarre

type PlateCarre struct {
	Width  float32
	Height float32
}

PlateCarree defines parameters for Plate Carree projection.

func (*PlateCarre) Forward

func (pc *PlateCarre) Forward(s S2) P2

Forward converts from LatLong to pixel coordinates.

func (*PlateCarre) Reverse

func (pc *PlateCarre) Reverse(p P2) S2

Reverse converts from pixel coordinates to LatLong.

type S2

type S2 struct {
	Lat  float32
	Long float32
}

S2 defines a LatLong coordinate.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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