tzf

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2022 License: MIT Imports: 4 Imported by: 12

README

TZF: a timezone finder for Go.

graph TD
    C[H3 Based Approximation file]
    D[Probuf based Bin file]
    H[Polygon search component]
    D --> |Reduce via cmd/reducePolygon|D
    A[Raw timezone boundary JSON file] --> |Convert via cmd/tzjson2pb|D
    D --> |Uber H3 Polyfill|C
    D --> H
    C --> GetTimezone
    H --> GetTimezone

TODO:

  • POC: polygon search based
  • Reduce Polygon size option
    • Reduce float precise
    • Reduce line numbers
  • H3 Based Approximation, something like Placekey

Documentation

Overview

Package tzf is a package convert (lng,lat) to timezone.

Inspired by timezonefinder https://github.com/jannikmi/timezonefinder, fast python package for finding the timezone of any point on earth (coordinates) offline.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finder

type Finder struct {
	// contains filtered or unexported fields
}

func NewFinderFromPB

func NewFinderFromPB(input *pb.Timezones) (*Finder, error)

func (*Finder) GetTimezoneLoc

func (f *Finder) GetTimezoneLoc(lng float64, lat float64) (*time.Location, error)
Example
package main

import (
	"fmt"

	"github.com/ringsaturn/tzf"
)

var f *tzf.Finder

func main() {
	fmt.Println(f.GetTimezoneLoc(116.6386, 40.0786))
}
Output:

Asia/Shanghai <nil>

func (*Finder) GetTimezoneName

func (f *Finder) GetTimezoneName(lng float64, lat float64) string
Example
package main

import (
	"fmt"

	"github.com/ringsaturn/tzf"
)

var f *tzf.Finder

func main() {
	fmt.Println(f.GetTimezoneName(116.6386, 40.0786))
}
Output:

Asia/Shanghai

Directories

Path Synopsis
cmd
tzjson2pb
CLI tool to convert GeoJSON based Timezone boundary to tzf's Probuf format.
CLI tool to convert GeoJSON based Timezone boundary to tzf's Probuf format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL