downloadosm

package module
v0.0.0-...-f223b11 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2021 License: MIT Imports: 14 Imported by: 0

README

go-download-osm

This is an experimental Go port of the Python tool download-osm, a "fast multi-mirror parallel planet and extracts downloader". The original tool is part of the openmaptiles/openmaptiles-tools package. This is a partial implementation of that tool, mostly focused on an OSM planet file download for now.

This tool will generate a list of URL's from a set of mirrors hosting the recent OSM planet file. The URL's can then be used by aria2 to download the file.

I came across download-osm while watching a recent talk from PostGIS Day 2021 given by Yuri Astrakhan (nyurik).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AreaSource

type AreaSource interface {
	Search(string) error
	GetCatalog() Catalog
	FetchCatalog() error
	ParseCatalog(string) Catalog
}

type Catalog

type Catalog struct {
	Mirrors     []*Mirror
	UsePrimary  bool
	ForceLatest bool
	Verbose     bool
}

func NewCatalog

func NewCatalog(opts ...CatalogOption) (*Catalog, error)

func (*Catalog) Init

func (c *Catalog) Init(client *Client) (*Downloads, error)

type CatalogOption

type CatalogOption func(*Catalog)

func WithCatalogForceLatest

func WithCatalogForceLatest() CatalogOption

func WithCatalogMirrors

func WithCatalogMirrors(mirrors []*Mirror) CatalogOption

func WithCatalogUsePrimary

func WithCatalogUsePrimary() CatalogOption

func WithCatalogVerbose

func WithCatalogVerbose() CatalogOption

type Client

type Client struct {
	UserAgent string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(userAgent string) *Client

func (*Client) ContentLength

func (c *Client) ContentLength(url string) (int, error)

func (*Client) Get

func (c *Client) Get(url string) (string, error)

type Downloads

type Downloads struct {
	URLs []string
	Hash string
}

func (Downloads) SaveURLs

func (d Downloads) SaveURLs()
type Link struct {
	Name string
	Href string
}

type Mirror

type Mirror struct {
	Country       string
	URL           string
	IsPrimary     bool
	Sources       []*Source
	HasMultiFiles bool
	Verbose       bool
}

func NewMirror

func NewMirror(opts ...MirrorOption) *Mirror

func (*Mirror) ExtractSources

func (m *Mirror) ExtractSources() ([]*Source, error)

func (*Mirror) GetSources

func (m *Mirror) GetSources() ([]*Source, error)

func (*Mirror) Init

func (m *Mirror) Init(client *Client) error

func (*Mirror) LoadSources

func (m *Mirror) LoadSources(client *Client)

type MirrorOption

type MirrorOption func(*Mirror)

func WithMirrorCountry

func WithMirrorCountry(country string) MirrorOption

func WithMirrorMultiFiles

func WithMirrorMultiFiles() MirrorOption

func WithMirrorPrimary

func WithMirrorPrimary() MirrorOption

func WithMirrorURL

func WithMirrorURL(url string) MirrorOption

func WithMirrorVerbose

func WithMirrorVerbose(verbose bool) MirrorOption

type Source

type Source struct {
	Name       string
	URL        string
	Timestamp  time.Time
	Mirror     *Mirror
	URLHash    string
	Hash       string
	FileLength int64
	Verbose    bool
}

func NewSource

func NewSource(opts ...SourceOption) *Source

func (*Source) LoadHash

func (s *Source) LoadHash(client *Client) error

func (*Source) LoadMetadata

func (s *Source) LoadMetadata(client *Client) error

func (*Source) Size

func (s *Source) Size() string

func (*Source) String

func (s *Source) String() string

func (*Source) StringHash

func (s *Source) StringHash() string

type SourceOption

type SourceOption func(*Source)

func WithSourceMirror

func WithSourceMirror(mirror *Mirror) SourceOption

func WithSourceName

func WithSourceName(name string) SourceOption

func WithSourceTimestamp

func WithSourceTimestamp(timestamp time.Time) SourceOption

func WithSourceURL

func WithSourceURL(url string) SourceOption

func WithSourceVerbose

func WithSourceVerbose(verbose bool) SourceOption

type Stat

type Stat struct {
	Timestamp   time.Time
	MirrorCount int
	Hash        string
	Size        string
}

func (Stat) String

func (s Stat) String() string

Jump to

Keyboard shortcuts

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