Documentation ¶
Index ¶
- func Change(ctx context.Context, change *osm.Change, ds osm.HistoryDatasourcer, ...) (*osm.Diff, error)
- func IsReverse(w1, w2 *osm.Way) bool
- func Relations(ctx context.Context, relations osm.Relations, ...) error
- func Ways(ctx context.Context, ways osm.Ways, datasource NodeHistoryDatasourcer, ...) error
- type ChildFirstOrdering
- type HistoryAsChildrenDatasourcer
- type NoHistoryError
- type NoVisibleChildError
- type NodeHistoryAsChildrenDatasourcer
- type NodeHistoryDatasourcer
- type Option
- type RelationHistoryDatasourcer
- type UnsupportedMemberTypeError
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 IsReverse ¶
IsReverse checks to see if this way update was a "reversal". It is very tricky to generally answer this question but easier for a relation minor update. Since the relation wasn't updated we assume things are still connected and can just check the endpoints.
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.
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 HistoryAsChildrenDatasourcer ¶
type HistoryAsChildrenDatasourcer interface { osm.HistoryDatasourcer NodeHistoryAsChildren(context.Context, osm.NodeID) ([]*shared.Child, error) WayHistoryAsChildren(context.Context, osm.WayID) ([]*shared.Child, error) RelationHistoryAsChildren(context.Context, osm.RelationID) ([]*shared.Child, error) }
HistoryAsChildrenDatasourcer is an advanced data source that returns the needed elements as children directly.
type NoHistoryError ¶
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 ¶
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 NodeHistoryAsChildrenDatasourcer ¶
type NodeHistoryAsChildrenDatasourcer interface { NodeHistoryDatasourcer NodeHistoryAsChildren(context.Context, osm.NodeID) ([]*shared.Child, error) }
NodeHistoryAsChildrenDatasourcer is an advanced data source that returns the needed nodes as children directly.
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 ¶
Option is a parameter that can be used for annotating.
func ChildFilter ¶
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 ¶
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 ¶
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.
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 ¶
func (e *UnsupportedMemberTypeError) Error() string
Error returns a pretty string of the error.