mbt

package
v0.0.10-a Latest Latest
Warning

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

Go to latest
Published: May 3, 2016 License: MIT Imports: 20 Imported by: 0

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 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 := uint(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: ",",
		},
	},
}
View Source
var CoverZoom = 18

CoverZoom sets the zoom level for flat coverings This is a global b/c it could go away if a dynamic cover is implemented

Functions

func FeatureTiles

func FeatureTiles(f *geo.Feature) (tiles []ts.Tile)

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

func MvtAdapter

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

MvtAdapter populates an mvt feature from a diglet geo feature

func ShapeTiles

func ShapeTiles(shp *geo.Shape) (tiles []ts.Tile)

Shape tiles returns a list of tiles that cover a shape at CoverZoom 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(workers int) (features chan *geo.Feature, err error)

type FeatureSource

type FeatureSource interface {
	Publish(workers int) (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(workers int) (features chan *geo.Feature, err error)

type Tiles

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

func InitTiles

func InitTiles(mbtpath string, upsert bool, desc string, extent uint) (tiles Tiles, err error)

func (Tiles) Build

func (t Tiles) 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