-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
I got different results because your code is different from that from the book:
(def walking-speed 4)
Book says:
... and an average of walking speed of 5 km per hour.
(defn distance
"Returns a rough estimate of the distance between two coordinate points, in kilometers. Works better with smaller distance"
[{lat1 :lat lon1 :lon} {lat2 :lat lon2 :lon}]
(let [deglen 110.25
x (- lat2 lat1)
y (* (Math/cos lat2) (- lon2 lon1))]
(* deglen (Math/sqrt (+ (* y y) (* x x))))))
Book has:
110.25 * sqrt((lat2 - lat1)^2 + cos(lat1) * (lon2 - lon1)^2)
Please notice that has cos(lat1) not cos(lat2)
Metadata
Metadata
Assignees
Labels
No labels