staticmap

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

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

Go to latest
Published: Mar 23, 2017 License: BSD-3-Clause Imports: 11 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-whosonfirst-staticmap

Go package for rendering static maps of Who's On First places.

Install

You will need to have both Go and the make programs installed on your computer. Assuming you do just type:

make bin

All of this package's dependencies are bundled with the code in the vendor directory.

Example

Note that all error handling has been removed for the sake of brevity.

import (
	"fmt"
	"github.com/whosonfirst/go-whosonfirst-staticmap"
	"image/png"		
	"log"
)

func main() {

	wofid := 85688637
	png := fmt.Sprintf("%d.png", wofid)
	
	sm, _ := staticmap.NewStaticMap(wofid)
	im, _ := sm.Render()

	fh, _ := os.Create(png)
	defer fh.Close()

	png.Encode(file, im)
}

Tools

wof-staticmap

Render a static map for a Who's On First ID from the command line.

./bin/wof-staticmap -h
Usage of ./bin/wof-staticmap:
  -data-root string
    	Where to look for Who's On First source data. (default "https://whosonfirst.mapzen.com/data")
  -height int
    	The height in pixels of your new map. (default 480)
  -id int
    	A valid Who's On First to render.
  -save-as string
    	Save the map to this path. If empty then the map will saved as {WOFID}.png.
  -width int
    	The width in pixels of your new map. (default 640)
wof-staticmapd

Render a static map for a Who's On First ID from an HTTP pony, optionally caching the result in S3.

./bin/wof-staticmapd -h
Usage of ./bin/wof-staticmapd:
  -cache
    	Cache rendered maps
  -cache-provider string
    	A valid cache provider. Valid options are: s3 (default "s3")
  -data-root string
    	Where to look for Who's On First source data. (default "https://whosonfirst.mapzen.com/data")
  -gracehttp.log
    	Enable logging. (default true)
  -height int
    	The default height in pixels for rendered maps. (default 480)
  -host string
    	The hostname to listen for requests on (default "localhost")
  -port int
    	The port number to listen for requests on (default 8080)
  -s3-bucket string
    	A valid S3 bucket where cached files are stored. (default "whosonfirst.mapzen.com")
  -s3-credentials string
    	A string descriptor for your AWS credentials. Valid options are: env:;shared:PATH_TO_SHARED_CREDENTIALS_FILE:SHARED_CREDENTIALS_PROFILE; iam: (default "shared:/Users/asc/.aws/credentials:default")
  -s3-prefix string
    	An optional subdirectory (prefix) where cached files are stored in S3. (default "static")
  -s3-region string
    	A valid AWS S3 region (default "us-east-1")
  -size value
    	Zero or more custom {LABEL}={WIDTH}x{HEIGHT} parameters.
  -width int
    	The default width in pixels for rendered maps. (default 640)

Examples

Default sizes
./bin/wof-staticmapd 
curl http://127.0.0.1:8080/?id=1108794405

Custom sizes
./bin/wof-staticmapd -size sq=100x100
curl http://127.0.0.1:8080/?id=1108794405&size=sq

Cached maps
./bin/wof-staticmapd -cache -cache-provider s3 -s3-prefix static -size example=300x300
curl http://127.0.0.1:8080/?id=85922227&size=example
curl http://whosonfirst.mapzen.com.s3.amazonaws.com/static/859/222/27/85922227-example.png

Caveats

Interior rings

This package does not do the right thing when rendering interior rings. Not even a little bit...

See also

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StaticMap

type StaticMap struct {
	DataRoot     string
	TileProvider string
	Fill         string
	Width        int
	Height       int
	// contains filtered or unexported fields
}

func NewStaticMap

func NewStaticMap(wofid int64) (*StaticMap, error)

func (*StaticMap) Fetch

func (s *StaticMap) Fetch() ([]byte, error)

func (*StaticMap) Render

func (s *StaticMap) Render() (image.Image, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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