Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectorFunc ¶
ConnectorFunc is used to inject a database connection method into NewDatabaseConnection
func NewPostgreSQLConnector ¶
func NewPostgreSQLConnector() ConnectorFunc
NewPostgreSQLConnector opens a connection to a postgresql database
func NewSQLiteConnector ¶
func NewSQLiteConnector() ConnectorFunc
NewSQLiteConnector opens a connection to a local sqlite database
type Datastore ¶
type Datastore interface { AddRoad(Road) error GetRoadByID(id string) (Road, error) GetRoadBySegmentID(segmentID string) (Road, error) GetRoadCount() int GetRoadsNearPoint(lat, lon float64, maxDistance uint64) ([]Road, error) GetRoadsWithinRect(lat0, lon0, lat1, lon1 float64) ([]Road, error) GetRoadSegmentByID(id string) (RoadSegment, error) GetSegmentsNearPoint(lat, lon float64, maxDistance uint64) ([]RoadSegment, error) GetSegmentsWithinRect(lat0, lon0, lat1, lon1 float64) ([]RoadSegment, error) RoadSegmentSurfaceUpdated(segmentID, surfaceType string, probability float64, timestamp time.Time) error UpdateRoadSegmentSurface(segmentID, surfaceType string, probability float64, timestamp time.Time) error CreateRoadSurfaceObserved(src *diwise.RoadSurfaceObserved) (*persistence.RoadSurfaceObserved, error) GetRoadSurfacesObserved() ([]persistence.RoadSurfaceObserved, error) }
Datastore is an interface that is used to inject the database into different handlers to improve testability
func NewDatabaseConnection ¶
func NewDatabaseConnection(connect ConnectorFunc, datafile io.Reader) (Datastore, error)
NewDatabaseConnection creates and returns a new instance of the Datastore interface
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Point encapsulates a WGS84 coordinate
func (Point) IsBoundedBy ¶
IsBoundedBy returns true if the point is bounded by the provided bounding box
type Rectangle ¶
type Rectangle struct {
// contains filtered or unexported fields
}
Rectangle is a rectangle shaped box based on a NW and a SE coordinate
func NewBoundingBoxFromRectangles ¶
NewBoundingBoxFromRectangles creates a new instance of a Rectangle by creating a union of two others
func NewRectangle ¶
NewRectangle takes two Points and returns a new Rectangle instance
func (Rectangle) DistanceFromPoint ¶
DistanceFromPoint calculates the distance from a rectangle and an exterior point. For points within the rectangle, 0 is returned
func (Rectangle) Intersects ¶
Intersects returns true if the two rectangles overlap in any way
type Road ¶
type Road interface { ID() string AddSegment(RoadSegment) GetSegment(id string) (RoadSegment, error) GetSegmentIdentities() []string GetSegmentsWithinDistanceFromPoint(maxDistance uint64, pt Point) ([]RoadSegment, uint64) GetSegmentsWithinRect(Rectangle) ([]RoadSegment, uint64) BoundingBox() Rectangle IsWithinDistanceFromPoint(maxDistance uint64, pt Point) bool // contains filtered or unexported methods }
Road is a road
type RoadSegment ¶
type RoadSegment interface { ID() string RoadID() string BoundingBox() Rectangle Coordinates() [][2]float64 IsWithinDistanceFromPoint(uint64, Point) bool SurfaceType() (string, float64) DateModified() *time.Time IsModified() bool // contains filtered or unexported methods }
RoadSegment is a road segment
type RoadSegmentLine ¶
type RoadSegmentLine interface { BoundingBox() Rectangle StartPoint() [2]float64 EndPoint() [2]float64 }
RoadSegmentLine represents a straight part of a road segment