aboutsummaryrefslogblamecommitdiff
path: root/models.go
blob: c98ed2f04d8c6b8a40a83fac253729bfa9732644 (plain) (tree)




















                                                               
                                                            









                                                           
                                                  








                                                           
                                                  













                                                                                   




                                   
package main

import (
	"time"

	"github.com/paulmach/orb"
	"github.com/paulmach/osm"
	"go.mongodb.org/mongo-driver/bson/primitive"
)

type Coords struct {
	Type        string    `bson:"type"`
	Coordinates []float64 `bson:"coordinates"`
}

type Node struct {
	ID        primitive.ObjectID `bson:"_id,omitempty"`
	OsmID     int64              `bson:"osm_id"`
	Visible   bool               `bson:"visible"`
	Version   int                `bson:"version,omitempty"`
	Timestamp time.Time          `bson:"timestamp"`
	Tags      []Tag              `bson:"tags,omitempty"`
	Location  Coords             `bson:"location"`
}

type Way struct {
	ID        primitive.ObjectID `bson:"_id,omitempty"`
	OsmID     int64              `bson:"osm_id"`
	Visible   bool               `bson:"visible"`
	Version   int                `bson:"version"`
	Timestamp time.Time          `bson:"timestamp"`
	Nodes     []int64            `bson:"nodes"`
	Tags      []Tag              `bson:"tags"`
}

type Relation struct {
	ID        primitive.ObjectID `bson:"_id,omitempty"`
	OsmID     int64              `bson:"osm_id"`
	Visible   bool               `bson:"visible"`
	Version   int                `bson:"version"`
	Timestamp time.Time          `bson:"timestamp"`
	Members   []Member           `bson:"members"`
	Tags      []Tag              `bson:"tags"`
}

type Member struct {
	Type osm.Type `bson:"type"`
	Ref  int64    `bson:"ref"`
	Role string   `bson:"role"`

	Version  int
	Location Coords `bson:"location"`

	// Orientation is the direction of the way around a ring of a multipolygon.
	// Only valid for multipolygon or boundary relations.
	Orientation orb.Orientation `bson:"orienation,omitempty"`
}

type Tag struct {
	Key   string `bson:"key"`
	Value string `bson:"value"`
}