element

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package element provides basic types for OSM elements (coords/nodes/ways/relations/etc).

Index

Constants

View Source
const (
	NODE     MemberType = 0
	WAY                 = 1
	RELATION            = 2
)
View Source
const RelIdOffset = -1e17

RelIdOffset is a constant we subtract from relation IDs to avoid conflicts with way and node IDs. Nodes, ways and relations have separate ID spaces in OSM, but we need unique IDs for updating and removing elements in diff mode. In a normal diff import relation IDs are negated to distinguish them from way IDs, because ways and relations can both be imported in the same polygon table. Nodes are only imported together with ways and relations in single table imports (see `type_mappings`). In this case we negate the way and relation IDs and aditionaly subtract RelIdOffset from the relation IDs. Ways will go from -0 to -100,000,000,000,000,000, relations from -100,000,000,000,000,000 down wards.

Variables

View Source
var MemberTypeValues = map[string]MemberType{
	"node":     NODE,
	"way":      WAY,
	"relation": RELATION,
}

Functions

func TryCloseWay

func TryCloseWay(refs []int64, nodes []Node, maxGap float64) bool

TryCloseWay closes the way if both end nodes are nearly identical. Returns true if it succeeds.

Types

type IdRefs

type IdRefs struct {
	Id   int64
	Refs []int64
}

func (*IdRefs) Add

func (idRefs *IdRefs) Add(ref int64)

func (*IdRefs) Delete

func (idRefs *IdRefs) Delete(ref int64)

type Member

type Member struct {
	Id   int64      `json:"id"`
	Type MemberType `json:"type"`
	Role string     `json:"role"`
	Way  *Way       `json:"-"`
	Node *Node      `json:"-"`
	Elem *OSMElem   `json:"-"`
}

type MemberType

type MemberType int

type Metadata

type Metadata struct {
	UserId    int
	UserName  string
	Version   int
	Timestamp time.Time
	Changeset int
}

type Node

type Node struct {
	OSMElem
	Lat  float64 `json:"lat"`
	Long float64 `json:"lon"`
}

type OSMElem

type OSMElem struct {
	Id       int64     `json:"-"`
	Tags     Tags      `json:"tags,omitempty"`
	Metadata *Metadata `json:"-"`
}

type Relation

type Relation struct {
	OSMElem
	Members []Member `json:"members"`
}

type Tags

type Tags map[string]string

func (*Tags) String

func (t *Tags) String() string

type Way

type Way struct {
	OSMElem
	Refs  []int64 `json:"refs"`
	Nodes []Node  `json:"nodes,omitempty"`
}

func (*Way) IsClosed

func (w *Way) IsClosed() bool

func (*Way) TryClose

func (w *Way) TryClose(maxGap float64) bool

Jump to

Keyboard shortcuts

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