<commit_before>package index

// normPoint takes the latitude and longitude of one point and return the x,y position on a world map.
// The map bounds are minimum -180,-90 and maximum 180,90. These values are x,y; not lat,lon.
func normPoint(lat, lon float64) (x float64, y float64, normd bool) {
	// Check if the rect is completely in bounds. This is likely to be the vast majority of cases.
	if lon >= -180 && lon <= 180 && lat >= -90 && lat <= 90 {
		return lon, lat, false
	}
	// TODO: replace loops with math/mod.
	for lat < -90 || lat > 90 {
		if lat < -90 {
			lat = -90 - (90 + lat)
			lon = 180 + lon
		}
		if lat > 90 {
			lat = 90 + (90 - lat)
			lon = 180 + lon
		}
	}
	for lon < -180 {
		lon += 360
	}
	for lon > 180 {
		lon -= 360
	}
	return lon, lat, true
}
<commit_msg>faster congruent modulo for points, fixes #83<commit_after>package index

import "math"

// normPoint takes the latitude and longitude of one point and return the x,y position on a world map.
// The map bounds are minimum -180,-90 and maximum 180,90. These values are x,y; not lat,lon.
func normPoint(lat, lon float64) (x, y float64, normd bool) {
	// Check if the rect is completely in bounds.
	// This is likely to be the vast majority of cases.
	if lon >= -180 && lon <= 180 && lat >= -90 && lat <= 90 {
		return lon, lat, false
	}
	lat = math.Mod(lat, 360)
	for lat < -90 || lat > 90 {
		if lat < -90 {
			lat = -90 - (90 + lat)
			lon = 180 + lon
		}
		if lat > 90 {
			lat = 90 + (90 - lat)
			lon = 180 + lon
		}
	}
	lon = math.Mod(lon, 360)
	for lon < -180 {
		lon += 360
	}
	for lon > 180 {
		lon -= 360
	}
	return lon, lat, true
}

{'fraction_non_alphanumeric': 0.12730627306273062, 'fraction_numerical': 0.07749077490774908, 'mean_word_length': 2.4617021276595743, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '2521774', 'n_tokens_mistral': 707, 'n_tokens_neox': 570, 'n_words': 248}