core

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: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compute

func Compute(
	ctx context.Context,
	parents []Parent,
	histories Datasourcer,
	opts *Options,
) ([]osm.Updates, error)

Compute does two things: first it computes the exact version of the children in each parent. Then it returns a set of updates for each version of the parent.

Types

type Child

type Child interface {
	ID() osm.FeatureID
	ChangesetID() osm.ChangesetID

	// VersionIndex is the index of the version if sorted from lowest to highest.
	// This is necessary since version don't have to start at 1 or be sequential.
	VersionIndex() int
	Visible() bool
	Timestamp() time.Time
	Committed() time.Time
	Update() osm.Update
}

A Child a thing contained by parents such as nodes for ways or nodes, ways and/or relations for relations.

type ChildList

type ChildList []Child

A ChildList is a set

func (ChildList) FindVisible

func (cl ChildList) FindVisible(cid osm.ChangesetID, at time.Time, eps time.Duration) Child

FindVisible locates the child visible at the given time. If 'at' is on or after osm.CommitInfoStart the committed time is used to determine visiblity. If 'at' is before, a range +-eps around the give time. Will return the closes visible node within that range, or the previous node if visible. Children after 'at' but within the eps must have the same changeset id as provided (the parent's). If the previous node is not visible, or does not exits will return nil.

func (ChildList) VersionBefore

func (cl ChildList) VersionBefore(end time.Time) Child

VersionBefore finds the last child before a given time.

type Datasourcer

type Datasourcer interface {
	Get(ctx context.Context, id osm.FeatureID) (ChildList, error)
	NotFound(err error) bool
}

A Datasourcer is something that acts like a datasource allowing us to fetch children as needed.

type NoHistoryError

type NoHistoryError struct {
	ChildID 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 {
	ChildID   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 Options

type Options struct {
	Threshold             time.Duration
	IgnoreInconsistency   bool
	IgnoreMissingChildren bool
	ChildFilter           func(osm.FeatureID) bool
}

Options allow for passing som parameters to the matching process.

type Parent

type Parent interface {
	ID() osm.FeatureID // used for logging
	ChangesetID() osm.ChangesetID

	Version() int
	Visible() bool
	Timestamp() time.Time
	Committed() time.Time

	// Refs returns normalized information about the children.
	// Currently this is the feature ids and if it is already annotated.
	// Note: we auto-annotate all unannotated children if they would have
	// been filtered out.
	Refs() (osm.FeatureIDs, []bool)
	SetChild(idx int, c Child)
}

A Parent is something that holds children. ie. ways have nodes as children and relations can have nodes, ways and relations as children.

Jump to

Keyboard shortcuts

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