go-osm: github.com/spatialcurrent/go-osm/osm Index | Files

package osm

import "github.com/spatialcurrent/go-osm/osm"

+build !js

+build !js

+build !js

Index

Package Files

Bounds.go Config.go Element.go EvaluateExpression.go Filter.go FilteredResource.go Input.go InputConfig.go Int64Set.go Int64Slice.go KeepNode.go KeepRelation.go KeepWay.go LoadConfig.go LoadIniSection.go MapToSlice.go MarshalNode.go MarshalPlanet.go MarshalWay.go Node.go NodeToFeature.go Output.go OutputConfig.go ParseBool.go ParsePath.go ParseSliceFloat64.go ParseSliceString.go Planet.go PlanetResource.go Relation.go RenderTemplate.go Resource.go SplitUri.go StringSet.go StringifyMapKeys.go Summary.go Tag.go TaggedElement.go TagsCache.go UInt64Set.go UInt64Slice.go UnmarshalBounds.go UnmarshalNode.go UnmarshalPlanet.go UnmarshalRelation.go UnmarshalTags.go UnmarshalWay.go Way.go

Variables

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

func AddToChannel Uses

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

func EvaluateExpression Uses

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 Uses

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

func KeepRelation Uses

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

func KeepWay Uses

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

func LoadIniSection Uses

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

func MapToSlice Uses

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

func MarshalNode Uses

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

func MarshalPlanet Uses

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

func MarshalWay Uses

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

func NodeToFeature Uses

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

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

func ParseBool Uses

func ParseBool(in string) bool

func ParsePath Uses

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 Uses

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

func ParseSliceString Uses

func ParseSliceString(in string) []string

func RenderTemplate Uses

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

func SearchInt64s Uses

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 Uses

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 Uses

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 Uses

func StringifyMapKeys(in interface{}) interface{}

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

func UnmarshalPlanet Uses

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 WaitThenClose Uses

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

type Bounds Uses

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 Uses

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

func UnmarshalBounds Uses

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 Uses

func (b Bounds) BoundingBox() string

func (Bounds) ContainsPoint Uses

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

type Config Uses

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 Uses

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

func (*Config) GetNameNodes Uses

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

func (*Config) HasDrop Uses

func (c *Config) HasDrop() bool

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

func (*Config) HasResourceType Uses

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

func (*Config) Init Uses

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

func (*Config) Validate Uses

func (c *Config) Validate() error

type Element Uses

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 Uses

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

func (*Element) DropChangeset Uses

func (e *Element) DropChangeset()

DropChangeset sets the Changeset Id to 0

func (*Element) DropTimestamp Uses

func (e *Element) DropTimestamp()

DropTimestamp sets the timestamp to nil

func (*Element) DropUserId Uses

func (e *Element) DropUserId()

DropUserId sets the UserId to 0

func (*Element) DropUserName Uses

func (e *Element) DropUserName()

DropUserName sets the UserName to ""

func (*Element) DropVersion Uses

func (e *Element) DropVersion()

DropVersion sets the version to 0

func (*Element) GetId Uses

func (e *Element) GetId() uint64

GetId returns the element's ID as an int64

type Filter Uses

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 Uses

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

func (Filter) ContainsPoint Uses

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

func (Filter) HasExpression Uses

func (fi Filter) HasExpression() bool

func (Filter) HasKeysToDrop Uses

func (fi Filter) HasKeysToDrop() bool

func (Filter) HasKeysToKeep Uses

func (fi Filter) HasKeysToKeep() bool

func (Filter) HasMaxExtent Uses

func (fi Filter) HasMaxExtent() bool

func (*Filter) Init Uses

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

type FilteredResource Uses

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

func (*FilteredResource) Init Uses

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

type Globals Uses

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 Uses

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 Uses

func (i *Input) Close() error

func (*Input) Init Uses

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

func (*Input) Open Uses

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

func (*Input) OpenFile Uses

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

func (*Input) OpenFileOnHDFS Uses

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

func (*Input) OpenS3Object Uses

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

func (*Input) OpenWeb Uses

func (i *Input) OpenWeb() error

type InputConfig Uses

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 Uses

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 Uses

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 Uses

func NewInt64Set() Int64Set

NewInt64Set returns a new Int64Set.

func (Int64Set) Add Uses

func (set Int64Set) Add(x int64)

Add adds parameter x to the set.

func (Int64Set) Slice Uses

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 Uses

type Int64Slice []int64

Int64Slice is a type alias for a slice of int64.

func NewInt64Slice Uses

func NewInt64Slice(length int, capacity int) Int64Slice

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

func (Int64Slice) Contains Uses

func (p Int64Slice) Contains(x int64) bool

func (Int64Slice) Len Uses

func (p Int64Slice) Len() int

func (Int64Slice) Less Uses

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

func (Int64Slice) Search Uses

func (p Int64Slice) Search(x int64) int

func (Int64Slice) Sort Uses

func (p Int64Slice) Sort()

func (Int64Slice) Swap Uses

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

type Node Uses

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 Uses

func NewNode() *Node

func UnmarshalNode Uses

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 (Node) Bounds Uses

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

func (Node) Tile Uses

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

type NodeReference Uses

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

type Output Uses

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 Uses

func (o Output) HasDrop() bool

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

func (Output) HasKeysToDrop Uses

func (o Output) HasKeysToDrop() bool

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

func (Output) HasKeysToKeep Uses

func (o Output) HasKeysToKeep() bool

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

func (*Output) Init Uses

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

type OutputConfig Uses

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 Uses

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 Uses

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 Uses

func NewPlanet() *Planet

func (*Planet) AddNode Uses

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

func (*Planet) AddRelation Uses

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

func (*Planet) AddTag Uses

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

func (*Planet) AddTags Uses

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

func (*Planet) AddWay Uses

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

func (*Planet) AddWayAsNode Uses

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

func (Planet) BoundingBox Uses

func (p Planet) BoundingBox() string

func (*Planet) ConvertWayToNode Uses

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

func (*Planet) ConvertWaysToNodes Uses

func (p *Planet) ConvertWaysToNodes(async bool)

func (Planet) Count Uses

func (p Planet) Count(key string) int

func (Planet) CountNodes Uses

func (p Planet) CountNodes(key string) int

func (Planet) CountRelations Uses

func (p Planet) CountRelations(key string) int

func (Planet) CountWays Uses

func (p Planet) CountWays(key string) int

func (*Planet) DropChangeset Uses

func (p *Planet) DropChangeset()

func (*Planet) DropRelations Uses

func (p *Planet) DropRelations()

func (*Planet) DropTimestamp Uses

func (p *Planet) DropTimestamp()

func (*Planet) DropVersion Uses

func (p *Planet) DropVersion()

func (*Planet) DropWays Uses

func (p *Planet) DropWays()

func (*Planet) Filter Uses

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

func (*Planet) FilterNodes Uses

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

func (*Planet) FilterWays Uses

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

func (*Planet) GetFeatureCollection Uses

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

func (*Planet) GetFeatures Uses

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

func (*Planet) GetTag Uses

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

func (*Planet) GetTagsAsMap Uses

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

func (Planet) GetWayNodeIdsAsSlice Uses

func (p Planet) GetWayNodeIdsAsSlice() UInt64Slice

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

func (*Planet) Init Uses

func (p *Planet) Init() error

func (Planet) Summarize Uses

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

func (*Planet) WayToFeature Uses

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

type PlanetResource Uses

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 Uses

func (pr PlanetResource) HasDrop() bool

func (*PlanetResource) Init Uses

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

type Relation Uses

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

func NewRelation Uses

func NewRelation() *Relation

func UnmarshalRelation Uses

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 (Relation) NumberOfMembers Uses

func (r Relation) NumberOfMembers() int

type RelationMember Uses

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

type Resource Uses

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 Uses

func (r *Resource) FileExists() bool

func (*Resource) GetType Uses

func (r *Resource) GetType() string

func (Resource) HasUri Uses

func (r Resource) HasUri() bool

func (*Resource) Init Uses

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

func (*Resource) IsType Uses

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

func (*Resource) UrlExists Uses

func (r *Resource) UrlExists() bool

type StringSet Uses

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 Uses

func NewStringSet() StringSet

NewStringSet returns a new StringSet.

func (StringSet) Add Uses

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

Add is a variadic function to add values to a set

- https://gobyexample.com/variadic-functions

func (StringSet) Contains Uses

func (set StringSet) Contains(x string) bool

func (StringSet) Intersect Uses

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

func (StringSet) Len Uses

func (set StringSet) Len() int

func (StringSet) Slice Uses

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 Uses

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

type Summary Uses

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 Uses

func (s Summary) BoundingBox() string

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

func (Summary) Print Uses

func (s Summary) Print()

Print prints the summary to stdout.

type Tag Uses

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 Uses

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 Uses

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 Uses

func (te TaggedElement) GetTagsIndex() []uint32

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

func (*TaggedElement) SetTags Uses

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

SetTags sets the elements Tags

func (*TaggedElement) SetTagsIndex Uses

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

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

type TagsCache Uses

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 Uses

func NewTagsCache() *TagsCache

func (*TagsCache) AddTag Uses

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

AddTag adds a tag to the cache and returns its index

func (*TagsCache) AddTags Uses

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 Uses

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

func (*TagsCache) Slice Uses

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

type UInt64Set Uses

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 Uses

func NewUInt64Set() UInt64Set

NewUInt64Set returns a new Int64Set.

func (UInt64Set) Add Uses

func (set UInt64Set) Add(x uint64)

Add adds parameter x to the set.

func (UInt64Set) Slice Uses

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 Uses

type UInt64Slice []uint64

UInt64Slice is a type alias for a slice of int64.

func NewUInt64Slice Uses

func NewUInt64Slice(length int, capacity int) UInt64Slice

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

func (UInt64Slice) Contains Uses

func (p UInt64Slice) Contains(x uint64) bool

func (UInt64Slice) Len Uses

func (p UInt64Slice) Len() int

func (UInt64Slice) Less Uses

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

func (UInt64Slice) Search Uses

func (p UInt64Slice) Search(x uint64) int

func (UInt64Slice) Sort Uses

func (p UInt64Slice) Sort()

func (UInt64Slice) Swap Uses

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

type Way Uses

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

func NewWay Uses

func NewWay() *Way

func UnmarshalWay Uses

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 (Way) NumberOfNodes Uses

func (w Way) NumberOfNodes() int

Package osm imports 29 packages (graph). Updated 2018-09-03. Refresh now. Tools for package owners.