annotate

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Change

func Change(
	ctx context.Context,
	change *osm.Change,
	ds osm.HistoryDatasourcer,
	opts ...Option,
) (*osm.Diff, error)

Change will annotate a change into a diff. It will use the HistoryDatasourcer to figure out the previous version of all the elements and build the diff. The IgnoreMissingChildren option can be used to handle missing histories. In this case the change will be considered a "new" action type.

func Relations

func Relations(
	ctx context.Context,
	relations osm.Relations,
	datasource osm.HistoryDatasourcer,
	opts ...Option,
) error

Relations computes the updates for the given relations and annotate members with stuff like changeset and lon/lat data. The input relations are modified to include this information.

func Ways

func Ways(
	ctx context.Context,
	ways osm.Ways,
	datasource NodeHistoryDatasourcer,
	opts ...Option,
) error

Ways computes the updates for the given ways and annotate the way nodes with changeset and lon/lat data. The input ways are modified to include this information.

Types

type ChildFirstOrdering

type ChildFirstOrdering struct {
	// CompletedIndex is the number of relation ids in the provided
	// array that have been finished. This can be used as a good restart position.
	CompletedIndex int
	// contains filtered or unexported fields
}

A ChildFirstOrdering is a struct that allows for a set of relations to be processed in a dept first order. Since relations can reference other relations we need to make sure children are added before parents.

func NewChildFirstOrdering

func NewChildFirstOrdering(
	ctx context.Context,
	ids []osm.RelationID,
	ds RelationHistoryDatasourcer,
) *ChildFirstOrdering

NewChildFirstOrdering creates a new ordering object. It is used to provided a child before parent ordering for relations. This order must be used when inserting+annotating relations into the datastore.

func (*ChildFirstOrdering) Close

func (o *ChildFirstOrdering) Close()

Close can be used to terminate the scanning process before all ids have been walked.

func (*ChildFirstOrdering) Err

func (o *ChildFirstOrdering) Err() error

Err returns a non-nil error if something went wrong with search, like a cycle, or a datasource error.

func (*ChildFirstOrdering) Next

func (o *ChildFirstOrdering) Next() bool

Next locates the next relation id that can be used. Returns false if the context is closed, something went wrong or the full tree has been walked.

func (*ChildFirstOrdering) RelationID

func (o *ChildFirstOrdering) RelationID() osm.RelationID

RelationID is the id found by the previous scan.

type NoHistoryError

type NoHistoryError struct {
	ID osm.FeatureID
}

NoHistoryError is returned if there is no entry in the history map for a specific child.

func (*NoHistoryError) Error

func (e *NoHistoryError) Error() string

Error returns a pretty string of the error.

type NoVisibleChildError

type NoVisibleChildError struct {
	ID        osm.FeatureID
	Timestamp time.Time
}

NoVisibleChildError is returned if there are no visible children for a parent at a given time.

func (*NoVisibleChildError) Error

func (e *NoVisibleChildError) Error() string

Error returns a pretty string of the error.

type NodeHistoryDatasourcer

type NodeHistoryDatasourcer interface {
	NodeHistory(context.Context, osm.NodeID) (osm.Nodes, error)
	NotFound(error) bool
}

NodeHistoryDatasourcer is an more strict interface for when we only need node history.

type Option

type Option func(*core.Options) error

Option is a parameter that can be used for annotating.

func ChildFilter

func ChildFilter(filter func(osm.FeatureID) bool) Option

ChildFilter allows for only a subset of children to be annotated on the parent. This can greatly improve update speed by only worrying about the children updated in the same batch. All unannotated children will be annotated regardless of the results of the filter function.

func IgnoreInconsistency

func IgnoreInconsistency(yes bool) Option

IgnoreInconsistency will try to match children even if they are missing. This should be used when you want to gracefully handle the weird data in OSM.

Nodes with unclear/inconsistent data will not be annotated. Causes include:

  • redacted data: In 2012 due to the license change data had to be removed. This could be some nodes of a way. There exist ways for which some nodes have just a single delete version, e.g. way 159081205, node 376130526
  • data pre element versioning: pre-2012(?) data versions were not kept, so for old ways there many be no information about some nodes. For example, a node may be updated after a way and there is no way to get the original version of the node and way.
  • bad editors: sometimes a node is edited 7 times in a single changeset and version 5 is a delete. See node 321452894, part of way 28831147.

func IgnoreMissingChildren

func IgnoreMissingChildren(yes bool) Option

IgnoreMissingChildren will ignore children for which the datasource returns datasource.ErrNotFound. This can be useful for partial history extracts where there may be relations for which the way was not included, e.g. a relation has a way inside the extract bounds and other ways outside the bounds.

func Threshold

func Threshold(t time.Duration) Option

Threshold is used if the "committed at" time is unknown and deals with the flexibility of commit orders, e.g. nodes in the same commit as the way can have a timestamp after the way. Threshold defines the time range to "forward group" these changes. Default 30 minutes.

type RelationHistoryDatasourcer

type RelationHistoryDatasourcer interface {
	RelationHistory(context.Context, osm.RelationID) (osm.Relations, error)
	NotFound(error) bool
}

RelationHistoryDatasourcer is an more strict interface for when we only need the relation history.

type UnsupportedMemberTypeError

type UnsupportedMemberTypeError struct {
	RelationID osm.RelationID
	MemberType osm.Type
	Index      int
}

UnsupportedMemberTypeError is returned if a relation member is not a node, way or relation.

func (*UnsupportedMemberTypeError) Error

Error returns a pretty string of the error.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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