mapping

package
v0.0.0-...-85720d3 Latest Latest
Warning

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

Go to latest
Published: May 7, 2014 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 Id

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

func Integer

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

func Key

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

func PseudoArea

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

func String

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

func Value

func Value(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 Field

type Field struct {
	Name string                 `json:"name"`
	Key  string                 `json:"key"`
	Type string                 `json:"type"`
	Args map[string]interface{} `json:"args"`
}

func (*Field) FieldType

func (field *Field) FieldType() *FieldType

type FieldSpec

type FieldSpec struct {
	Key  string
	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"`
}

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 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"`
}

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() *TagMatcher

func (*Mapping) NodeTagFilter

func (m *Mapping) NodeTagFilter() *TagFilter

func (*Mapping) PointMatcher

func (m *Mapping) PointMatcher() *TagMatcher

func (*Mapping) PolygonMatcher

func (m *Mapping) PolygonMatcher() *TagMatcher

func (*Mapping) RelationTagFilter

func (m *Mapping) RelationTagFilter() *RelationTagFilter

func (*Mapping) WayTagFilter

func (m *Mapping) WayTagFilter() *TagFilter

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 RelationTagFilter

type RelationTagFilter struct {
	TagFilter
}

func (*RelationTagFilter) Filter

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

type SubMapping

type SubMapping struct {
	Mapping map[string][]string
}

type Table

type Table struct {
	Name     string
	Type     TableType             `json:"type"`
	Mapping  map[string][]string   `json:"mapping"`
	Mappings map[string]SubMapping `json:"mappings"`
	Fields   []*Field              `json:"fields"`
	Filters  *Filters              `json:"filters"`
}

func (*Table) ExtraTags

func (t *Table) ExtraTags() map[string]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"
)

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 TagMatcher

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

func (*TagMatcher) Match

func (tagMatcher *TagMatcher) Match(tags *element.Tags) []Match

type TagTables

type TagTables map[string]map[string][]DestTable

Jump to

Keyboard shortcuts

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