@rainder/geo-tz
Returns a precise timezone at the specific gps coordinates
Last updated a year ago by rainder .
ISC · Repository · Bugs · Original npm · Tarball
$ cnpm install @rainder/geo-tz 
SYNC missed versions from official npm registry.

geo-tz

It takes some time to load and preprocess shapefile, but once it's loaded it's super fast.

Note: both *.shp and *.dbf source files are required.

API

loadShapefile(filepath, options): Promise

options object

{
  //uses polygon minification algorithm 
  //by dropping points in the polygon.
  //WARNING: loses geometry precision if used
  minify: { //defaults to false
  
    //defines maximum amount of points in the polygon
    max_polygon_size: 150, 
    
    //precision step in meters
    precision_step: 100, 
  },
  
  //defines geo indexing precision.
  //increasing value allows to find timezone faster, but uses more memory
  index_precision: 1,
}

Usage

Download timezone shape file

$ wget http://efele.net/maps/tz/world/tz_world.zip

Load shape file into the memory

const geoTimezone = require('@rainder/geo-tz')

geoTimezone.loadShapefile('./tz_world.shp').then((tz) => {
  const point = {
    type: 'Point',
    coordinates: [-0.15, 51.5]
  };
  
  tz(point); //Europe/London
})
Maintainers (1)
Downloads
Today 0
This Week 3
This Month 3
Last Day 0
Last Week 0
Last Month 9
Dependencies (5)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |