Skip to content

Commit 34624d3

Browse files
rsneddsymonds
authored andcommitted
s2: Move earth radius constant to common test constant.
Signed-off-by: David Symonds <dsymonds@golang.org>
1 parent af0013a commit 34624d3

File tree

4 files changed

+3
-7
lines changed

4 files changed

+3
-7
lines changed

s2/point_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ func TestOriginPoint(t *testing.T) {
3939
}
4040

4141
// Check that the origin is not too close to either pole.
42-
// The Earth's mean radius in kilometers (according to NASA).
43-
const earthRadiusKm = 6371.01
4442
if dist := math.Acos(OriginPoint().Z) * earthRadiusKm; dist <= 50 {
4543
t.Errorf("Origin point is to close to the North Pole. Got %v, want >= 50km", dist)
4644
}

s2/predicates_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ func TestPredicatesRobustSign(t *testing.T) {
227227
}
228228

229229
func TestPredicatesStableSignFailureRate(t *testing.T) {
230-
const earthRadiusKm = 6371.01
231230
const iters = 1000
232231

233232
// Verify that stableSign is able to handle most cases where the three

s2/s2_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ func float64Near(x, y, ε float64) bool {
4242

4343
// TODO(roberts): Add in flag to allow specifying the random seed for repeatable tests.
4444

45+
// The Earth's mean radius in kilometers (according to NASA).
46+
const earthRadiusKm = 6371.01
47+
4548
// kmToAngle converts a distance on the Earth's surface to an angle.
4649
func kmToAngle(km float64) s1.Angle {
47-
// The Earth's mean radius in kilometers (according to NASA).
48-
const earthRadiusKm = 6371.01
4950
return s1.Angle(km / earthRadiusKm)
5051
}
5152

s2/s2_test_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import (
2323
)
2424

2525
func TestKmToAngle(t *testing.T) {
26-
const earthRadiusKm = 6371.01
27-
2826
tests := []struct {
2927
have float64
3028
want s1.Angle

0 commit comments

Comments
 (0)