common

package
v0.0.0-...-069f472 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxHeight = 1934
	MinHeight = -1934
)
View Source
const DefaultTransparentDim = 2.0 / 100.0

DefaultTransparentDim sets the default dimming factor of transparent nodes to 2%.

View Source
const MTSatelliteVersion = "0.9.1"

Variables

View Source
var (
	ErrNoMoreBlocks           = errors.New("no more blocks")
	ErrMapContentSizeMismatch = errors.New("content size does not match")
	ErrBlockTruncated         = errors.New("block is truncated")
)

Error returned if a Producer has run to its end.

View Source
var BackgroundColor = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
View Source
var ResizeFilter = rez.NewLanczosFilter(3)

ResizeFilter is used to scale down the pyramid tiles.

Functions

func BackgroundImage

func BackgroundImage(width, height int, bg color.RGBA) *image.RGBA

func BigMin

func BigMin(minz, maxz, zcode int64) int64

func BlendColor

func BlendColor(c1, c2 color.RGBA, a float32) color.RGBA

func Clamp32f

func Clamp32f(x, a, b float32) float32

func ColorToHex

func ColorToHex(col color.RGBA) string

func CoordToInterleaved

func CoordToInterleaved(c Coord) (result int64)

func CoordToPlain

func CoordToPlain(c Coord) int64

func DecodeFromBigEndian

func DecodeFromBigEndian(key []byte) (int64, error)

func DecodeStringFromBytes

func DecodeStringFromBytes(key []byte) (pos int64, err error)

DecodeStringFromBytes constructs a database key out of byte slice.

func DecodeStringFromBytesToInterleaved

func DecodeStringFromBytesToInterleaved(key []byte) (v int64, err error)

func EncodeStringToBytes

func EncodeStringToBytes(key int64) ([]byte, error)

EncodeStringToBytes encodes a block pos to byte slice.

func EncodeStringToBytesFromInterleaved

func EncodeStringToBytesFromInterleaved(key int64) ([]byte, error)

func EncodeToBigEndian

func EncodeToBigEndian(key int64) ([]byte, error)

func EncodeToMem

func EncodeToMem(img image.Image) []byte

func FromBigEndian

func FromBigEndian(key []byte) int64

func HashImage

func HashImage(img *image.RGBA) []byte

func IdentityTranscoder

func IdentityTranscoder(key []byte) ([]byte, error)

func IsPostgreSQL

func IsPostgreSQL(host string) (string, bool)

func LoadPNG

func LoadPNG(path string, bg color.RGBA) image.Image

func Max

func Max(a, b int) int

func Min

func Min(a, b int) int

func NaiveBigMin

func NaiveBigMin(minz, maxz, zcode int64) int64

NaiveBigMin is for correctness checks of BigMin only.

func Order

func Order(a, b int) (int, int)

func Order16

func Order16(a, b int16) (int16, int16)

func Order64

func Order64(a, b int64) (int64, int64)

func ParseColor

func ParseColor(col string) (color.RGBA, error)

func ParseColorDefault

func ParseColorDefault(col string, def color.RGBA) color.RGBA

func PrintVersionAndExit

func PrintVersionAndExit()

func SaveAsPNG

func SaveAsPNG(path string, img image.Image) (err error)

func SaveAsPNGAtomic

func SaveAsPNGAtomic(path string, img image.Image) (err error)

func StringToBytes

func StringToBytes(key int64) []byte

func ToBigEndian

func ToBigEndian(key int64) []byte

func TranscodeInterleavedToPlain

func TranscodeInterleavedToPlain(key []byte) ([]byte, error)

func TranscodePlainToInterleaved

func TranscodePlainToInterleaved(key []byte) ([]byte, error)

func TransformInterleavedToPlain

func TransformInterleavedToPlain(pos int64) int64

func TransformPlainToInterleaved

func TransformPlainToInterleaved(pos int64) int64

Types

type BaseTileCreator

type BaseTileCreator struct {
	// contains filtered or unexported fields
}

func NewBaseTileCreator

func NewBaseTileCreator(
	client DBClient,
	colors *Colors,
	bg color.RGBA,
	yMin, yMax int16,
	transparent bool,
	baseDir string) *BaseTileCreator

func (*BaseTileCreator) Close

func (btc *BaseTileCreator) Close() error

func (*BaseTileCreator) RenderArea

func (btc *BaseTileCreator) RenderArea(x, z int16) error

func (*BaseTileCreator) WriteFunc

func (btc *BaseTileCreator) WriteFunc(i, j int, update BaseTileUpdateFunc) func() (bool, error)

WriteFunc returns a function intended to be run in background so the creation of the next tile with this creator can be done concurrently.

type BaseTileHash

type BaseTileHash struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewBaseTileHash

func NewBaseTileHash(maxEntries int) *BaseTileHash

func (*BaseTileHash) Update

func (bth *BaseTileHash) Update(x, y int, hash []byte) bool

type BaseTileUpdateFunc

type BaseTileUpdateFunc func(x, y int, hash []byte) bool

type Block

type Block struct {
	Coord Coord
	Data  []byte
}

Block data from Minetest database.

type BlockConsumer

type BlockConsumer interface {
	Consume(*Block) error
	// Closes the open database connections.
	Close() error
}

BlockConsumer is used to store blocks in a new Minetest database.

type BlockProducer

type BlockProducer interface {
	// error is ErrNoMoreBlocks if it run out of blocks.
	Next(*Block) error
	// Closes the open database connections.
	Close() error
}

BlockProducer is used to over a existing Minetest database and return its content block by block.

type Colors

type Colors struct {
	Colors         []color.RGBA
	NameIndex      map[string]int32
	NumTransparent int32
	TransparentDim float32
}

func ParseColors

func ParseColors(filename string) (colors *Colors, err error)

func (*Colors) BlendColors

func (colors *Colors) BlendColors(sp *span, col color.RGBA, pos int32) color.RGBA

func (*Colors) IsTransparent

func (colors *Colors) IsTransparent(index int32) bool

type Coord

type Coord struct {
	X, Y, Z int16
}

func ClipCoord

func ClipCoord(c Coord) Coord

func DecodeStringBytesToCoord

func DecodeStringBytesToCoord(key []byte) (coord Coord, err error)

func InterleavedToCoord

func InterleavedToCoord(pos int64) Coord

func MaxCoord

func MaxCoord(a, b Coord) Coord

func MinCoord

func MinCoord(a, b Coord) Coord

func PlainToCoord

func PlainToCoord(i int64) (c Coord)

func (Coord) String

func (c Coord) String() string

type Coverage3D

type Coverage3D struct {
	// contains filtered or unexported fields
}

func NewCoverage3D

func NewCoverage3D() *Coverage3D

func (*Coverage3D) Insert

func (c3d *Coverage3D) Insert(c Coord)

func (*Coverage3D) Query

func (c3d *Coverage3D) Query(c1, c2 Coord) []Range

type Cuboid

type Cuboid struct {
	P1, P2 Coord
}

func (Cuboid) Contains

func (cub Cuboid) Contains(c Coord) bool

type DBClient

type DBClient interface {
	QueryCuboid(cuboid Cuboid, fn func(*Block) *Block) (count int, err error)
	Close() error
}

type DBClientFactory

type DBClientFactory interface {
	Create() (DBClient, error)
	Close() error
}

func CreateDBClientFactory

func CreateDBClientFactory(host string, port int) (DBClientFactory, error)

type DecodedBlock

type DecodedBlock struct {
	Version     byte
	Transparent bool
	MapContent  []byte
	AirID       int32
	IgnoreID    int32
	IndexMap    map[int32]int32
}

func NewDecodedBlock

func NewDecodedBlock(data []byte, colors *Colors) (db *DecodedBlock, err error)

func (*DecodedBlock) AirOnly

func (db *DecodedBlock) AirOnly() bool

func (*DecodedBlock) Content

func (db *DecodedBlock) Content(x, y, z int) (content int32, found bool)

type KeyDecoder

type KeyDecoder func([]byte) (int64, error)

type KeyEncoder

type KeyEncoder func(int64) ([]byte, error)

type KeyJoiner

type KeyJoiner func(Coord) int64

type KeySplitter

type KeySplitter func(int64) Coord

type KeyTranscoder

type KeyTranscoder func([]byte) ([]byte, error)

type KeyTransformer

type KeyTransformer func(int64) int64

type PGClient

type PGClient struct {
	// contains filtered or unexported fields
}

func (*PGClient) Close

func (pgc *PGClient) Close() error

func (*PGClient) QueryCuboid

func (pgc *PGClient) QueryCuboid(
	cuboid Cuboid,
	fn func(*Block) *Block,
) (int, error)

type PGClientFactory

type PGClientFactory struct {
	// contains filtered or unexported fields
}

func NewPGClientFactory

func NewPGClientFactory(connS string) (*PGClientFactory, error)

func (*PGClientFactory) Close

func (pgcf *PGClientFactory) Close() error

func (*PGClientFactory) Create

func (pgcf *PGClientFactory) Create() (DBClient, error)

type Range

type Range struct {
	Z  int16
	Y1 int16
	Y2 int16
	X1 int16
	X2 int16
}

type RedisClient

type RedisClient struct {
	// contains filtered or unexported fields
}

func NewRedisClient

func NewRedisClient(network, address string) (client *RedisClient, err error)

func (*RedisClient) Close

func (client *RedisClient) Close() error

func (*RedisClient) QueryCuboid

func (client *RedisClient) QueryCuboid(cuboid Cuboid, fn func(*Block) *Block) (count int, err error)

type RedisClientFactory

type RedisClientFactory struct {
	// contains filtered or unexported fields
}

func NewRedisClientFactory

func NewRedisClientFactory(host string, port int) (*RedisClientFactory, error)

func (*RedisClientFactory) Close

func (rcf *RedisClientFactory) Close() error

func (*RedisClientFactory) Create

func (rcf *RedisClientFactory) Create() (DBClient, error)

type Renderer

type Renderer struct {
	RejectedBlocks    int
	SolidBlocks       int
	TransparentBlocks int
	// contains filtered or unexported fields
}

func NewRenderer

func NewRenderer(width, height int, transparent bool) (renderer *Renderer)

func (*Renderer) CreateImage

func (r *Renderer) CreateImage(colors []color.RGBA, background color.RGBA) *image.RGBA

func (*Renderer) CreateShadedImage

func (r *Renderer) CreateShadedImage(
	xOfs, zOfs, width, height int,
	cols *Colors, background color.RGBA) *image.RGBA

func (*Renderer) GetPos

func (r *Renderer) GetPos() (int16, int16)

func (*Renderer) IsEmpty

func (r *Renderer) IsEmpty() bool

func (*Renderer) IsFilled

func (r *Renderer) IsFilled() bool

func (*Renderer) RenderBlock

func (r *Renderer) RenderBlock(block *Block, colors *Colors) (err error)

func (*Renderer) Reset

func (r *Renderer) Reset()

func (*Renderer) SetPos

func (r *Renderer) SetPos(xOfs, zOfs int16)

type YOrder

type YOrder struct {
	RenderFn func(*Block) error
	// contains filtered or unexported fields
}

func NewYOrder

func NewYOrder(renderFn func(*Block) error, capacity int) *YOrder

func (*YOrder) Drain

func (yo *YOrder) Drain() error

func (*YOrder) Len

func (yo *YOrder) Len() int

func (*YOrder) Less

func (yo *YOrder) Less(i, j int) bool

func (*YOrder) Pop

func (yo *YOrder) Pop() interface{}

func (*YOrder) Push

func (yo *YOrder) Push(x interface{})

func (*YOrder) RenderBlock

func (yo *YOrder) RenderBlock(block *Block) (*Block, error)

func (*YOrder) Reset

func (yo *YOrder) Reset()

func (*YOrder) Swap

func (yo *YOrder) Swap(i, j int)

Jump to

Keyboard shortcuts

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