geojson2svg

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MIT Imports: 9 Imported by: 0

README

geojson2svg

Build Status

geojson2svg is a package to draw svg's from geojson data. Under the hood it uses https://github.com/paulmach/go.geojson to parse the geojson strings to Go structs.

example image

Installation

go get github.com/fapian/geojson2svg/pkg/geojson2svg

Examples

See the tests for usage examples.

Documentation

Documentation can be found here

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 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 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 {
	// 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 New

func New() *SVG

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

func (*SVG) AddFeature

func (svg *SVG) AddFeature(f *geojson.Feature) error

AddFeature adds a geojson feature to the svg.

func (*SVG) AddFeatureCollection

func (svg *SVG) AddFeatureCollection(fc *geojson.FeatureCollection) error

AddFeatureCollection adds a geojson featurecollection to the svg.

func (*SVG) AddFeatureCollectionString

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

AddFeatureCollection adds a geojson featurecollection to the svg.

func (*SVG) AddFeatureString

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

AddFeature adds a geojson feature to the svg.

func (*SVG) AddGeometry

func (svg *SVG) AddGeometry(g *geojson.Geometry) error

AddGeometry adds a geojson geometry to the svg.

func (*SVG) AddGeometryString

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

AddGeometry adds a geojson geometry to the svg.

func (*SVG) Draw

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

Draw renders the final SVG with the given options to a string. All coordinates will be scaled to fit into the svg.

Jump to

Keyboard shortcuts

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