From 7c031547063d7e250388202432a23b5f68ba6645 Mon Sep 17 00:00:00 2001 From: Andrea Giacobino Date: Sat, 29 Jun 2024 19:55:29 +0200 Subject: [PATCH] feat: remove unnecessary Size function --- db/db.go | 1 - db/rtree.go | 7 ------- db/rtree_test.go | 2 -- 3 files changed, 10 deletions(-) diff --git a/db/db.go b/db/db.go index 8ecbb78..e015c5b 100644 --- a/db/db.go +++ b/db/db.go @@ -4,7 +4,6 @@ import "errors" type TzDBIndex interface { Lookup(lat, lon float64) (string, error) - Size() int } var ( diff --git a/db/rtree.go b/db/rtree.go index 37bd9f1..ff4174c 100644 --- a/db/rtree.go +++ b/db/rtree.go @@ -15,7 +15,6 @@ import ( type Geo2TzRTreeIndex struct { land rtree.RTreeG[timezoneGeo] sea rtree.RTreeG[timezoneGeo] - size int } // IsOcean checks if the timezone is for oceans @@ -25,7 +24,6 @@ func IsOcean(label string) bool { // Insert adds a new timezone bounding box to the index func (g *Geo2TzRTreeIndex) Insert(min, max [2]float64, element timezoneGeo) { - g.size++ if IsOcean(element.Name) { g.sea.Insert(min, max, element) return @@ -117,11 +115,6 @@ func (g *Geo2TzRTreeIndex) Lookup(lat, lng float64) (tzID string, err error) { return } -// Size returns the number of timezones in the index -func (g *Geo2TzRTreeIndex) Size() int { - return g.size -} - // isPointInPolygonPIP checks if a point is inside a polygon using the Point in Polygon algorithm func isPointInPolygonPIP(point vertex, polygon polygon) bool { oddNodes := false diff --git a/db/rtree_test.go b/db/rtree_test.go index e717005..ba4f3ed 100644 --- a/db/rtree_test.go +++ b/db/rtree_test.go @@ -21,7 +21,6 @@ func TestGeo2TzTreeIndex_LookupZone(t *testing.T) { // load the database gsi, err := NewGeo2TzRTreeIndexFromGeoJSON("../tzdata/timezones.zip") assert.NoError(t, err) - assert.NotEmpty(t, gsi.Size()) // load the coordinates err = helpers.LoadJSON("testdata/coordinates.json", &tests) @@ -46,7 +45,6 @@ func BenchmarkGeo2TzTreeIndex_LookupZone(b *testing.B) { // load the database gsi, err := NewGeo2TzRTreeIndexFromGeoJSON("../tzdata/timezones.zip") assert.NoError(b, err) - assert.NotEmpty(b, gsi.Size()) // load the coordinates var tests []struct {