solidarity-service/handler/haversine_distance.go

15 lines
425 B
Go

package handler
import (
"github.com/paulmach/orb"
"github.com/paulmach/orb/geojson"
"solidarity-service/utils"
)
func (handler *SolidarityServiceHandler) CalculateDistanceBetweenFeatures(feature1, feature2 *geojson.Feature) int64 {
coords1 := feature1.Geometry.(orb.Point)
coords2 := feature2.Geometry.(orb.Point)
distance := utils.Haversine(coords1[1], coords1[0], coords2[1], coords2[0])
return int64(distance)
}