2013-01-28 10:55:34 +04:00
|
|
|
package element
|
|
|
|
|
2013-05-15 11:49:38 +04:00
|
|
|
import (
|
|
|
|
"goposm/geom/geos"
|
|
|
|
)
|
|
|
|
|
2013-01-28 10:55:34 +04:00
|
|
|
type Tags map[string]string
|
|
|
|
|
|
|
|
type OSMElem struct {
|
2013-08-02 12:08:01 +04:00
|
|
|
Id int64 `json:"-"`
|
|
|
|
Tags Tags `json:"tags,omitempty"`
|
|
|
|
Geom *Geometry `json:"-"`
|
2013-01-28 10:55:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
type Node struct {
|
2013-04-03 00:07:27 +04:00
|
|
|
OSMElem
|
2013-08-02 12:08:01 +04:00
|
|
|
Lat float64 `json:"lat"`
|
|
|
|
Long float64 `json:"lon"`
|
2013-01-28 10:55:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
type Way struct {
|
2013-04-03 00:07:27 +04:00
|
|
|
OSMElem
|
2013-08-02 12:08:01 +04:00
|
|
|
Refs []int64 `json:"refs"`
|
|
|
|
Nodes []Node `json:"nodes,omitempty"`
|
2013-05-15 11:49:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
type Geometry struct {
|
|
|
|
Geom *geos.Geom
|
|
|
|
Wkb []byte
|
2013-01-28 10:55:34 +04:00
|
|
|
}
|
|
|
|
|
2013-05-13 17:19:39 +04:00
|
|
|
func (w *Way) IsClosed() bool {
|
|
|
|
return len(w.Refs) >= 4 && w.Refs[0] == w.Refs[len(w.Refs)-1]
|
|
|
|
}
|
|
|
|
|
2013-01-28 10:55:34 +04:00
|
|
|
type MemberType int
|
|
|
|
|
|
|
|
const (
|
2013-04-03 00:07:27 +04:00
|
|
|
NODE MemberType = 0
|
|
|
|
WAY = 1
|
|
|
|
RELATION = 2
|
2013-01-28 10:55:34 +04:00
|
|
|
)
|
|
|
|
|
2013-05-31 17:49:22 +04:00
|
|
|
var MemberTypeValues = map[string]MemberType{
|
|
|
|
"node": NODE,
|
|
|
|
"way": WAY,
|
|
|
|
"relation": RELATION,
|
|
|
|
}
|
|
|
|
|
2013-01-28 10:55:34 +04:00
|
|
|
type Member struct {
|
2013-08-02 12:08:01 +04:00
|
|
|
Id int64 `json:"id"`
|
|
|
|
Type MemberType `json:"type"`
|
|
|
|
Role string `json:"role"`
|
|
|
|
Way *Way `json:"-"`
|
2013-01-28 10:55:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
type Relation struct {
|
2013-04-03 00:07:27 +04:00
|
|
|
OSMElem
|
2013-08-02 12:08:01 +04:00
|
|
|
Members []Member `json:"members"`
|
2013-01-28 10:55:34 +04:00
|
|
|
}
|
2013-08-06 18:14:29 +04:00
|
|
|
|
|
|
|
type IdRefs struct {
|
|
|
|
Id int64
|
|
|
|
Refs []int64
|
|
|
|
}
|