diff --git a/README.md b/README.md index afa923c9..22fdcd5e 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ to geography are not part of the core library (e.g. easting/northing conversions, ellipsoid approximations, geodetic vs. geocentric coordinates, etc). -See http://godoc.org/github.com/golang/geo for specific package documentation. +See http://pkg.go.dev/github.com/golang/geo for specific package documentation. For an analogous library in C++, see https://github.com/google/s2geometry, in Java, see https://github.com/google/s2-geometry-library-java, and Python, see @@ -98,20 +98,20 @@ Legend: * 🟔 - Mostly Complete * āŒ - Not available -## [ā„Ā¹](https://godoc.org/github.com/golang/geo/r1) - One-dimensional Cartesian coordinates +## [ā„Ā¹](https://pkg.go.dev/github.com/golang/geo/r1) - One-dimensional Cartesian coordinates C++ Type | Go :--------- | --- R1Interval | āœ… -## [ā„Ā²](https://godoc.org/github.com/golang/geo/r2) - Two-dimensional Cartesian coordinates +## [ā„Ā²](https://pkg.go.dev/github.com/golang/geo/r2) - Two-dimensional Cartesian coordinates C++ Type | Go :------- | --- R2Point | āœ… R2Rect | āœ… -## [ā„Ā³](https://godoc.org/github.com/golang/geo/r3) - Three-dimensional Cartesian coordinates +## [ā„Ā³](https://pkg.go.dev/github.com/golang/geo/r3) - Three-dimensional Cartesian coordinates C++ Type | Go :------------ | --- @@ -119,7 +119,7 @@ R3Vector | āœ… R3ExactVector | āœ… Matrix3x3 | āœ… -## [S¹](https://godoc.org/github.com/golang/geo/s1) - Circular Geometry +## [S¹](https://pkg.go.dev/github.com/golang/geo/s1) - Circular Geometry C++ Type | Go :----------- | --- @@ -127,7 +127,7 @@ S1Angle | āœ… S1ChordAngle | āœ… S1Interval | āœ… -## [S²](https://godoc.org/github.com/golang/geo/s2) - Spherical Geometry +## [S²](https://pkg.go.dev/github.com/golang/geo/s2) - Spherical Geometry ### Basic Types diff --git a/s2/cell_index_test.go b/s2/cell_index_test.go index 3ef82a97..7389d806 100644 --- a/s2/cell_index_test.go +++ b/s2/cell_index_test.go @@ -214,7 +214,7 @@ func verifyCellIndexContents(t *testing.T, desc string, index *CellIndex) { // Verify that the cell does not intersect the range. if x.cellID.RangeMin() <= r.LimitID().Prev() && x.cellID.RangeMax() >= r.StartID() { - t.Errorf("%s: CellID does not interect the current range: %v <= %v && %v >= %v", desc, x.cellID.RangeMin(), r.LimitID().Prev(), x.cellID.RangeMax(), r.StartID()) + t.Errorf("%s: CellID does not intersect the current range: %v <= %v && %v >= %v", desc, x.cellID.RangeMin(), r.LimitID().Prev(), x.cellID.RangeMax(), r.StartID()) } } } diff --git a/s2/edge_distances_test.go b/s2/edge_distances_test.go index 568ac9c1..cadac3f4 100644 --- a/s2/edge_distances_test.go +++ b/s2/edge_distances_test.go @@ -202,26 +202,26 @@ func TestEdgeDistancesUpdateMinInteriorDistanceRejectionTestIsConservative(t *te a: Point{r3.Vector{X: 1, Y: -8.9031850507928352e-11, Z: 0}}, b: Point{r3.Vector{X: -0.99999999999996347, Y: 2.7030110029169596e-07, Z: 1.555092348806121e-99}}, minDist: minDist, - want: false, + want: true, }, { x: Point{r3.Vector{X: 1, Y: -4.7617930898495072e-13, Z: 0}}, a: Point{r3.Vector{X: -1, Y: -1.6065916409055676e-10, Z: 0}}, b: Point{r3.Vector{X: 1, Y: 0, Z: 9.9964883247706732e-35}}, minDist: minDist, - want: false, + want: true, }, { x: Point{r3.Vector{X: 1, Y: 0, Z: 0}}, a: Point{r3.Vector{X: 1, Y: -8.4965026896454536e-11, Z: 0}}, b: Point{r3.Vector{X: -0.99999999999966138, Y: 8.2297529603339328e-07, Z: 9.6070344113320997e-21}}, minDist: minDist, - want: false, + want: true, }, } for _, test := range tests { - if _, ok := UpdateMinDistance(test.x, test.a, test.b, test.minDist); !ok { + if _, ok := UpdateMinDistance(test.x, test.a, test.b, test.minDist); ok != test.want { t.Errorf("UpdateMinDistance(%v, %v, %v, %v) = %v, want %v", test.x, test.a, test.b, test.minDist, ok, test.want) } } diff --git a/s2/latlng.go b/s2/latlng.go index 310c36e9..068fee95 100644 --- a/s2/latlng.go +++ b/s2/latlng.go @@ -64,7 +64,7 @@ func (ll LatLng) Distance(ll2 LatLng) s1.Angle { lng1, lng2 := ll.Lng.Radians(), ll2.Lng.Radians() dlat := math.Sin(0.5 * (lat2 - lat1)) dlng := math.Sin(0.5 * (lng2 - lng1)) - x := dlat*dlat + dlng*dlng*math.Cos(lat1)*math.Cos(lat2) + x := float64(dlat*dlat) + float64(dlng*dlng*math.Cos(lat1)*math.Cos(lat2)) return s1.Angle(2*math.Atan2(math.Sqrt(x), math.Sqrt(math.Max(0, 1-x)))) * s1.Radian } @@ -72,7 +72,7 @@ func (ll LatLng) Distance(ll2 LatLng) s1.Angle { // functions. Let's see if that's really necessary before exposing the same functionality. func latitude(p Point) s1.Angle { - return s1.Angle(math.Atan2(p.Z, math.Sqrt(p.X*p.X+p.Y*p.Y))) * s1.Radian + return s1.Angle(math.Atan2(p.Z, math.Sqrt(float64(p.X*p.X)+float64(p.Y*p.Y)))) * s1.Radian } func longitude(p Point) s1.Angle { diff --git a/s2/lexicon.go b/s2/lexicon.go index 42481cba..cb6125ce 100644 --- a/s2/lexicon.go +++ b/s2/lexicon.go @@ -129,9 +129,7 @@ func (l *sequenceLexicon) add(ids []int32) int32 { if id, ok := l.idSet[hashSet(ids)]; ok { return id } - for _, v := range ids { - l.values = append(l.values, v) - } + l.values = append(l.values, ids...) l.begins = append(l.begins, uint32(len(l.values))) id := int32(len(l.begins)) - 2 diff --git a/s2/metric_test.go b/s2/metric_test.go index 63a950cb..70f7adbc 100644 --- a/s2/metric_test.go +++ b/s2/metric_test.go @@ -30,7 +30,7 @@ func TestMetric(t *testing.T) { t.Errorf("MaxEdgeAspect = %v, want >= 1", MaxEdgeAspect) } if got := MaxEdgeMetric.Deriv / MinEdgeMetric.Deriv; MaxEdgeAspect > got { - t.Errorf("Edge Aspect: %v/%v = %v, want <= %v", MaxEdgeMetric.Deriv, MinEdgeMetric.Deriv, got, MaxDiagAspect) + t.Errorf("Edge Aspect: %v/%v = %v, want <= %v", MaxEdgeMetric.Deriv, MinEdgeMetric.Deriv, got, MaxEdgeAspect) } if MaxDiagAspect < 1 { t.Errorf("MaxDiagAspect = %v, want >= 1", MaxDiagAspect) diff --git a/s2/query_options.go b/s2/query_options.go index 9b7e38d6..84401d94 100644 --- a/s2/query_options.go +++ b/s2/query_options.go @@ -130,7 +130,7 @@ func (q *queryOptions) MaxError(x s1.ChordAngle) *queryOptions { // This must be at least 1. func (q *queryOptions) MaxResults(x int) *queryOptions { // TODO(roberts): What should be done if the value is <= 0? - q.maxResults = int(x) + q.maxResults = x return q }