Add PostgreSQL database option and more booking flow functionalities

This commit is contained in:
2023-05-08 01:29:59 +02:00
parent d8346a20be
commit e2e6759dc0
40 changed files with 1594 additions and 907 deletions

View File

@@ -1,3 +1,4 @@
// Package geoutils provides utility functions to handler geographic calculations such as distance between geometries.
package geoutils
import (
@@ -5,9 +6,10 @@ import (
"github.com/paulmach/orb"
"github.com/paulmach/orb/geo"
"github.com/rs/zerolog/log"
)
// DistanceFromLineString provides the shorteds distance between a point and a linestring.
// It returns the distance in meters, and the index of the closest linestring segment to the point
func DistanceFromLineString(point orb.Point, lineString orb.LineString) (distance float64, closestIndex int) {
minDistance := math.Inf(1)
closest := -1
@@ -23,14 +25,16 @@ func DistanceFromLineString(point orb.Point, lineString orb.LineString) (distanc
}
}
log.Debug().
Float64("min distance", minDistance).
Int("index", closest).
Any("point", point).
Msg("minimum distance to polyline")
// log.Debug().
// Float64("min distance", minDistance).
// Int("index", closest).
// Any("point", point).
// Msg("minimum distance to polyline")
return minDistance, closest
}
// projectToSegment projects the point to the segment. This function is used in DistanceFromLineString for point-to-segment distance calculation
func projectToSegment(point, a, b orb.Point) orb.Point {
x := a[0]
y := a[1]