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 NewFinderFromRawJSON ¶ added in v0.2.0
func NewFinderFromRawJSON(input *convert.BoundaryFile) (*Finder, error)
func (*Finder) GetTimezoneLoc ¶
Example ¶
package main
import (
"fmt"
"github.com/ringsaturn/tzf"
tzfrel "github.com/ringsaturn/tzf-rel"
"github.com/ringsaturn/tzf/pb"
"google.golang.org/protobuf/proto"
)
func main() {
input := &pb.Timezones{}
// Lite data, about 16.7MB
dataFile := tzfrel.LiteData
// Full data, about 83.5MB
// dataFile := tzfrel.FullData
if err := proto.Unmarshal(dataFile, input); err != nil {
panic(err)
}
finder, _ := tzf.NewFinderFromPB(input)
fmt.Println(finder.GetTimezoneLoc(116.6386, 40.0786))
}
Output: Asia/Shanghai <nil>
func (*Finder) GetTimezoneName ¶
Example ¶
package main
import (
"fmt"
"github.com/ringsaturn/tzf"
tzfrel "github.com/ringsaturn/tzf-rel"
"github.com/ringsaturn/tzf/pb"
"google.golang.org/protobuf/proto"
)
func main() {
input := &pb.Timezones{}
// Lite data, about 16.7MB
dataFile := tzfrel.LiteData
// Full data, about 83.5MB
// dataFile := tzfrel.FullData
if err := proto.Unmarshal(dataFile, input); err != nil {
panic(err)
}
finder, _ := tzf.NewFinderFromPB(input)
fmt.Println(finder.GetTimezoneName(116.6386, 40.0786))
}
Output: Asia/Shanghai
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
reducePolygon
command
CLI tool to reduce polygon filesize
|
CLI tool to reduce polygon filesize |
|
tzjson2pb
command
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. |
|
Package reduce could reduce Polygon size both polygon lines and float precise.
|
Package reduce could reduce Polygon size both polygon lines and float precise. |
Click to show internal directories.
Click to hide internal directories.