From de8ffa2d5a5846274f7acca3893d16f71329197a Mon Sep 17 00:00:00 2001 From: ringsaturn Date: Sat, 11 Mar 2023 17:30:33 +0800 Subject: [PATCH 1/3] update docs --- preindex/preindex.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/preindex/preindex.go b/preindex/preindex.go index 370e8a9..1480c0c 100644 --- a/preindex/preindex.go +++ b/preindex/preindex.go @@ -17,6 +17,13 @@ // // A sample image of output tiles show on maps: // https://user-images.githubusercontent.com/13536789/200174943-7d40661e-bda5-4b79-a867-ec637e245a49.png +// +// Some areas are excluded from prefindex, since default most small tile `level==11` +// couldn't cover polygon shape details, see [tzf#76] for more backgrounds. +// Latest excluded areas can be views here [exclude.geojson] +// +// [tzf#76]: https://github.com/ringsaturn/tzf/issues/76 +// [exclude.geojson]: http://geojson.io/#data=data:text/x-url,https%3A%2F%2Fraw.githubusercontent.com%2Fringsaturn%2Ftzf%2Fmain%2Fpreindex%2Fexclude.geojson package preindex import ( @@ -46,6 +53,29 @@ func DropEdgeTiles(tiles []maptile.Tile) []maptile.Tile { tilehash[tile] = true } + /* + Tiles: + + ┌───────────┬───────────┬───────────┐ + │ │ │ │ + │ │ │ │ + │ x-1,y-1,z │ x+0,y-1,z │ x+1,y-1,z │ + │ │ │ │ + │ │ │ │ + ├───────────┼───────────┼───────────┤ + │ │ │ │ + │ │ │ │ + │ x-1,y+0,z │ x+0,y+0,z │ x+1,y+0,z │ + │ │ │ │ + │ │ │ │ + ├───────────┼───────────┼───────────┤ + │ │ │ │ + │ │ │ │ + │ x-1,y+1,z │ x+0,y+1,z │ x+1,y+1,z │ + │ │ │ │ + │ │ │ │ + └───────────┴───────────┴───────────┘ + */ // filter all neighbor in tiles for _, tile := range tiles { neighbors := []maptile.Tile{ From 553b1c4114458cd4a22240f4b833ae0781273ef0 Mon Sep 17 00:00:00 2001 From: ringsaturn Date: Sun, 12 Mar 2023 21:41:34 +0800 Subject: [PATCH 2/3] mark Deprecated --- backports.go | 3 +-- tzf.go | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/backports.go b/backports.go index 7f5d576..33230e2 100644 --- a/backports.go +++ b/backports.go @@ -2,8 +2,7 @@ package tzf // Backports support for not updated systems // -// tzf will try to maintain timezone name backport compatibility until -// new major version release will remove too old names. +// Deprecated: tzf will no longer support this feature. And wil remove in v0.13.0 var backportstz = map[string]string{ "Europe/Kyiv": "Europe/Kiev", // [2022b] https://github.com/evansiroky/timezone-boundary-builder/releases/tag/2022b commit https://github.com/evansiroky/timezone-boundary-builder/commit/ea87ea5c8bf435d8318a40eb2ab69ea2f7a375aa "Europe/Uzhgorod": "Europe/Kyiv", // [2022d] https://github.com/evansiroky/timezone-boundary-builder/releases/tag/2022d diff --git a/tzf.go b/tzf.go index a655c9d..eb3c6bf 100644 --- a/tzf.go +++ b/tzf.go @@ -192,7 +192,7 @@ func NewFinderFromCompressed(input *pb.CompressedTimezones, opts ...OptionFunc) return NewFinderFromPB(tzs, opts...) } -func getRTreeRangeShifed(lng float64, lat float64) float64 { +func getRTreeRangeShifted(lng float64, lat float64) float64 { if 73 < lng && lng < 140 && 8 < lat && lat < 54 { return 70.0 } @@ -200,19 +200,19 @@ func getRTreeRangeShifed(lng float64, lat float64) float64 { } func (f *Finder) getItemInRanges(lng float64, lat float64) []*tzitem { - candicates := []*tzitem{} + candidates := []*tzitem{} // TODO(ringsaturn): fix this range - shifted := getRTreeRangeShifed(lng, lat) + shifted := getRTreeRangeShifted(lng, lat) f.tr.Search([2]float64{lng - shifted, lat - shifted}, [2]float64{lng + shifted, lat + shifted}, func(min, max [2]float64, data *tzitem) bool { - candicates = append(candicates, data) + candidates = append(candidates, data) return true }) - if len(candicates) == 0 { - candicates = f.items + if len(candidates) == 0 { + candidates = f.items } - return candicates + return candidates } func (f *Finder) getItem(lng float64, lat float64) ([]*tzitem, error) { @@ -221,11 +221,11 @@ func (f *Finder) getItem(lng float64, lat float64) ([]*tzitem, error) { Y: float64(lat), } ret := []*tzitem{} - candicates := f.getItemInRanges(lng, lat) - if len(candicates) == 0 { + candidates := f.getItemInRanges(lng, lat) + if len(candidates) == 0 { return nil, ErrNoTimezoneFound } - for _, item := range candicates { + for _, item := range candidates { if item.ContainsPoint(p) { ret = append(ret, item) } @@ -263,6 +263,7 @@ func (f *Finder) GetTimezoneNames(lng float64, lat float64) ([]string, error) { return ret, nil } +// Deprecated: tzf will no longer support this feature. And wil remove in v0.13.0 func (f *Finder) GetTimezoneLoc(lng float64, lat float64) (*time.Location, error) { item, err := f.getItem(lng, lat) if err != nil { @@ -271,9 +272,10 @@ func (f *Finder) GetTimezoneLoc(lng float64, lat float64) (*time.Location, error return item[0].location, nil } +// Deprecated: tzf will no longer support this feature. And wil remove in v0.13.0 func (f *Finder) GetTimezone(lng float64, lat float64) (*pb.Timezone, error) { if f.opt.DropPBTZ { - return nil, errors.New("tzf: not suppor when reduce mem") + return nil, errors.New("tzf: not support when reduce mem") } item, err := f.getItem(lng, lat) if err != nil { @@ -282,6 +284,7 @@ func (f *Finder) GetTimezone(lng float64, lat float64) (*pb.Timezone, error) { return item[0].pbtz, nil } +// Deprecated: tzf will no longer support this feature. And wil remove in v0.13.0 func (f *Finder) GetTimezoneShapeByName(name string) (*pb.Timezone, error) { for _, item := range f.items { if item.name == name { @@ -291,6 +294,7 @@ func (f *Finder) GetTimezoneShapeByName(name string) (*pb.Timezone, error) { return nil, fmt.Errorf("timezone=%v not found", name) } +// Deprecated: tzf will no longer support this feature. And wil remove in v0.13.0 func (f *Finder) GetTimezoneShapeByShift(shift int) ([]*pb.Timezone, error) { if f.opt.DropPBTZ { return nil, errors.New("tzf: not suppor when reduce mem") From bcdddecd84309082f2e7916a1d30ec6eb3c4547d Mon Sep 17 00:00:00 2001 From: ringsaturn Date: Sun, 12 Mar 2023 21:45:59 +0800 Subject: [PATCH 3/3] fix typo --- tzf.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tzf.go b/tzf.go index eb3c6bf..9290f34 100644 --- a/tzf.go +++ b/tzf.go @@ -297,7 +297,7 @@ func (f *Finder) GetTimezoneShapeByName(name string) (*pb.Timezone, error) { // Deprecated: tzf will no longer support this feature. And wil remove in v0.13.0 func (f *Finder) GetTimezoneShapeByShift(shift int) ([]*pb.Timezone, error) { if f.opt.DropPBTZ { - return nil, errors.New("tzf: not suppor when reduce mem") + return nil, errors.New("tzf: not support when reduce mem") } res := make([]*pb.Timezone, 0) for _, item := range f.items {