solidarity-service/handler/haversine_distance.go

15 lines
425 B
Go
Raw Permalink Normal View History

2023-10-20 11:41:39 +00:00
package handler
import (
"github.com/paulmach/orb"
"github.com/paulmach/orb/geojson"
2023-10-20 11:47:51 +00:00
"solidarity-service/utils"
2023-10-20 11:41:39 +00:00
)
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)
}