geojson2svg

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

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

Go to latest
Published: Apr 15, 2021 License: MIT Imports: 11 Imported by: 1

README

geojson2svg

Work in progress. This is a fork of whosonfirst/go-geojson-svg, which is itself a fork of fapian/geojson2svg (with some extent functionality added).

This library rely on paulmach/go.geojson for GeoJSON decoding at the moment. At some point I may update it to either paulmach/orb or preferably twpayne/go-geom.

Documentation

Overview

Package geojson2svg provides the SVG type to convert geojson geometries, features and featurecollections into a SVG image.

See the tests for usage examples.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Extent

type Extent struct{ MinX, MinY, MaxX, MaxY float64 }

type Option

type Option func(*SVG)

An Option represents a single SVG option.

func UseProperties

func UseProperties(props []string) Option

UseProperties configures which geojson properties should be copied to the resulting SVG element.

func WithAttribute

func WithAttribute(k, v string) Option

WithAttribute adds the key value pair as attribute to the resulting SVG root element.

func WithAttributes

func WithAttributes(as map[string]string) Option

WithAttributes adds the map of key value pairs as attributes to the resulting SVG root element.

func WithExtent

func WithExtent(e *Extent) Option

WithExtent configures the SVG to use the specified extent.

func WithMercator

func WithMercator(m bool) Option

WithMercator configures the SVG to use the Mercator projection.

func WithPadding

func WithPadding(p Padding) Option

WithPadding configures the SVG to use the specified padding.

type Padding

type Padding struct{ Top, Right, Bottom, Left float64 }

Padding represents the possible padding of the SVG.

type SVG

type SVG struct {
	Mercator bool
	Extent   *Extent
	Debug    bool
	// contains filtered or unexported fields
}

SVG represents the SVG that should be created. Use the New function to create a SVG. New will handle the defaualt values.

default padding (top: 0, right: 0, bottom: 0, left: 0)

default properties (class)

default attributes ()

func NewSVG

func NewSVG() *SVG

NewSVG returns a new SVG that can be used to to draw geojson geometries, features and featurecollections.

func (*SVG) AddFeature

func (svg *SVG) AddFeature(fs string) error

AddFeature adds a geojson feature to the svg.

func (*SVG) AddFeatureCollection

func (svg *SVG) AddFeatureCollection(fcs string) error

AddFeatureCollection adds a geojson featurecollection to the svg.

func (*SVG) AddGeometry

func (svg *SVG) AddGeometry(gs string) error

AddGeometry adds a geojson geometry to the svg.

func (*SVG) Draw

func (svg *SVG) Draw(width, height float64, opts ...Option) string

Jump to

Keyboard shortcuts

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