mapping

package
v0.0.0-...-58557e7 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2015 License: Apache-2.0 Imports: 8 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 Bool

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

func BoolInt

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

func Direction

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

func Geometry

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

func HstoreString

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

func Id

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

func Int64

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

func Integer

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

func KeyName

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

func MemberString

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

func PseudoArea

func PseudoArea(val string, elem *element.OSMElem, 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 with a relation with tags.

func String

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

func ValueName

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

func WayZOrder

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

Types

type DestTable

type DestTable struct {
	Name       string
	SubMapping string
}

type ElementFilter

type ElementFilter func(tags *element.Tags) 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                 `json:"name"`
	Key  Key                    `json:"key"`
	Keys []Key                  `json:"keys"`
	Type string                 `json:"type"`
	Args map[string]interface{} `json:"args"`
}

func (*Field) FieldType

func (field *Field) FieldType() *FieldType

type FieldSpec

type FieldSpec struct {
	Key  Key
	Type FieldType
}

func (*FieldSpec) Value

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

type FieldType

type FieldType struct {
	Name     string
	GoType   string
	Func     MakeValue
	MakeFunc MakeMakeValue
}

type Filters

type Filters struct {
	ExcludeTags *[][2]string `json:"exclude_tags"`
	IncludeTags *[][2]string `json:"include_tags"`
}

type GeneralizedTable

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

type GeneralizedTables

type GeneralizedTables map[string]*GeneralizedTable

type Key

type Key string

type MakeMakeValue

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

type MakeValue

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

func MakeSuffixReplace

func MakeSuffixReplace(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            `json:"tables"`
	GeneralizedTables GeneralizedTables `json:"generalized_tables"`
	Tags              Tags              `json:"tags"`
	// SingleIdSpace mangles the overlapping node/way/relation IDs
	// to be unique (nodes positive, ways negative, relations negative -1e17)
	SingleIdSpace bool `json:"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) RelationTagFilter

func (m *Mapping) RelationTagFilter() TagFilterer

func (*Mapping) StreetMatcher

func (m *Mapping) StreetMatcher() RelWayMatcher

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) Row

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

type NodeMatcher

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

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 map[Key][]Value
}

type Table

type Table struct {
	Name         string
	Type         TableType             `json:"type"`
	Mapping      map[Key][]Value       `json:"mapping"`
	Mappings     map[string]SubMapping `json:"mappings"`
	TypeMappings TypeMappings          `json:"type_mappings"`
	Fields       []*Field              `json:"columns"` // TODO rename Fields internaly to Columns
	OldFields    []*Field              `json:"fields"`
	Filters      *Filters              `json:"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) MakeRow

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

type TableType

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

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][]DestTable

type Tags

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

type TypeMappings

type TypeMappings struct {
	Points      map[Key][]Value `json:"points"`
	LineStrings map[Key][]Value `json:"linestrings"`
	Polygons    map[Key][]Value `json:"polygons"`
	Relations   map[Key][]Value `json:"relations"`
}

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