<commit_before>package geodist

import (
	"github.com/cet001/mathext"
	"math"
)

// A geographical coordinate that represents a specific point on the earth.
type Coord struct {
	Lat float32
	Lng float32
}

// Returns the **approximate** distance (in kilometers) between coordinates c1 and
// c2.  This distance function is much faster than, say, the Haversine fomrula
// or the spherical law of cosines, as it does not take into account the
// curvature of the earth.  Instead, this function trivially takes the Euclidian
// distance between the two coordinates.  Because of this, the accuracy becomes
// worse the farther apart coordinates c1 and c2 become.
//
// This function is practical in situations where you need to calculate the
// distance between two "relatively close" points on a map (e.g. 2 houses
// located in the same neighborhood or city).
//
// See http://jonisalonen.com/2014/computing-distance-between-coordinates-can-be-simple-and-fast/
func ApproxDist(c1, c2 Coord) float64 {
	const degreeLengthKm float64 = 110.25 // length of 1 degree latitude at the equator
	x := float64(c1.Lat - c2.Lat)
	y := float64(c1.Lng-c2.Lng) * math.Cos(float64(c2.Lat)*mathext.Deg2rad)
	return degreeLengthKm * math.Sqrt((x*x)+(y*y))
}
<commit_msg>Documentation update.<commit_after>package geodist

import (
	"github.com/cet001/mathext"
	"math"
)

// A geographical coordinate that represents a specific point on the earth.
type Coord struct {
	Lat float32
	Lng float32
}

// Returns the **approximate** distance (in kilometers) between coordinates c1 and
// c2.  This distance function is much faster than, say, the Haversine fomrula
// or the spherical law of cosines, as it does not take into account the
// curvature of the earth.  Instead, ApproxDist() trivially takes the Euclidian
// distance between the two coordinates -- and as a result of this, its accuracy
// decreases as the actual distance bertween c1 and c2 increases.
//
// This function is practical in situations where you need to calculate the
// distance between two "relatively close" points on a map (e.g. 2 houses
// located in the same neighborhood or city).
//
// See http://jonisalonen.com/2014/computing-distance-between-coordinates-can-be-simple-and-fast/
func ApproxDist(c1, c2 Coord) float64 {
	const degreeLengthKm float64 = 110.25 // length of 1 degree latitude at the equator
	x := float64(c1.Lat - c2.Lat)
	y := float64(c1.Lng-c2.Lng) * math.Cos(float64(c2.Lat)*mathext.Deg2rad)
	return degreeLengthKm * math.Sqrt((x*x)+(y*y))
}

{'fraction_non_alphanumeric': 0.09773539928486293, 'fraction_numerical': 0.03178386968613429, 'mean_word_length': 3.91796875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '611823', 'n_tokens_mistral': 836, 'n_tokens_neox': 776, 'n_words': 301}