Socket
Book a DemoInstallSign in
Socket

@rainder/geo-tz

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rainder/geo-tz

Returns a precise timezone at the specific gps coordinates

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

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.

Installation

npm install @rainder/geo-tz

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
})

Keywords

gps

FAQs

Package last updated on 13 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts