osm

package
v0.0.0-...-0ae72cd Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2018 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

+build !js

+build !js

+build !js

Index

Constants

This section is empty.

Variables

View Source
var SUPPORTED_SCHEMES = []string{
	"file",
	"http",
	"https",
	"s3",
	"hdfs",
}

Functions

func AddToChannel

func AddToChannel(ch chan interface{}, values interface{})

func EvaluateExpression

func EvaluateExpression(ctx map[string]interface{}, root dfl.Node, funcs *dfl.FunctionMap, dfl_attributes []string, dfl_cache *dfl.Cache) (bool, error)

EvaluateExpression evaluates a DFL expression against a dfl.Context ctx. If the parameter dfl_cache is not nil, then checks the cache with the input for previous result. If the cache does not contain the result, then save the result to the cache. Returns the boolean result of the expression, and an error if any.

func KeepNode

func KeepNode(planet *Planet, fi *Filter, n *Node, dfl_cache *dfl.Cache) (bool, error)

func KeepRelation

func KeepRelation(planet *Planet, fi *Filter, r *Relation, dfl_cache *dfl.Cache) (bool, error)

func KeepWay

func KeepWay(planet *Planet, fi *Filter, w *Way, dfl_cache *dfl.Cache) (bool, error)

func LoadIniSection

func LoadIniSection(uri string, section string, keys []string) (map[string]string, error)

func MapToSlice

func MapToSlice(m map[string]interface{}, keys []string) []string

func MarshalNode

func MarshalNode(encoder *xml.Encoder, planet *Planet, output_config *Output, n *Node) error

func MarshalPlanet

func MarshalPlanet(output *Output, config *Config, planet *Planet) error

func MarshalWay

func MarshalWay(encoder *xml.Encoder, planet *Planet, output_config *Output, w *Way) error

func NodeToFeature

func NodeToFeature(n *Node, tc *TagsCache) graph.Feature

NodeToFeature converts a Node to a graph.Feature, which searilizes to GeoJSON.

func ParseBool

func ParseBool(in string) bool

func ParsePath

func ParsePath(path string) (string, string, error)

ParsePath splits a path into a top directory and child path Returns the top directory and child path, or an error if any.

func ParseSliceFloat64

func ParseSliceFloat64(in string) ([]float64, error)

func ParseSliceString

func ParseSliceString(in string) []string

func RenderTemplate

func RenderTemplate(template_text string, ctx map[string]interface{}) (string, error)

func SearchInt64s

func SearchInt64s(a []int64, x int64) int

SearchInt64s searches slice "a" for the value "x" and returns the index. The index may be a false positive, so it is important to check the target value at the returned index.

func SearchUInt64s

func SearchUInt64s(a []uint64, x uint64) int

SearchUInt64s searches slice "a" for the value "x" and returns the index. The index may be a false positive, so it is important to check the target value at the returned index.

func SplitUri

func SplitUri(uri string, schemes []string) (string, string)

SplitUri splits a uri string and returns the scheme and path. If no scheme is specified, then returns scheme "file" and the input uri as the path.

func StringifyMapKeys

func StringifyMapKeys(in interface{}) interface{}

https://github.com/gohugoio/hugo/pull/4138

func UnmarshalNode

func UnmarshalNode(decoder *xml.Decoder, e xml.StartElement, input *Input) (*Node, uint64, string, []Tag, error)

UnmarshalNode unmarshals a node from an XML element. Returns the Node, the tags as a separate slice, and an error if any. For example:

<node id="4580586204" lat="38.949900" lon="-77.080715" timestamp="2016-12-30T03:51:18Z">
  <tag k="name" v="District Taco"></tag>
  <tag k="amenity" v="restaurant"></tag>
  <tag k="addr:city" v="Washington"></tag>
  <tag k="addr:state" v="DC"></tag>
</node>

func UnmarshalPlanet

func UnmarshalPlanet(p *Planet, input *Input, logger *compositelogger.CompositeLogger) error

UnmarshalPlanet reads an OSM Planet File from an io.Reader and unmarshals the data into the *Planet object. Returns an error if any.

func UnmarshalRelation

func UnmarshalRelation(decoder *xml.Decoder, e xml.StartElement, input *Input) (*Relation, uint64, string, []Tag, error)

UnmarshalRelation unmarhals a relation from an XML stream Returns the unmarshalled relation, and an error if any.

func UnmarshalWay

func UnmarshalWay(decoder *xml.Decoder, e xml.StartElement, input *Input) (*Way, uint64, string, []Tag, error)

UnmarshalWay unmarshals a Way from an XML stream. Returns the way's tags as a separate slice, so they can be cached

func WaitThenClose

func WaitThenClose(wg *sync.WaitGroup, c chan<- string)

Types

type Bounds

type Bounds struct {
	MinimumLongitude float64 `xml:"minlon,attr"`
	MinimumLatitude  float64 `xml:"minlat,attr"`
	MaximumLongitude float64 `xml:"maxlon,attr"`
	MaximumLatitude  float64 `xml:"maxlat,attr"`
}

func NewBounds

func NewBounds(minlon float64, minlat float64, maxlon float64, maxlat float64) *Bounds

func UnmarshalBounds

func UnmarshalBounds(decoder *xml.Decoder, e xml.StartElement) (Bounds, error)

UnmarshalBounds unmarshals a bounds XML element. For example:

<bounds minlon="-77.120100" minlat="38.791340" maxlon="-76.909060" maxlat="38.996030"></bounds>

func (Bounds) BoundingBox

func (b Bounds) BoundingBox() string

func (Bounds) ContainsPoint

func (b Bounds) ContainsPoint(lon float64, lat float64) bool

type Config

type Config struct {
	Globals               Globals        `hcl:"globals,omitempty"`
	InputConfigs          []InputConfig  `hcl:"inputs,omitempty"`
	OutputConfigs         []OutputConfig `hcl:"outputs,omitempty"`
	Inputs                []*Input       `hcl:"-"`
	Outputs               []*Output      `hcl:"-"`
	DropAllNodes          bool           `hcl:"-"`
	DropAllWays           bool           `hcl:"-"`
	DropAllRelations      bool           `hcl:"-"`
	ConvertAllWaysToNodes bool           `hcl:"-"`
	DropAllVersions       bool           `hcl:"-"`
	DropAllTimestamps     bool           `hcl:"-"`
	DropAllChangesets     bool           `hcl:"-"`
	DropAllUserIds        bool           `hcl:"-"`
	DropAllUserNames      bool           `hcl:"-"`
	OutputKeysToKeep      StringSet      `hcl:"-"` //
	OutputKeysToDrop      StringSet      `hcl:"-"` //
}

func LoadConfig

func LoadConfig(uri string) (*Config, error)

func (*Config) GetNameNodes

func (c *Config) GetNameNodes() []string

func (*Config) HasDrop

func (c *Config) HasDrop() bool

HasDrop returns true if you'll be dropping anything during input

func (*Config) HasResourceType

func (c *Config) HasResourceType(t string) bool

func (*Config) Init

func (c *Config) Init(ctx map[string]interface{}, funcs *dfl.FunctionMap) error

func (*Config) Validate

func (c *Config) Validate() error

type Element

type Element struct {
	Id        uint64     `xml:"id,attr" parquet:"name=id, type=UINT_64"`                                // The planet-wide unique (literally) id of the element.
	Version   uint16     `xml:"version,attr,omitempty" parquet:"name=version type=UINT_16"`             // The version of this element.  Every modification increments this counter.
	Timestamp *time.Time `xml:"timestamp,attr,omitempty" parquet:"name=timestamp type=TimestampMicros"` // The timestamp of when this element was created or last modified.
	Changeset uint64     `xml:"changeset,attr,omitempty" parquet:"name=changest type=UINT_64"`          // The ID of the changeset that created or modified this element.
	UserId    uint64     `xml:"uid,attr,omitempty" parquet:"name=uid, type=UINT_64"`                    // The id of the user that created or last modified this element.
	UserName  string     `xml:"user,attr,omitempty"`                                                    // The name of the user that created or last modified this element.
}

Element is the base abstract element that Nodes, Ways, and Relations extend.

func (*Element) DropAttributes

func (e *Element) DropAttributes(pr *PlanetResource)

func (*Element) DropChangeset

func (e *Element) DropChangeset()

DropChangeset sets the Changeset Id to 0

func (*Element) DropTimestamp

func (e *Element) DropTimestamp()

DropTimestamp sets the timestamp to nil

func (*Element) DropUserId

func (e *Element) DropUserId()

DropUserId sets the UserId to 0

func (*Element) DropUserName

func (e *Element) DropUserName()

DropUserName sets the UserName to ""

func (*Element) DropVersion

func (e *Element) DropVersion()

DropVersion sets the version to 0

func (*Element) GetId

func (e *Element) GetId() uint64

GetId returns the element's ID as an int64

type Filter

type Filter struct {
	KeysToKeep     []string         `hcl:"keys_keep"`
	KeysToDrop     []string         `hcl:"keys_drop"`
	ExpressionText string           `hcl:"expression"`
	Expression     dfl.Node         `hcl:"-"`
	Functions      *dfl.FunctionMap `hcl:"-"`
	Attributes     []string         `hcl:"-"`
	UseCache       bool             `hcl:"use_cache"`
	BoundingBox    []float64        `hcl:"bbox"`
	MaxExtent      *Bounds          `hcl:"-"`
}

func NewFilter

func NewFilter(keysToKeep []string, keysToDrop []string, exp string, useCache bool, bbox []float64) *Filter

func (Filter) ContainsPoint

func (fi Filter) ContainsPoint(lon float64, lat float64) bool

func (Filter) HasExpression

func (fi Filter) HasExpression() bool

func (Filter) HasKeysToDrop

func (fi Filter) HasKeysToDrop() bool

func (Filter) HasKeysToKeep

func (fi Filter) HasKeysToKeep() bool

func (Filter) HasMaxExtent

func (fi Filter) HasMaxExtent() bool

func (*Filter) Init

func (f *Filter) Init(globals map[string]interface{}, funcs *dfl.FunctionMap) error

type FilteredResource

type FilteredResource struct {
	*Resource
	Filter *Filter `hcl:"filter"` // filter input
}

func (*FilteredResource) Init

func (fr *FilteredResource) Init(globals map[string]interface{}, ctx map[string]interface{}, funcs *dfl.FunctionMap) error

type Globals

type Globals struct {
	Input  map[string]interface{} `hcl:"input,omitempty"`  // input global config
	Output map[string]interface{} `hcl:"output,omitempty"` // output global config
}

type Input

type Input struct {
	*PlanetResource `hcl:"resource"`
	Reader          reader.ByteReadCloser `hcl:"-"`
}

Input is a struct for holding all the configuration describing an input destination

func (*Input) Close

func (i *Input) Close() error

func (*Input) Init

func (i *Input) Init(globals map[string]interface{}, ctx map[string]interface{}, funcs *dfl.FunctionMap) error

func (*Input) Open

func (i *Input) Open(read_buffer_size int, s3_client *s3.S3, hdfs_clients map[string]*hdfs.Client) error

func (*Input) OpenFile

func (i *Input) OpenFile(read_buffer_size int) error

func (*Input) OpenFileOnHDFS

func (i *Input) OpenFileOnHDFS(hdfs_client *hdfs.Client, read_buffer_size int) error

func (*Input) OpenS3Object

func (i *Input) OpenS3Object(s3_client *s3.S3) error

func (*Input) OpenWeb

func (i *Input) OpenWeb() error

type InputConfig

type InputConfig struct {
	Uri           string   `hcl:"uri"`            // resource URI
	DropNodes     bool     `hcl:"drop_nodes"`     //drop nodes
	DropWays      bool     `hcl:"drop_ways"`      // drop ways
	DropRelations bool     `hcl:"drop_relations"` // drop relations
	DropVersion   bool     `hcl:"drop_version"`   // drop version numbers
	DropChangeset bool     `hcl:"drop_changeset"` // drop changeset id
	DropTimestamp bool     `hcl:"drop_timestamp"` // drop last modified timestamp
	DropUserId    bool     `hcl:"drop_user_id"`   // drop the id of the user that last modified an element
	DropUserName  bool     `hcl:"drop_user_name"` // drop the name of the user that last modified an element
	KeysToKeep    []string `hcl:"keep_keys"`      // slice of keys to keep from read elements.  This is not a filter.
	KeysToDrop    []string `hcl:"drop_keys"`      // slice of keys to drop from read elements.  This is not a filter.
	//WaysToNodes   bool     `hcl:"ways_to_nodes"`  // convert ways into nodes
	Filter *Filter `hcl:"filter"` // filter input
}

func NewInputConfig

func NewInputConfig(uri string, drop_nodes bool, drop_ways bool, drop_relations bool, filter *Filter) InputConfig

func NewInputConfig(uri string, drop_nodes bool, drop_ways bool, drop_relations bool, ways_to_nodes bool, filter *Filter) InputConfig {

type Int64Set

type Int64Set map[int64]struct{}

Int64Set is a logical set of int64 values using a map[int64]struct{} backend. The use of a int64 -> empty struct backend provides a higher write performance versus a slice backend.

func NewInt64Set

func NewInt64Set() Int64Set

NewInt64Set returns a new Int64Set.

func (Int64Set) Add

func (set Int64Set) Add(x int64)

Add adds parameter x to the set.

func (Int64Set) Slice

func (set Int64Set) Slice(sorted bool) Int64Slice

Slice returns a slice representation of this set. If parameter sorted is true, then sorts the values using natural sort order.

type Int64Slice

type Int64Slice []int64

Int64Slice is a type alias for a slice of int64.

func NewInt64Slice

func NewInt64Slice(length int, capacity int) Int64Slice

NewInt64Slice returns a new Int64Slice with length and capacity given as parameters.

func (Int64Slice) Contains

func (p Int64Slice) Contains(x int64) bool

func (Int64Slice) Len

func (p Int64Slice) Len() int

func (Int64Slice) Less

func (p Int64Slice) Less(i, j int) bool

func (Int64Slice) Search

func (p Int64Slice) Search(x int64) int

func (Int64Slice) Sort

func (p Int64Slice) Sort()

func (Int64Slice) Swap

func (p Int64Slice) Swap(i, j int)

type Node

type Node struct {
	TaggedElement
	Longitude float64 `xml:"lon,attr" parquet:"name=lon, type=DOUBLE"`
	Latitude  float64 `xml:"lat,attr" parquet:"name=lat, type=DOUBLE"`
}

func NewNode

func NewNode() *Node

func (Node) Bounds

func (n Node) Bounds() *rtreego.Rect

func (Node) Tile

func (n Node) Tile(z int) []int

type NodeReference

type NodeReference struct {
	Reference uint64 `xml:"ref,attr" parquet:"ref, type=UINT_64"`
}

type Output

type Output struct {
	*PlanetResource
	WaysToNodes bool `hcl:"ways_to_nodes"` // convert ways into nodes
	Pretty      bool `hcl:"pretty"`        // write pretty output (newlines and tabs for .osm XML)
}

Output is a struct for holding all the configuration describing an output destination

func (Output) HasDrop

func (o Output) HasDrop() bool

HasDrop returns true if any property of elements will be dropped in the output.

func (Output) HasKeysToDrop

func (o Output) HasKeysToDrop() bool

HasKeysToDrop returns true if there are keys to drop in the output, otherwise false.

func (Output) HasKeysToKeep

func (o Output) HasKeysToKeep() bool

HasKeysToKeep returns true if there are keys to keep in the output, otherwise false.

func (*Output) Init

func (o *Output) Init(globals map[string]interface{}, ctx map[string]interface{}, funcs *dfl.FunctionMap) error

type OutputConfig

type OutputConfig struct {
	Uri           string   `hcl:"uri"`            // resource URI
	DropNodes     bool     `hcl:"drop_nodes"`     // drop nodes
	DropWays      bool     `hcl:"drop_ways"`      // drop ways
	DropRelations bool     `hcl:"drop_relations"` // drop relations
	DropVersion   bool     `hcl:"drop_version"`   // drop version numbers
	DropChangeset bool     `hcl:"drop_changeset"` // drop changeset id
	DropTimestamp bool     `hcl:"drop_timestamp"` // drop last modified timestamp
	DropUserId    bool     `hcl:"drop_user_id"`   // drop the id of the user that last modified an element
	DropUserName  bool     `hcl:"drop_user_name"` // drop the name of the user that last modified an element
	KeysToKeep    []string `hcl:"keep_keys"`      // slice of keys to keep from read elements.  This is not a filter.
	KeysToDrop    []string `hcl:"drop_keys"`      // slice of keys to drop from read elements.  This is not a filter.
	WaysToNodes   bool     `hcl:"ways_to_nodes"`  // convert ways into nodes
	Filter        *Filter  `hcl:"filter"`         // filter input
	Pretty        bool     `hcl:"pretty"`         // write pretty output (newlines and tabs for .osm XML)
}

func NewOutputConfig

func NewOutputConfig(uri string, filter *Filter, drop_nodes, drop_ways, drop_relations, drop_version, drop_changeset, drop_timestamp, drop_uid, drop_user, ways_to_nodes, pretty bool) OutputConfig

type Planet

type Planet struct {
	XMLName   xml.Name  `xml:"osm"`
	Version   string    `xml:"version,attr,omitempty"`
	Generator string    `xml:"generator,attr,omitempty"`
	Timestamp time.Time `xml:"timestamp,attr"`
	Bounds    Bounds    `xml:"bounds,omitempty"`

	Nodes []*Node `xml:"node"`

	Ways []*Way `xml:"way"`

	Relations []*Relation `xml:"relation"`

	Tags      *TagsCache        `xml:"-"`
	UserNames map[uint64]string `xml:"-"` // map of UserName by UserId
	Rtree     *rtreego.Rtree    `xml:"-"`
	// contains filtered or unexported fields
}

func NewPlanet

func NewPlanet() *Planet

func (*Planet) AddNode

func (p *Planet) AddNode(n *Node) error

func (*Planet) AddRelation

func (p *Planet) AddRelation(r *Relation) error

func (*Planet) AddTag

func (p *Planet) AddTag(t Tag) uint32

func (*Planet) AddTags

func (p *Planet) AddTags(tags []Tag) []uint32

func (*Planet) AddWay

func (p *Planet) AddWay(w *Way) error

func (*Planet) AddWayAsNode

func (p *Planet) AddWayAsNode(w *Way, node_id uint64) error

func (Planet) BoundingBox

func (p Planet) BoundingBox() string

func (*Planet) ConvertWayToNode

func (p *Planet) ConvertWayToNode(w *Way, way_node_id uint64) (*Node, error)

func (*Planet) ConvertWaysToNodes

func (p *Planet) ConvertWaysToNodes(async bool)

func (Planet) Count

func (p Planet) Count(key string) int

func (Planet) CountNodes

func (p Planet) CountNodes(key string) int

func (Planet) CountRelations

func (p Planet) CountRelations(key string) int

func (Planet) CountWays

func (p Planet) CountWays(key string) int

func (*Planet) DropChangeset

func (p *Planet) DropChangeset()

func (*Planet) DropRelations

func (p *Planet) DropRelations()

func (*Planet) DropTimestamp

func (p *Planet) DropTimestamp()

func (*Planet) DropVersion

func (p *Planet) DropVersion()

func (*Planet) DropWays

func (p *Planet) DropWays()

func (*Planet) Filter

func (p *Planet) Filter(fi *Filter, dfl_cache *dfl.Cache) error

func (*Planet) FilterNodes

func (p *Planet) FilterNodes(fi *Filter, dfl_cache *dfl.Cache) error

func (*Planet) FilterWays

func (p *Planet) FilterWays(fi *Filter, dfl_cache *dfl.Cache) error

func (*Planet) GetFeatureCollection

func (p *Planet) GetFeatureCollection(output *Output) (graph.FeatureCollection, error)

func (*Planet) GetFeatures

func (p *Planet) GetFeatures(output *Output) ([]graph.Feature, error)

func (*Planet) GetTag

func (p *Planet) GetTag(tagIndex uint32) Tag

func (*Planet) GetTagsAsMap

func (p *Planet) GetTagsAsMap(tagIndicies []uint32) map[string]interface{}

func (Planet) GetWayNodeIdsAsSlice

func (p Planet) GetWayNodeIdsAsSlice() UInt64Slice

GetWayNodeIdsAsSlice returns a slice of all the IDs of the Nodes that are part of ways.

func (*Planet) Init

func (p *Planet) Init() error

func (Planet) Summarize

func (p Planet) Summarize(keys []string) Summary

func (*Planet) WayToFeature

func (p *Planet) WayToFeature(w *Way) graph.Feature

type PlanetResource

type PlanetResource struct {
	*FilteredResource
	DropNodes     bool     `hcl:"drop_nodes"`     // drop nodes
	DropWays      bool     `hcl:"drop_ways"`      // drop ways
	DropRelations bool     `hcl:"drop_relations"` // drop relations
	DropVersion   bool     `hcl:"drop_version"`   // drop version numbers
	DropChangeset bool     `hcl:"drop_changeset"` // drop changeset id
	DropTimestamp bool     `hcl:"drop_timestamp"` // drop last modified timestamp
	DropUserId    bool     `hcl:"drop_user_id"`   // drop the id of the user that last modified an element
	DropUserName  bool     `hcl:"drop_user_name"` // drop the name of the user that last modified an element
	KeysToKeep    []string `hcl:"keep_keys"`      // slice of keys to keep from read elements.  This is not a filter.
	KeysToDrop    []string `hcl:"drop_keys"`      // slice of keys to drop from read elements.  This is not a filter.
}

func (PlanetResource) HasDrop

func (pr PlanetResource) HasDrop() bool

func (*PlanetResource) Init

func (pr *PlanetResource) Init(globals map[string]interface{}, ctx map[string]interface{}, funcs *dfl.FunctionMap) error

type Relation

type Relation struct {
	TaggedElement
	Members []RelationMember `xml:"member"`
}

func NewRelation

func NewRelation() *Relation

func (Relation) NumberOfMembers

func (r Relation) NumberOfMembers() int

type RelationMember

type RelationMember struct {
	Type      string `xml:"type,attr"`
	Reference uint64 `xml:"ref,attr"`
	Role      string `xml:"role,attr"`
}

type Resource

type Resource struct {
	Uri          string `hcl:"uri"` // resoure URI
	Type         string `hcl:"-"`   // type of resource inferred from uri
	Scheme       string `hcl:"-"`   // scheme, .e.g., http, https, file, s3
	Path         string `hcl:"-"`   // path
	PathExpanded string `hcl:"-"`   // path with home directory expanded
	NameNode     string `hcl:"-"`   // FQDN of Name Node
	Bucket       string `hcl:"-"`   // S3 Bucket
	Key          string `hcl:"-"`   // S3 Key
	Exists       bool   `hcl:"-"`   // resource exists
}

Resource is an abstract struct for URI addressable resources

func (*Resource) FileExists

func (r *Resource) FileExists() bool

func (*Resource) GetType

func (r *Resource) GetType() string

func (Resource) HasUri

func (r Resource) HasUri() bool

func (*Resource) Init

func (r *Resource) Init(ctx map[string]interface{}) error

func (*Resource) IsType

func (r *Resource) IsType(t string) bool

func (*Resource) UrlExists

func (r *Resource) UrlExists() bool

type StringSet

type StringSet map[string]struct{}

StringSet is a logical set of string values using a map[string]struct{} backend. The use of a string -> empty struct backend provides a higher write performance versus a slice backend.

func NewStringSet

func NewStringSet() StringSet

NewStringSet returns a new StringSet.

func (StringSet) Add

func (set StringSet) Add(values ...string)

Add is a variadic function to add values to a set

func (StringSet) Contains

func (set StringSet) Contains(x string) bool

func (StringSet) Intersect

func (set StringSet) Intersect(values interface{}) StringSet

func (StringSet) Len

func (set StringSet) Len() int

func (StringSet) Slice

func (set StringSet) Slice(sorted bool) sort.StringSlice

Slice returns a slice representation of this set. If parameter sorted is true, then sorts the values using natural sort order.

func (StringSet) Union

func (set StringSet) Union(values interface{}) StringSet

type Summary

type Summary struct {
	Bounds         Bounds                    `xml:"bounds,omitempty"` // the maximum bounds of the Planet.  read from input and not validated.
	CountUsers     int                       `xml:"users"`            // number of users in the Planet
	CountNodes     int                       `xml:"nodes"`            // number of nodes in the Planet
	CountWays      int                       `xml:"ways"`             // number of ways in the Planet
	CountRelations int                       `xml:"relations"`        // number of relations in the Planet
	CountKeys      int                       `xml:"keys"`             // total number of unique keys in the Planet
	CountTags      int                       `xml:"tags"`             // total number of unique key=value combinations in the Planet
	CountsByKey    map[string]map[string]int `xml:"by_key"`           // count of nodes, ways, and relations by key
}

Summary is a struct for storing the results of a summariziation of the data in a Planet.

func (Summary) BoundingBox

func (s Summary) BoundingBox() string

BoundingBox returns the summary's bounds as a bbox (aka "minx,miny,maxx,maxy").

func (Summary) Print

func (s Summary) Print()

Print prints the summary to stdout.

type Tag

type Tag struct {
	Key   string `xml:"k,attr"` // the key
	Value string `xml:"v,attr"` // the value
}

Tag is a key=value construct used in an OpenStreetMap for associating attributes with physical geospatial features or relationships among those features.

func UnmarshalTags

func UnmarshalTags(decoder *xml.Decoder, keep_keys []string, drop_keys []string) []Tag

UnmarshalTags unmarshals a slice of tags from an XML stream Called between a Node xml.StartElement and a Node xml.EndElement Returns a slice of Tag

type TaggedElement

type TaggedElement struct {
	Element            // the extended OSM element
	Tags      []Tag    `xml:"tag"`                                                          // a slice of tags for this element
	TagsIndex []uint32 `xml:"-" parquet:"name=tags, type=U_INT32, repetitiontype=REPEATED"` // a slice of indexes in the Planet TagCache.
}

TaggedElement is an abstract struct that attaches tags to OSM elements and associated functions

func (TaggedElement) GetTagsIndex

func (te TaggedElement) GetTagsIndex() []uint32

GetTagsIndex returns a slice of indexes in the Planet TagCache for this element

func (*TaggedElement) SetTags

func (te *TaggedElement) SetTags(tags []Tag)

SetTags sets the elements Tags

func (*TaggedElement) SetTagsIndex

func (te *TaggedElement) SetTagsIndex(tagsIndex []uint32)

SetTagsIndex sets the indexes in the Planet TagCache to retrieve the associated Tag

type TagsCache

type TagsCache struct {
	Values []Tag                        // slice of cached tags
	Index  map[string]map[string]uint32 // map[key][value] ==> index in Values
}

TagsCache is a cache of tags with a map for reverse lookup

func NewTagsCache

func NewTagsCache() *TagsCache

func (*TagsCache) AddTag

func (tc *TagsCache) AddTag(t Tag) uint32

AddTag adds a tag to the cache and returns its index

func (*TagsCache) AddTags

func (tc *TagsCache) AddTags(tags []Tag) []uint32

AddTags add the slice of tags to the cache and returns a slice of indicies

func (*TagsCache) Map

func (tc *TagsCache) Map(tagIndicies []uint32) map[string]interface{}

func (*TagsCache) Slice

func (tc *TagsCache) Slice(tagIndicies []uint32) []Tag

type UInt64Set

type UInt64Set map[uint64]struct{}

UInt64Set is a logical set of int64 values using a map[uint64]struct{} backend. The use of a uint64 -> empty struct backend provides a higher write performance versus a slice backend.

func NewUInt64Set

func NewUInt64Set() UInt64Set

NewUInt64Set returns a new Int64Set.

func (UInt64Set) Add

func (set UInt64Set) Add(x uint64)

Add adds parameter x to the set.

func (UInt64Set) Slice

func (set UInt64Set) Slice(sorted bool) UInt64Slice

Slice returns a slice representation of this set. If parameter sorted is true, then sorts the values using natural sort order.

type UInt64Slice

type UInt64Slice []uint64

UInt64Slice is a type alias for a slice of int64.

func NewUInt64Slice

func NewUInt64Slice(length int, capacity int) UInt64Slice

NewUInt64Slice returns a new UInt64Slice with length and capacity given as parameters.

func (UInt64Slice) Contains

func (p UInt64Slice) Contains(x uint64) bool

func (UInt64Slice) Len

func (p UInt64Slice) Len() int

func (UInt64Slice) Less

func (p UInt64Slice) Less(i, j int) bool

func (UInt64Slice) Search

func (p UInt64Slice) Search(x uint64) int

func (UInt64Slice) Sort

func (p UInt64Slice) Sort()

func (UInt64Slice) Swap

func (p UInt64Slice) Swap(i, j int)

type Way

type Way struct {
	TaggedElement
	NodeReferences []NodeReference `xml:"nd"`
}

func NewWay

func NewWay() *Way

func (Way) NumberOfNodes

func (w Way) NumberOfNodes() int

Jump to

Keyboard shortcuts

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