pmtiles

package
v1.10.4 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: BSD-3-Clause Imports: 41 Imported by: 12

Documentation

Index

Constants

View Source
const (
	UnknownCompression Compression = 0
	NoCompression                  = 1
	Gzip                           = 2
	Brotli                         = 3
	Zstd                           = 4
)
View Source
const (
	UnknownTileType TileType = 0
	Mvt                      = 1
	Png                      = 2
	Jpeg                     = 3
	Webp                     = 4
	Avif                     = 5
)
View Source
const HEADERV3_LEN_BYTES = 127

Variables

This section is empty.

Functions

func BboxRegion added in v1.10.0

func BboxRegion(bbox string) (orb.MultiPolygon, error)

func Convert added in v1.0.0

func Convert(logger *log.Logger, input string, output string, deduplicate bool, tmpfile *os.File) error

func ConvertMbtiles added in v1.1.0

func ConvertMbtiles(logger *log.Logger, input string, output string, deduplicate bool, tmpfile *os.File) error

func ConvertPmtilesV2 added in v1.1.0

func ConvertPmtilesV2(logger *log.Logger, input string, output string, deduplicate bool, tmpfile *os.File) error

func Extract added in v1.9.0

func Extract(logger *log.Logger, bucketURL string, key string, maxzoom int8, region_file string, bbox string, output string, download_threads int, overfetch float32, dry_run bool) error

func IdToZxy added in v1.0.0

func IdToZxy(i uint64) (uint8, uint32, uint32)

func MergeRanges added in v1.9.0

func MergeRanges(ranges []SrcDstRange, overfetch float32) (*list.List, uint64)

MergeRanges takes a slice of SrcDstRanges, that: * is non-contiguous, and is sorted by NewOffset * an Overfetch parameter

  • overfetch = 0.2 means we can request an extra 20%
  • overfetch = 1.00 means we can double our total transfer size

Return a slice of OverfetchRanges

Each OverfetchRange is one or more input ranges
input ranges are merged in order of smallest byte distance to next range
until the overfetch budget is consumed.
The slice is sorted by Length

func NormalizeBucketKey added in v1.9.1

func NormalizeBucketKey(bucket string, prefix string, key string) (string, string, error)

func ParentId added in v1.7.0

func ParentId(i uint64) uint64

fast parent ID calculation without converting to ZXY.

func ParseEntryV2 added in v1.1.0

func ParseEntryV2(b []byte) (uint8, Zxy, Range)

func ReencodeEntries added in v1.9.0

func ReencodeEntries(dir []EntryV3) ([]EntryV3, []SrcDstRange, uint64, uint64, uint64)

Given a tile entries for a Source archive, sorted in TileID order, return: * Re-encoded tile-entries, with their offsets changed to contiguous (clustered) order in a new archive. * SrcDstRange: slice of offsets in the source archive, offset in the new archive, and length.

  • Each range is one or more tiles
  • the output must not have contiguous entries
  • It is sorted by new offsets, but not necessarily by source offsets

* The total size of the tile section in the new archive * The # of addressed tiles (sum over RunLength) * # the number of unique offsets ("tile contents")

  • this might not be the last SrcDstRange new_offset + length, it's the highest offset (can be in the middle)

func RelevantEntries added in v1.9.0

func RelevantEntries(bitmap *roaring64.Bitmap, maxzoom uint8, dir []EntryV3) ([]EntryV3, []EntryV3)

given a bitmap and a set of existing entries, create only relevant entries return sorted slice of entries, and slice of all leaf entries any runlengths > 1 will be "trimmed" to the relevance bitmap

func Show added in v1.1.0

func Show(logger *log.Logger, bucketURL string, key string, show_tile bool, z int, x int, y int) error

func UnmarshalRegion added in v1.9.1

func UnmarshalRegion(data []byte) (orb.MultiPolygon, error)

func Upload added in v1.1.0

func Upload(logger *log.Logger, input string, bucket string, key string, max_concurrency int) error

func Verify added in v1.10.0

func Verify(logger *log.Logger, file string) error

func WriteImage added in v1.7.0

func WriteImage(interior *roaring64.Bitmap, boundary *roaring64.Bitmap, exterior *roaring64.Bitmap, filename string, zoom uint8)

func ZxyToId added in v1.0.0

func ZxyToId(z uint8, x uint32, y uint32) uint64

Types

type Bucket added in v1.9.1

type Bucket interface {
	Close() error
	NewRangeReader(ctx context.Context, key string, offset int64, length int64) (io.ReadCloser, error)
}

func OpenBucket added in v1.9.1

func OpenBucket(ctx context.Context, bucketURL string, bucketPrefix string) (Bucket, error)

type BucketAdapter added in v1.9.1

type BucketAdapter struct {
	Bucket *blob.Bucket
}

func (BucketAdapter) Close added in v1.9.1

func (ba BucketAdapter) Close() error

func (BucketAdapter) NewRangeReader added in v1.9.1

func (ba BucketAdapter) NewRangeReader(ctx context.Context, key string, offset, length int64) (io.ReadCloser, error)

type CacheKey added in v1.2.0

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

type CachedValue added in v1.2.0

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

type Compression added in v1.0.0

type Compression uint8

type CopyDiscard added in v1.9.0

type CopyDiscard struct {
	Wanted  uint64
	Discard uint64
}

"want the next N bytes, then discard N bytes"

type DirectoryV2 added in v1.1.0

type DirectoryV2 struct {
	Entries map[Zxy]Range
	LeafZ   uint8
	Leaves  map[Zxy]Range
}

func ParseDirectoryV2 added in v1.1.0

func ParseDirectoryV2(dir_bytes []byte) DirectoryV2

func ParseHeaderV2 added in v1.1.0

func ParseHeaderV2(reader io.Reader) ([]byte, DirectoryV2)

func (DirectoryV2) SizeBytes added in v1.1.0

func (d DirectoryV2) SizeBytes() int

type EntryV3 added in v1.0.0

type EntryV3 struct {
	TileId    uint64
	Offset    uint64
	Length    uint32
	RunLength uint32
}

type HeaderV3 added in v1.0.0

type HeaderV3 struct {
	SpecVersion         uint8
	RootOffset          uint64
	RootLength          uint64
	MetadataOffset      uint64
	MetadataLength      uint64
	LeafDirectoryOffset uint64
	LeafDirectoryLength uint64
	TileDataOffset      uint64
	TileDataLength      uint64
	AddressedTilesCount uint64
	TileEntriesCount    uint64
	TileContentsCount   uint64
	Clustered           bool
	InternalCompression Compression
	TileCompression     Compression
	TileType            TileType
	MinZoom             uint8
	MaxZoom             uint8
	MinLonE7            int32
	MinLatE7            int32
	MaxLonE7            int32
	MaxLatE7            int32
	CenterZoom          uint8
	CenterLonE7         int32
	CenterLatE7         int32
}

type HttpBucket added in v1.9.1

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

func (HttpBucket) Close added in v1.9.1

func (b HttpBucket) Close() error

func (HttpBucket) NewRangeReader added in v1.9.1

func (b HttpBucket) NewRangeReader(ctx context.Context, key string, offset, length int64) (io.ReadCloser, error)

type OffsetLen added in v1.0.0

type OffsetLen struct {
	Offset uint64
	Length uint32
}

type OverfetchListItem added in v1.9.0

type OverfetchListItem struct {
	Rng          SrcDstRange
	CopyDiscards []CopyDiscard
	BytesToNext  uint64 // the "priority"
	// contains filtered or unexported fields
}

A single request, where only some of the bytes in the requested range we want

type OverfetchRange added in v1.9.0

type OverfetchRange struct {
	Rng          SrcDstRange
	CopyDiscards []CopyDiscard
}

type Range

type Range struct {
	Offset uint64
	Length uint64
}

type Request

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

type Resolver added in v1.0.0

type Resolver struct {
	Entries        []EntryV3
	Offset         uint64
	OffsetMap      map[string]OffsetLen
	AddressedTiles uint64 // none of them can be empty
	// contains filtered or unexported fields
}

func NewResolver added in v1.0.0

func NewResolver(deduplicate bool, compress bool) *Resolver

func (*Resolver) AddTileIsNew added in v1.0.0

func (r *Resolver) AddTileIsNew(tile_id uint64, data []byte) (bool, []byte)

must be called in increasing tile_id order, uniquely

func (*Resolver) NumContents added in v1.6.0

func (r *Resolver) NumContents() uint64

type Response

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

type Server added in v1.7.0

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

func NewServer added in v1.7.0

func NewServer(bucketURL string, prefix string, logger *log.Logger, cacheSize int, cors string, publicHostname string) (*Server, error)

func NewServerWithBucket added in v1.10.3

func NewServerWithBucket(bucket Bucket, prefix string, logger *log.Logger, cacheSize int, cors string, publicHostname string) (*Server, error)

func (*Server) Get added in v1.7.0

func (server *Server) Get(ctx context.Context, path string) (int, map[string]string, []byte)

func (*Server) Start added in v1.7.0

func (server *Server) Start()

type SrcDstRange added in v1.9.0

type SrcDstRange struct {
	SrcOffset uint64
	DstOffset uint64
	Length    uint64
}

type TileType added in v1.0.0

type TileType uint8

type Zxy

type Zxy struct {
	Z uint8
	X uint32
	Y uint32
}

func GetParentTile

func GetParentTile(tile Zxy, level uint8) Zxy

Jump to

Keyboard shortcuts

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