mbt

package
v0.0.13-a Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2016 License: MIT Imports: 16 Imported by: 3

Documentation

Overview

Diglet is a set of geospatial tools focused around rendering large feature sets efficiently.

Index

Constants

This section is empty.

Variables

View Source
var (
	CsvExt     = "csv"
	GeojsonExt = "geojson"
)
View Source
var ClipBuffer = 10

ClipBuffer is the number of pixels to buffer a tile clipping

View Source
var Cmd = cli.Command{
	Name:        "mbt",
	Aliases:     []string{"build"},
	Usage:       "Builds an mbtiles database from the input data source",
	Description: "Builds an mbtiles database from the given format",
	ArgsUsage:   "input_source",
	Action: func(c *cli.Context) {

		out := c.String("output")
		desc := c.String("desc")
		layer := c.String("layer-name")
		zmin := c.Int("min")
		zmax := c.Int("max")
		extent := c.Int("extent")
		upsert := c.Bool("upsert")
		force := c.Bool("force")

		if len(c.Args()) == 0 || out == "" {
			util.Die(c, "input_source & --out required")
		} else if zmax < zmin || zmin < 0 || zmax > 23 {
			util.Die(c, "--max > --min, --min > 0 --max < 24 not satisfied")
		}

		source, err := getSource(c)
		util.Check(err)
		if force {
			os.Remove(out)
		}
		tiles, err := InitTiles(out, upsert, desc, extent)
		util.Check(err)
		err = tiles.Build(source, layer, zmin, zmax)
		util.Check(err)

		file, _ := os.Open(out)
		defer file.Close()
		stat, _ := file.Stat()
		exp := float64(stat.Size()) / float64(1<<20)
		util.Info("%s was successfully caught!", out)
		util.Info("Diglet gained %f MB of EXP!", exp)
	},
	Flags: []cli.Flag{
		cli.StringFlag{
			Name:  "o, output",
			Usage: "REQUIRED: Path to write mbtiles to",
		},
		cli.StringFlag{
			Name:  "input-type",
			Value: "sniff",
			Usage: "Type of input files, 'sniff' will pick type based on the extension",
		},
		cli.BoolFlag{
			Name:  "f, force",
			Usage: "Remove the existing .mbtiles file before running.",
		},
		cli.BoolFlag{
			Name:  "u, upsert",
			Usage: "Upsert into mbtiles instead of replacing.",
		},
		cli.StringFlag{
			Name:  "layer-name",
			Value: "features",
			Usage: "Name of the layer for the features to be added to",
		},
		cli.StringFlag{
			Name:  "desc, description",
			Value: "Generated from Diglet",
			Usage: "Value inserted into the description entry of the mbtiles",
		},
		cli.IntFlag{
			Name:  "extent",
			Value: 4096,
			Usage: "Extent of tiles to be built. Default is 4096",
		},
		cli.IntFlag{
			Name:  "max, max-zoom",
			Value: 10,
			Usage: "Maximum zoom level to build tiles for",
		},
		cli.IntFlag{
			Name:  "min, min-zoom",
			Value: 5,
			Usage: "Minimum zoom level to build tiles from",
		},
		cli.StringFlag{
			Name: "filter",
			Usage: "Only include fields keys in this comma delimited list.\t" +
				"EXAMPLE --filter name,date,case_number,id\t" +
				"NOTE all fields are lowercased and non-word chars replaced with '_'",
		},
		cli.StringFlag{
			Name:  "csv-lat",
			Usage: "Column containing a single longitude point",
		},
		cli.StringFlag{
			Name:  "csv-lon",
			Usage: "Column containing a single longitude point",
		},
		cli.StringFlag{
			Name: "csv-shape",
			Usage: "Column containing shape in geojson-like 'coordinates' form.\t" +
				"Does not support multi-geometries",
		},
		cli.StringFlag{
			Name:  "csv-delimiter",
			Value: ",",
		},
	},
}

Functions

func FeatureTiles

func FeatureTiles(f *geo.Feature, zoom int) (tiles []tiles.Tile)

FeatureTiles returns a list of tiles that cover the feature at the given zoom level Dups are not checked for, so they can exist

func MvtAdapter

func MvtAdapter(f *geo.Feature, t tiles.Tile) (a *mvt.Feature)

MvtAdapter populates an mvt feature from a diglet geo feature

func ShapeTiles

func ShapeTiles(shp *geo.Shape, zoom int) (tiles []tiles.Tile)

Shape tiles returns a list of tiles that cover a shape at the given zoom level

Types

type CsvSource

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

func NewCsvSource

func NewCsvSource(path string, filter []string, delimiter string, fields GeoFields) *CsvSource

func (*CsvSource) Publish

func (c *CsvSource) Publish() (features chan *geo.Feature, err error)

type FeatureSource

type FeatureSource interface {
	Publish() (chan *geo.Feature, error)
}

type GeoFields

type GeoFields map[string]string

func (GeoFields) HasCoordinates

func (g GeoFields) HasCoordinates() bool

func (GeoFields) HasShape

func (g GeoFields) HasShape() bool

func (GeoFields) Validate

func (g GeoFields) Validate() bool

type GeojsonSource

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

func NewGeojsonSource

func NewGeojsonSource(path string, filter []string) *GeojsonSource

func (*GeojsonSource) Publish

func (gj *GeojsonSource) Publish() (features chan *geo.Feature, err error)

type Tileset

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

func InitTiles

func InitTiles(mbtpath string, upsert bool, desc string, extent int) (t Tileset, err error)

func (Tileset) Build

func (t Tileset) Build(source FeatureSource, layerName string, zmin, zmax int) (err error)

Directories

Path Synopsis
mvt
vector_tile
Package vector_tile provides the go code needed to read and write Mapbox vector tiles (https://github.com/mapbox/vector-tile-spec).
Package vector_tile provides the go code needed to read and write Mapbox vector tiles (https://github.com/mapbox/vector-tile-spec).

Jump to

Keyboard shortcuts

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