gokml_gx

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

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

Go to latest
Published: Oct 5, 2016 License: MIT Imports: 5 Imported by: 0

README

GoKML GX

A KML library with Google Extensions (http://www.google.com/kml/ext/2.2), that besides being able to encode/decode to XML.

This library is based on the good work done by dahenson

Overview

Go KML GX was written to be able to read Google My Tracks data. Google My Tracks uses Google's KML extensions in it's documents. This implementation has a focus on the extension elements that is used by My Tracks.

This library can also take in or produce a KMZ (zipped KML) file in. It can unzip the KMZ file and produce a set of Go structs from the KML file inside the archive, or in reverse create a KMZ file.

Status

This is currently a work in progress. Not all parts of Google's KML extensions are implemented, and not all of My Tracks elements are implemented.

Documentation

Overview

A KML library with Google KML extensions

Index

Constants

View Source
const (
	DefaultNamespace = "http://www.opengis.net/kml/2.2"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomAuthor

type AtomAuthor struct {
	XMLName xml.Name `xml:"http://www.w3.org/2005/Atom author"`
	Name    string   `xml:"name,omitempty"`
}

* Container type Atom Author

func NewAtomAuthor

func NewAtomAuthor(name string) AtomAuthor

NewAtomAuthor() creates a new atom authro

type Color

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

func NewColorHSLA

func NewColorHSLA(h, s, l, a float64) *Color

func NewColorRGBA

func NewColorRGBA(r, g, b, a float64) *Color

func (*Color) Code

func (c *Color) Code() string

func (*Color) Marshal

func (c *Color) Marshal() ([]byte, error)

type Data

type Data struct {
	XMLName xml.Name `xml:"Data"`
	Name    string   `xml:"name,attr"`
	Value   string   `xml:"value"`
}

Data that goes in ExtendedData

type Document

type Document struct {
	XMLName     xml.Name    `xml:"Document"`
	Id          string      `xml:"id,attr,omitempty"`
	Name        string      `xml:"name,omitempty"`
	Visibility  int         `xml:"visibility,omitempty"`
	Open        int         `xml:"open,omitempty"`
	AtomAuthor  AtomAuthor  `xml:"http://www.w3.org/2005/Atom author,omitempty"`
	Address     string      `xml:"address,omitempty"`
	PhoneNumber string      `xml:"phoneNumber,omitempty"`
	Description string      `xml:"description,omitempty"`
	Schema      []Schema    `xml:"Schema"`
	DocStyle    []Style     `xml:"Style"`
	Placemarks  []Placemark `xml:"Placemark"`
	Folders     []Folder    `xml:"Folder"`
	Elements    []interface{}
}

* Container type Document

func NewDocument

func NewDocument(id, name string) Document

NewDocument() creates a new document

func (*Document) AddElement

func (d *Document) AddElement(e Element)

AddElement() adds a path to the document

func (*Document) AddFolder

func (d *Document) AddFolder(f Folder)

AddFolder() adds a folder to the document

func (*Document) AddPlacemark

func (d *Document) AddPlacemark(p Placemark)

AddPlacemark() adds a placemark to the document

func (*Document) AddSchema

func (d *Document) AddSchema(s Schema)

AddSchema() adds a schema to the document

func (*Document) AddStyle

func (d *Document) AddStyle(s Style)

AddStyle() adds a style to the document

func (*Document) Marshal

func (d *Document) Marshal() ([]byte, error)

Document.Marshal() returns the marshalled xml structure

type Element

type Element interface {
	Marshal() ([]byte, error)
}

type ExtendedData

type ExtendedData struct {
	XMLName xml.Name `xml:"ExtendedData"`
	Datas   []Data   `xml:"Data"`
}

ExtendedData for placemarks

func NewExtendedData

func NewExtendedData() ExtendedData

NewExtendedData() creates new extended data

func (*ExtendedData) AddData

func (e *ExtendedData) AddData(name, value string)

AddData() adds data of {name, value} to the ExtendedData structure

type Folder

type Folder struct {
	XMLName     xml.Name    `xml:"Folder"`
	Id          string      `xml:"id,attr,omitempty"`
	Name        string      `xml:"name,omitempty"`
	Visibility  int         `xml:"visibility,omitempty"`
	Open        int         `xml:"open,omitempty"`
	Address     string      `xml:"address,omitempty"`
	PhoneNumber string      `xml:"phoneNumber,omitempty"`
	Description string      `xml:"description,omitempty"`
	Placemarks  []Placemark `xml:"Placemark"`
	Folders     []Folder    `xml:"Folder"`
	Elements    []interface{}
}

* Container type Folder

func NewFolder

func NewFolder(id, name string) Folder

NewFolder() creates a new folder

func (*Folder) AddElement

func (f *Folder) AddElement(e interface{})

AddElement() adds a path to the document

func (*Folder) AddFolder

func (d *Folder) AddFolder(f Folder)

AddFolder() adds a sub folder to this folder

func (*Folder) AddPlacemark

func (f *Folder) AddPlacemark(p Placemark)

AddPlacemark() adds a placemark to the folder

func (*Folder) SetVisibility

func (f *Folder) SetVisibility(visibility bool)

SetVisibility() sets the visibility of the folder

type GxSimpleArrayField

type GxSimpleArrayField struct {
	XMLName     xml.Name `xml:"http://www.google.com/kml/ext/2.2 SimpleArrayField"`
	Name        string   `xml:"name,attr,omitempty"`
	Type        string   `xml:"type,attr,omitempty"`
	DisplayName string   `xml:"displayName,omitempty"`
}

type IconStyle

type IconStyle struct {
	XMLName xml.Name `xml:"IconStyle"`
	Scale   string   `xml:"scale,omitempty"`
	Heading string   `xml:"heading,omitempty"`
	Href    string   `xml:"Icon>href,omitempty"`
}

IconStyle

func NewIconStyle

func NewIconStyle(scale, heading, href string) IconStyle

type Kml

type Kml struct {
	XMLName    xml.Name    `xml:"kml"`
	Namespace  string      `xml:"xmlns,attr"`
	Document   Document    `xml:"Document"`
	Placemarks []Placemark `xml:"Placemark"`
	Folders    []Folder    `xml:"Folder"`
	Elements   []Element
}

Kml is the base Kml document

func JsonUnmarshal

func JsonUnmarshal(doc []byte) (Kml, error)

JSON Unmarshal() returns a kml struct unmarshalled from the provided byte array

func NewKml

func NewKml(namespace string) Kml

NewKml() creates a new Kml structure with the specified namespace

func Unmarshal

func Unmarshal(doc []byte) (Kml, error)

Unmarshal() returns a kml struct unmarshalled from the provided byte array

func (*Kml) AddDocument

func (k *Kml) AddDocument(d Document)

AddDocument() adds a document to the kml structure

func (*Kml) AddElement

func (k *Kml) AddElement(e Element)

AddElement() adds a path to the document

func (*Kml) AddFolder

func (k *Kml) AddFolder(p Folder)

AddFolder() adds a folder to the document

func (*Kml) AddPlacemark

func (k *Kml) AddPlacemark(p Placemark)

AddPlacemark() adds a placemark to the document

func (*Kml) JsonMarshal

func (k *Kml) JsonMarshal() ([]byte, error)

JSON Marshal() returns a properly indented XML structure

func (*Kml) Marshal

func (k *Kml) Marshal() ([]byte, error)

Marshal() returns a properly indented XML structure

type LineStyle

type LineStyle struct {
	XMLName xml.Name `xml:"LineStyle"`
	Color   string   `xml:"color,omitempty"`
	Width   string   `xml:"width,omitempty"`
}

LineStyle

func NewLineStyle

func NewLineStyle(color, width string) LineStyle

type Path

type Path struct {
	XMLName     xml.Name     `xml:"Placemark"`
	Id          string       `xml:"id,attr,omitempty"`
	Name        string       `xml:"name,omitempty"`
	Description string       `xml:"description,omitempty"`
	StyleUrl    string       `xml:"styleUrl,omitempty"`
	Coordinates string       `xml:"LineString>coordinates"`
	Extended    ExtendedData `xml:"ExtendedData"`
	Style       Style        `xml:",omitempty"`
	TimeStamp   string       `xml:"TimeStamp,omitempty"`
}

* Path

func NewPath

func NewPath(id, name, desc, lat, lon, alt, styleurl string) Path

NewPath() creates a new Path. All parameters are strings.

func (*Path) AddCoordinates

func (p *Path) AddCoordinates(lat, lon, alt string)

AddCoordinates takes latitude, longitude, and altitude and adds the Coordinate value to the path

func (*Path) AddExtendedData

func (p *Path) AddExtendedData(e ExtendedData)

AddExtendedData() adds an ExtendedData structure to the Path

func (*Path) Marshal

func (p *Path) Marshal() ([]byte, error)

Path.Marshal()

func (*Path) SetCoordinates

func (p *Path) SetCoordinates(lat, lon, alt string)

SetCoordinates takes latitude, longitude, and altitude and sets the Coordinates value of the Path.

type Placemark

type Placemark struct {
	XMLName     xml.Name     `xml:"Placemark"`
	Id          string       `xml:"id,attr,omitempty"`
	Name        string       `xml:"name,omitempty"`
	Description string       `xml:"description,omitempty"`
	StyleUrl    string       `xml:"styleUrl,omitempty"`
	Coordinates string       `xml:"Point>coordinates"`
	Extended    ExtendedData `xml:"ExtendedData"`
}

* Placemark

func NewPlacemark

func NewPlacemark(id, name, desc, lat, lon, alt, styleurl string) Placemark

NewPlacemark() creates a new placemark. All parameters are strings.

func (*Placemark) AddExtendedData

func (p *Placemark) AddExtendedData(e ExtendedData)

AddExtendedData() adds an ExtendedData structure to the Placemark

func (*Placemark) Marshal

func (p *Placemark) Marshal() ([]byte, error)

Placemark.Marshal()

func (*Placemark) SetCoordinates

func (p *Placemark) SetCoordinates(lat, lon, alt string)

SetCoordinates takes latitude, longitude, and altitude and sets the Coordinates value of the Placemark.

type Schema

type Schema struct {
	XMLName xml.Name `xml:"Schema"`
	Id      string   `xml:"id,attr,omitempty"`
	Name    string   `xml:"name,attr,omitempty"`
}

func NewSchema

func NewSchema(id, name string) Schema

type Style

type Style struct {
	XMLName xml.Name  `xml:"Style"`
	Id      string    `xml:"id,attr,omitempty"`
	Line    LineStyle `xml:"LineStyle"`
	Icon    IconStyle `xml:"IconStyle"`
}

Style for features

func NewStyle

func NewStyle(id string) Style

func (*Style) AddIconStyle

func (s *Style) AddIconStyle(is IconStyle)

func (*Style) AddLineStyle

func (s *Style) AddLineStyle(ls LineStyle)

Jump to

Keyboard shortcuts

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