Skip to content

Errata in Activity 3.01 #4

Description

@roboli

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions