exporter

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package exporter provides the base export functionality with support for multiple workers.

Index

Constants

View Source
const (
	ProgressUpdateRate = time.Duration(15) * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	TileJSON         string // Input TileJSON filename
	Output           string // Output filename
	MbTiles          bool   // True if outputting to a mbtiles file, otherwise outputs to a directory
	Dsn              string // DSN to connect to postgres to query tiles
	InitSQLCmd       string // Initialization SQL command to be sent on session start for custom configuration or tuning
	NumWorkers       int    // Number of workers to process tiles in parallel
	Version          string // Tileset version written to the mbtiles file metadata
	Zoom             string // List of zooms to process, separated by a comma
	TilesFile        string // A list of custom tile coordinates to also generate, in addition to what is specified in zooms
	MbTilesBatchSize uint   // how many tiles to fetch in a batch and then write altogether to mbtiles
}

Config holds the configuration for the exporter

type Exporter

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

Exporter handles the tile export process

func NewExporter

func NewExporter(config Config) (*Exporter, error)

NewExporter creates a new exporter instance

func (*Exporter) Close

func (e *Exporter) Close()

Close closes the database connection pool

func (*Exporter) ConnectWithRetries

func (e *Exporter) ConnectWithRetries(numRetries int) (*pgxpool.Conn, error)

ConnectWithRetries attempts to acquire a database connection with retries

func (*Exporter) CreateWriters

func (e *Exporter) CreateWriters() (tileutils.TileWriter, tileutils.TileBulkWriter, func(), error)

CreateWriters creates the appropriate tile writers based on configuration

func (*Exporter) Export

func (e *Exporter) Export() error

Export runs the complete tile export process

func (*Exporter) GenerateTileList

func (e *Exporter) GenerateTileList(zooms []int) ([]tileutils.TileCoords, error)

GenerateTileList creates the list of tiles to process

func (*Exporter) GenerateZoomLevels

func (e *Exporter) GenerateZoomLevels() ([]int, error)

GenerateZoomLevels parses the zoom configuration and returns zoom levels

func (*Exporter) GetTotalProgress

func (e *Exporter) GetTotalProgress() int

GetTotalProgress returns the total progress across all workers

func (*Exporter) ProgressReporter

func (e *Exporter) ProgressReporter(ctx context.Context, totalTiles int)

ProgressReporter runs a progress reporting loop

func (*Exporter) UpdateProgress

func (e *Exporter) UpdateProgress(workerNum, count int)

UpdateProgress updates the progress for a worker

type WorkerParams

type WorkerParams struct {
	Num               int
	Wg                *sync.WaitGroup
	Exporter          *Exporter
	TileList          []tileutils.TileCoords
	GzipCompression   bool
	Writer            tileutils.TileWriter
	BulkWriter        tileutils.TileBulkWriter
	Conn              *pgxpool.Conn
	GzipCompressor    *tileutils.WorkerGzipCompressor
	GzipBufferPool    *tileutils.BytesBufferPool
	TileCache         []mbtiles.TileData
	TileCachePosition uint
	TileBufferCache   []*bytes.Buffer
	Count             uint
}

WorkerParams holds parameters for a tile worker

func (*WorkerParams) Do

func (p *WorkerParams) Do()

Do processes a slice of tiles for a single worker

func (*WorkerParams) FetchTile

func (p *WorkerParams) FetchTile(coord tileutils.TileCoords) error

Jump to

Keyboard shortcuts

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