mapping

package
v0.0.0-...-e2e308c Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package mapping provides functions for defining and executing the database schema.

Index

Constants

This section is empty.

Variables

View Source
var AvailableFieldTypes map[string]FieldType

Functions

func Area

func Area(val string, elem *element.OSMElem, geom *geom.Geometry, match Match) interface{}

func Bool

func Bool(val string, elem *element.OSMElem, geom *geom.Geometry, match Match) interface{}

func BoolInt

func BoolInt(val string, elem *element.OSMElem, geom *geom.Geometry, match Match) interface{}

func DefaultWayZOrder

func DefaultWayZOrder(val string, elem *element.OSMElem, geom *geom.Geometry, match Match) interface{}

func Direction

func Direction(val string, elem *element.OSMElem, geom *geom.Geometry, match Match) interface{}

func Geometry

func Geometry(val string, elem *element.OSMElem, geom *geom.Geometry, match Match) interface{}

func Id

func Id(val string, elem *element.OSMElem, geom *geom.Geometry, match Match) interface{}

func Integer

func Integer(val string, elem *element.OSMElem, geom *geom.Geometry, match Match) interface{}

func KeyName

func KeyName(val string, elem *element.OSMElem, geom *geom.Geometry, match Match) interface{}

func RelationMemberID

func RelationMemberID(rel *element.Relation, member *element.Member, match Match) interface{}

func RelationMemberIndex

func RelationMemberIndex(rel *element.Relation, member *element.Member, match Match) interface{}

func RelationMemberRole

func RelationMemberRole(rel *element.Relation, member *element.Member, match Match) interface{}

func RelationMemberType

func RelationMemberType(rel *element.Relation, member *element.Member, match Match) interface{}

func SelectRelationPolygons

func SelectRelationPolygons(polygonTagMatcher RelWayMatcher, rel *element.Relation) []element.Member

SelectRelationPolygons returns a slice of all members that are already imported as part of the relation. Outer members are "imported" if they share the same destination table. Inner members are "imported" when they also share the same key/value.

func String

func String(val string, elem *element.OSMElem, geom *geom.Geometry, match Match) interface{}

func ValueName

func ValueName(val string, elem *element.OSMElem, geom *geom.Geometry, match Match) interface{}

func WebmercArea

func WebmercArea(val string, elem *element.OSMElem, geom *geom.Geometry, match Match) interface{}

Types

type Areas

type Areas struct {
	AreaTags   []Key `yaml:"area_tags"`
	LinearTags []Key `yaml:"linear_tags"`
}

type DestTable

type DestTable struct {
	Name       string
	SubMapping string
}

type ElementFilter

type ElementFilter func(tags element.Tags, key Key, closed bool) bool

type ExcludeFilter

type ExcludeFilter struct {
	// contains filtered or unexported fields
}

func (*ExcludeFilter) Filter

func (f *ExcludeFilter) Filter(tags *element.Tags) bool

type Field

type Field struct {
	Name       string                 `yaml:"name"`
	Key        Key                    `yaml:"key"`
	Keys       []Key                  `yaml:"keys"`
	Type       string                 `yaml:"type"`
	Args       map[string]interface{} `yaml:"args"`
	FromMember bool                   `yaml:"from_member"`
}

func (*Field) FieldType

func (field *Field) FieldType() *FieldType

type FieldSpec

type FieldSpec struct {
	Key  Key
	Type FieldType
}

func (*FieldSpec) MemberValue

func (f *FieldSpec) MemberValue(rel *element.Relation, member *element.Member, geom *geom.Geometry, match Match) interface{}

func (*FieldSpec) Value

func (f *FieldSpec) Value(elem *element.OSMElem, geom *geom.Geometry, match Match) interface{}

type FieldType

type FieldType struct {
	Name       string
	GoType     string
	Func       MakeValue
	MakeFunc   MakeMakeValue
	MemberFunc MakeMemberValue
	FromMember bool
}

type Filters

type Filters struct {
	ExcludeTags *[][]string `yaml:"exclude_tags"`
}

type GeneralizedTable

type GeneralizedTable struct {
	Name            string
	SourceTableName string  `yaml:"source"`
	Tolerance       float64 `yaml:"tolerance"`
	SqlFilter       string  `yaml:"sql_filter"`
}

type GeneralizedTables

type GeneralizedTables map[string]*GeneralizedTable

type Key

type Key string

type KeyValues

type KeyValues map[Key][]orderedValue

func (*KeyValues) UnmarshalYAML

func (kv *KeyValues) UnmarshalYAML(unmarshal func(interface{}) error) error

type MakeMakeValue

type MakeMakeValue func(string, FieldType, Field) (MakeValue, error)

type MakeMemberValue

type MakeMemberValue func(*element.Relation, *element.Member, Match) interface{}

type MakeValue

type MakeValue func(string, *element.OSMElem, *geom.Geometry, Match) interface{}

func MakeEnumerate

func MakeEnumerate(fieldName string, fieldType FieldType, field Field) (MakeValue, error)

func MakeHStoreString

func MakeHStoreString(fieldName string, fieldType FieldType, field Field) (MakeValue, error)

func MakePseudoArea

func MakePseudoArea(fieldName string, fieldType FieldType, field Field) (MakeValue, error)

func MakeSuffixReplace

func MakeSuffixReplace(fieldName string, fieldType FieldType, field Field) (MakeValue, error)

func MakeWayZOrder

func MakeWayZOrder(fieldName string, fieldType FieldType, field Field) (MakeValue, error)

func MakeZOrder

func MakeZOrder(fieldName string, fieldType FieldType, field Field) (MakeValue, error)

type Mapping

type Mapping struct {
	Tables            Tables            `yaml:"tables"`
	GeneralizedTables GeneralizedTables `yaml:"generalized_tables"`
	Tags              Tags              `yaml:"tags"`
	Areas             Areas             `yaml:"areas"`
	// SingleIdSpace mangles the overlapping node/way/relation IDs
	// to be unique (nodes positive, ways negative, relations negative -1e17)
	SingleIdSpace bool `yaml:"use_single_id_space"`
}

func NewMapping

func NewMapping(filename string) (*Mapping, error)

func (*Mapping) ElementFilters

func (m *Mapping) ElementFilters() map[string][]ElementFilter

func (*Mapping) LineStringMatcher

func (m *Mapping) LineStringMatcher() WayMatcher

func (*Mapping) NodeTagFilter

func (m *Mapping) NodeTagFilter() TagFilterer

func (*Mapping) PointMatcher

func (m *Mapping) PointMatcher() NodeMatcher

func (*Mapping) PolygonMatcher

func (m *Mapping) PolygonMatcher() RelWayMatcher

func (*Mapping) RelationMatcher

func (m *Mapping) RelationMatcher() RelationMatcher

func (*Mapping) RelationMemberMatcher

func (m *Mapping) RelationMemberMatcher() RelationMatcher

func (*Mapping) RelationTagFilter

func (m *Mapping) RelationTagFilter() TagFilterer

func (*Mapping) WayTagFilter

func (m *Mapping) WayTagFilter() TagFilterer

type Match

type Match struct {
	Key   string
	Value string
	Table DestTable
	// contains filtered or unexported fields
}

func (*Match) MemberRow

func (m *Match) MemberRow(rel *element.Relation, member *element.Member, geom *geom.Geometry) []interface{}

func (*Match) Row

func (m *Match) Row(elem *element.OSMElem, geom *geom.Geometry) []interface{}

type NodeMatcher

type NodeMatcher interface {
	MatchNode(node *element.Node) []Match
}

type OrderedDestTable

type OrderedDestTable struct {
	DestTable
	// contains filtered or unexported fields
}

type RelWayMatcher

type RelWayMatcher interface {
	WayMatcher
	RelationMatcher
}

type RelationMatcher

type RelationMatcher interface {
	MatchRelation(rel *element.Relation) []Match
}

type RelationTagFilter

type RelationTagFilter struct {
	TagFilter
}

func (*RelationTagFilter) Filter

func (f *RelationTagFilter) Filter(tags *element.Tags) bool

type SubMapping

type SubMapping struct {
	Mapping KeyValues
}

type Table

type Table struct {
	Name         string
	Type         TableType             `yaml:"type"`
	Mapping      KeyValues             `yaml:"mapping"`
	Mappings     map[string]SubMapping `yaml:"mappings"`
	TypeMappings TypeMappings          `yaml:"type_mappings"`
	Fields       []*Field              `yaml:"columns"` // TODO rename Fields internaly to Columns
	OldFields    []*Field              `yaml:"fields"`
	Filters      *Filters              `yaml:"filters"`
}

func (*Table) ExtraTags

func (t *Table) ExtraTags() map[Key]bool

func (*Table) TableFields

func (t *Table) TableFields() *TableFields

type TableFields

type TableFields struct {
	// contains filtered or unexported fields
}

func (*TableFields) MakeMemberRow

func (t *TableFields) MakeMemberRow(rel *element.Relation, member *element.Member, geom *geom.Geometry, match Match) []interface{}

func (*TableFields) MakeRow

func (t *TableFields) MakeRow(elem *element.OSMElem, geom *geom.Geometry, match Match) []interface{}

type TableType

type TableType string
const (
	PolygonTable        TableType = "polygon"
	LineStringTable     TableType = "linestring"
	PointTable          TableType = "point"
	GeometryTable       TableType = "geometry"
	RelationTable       TableType = "relation"
	RelationMemberTable TableType = "relation_member"
)

func (*TableType) UnmarshalJSON

func (tt *TableType) UnmarshalJSON(data []byte) error

type Tables

type Tables map[string]*Table

type TagFilter

type TagFilter struct {
	// contains filtered or unexported fields
}

func (*TagFilter) Filter

func (f *TagFilter) Filter(tags *element.Tags) bool

type TagFilterer

type TagFilterer interface {
	Filter(tags *element.Tags) bool
}

type TagTables

type TagTables map[Key]map[Value][]OrderedDestTable

type Tags

type Tags struct {
	LoadAll bool  `yaml:"load_all"`
	Exclude []Key `yaml:"exclude"`
	Include []Key `yaml:"include"`
}

type TypeMappings

type TypeMappings struct {
	Points      KeyValues `yaml:"points"`
	LineStrings KeyValues `yaml:"linestrings"`
	Polygons    KeyValues `yaml:"polygons"`
}

type Value

type Value string

type WayMatcher

type WayMatcher interface {
	MatchWay(way *element.Way) []Match
}

Jump to

Keyboard shortcuts

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