image

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: BSD-3-Clause Imports: 9 Imported by: 8

README

go-whosonfirst-image

Use go-whosonfirst-svg and oksvg to render Who's On First features as raster images.

Example

import (
	"github.com/whosonfirst/go-whosonfirst-image"
	"image/png"
	"io"
	"os"
)

func main() {

     	path := "/path/to/feature.geojson"

	r, _ := os.Open(path)
	defer r.Close()
	
	body, err := io.ReadAll(r)

	opts := image.NewDefaultOptions()
	img, _ := image.FeatureToImage(body, opts)

	png.Encode(opts.Writer, img)
}

Error handling removed for brevity.

Tools

wof-feature-to-png
./bin/wof-feature-to-png /usr/local/data/whosonfirst-data-constituency-us/data/110/874/663/7/1108746637.geojson > 1108746637.png

Would produce:

As in: https://spelunker.whosonfirst.org/id/1108746637/

See also

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FeatureToImage

func FeatureToImage(f []byte, opts *Options) (image.Image, error)

func FeatureToPNG

func FeatureToPNG(f []byte, opts *Options) error

Types

type Options

type Options struct {
	Width         int
	Height        int
	Writer        io.Writer
	StyleFunction svg.StyleFunction
}

func NewDefaultOptions

func NewDefaultOptions() *Options

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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