Skip to content

Commit a06e4b3

Browse files
committed
Go 1.21 added builtin min and max methods meaning we no longer need to make our own.
1 parent 394b634 commit a06e4b3

21 files changed

+61
-61
lines changed

s2/builder_snapper.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ func (sf CellIDSnapper) MinVertexSeparation() s1.Angle {
264264
// 0.5 * MaxDiagMetric.Value(level) when snapped.
265265
minEdge := s1.Angle(MinEdgeMetric.Value(sf.level))
266266
maxDiag := s1.Angle(MaxDiagMetric.Value(sf.level))
267-
return maxAngle(minEdge,
267+
return max(minEdge,
268268
// per 2 above, a little less than 2 / sqrt(13)
269-
maxAngle(0.548*sf.snapRadius,
269+
max(0.548*sf.snapRadius,
270270
sf.snapRadius-0.5*maxDiag))
271271
}
272272

@@ -317,8 +317,8 @@ func (sf CellIDSnapper) MinEdgeVertexSeparation() s1.Angle {
317317

318318
// Otherwise, these bounds hold for any snapRadius.
319319
vertexSep := sf.MinVertexSeparation()
320-
return maxAngle(0.397*minDiag, // sqrt(3/19) in the plane
321-
maxAngle(0.219*sf.snapRadius, // 2*sqrt(3/247) in the plane
320+
return max(0.397*minDiag, // sqrt(3/19) in the plane
321+
max(0.219*sf.snapRadius, // 2*sqrt(3/247) in the plane
322322
0.5*(vertexSep/sf.snapRadius)*vertexSep))
323323
}
324324

@@ -429,14 +429,14 @@ func (sf IntLatLngSnapper) exponentForMaxSnapRadius(snapRadius s1.Angle) int {
429429
// When choosing an exponent, we need to account for the error bound of
430430
// (9 * sqrt(2) + 1.5) * dblEpsilon added by minSnapRadiusForExponent.
431431
snapRadius -= (9*math.Sqrt2 + 1.5) * dblEpsilon
432-
snapRadius = maxAngle(snapRadius, 1e-30)
432+
snapRadius = max(snapRadius, 1e-30)
433433
exponent := math.Log10((1 / math.Sqrt2) / snapRadius.Degrees())
434434

435435
// There can be small errors in the calculation above, so to ensure that
436436
// this function is the inverse of minSnapRadiusForExponent we subtract a
437437
// small error tolerance.
438-
return maxInt(minIntSnappingExponent,
439-
minInt(maxIntSnappingExponent, int(math.Ceil(exponent-2*dblEpsilon))))
438+
return max(minIntSnappingExponent,
439+
min(maxIntSnappingExponent, int(math.Ceil(exponent-2*dblEpsilon))))
440440
}
441441

442442
// MinVertexSeparation reports the minimum separation between vertices depending on
@@ -457,7 +457,7 @@ func (sf IntLatLngSnapper) MinVertexSeparation() s1.Angle {
457457
// only select a new site when it is at least snapRadius away from all
458458
// existing sites, and snapping a vertex can move it by up to
459459
// ((1 / sqrt(2)) * sf.to) degrees.
460-
return maxAngle(0.471*sf.snapRadius, // sqrt(2)/3 in the plane
460+
return max(0.471*sf.snapRadius, // sqrt(2)/3 in the plane
461461
sf.snapRadius-s1.Degree*s1.Angle(1/math.Sqrt2)*sf.to)
462462
}
463463

@@ -489,8 +489,8 @@ func (sf IntLatLngSnapper) MinEdgeVertexSeparation() s1.Angle {
489489
// bound approaches 0.5 * snapRadius as the snap radius becomes large
490490
// relative to the grid spacing.
491491
vertexSep := sf.MinVertexSeparation()
492-
return maxAngle(0.277*s1.Degree*sf.to, // 1/sqrt(13) in the plane
493-
maxAngle(0.222*sf.snapRadius, // 2/9 in the plane
492+
return max(0.277*s1.Degree*sf.to, // 1/sqrt(13) in the plane
493+
max(0.222*sf.snapRadius, // 2/9 in the plane
494494
0.5*(vertexSep/sf.snapRadius)*vertexSep))
495495
}
496496

s2/builder_snapper_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func TestCellIDSnapperLevelToFromSnapRadius(t *testing.T) {
5050
if got := f.levelForMaxSnapRadius(radius); got != level {
5151
t.Errorf("levelForMaxSnapRadius(%v) = %v, want %v", radius, got, level)
5252
}
53-
if got, want := f.levelForMaxSnapRadius(0.999*radius), minInt(level+1, MaxLevel); got != want {
53+
if got, want := f.levelForMaxSnapRadius(0.999*radius), min(level+1, MaxLevel); got != want {
5454
t.Errorf("levelForMaxSnapRadius(0.999*%v) = %v, want %v (level %d)", radius, got, want, level)
5555
}
5656
}
@@ -84,7 +84,7 @@ func TestIntLatLngSnapperExponentToFromSnapRadius(t *testing.T) {
8484
if got := sf.exponentForMaxSnapRadius(radius); got != exp {
8585
t.Errorf("exponentForMaxSnapRadius(%v) = %v, want %v", radius, got, exp)
8686
}
87-
if got, want := sf.exponentForMaxSnapRadius(0.999*radius), minInt(exp+1, maxIntSnappingExponent); got != want {
87+
if got, want := sf.exponentForMaxSnapRadius(0.999*radius), min(exp+1, maxIntSnappingExponent); got != want {
8888
t.Errorf("exponentForMaxSnapRadius(%v) = %v, want %v", 0.999*radius, got, want)
8989
}
9090
}

s2/cell.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ func (c Cell) distanceInternal(targetXYZ Point, toInterior bool) s1.ChordAngle {
622622
// arbitrary quadrilaterals after they are projected onto the sphere.
623623
// Therefore the simplest approach is just to find the minimum distance to
624624
// any of the four edges.
625-
return minChordAngle(edgeDistance(-dir00, c.uv.X.Lo),
625+
return min(edgeDistance(-dir00, c.uv.X.Lo),
626626
edgeDistance(dir01, c.uv.X.Hi),
627627
edgeDistance(-dir10, c.uv.Y.Lo),
628628
edgeDistance(dir11, c.uv.Y.Hi))
@@ -633,7 +633,7 @@ func (c Cell) distanceInternal(targetXYZ Point, toInterior bool) s1.ChordAngle {
633633
// tests above, because (1) the edges don't meet at right angles and (2)
634634
// there are points on the far side of the sphere that are both above *and*
635635
// below the cell, etc.
636-
return minChordAngle(c.vertexChordDist2(target, false, false),
636+
return min(c.vertexChordDist2(target, false, false),
637637
c.vertexChordDist2(target, true, false),
638638
c.vertexChordDist2(target, false, true),
639639
c.vertexChordDist2(target, true, true))
@@ -651,7 +651,7 @@ func (c Cell) MaxDistance(target Point) s1.ChordAngle {
651651
// First check the 4 cell vertices. If all are within the hemisphere
652652
// centered around target, the max distance will be to one of these vertices.
653653
targetUVW := faceXYZtoUVW(int(c.face), target)
654-
maxDist := maxChordAngle(c.vertexChordDist2(targetUVW, false, false),
654+
maxDist := max(c.vertexChordDist2(targetUVW, false, false),
655655
c.vertexChordDist2(targetUVW, true, false),
656656
c.vertexChordDist2(targetUVW, false, true),
657657
c.vertexChordDist2(targetUVW, true, true))
@@ -685,7 +685,7 @@ func (c Cell) DistanceToEdge(a, b Point) s1.ChordAngle {
685685

686686
// First, check the minimum distance to the edge endpoints A and B.
687687
// (This also detects whether either endpoint is inside the cell.)
688-
minDist := minChordAngle(c.Distance(a), c.Distance(b))
688+
minDist := min(c.Distance(a), c.Distance(b))
689689
if minDist == 0 {
690690
return minDist
691691
}
@@ -717,7 +717,7 @@ func (c Cell) MaxDistanceToEdge(a, b Point) s1.ChordAngle {
717717
// If the maximum distance from both endpoints to the cell is less than π/2
718718
// then the maximum distance from the edge to the cell is the maximum of the
719719
// two endpoint distances.
720-
maxDist := maxChordAngle(c.MaxDistance(a), c.MaxDistance(b))
720+
maxDist := max(c.MaxDistance(a), c.MaxDistance(b))
721721
if maxDist <= s1.RightChordAngle {
722722
return maxDist
723723
}

s2/cellid_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func TestCellIDAllNeighbors(t *testing.T) {
296296

297297
// testAllNeighbors computes approximately 2**(2*(diff+1)) cell ids,
298298
// so it's not reasonable to use large values of diff.
299-
maxDiff := minInt(6, MaxLevel-id.Level()-1)
299+
maxDiff := min(6, MaxLevel-id.Level()-1)
300300
level := id.Level() + randomUniformInt(maxDiff)
301301

302302
// We compute AllNeighbors, and then add in all the children of id

s2/cellunion.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ func (cu *CellUnion) ExpandAtLevel(level int) {
491491
func (cu *CellUnion) ExpandByRadius(minRadius s1.Angle, maxLevelDiff int) {
492492
minLevel := MaxLevel
493493
for _, cid := range *cu {
494-
minLevel = minInt(minLevel, cid.Level())
494+
minLevel = min(minLevel, cid.Level())
495495
}
496496

497497
// Find the maximum level such that all cells are at least "minRadius" wide.
@@ -501,7 +501,7 @@ func (cu *CellUnion) ExpandByRadius(minRadius s1.Angle, maxLevelDiff int) {
501501
// The easiest way to handle this is to expand twice.
502502
cu.ExpandAtLevel(0)
503503
}
504-
cu.ExpandAtLevel(minInt(minLevel+maxLevelDiff, radiusLevel))
504+
cu.ExpandAtLevel(min(minLevel+maxLevelDiff, radiusLevel))
505505
}
506506

507507
// Equal reports whether the two CellUnions are equal.

s2/cellunion_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,9 +933,9 @@ func TestCellUnionExpand(t *testing.T) {
933933
// that figures out an appropriate cell level to use for the expansion.
934934
minLevel := MaxLevel
935935
for _, cid := range covering {
936-
minLevel = minInt(minLevel, cid.Level())
936+
minLevel = min(minLevel, cid.Level())
937937
}
938-
expandLevel := minInt(minLevel+maxLevelDiff, MinWidthMetric.MaxLevel(radius))
938+
expandLevel := min(minLevel+maxLevelDiff, MinWidthMetric.MaxLevel(radius))
939939

940940
// Generate a covering for the expanded cap, and measure the new maximum
941941
// distance from the cap center to any point in the covering.

s2/edge_crossings_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ func TestEdgeutilIntersectionError(t *testing.T) {
120120
if got, want := pointDist, intersectionError; got > want {
121121
t.Errorf("%v.Distance(%v) = %v want <= %v", expected, actual, got, want)
122122
}
123-
maxEdgeDist = maxAngle(maxEdgeDist, maxAngle(distAB, distCD))
124-
maxPointDist = maxAngle(maxPointDist, pointDist)
123+
maxEdgeDist = max(maxEdgeDist, max(distAB, distCD))
124+
maxPointDist = max(maxPointDist, pointDist)
125125
}
126126
}
127127

s2/edge_distances.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func UpdateMinDistance(x, a, b Point, minDist s1.ChordAngle) (s1.ChordAngle, boo
6060
// than maxDist, and if so, returns the updated value and true.
6161
// Otherwise it returns false. The case A == B is handled correctly.
6262
func UpdateMaxDistance(x, a, b Point, maxDist s1.ChordAngle) (s1.ChordAngle, bool) {
63-
dist := maxChordAngle(ChordAngleBetweenPoints(x, a), ChordAngleBetweenPoints(x, b))
63+
dist := max(ChordAngleBetweenPoints(x, a), ChordAngleBetweenPoints(x, b))
6464
if dist > s1.RightChordAngle {
6565
dist, _ = updateMinDistance(Point{x.Mul(-1)}, a, b, dist, true)
6666
dist = s1.StraightChordAngle - dist

s2/edge_query_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ func generateEdgeQueryWithTargets(opts *edgeQueryBenchmarkOptions, query *EdgeQu
448448
numTargets := maxTargetsPerIndex
449449
if opts.targetType == queryTypeIndex {
450450
// Limit the total number of target edges to reduce the benchmark running times.
451-
numTargets = minInt(numTargets, 500000/opts.numTargetEdges)
451+
numTargets = min(numTargets, 500000/opts.numTargetEdges)
452452
}
453453

454454
for i := 0; i < numTargets; i++ {

s2/edge_tessellator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ type EdgeTessellator struct {
196196
func NewEdgeTessellator(p Projection, tolerance s1.Angle) *EdgeTessellator {
197197
return &EdgeTessellator{
198198
projection: p,
199-
scaledTolerance: s1.ChordAngleFromAngle(maxAngle(tolerance, minTessellationTolerance)),
199+
scaledTolerance: s1.ChordAngleFromAngle(max(tolerance, minTessellationTolerance)),
200200
}
201201
}
202202

@@ -287,5 +287,5 @@ func (e *EdgeTessellator) estimateMaxError(pa r2.Point, a Point, pb r2.Point, b
287287
mid2 := Interpolate(t2, a, b)
288288
pmid1 := e.projection.Unproject(e.projection.Interpolate(t1, pa, pb))
289289
pmid2 := e.projection.Unproject(e.projection.Interpolate(t2, pa, pb))
290-
return maxChordAngle(ChordAngleBetweenPoints(mid1, pmid1), ChordAngleBetweenPoints(mid2, pmid2))
290+
return max(ChordAngleBetweenPoints(mid1, pmid1), ChordAngleBetweenPoints(mid2, pmid2))
291291
}

s2/index_cell_data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ func (d *indexCellData) dimRangeEdges(dim0, dim1 int) []edgeAndIDChain {
314314
size := 0
315315

316316
for dim := dim0; dim <= dim1; dim++ {
317-
start = minInt(start, d.dimRegions[dim].start)
317+
start = min(start, d.dimRegions[dim].start)
318318
size += d.dimRegions[dim].size
319319
}
320320

s2/lax_loop.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (l *LaxLoop) Edge(e int) Edge {
6969
}
7070
func (l *LaxLoop) Dimension() int { return 2 }
7171
func (l *LaxLoop) ReferencePoint() ReferencePoint { return referencePointForShape(l) }
72-
func (l *LaxLoop) NumChains() int { return minInt(1, l.numVertices) }
72+
func (l *LaxLoop) NumChains() int { return min(1, l.numVertices) }
7373
func (l *LaxLoop) Chain(i int) Chain { return Chain{0, l.numVertices} }
7474
func (l *LaxLoop) ChainEdge(i, j int) Edge {
7575
var k int

s2/lax_polyline.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ func LaxPolylineFromPolyline(p Polyline) *LaxPolyline {
4040
return LaxPolylineFromPoints(p)
4141
}
4242

43-
func (l *LaxPolyline) NumEdges() int { return maxInt(0, len(l.vertices)-1) }
43+
func (l *LaxPolyline) NumEdges() int { return max(0, len(l.vertices)-1) }
4444
func (l *LaxPolyline) Edge(e int) Edge { return Edge{l.vertices[e], l.vertices[e+1]} }
4545
func (l *LaxPolyline) ReferencePoint() ReferencePoint { return OriginReferencePoint(false) }
46-
func (l *LaxPolyline) NumChains() int { return minInt(1, l.NumEdges()) }
46+
func (l *LaxPolyline) NumChains() int { return min(1, l.NumEdges()) }
4747
func (l *LaxPolyline) Chain(i int) Chain { return Chain{0, l.NumEdges()} }
4848
func (l *LaxPolyline) ChainEdge(i, j int) Edge { return Edge{l.vertices[j], l.vertices[j+1]} }
4949
func (l *LaxPolyline) ChainPosition(e int) ChainPosition { return ChainPosition{0, e} }

s2/point.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ func (p Point) IsNormalizable() bool {
334334
//
335335
// The fastest way to ensure this is to test whether the largest component of
336336
// the result has a magnitude of at least 2**-242.
337-
return maxFloat64(math.Abs(p.X), math.Abs(p.Y), math.Abs(p.Z)) >= math.Ldexp(1, -242)
337+
return max(math.Abs(p.X), math.Abs(p.Y), math.Abs(p.Z)) >= math.Ldexp(1, -242)
338338
}
339339

340340
// EnsureNormalizable scales a vector as necessary to ensure that the result can
@@ -355,7 +355,7 @@ func (p Point) EnsureNormalizable() Point {
355355
// Note that we must scale by a power of two to avoid rounding errors.
356356
// The code below scales "p" such that the largest component is
357357
// in the range [1, 2).
358-
pMax := maxFloat64(math.Abs(p.X), math.Abs(p.Y), math.Abs(p.Z))
358+
pMax := max(math.Abs(p.X), math.Abs(p.Y), math.Abs(p.Z))
359359

360360
// This avoids signed overflow for any value of Ilogb().
361361
return Point{p.Mul(math.Ldexp(2, -1-math.Ilogb(pMax)))}

s2/point_measures.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func PointArea(a, b, c Point) float64 {
6666
s := 0.5 * (sa + sb + sc)
6767
if s >= 3e-4 {
6868
// Consider whether Girard's formula might be more accurate.
69-
dmin := s - maxAngle(sa, sb, sc)
69+
dmin := s - max(sa, sb, sc)
7070
if dmin < 1e-2*s*s*s*s*s {
7171
// This triangle is skinny enough to use Girard's formula.
7272
area := GirardArea(a, b, c)

s2/polyline.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func (p *Polyline) ReferencePoint() ReferencePoint {
190190

191191
// NumChains reports the number of contiguous edge chains in this Polyline.
192192
func (p *Polyline) NumChains() int {
193-
return minInt(1, p.NumEdges())
193+
return min(1, p.NumEdges())
194194
}
195195

196196
// Chain returns the i-th edge Chain in the Shape.
@@ -578,7 +578,7 @@ func (p *Polyline) Uninterpolate(point Point, nextVertex int) float64 {
578578
}
579579
// The ratio can be greater than 1.0 due to rounding errors or because the
580580
// point is not exactly on the polyline.
581-
return minFloat64(1.0, float64(lengthToPoint/sum))
581+
return min(1.0, float64(lengthToPoint/sum))
582582
}
583583

584584
// TODO(roberts): Differences from C++.

s2/polyline_alignment.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,11 @@ func (w *window) dilate(radius int) *window {
271271

272272
newStrides := make([]columnStride, w.rows)
273273
for row := 0; row < w.rows; row++ {
274-
prevRow := maxInt(0, row-radius)
275-
nextRow := minInt(row+radius, w.rows-1)
274+
prevRow := max(0, row-radius)
275+
nextRow := min(row+radius, w.rows-1)
276276
newStrides[row] = columnStride{
277-
start: maxInt(0, w.strides[prevRow].start-radius),
278-
end: minInt(w.strides[nextRow].end+radius, w.cols),
277+
start: max(0, w.strides[prevRow].start-radius),
278+
end: min(w.strides[nextRow].end+radius, w.cols),
279279
}
280280
}
281281

@@ -458,7 +458,7 @@ func dynamicTimewarp(a, b *Polyline, w *window) *vertexAlignment {
458458
uCost := costs.boundsCheckedTableCost(row-1, col-0, prev)
459459
lCost := costs.boundsCheckedTableCost(row-0, col-1, curr)
460460

461-
costs[row][col] = minFloat64(dCost, uCost, lCost) +
461+
costs[row][col] = min(dCost, uCost, lCost) +
462462
(*a)[row].Sub((*b)[col].Vector).Norm()
463463
}
464464
prev = curr
@@ -473,7 +473,7 @@ func dynamicTimewarp(a, b *Polyline, w *window) *vertexAlignment {
473473
// this incurs is larger than the cost to simply redo the comparisons.
474474
// It's probably worth revisiting this assumption in the future.
475475
// As it turns out, the following code ends up effectively free.
476-
warpPath := make([]warpPair, 0, maxInt(rows, cols))
476+
warpPath := make([]warpPair, 0, max(rows, cols))
477477
row := rows - 1
478478
col := cols - 1
479479
curr = w.checkedColumnStride(row)

s2/polyline_alignment_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ func bruteForceCost(table costTable, i, j int) float64 {
345345
} else if j == 0 {
346346
return bruteForceCost(table, i-1, j) + table[i][j]
347347
} else {
348-
return minFloat64(bruteForceCost(table, i-1, j-1),
348+
return min(bruteForceCost(table, i-1, j-1),
349349
bruteForceCost(table, i-1, j),
350350
bruteForceCost(table, i, j-1)) +
351351
table[i][j]

s2/rect.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ func (r *Rect) decode(d *decoder) {
468468
// The latlng must be valid.
469469
func (r Rect) DistanceToLatLng(ll LatLng) s1.Angle {
470470
if r.Lng.Contains(float64(ll.Lng)) {
471-
return maxAngle(0, ll.Lat-s1.Angle(r.Lat.Hi), s1.Angle(r.Lat.Lo)-ll.Lat)
471+
return max(0, ll.Lat-s1.Angle(r.Lat.Hi), s1.Angle(r.Lat.Lo)-ll.Lat)
472472
}
473473

474474
i := s1.IntervalFromEndpoints(r.Lng.Hi, r.Lng.ComplementCenter())
@@ -505,7 +505,7 @@ func (r Rect) DirectedHausdorffDistance(other Rect) s1.Angle {
505505
//
506506
// H(A, B) = max{h(A, B), h(B, A)}.
507507
func (r Rect) HausdorffDistance(other Rect) s1.Angle {
508-
return maxAngle(r.DirectedHausdorffDistance(other),
508+
return max(r.DirectedHausdorffDistance(other),
509509
other.DirectedHausdorffDistance(r))
510510
}
511511

@@ -567,14 +567,14 @@ func directedHausdorffDistance(lngDiff s1.Angle, a, b r1.Interval) s1.Angle {
567567
// Cases A1 and B1.
568568
aLo := PointFromLatLng(LatLng{s1.Angle(a.Lo), 0})
569569
aHi := PointFromLatLng(LatLng{s1.Angle(a.Hi), 0})
570-
maxDistance := maxAngle(
570+
maxDistance := max(
571571
DistanceFromSegment(aLo, bLo, bHi),
572572
DistanceFromSegment(aHi, bLo, bHi))
573573

574574
if lngDiff <= math.Pi/2 {
575575
// Case A2.
576576
if a.Contains(0) && b.Contains(0) {
577-
maxDistance = maxAngle(maxDistance, lngDiff)
577+
maxDistance = max(maxDistance, lngDiff)
578578
}
579579
return maxDistance
580580
}
@@ -583,20 +583,20 @@ func directedHausdorffDistance(lngDiff s1.Angle, a, b r1.Interval) s1.Angle {
583583
p := bisectorIntersection(b, bLng)
584584
pLat := LatLngFromPoint(p).Lat
585585
if a.Contains(float64(pLat)) {
586-
maxDistance = maxAngle(maxDistance, p.Angle(bLo.Vector))
586+
maxDistance = max(maxDistance, p.Angle(bLo.Vector))
587587
}
588588

589589
// Case B3.
590590
if pLat > s1.Angle(a.Lo) {
591591
intDist, ok := interiorMaxDistance(r1.Interval{Lo: a.Lo, Hi: math.Min(float64(pLat), a.Hi)}, bLo)
592592
if ok {
593-
maxDistance = maxAngle(maxDistance, intDist)
593+
maxDistance = max(maxDistance, intDist)
594594
}
595595
}
596596
if pLat < s1.Angle(a.Hi) {
597597
intDist, ok := interiorMaxDistance(r1.Interval{Lo: math.Max(float64(pLat), a.Lo), Hi: a.Hi}, bHi)
598598
if ok {
599-
maxDistance = maxAngle(maxDistance, intDist)
599+
maxDistance = max(maxDistance, intDist)
600600
}
601601
}
602602

0 commit comments

Comments
 (0)