Code Monkey home page Code Monkey logo

espgpstimezone's Introduction

ESP GPS TimeZone

This is a library to determine the timezone for a given GPS coordinate. The library uses the combined-with-oceans.json file found at Timezone Boundary Builder. This file is processed by the code in the GeoJson directory to produce the per timezone files found in the SDCard/TimeZoneJson directory. All the timezone JSON files total over 230 Megabytes and an SD card or other large storage is required for all timezones, but a subset of the files can be supported by the flash filesystem.

Using the library

An ESPGPSTimeZone object is first created specifying the filesystem and the path to the timezone JSON files. findTZ can then be called to lookup the timezone for a given coordinate. If the lookup is successful the timezone name, posix timezone specification, and radius are available. Radius can be used to check if a new coordinate is in the same timezone without having to process any timezone JSON files.

Declaring the ESPGPSTimeZone object

ESPGPSTimeZone objectName(fs::FS& fileSys, const char* path);
  • fileSys - the file system for the configFileName (LittleFS, SPIFFS, SD)
  • path - the path to the timezone JSON files

Object Methods

bool findTZ(double lat, double longi)
  • lat - the latitude of the GPS coordinate
  • longi - the longitude of the GPS coordinate

Find the timezone of the GPS coordinate, returning false if the timezone can not be found

bool inCircle(double centerLat, double centerLong,
              double locationLat, double locationLong, double radius)
bool inCircle(std::array<double, 2> center, std::array<double, 2> location,
              double radius)
  • centerLat - the latitude of the circle center GPS coordinate
  • centerLong - the longitude of the circle center GPS coordinate
  • locationLat - the latitude of the location GPS coordinate
  • locationLong - the longitude of the location GPS coordinate
  • radius - the radius of the circle
  • center - the circle center GPS coordinate { longitude, latitude }
  • location - the location GPS coordinate { longitude, latitude }

Determine if a given GPS coordinate is within a circle defined by the center coordinate and the radius. This allows a GPS coordinate (center) and radius to be stored and used to determine if a new location is in the same timezone without having to process any timezone JSON files.

const char* tzName()

Get the timezone name.

const char* posix()

Get the timezone posix specification.

double radius()

Get radius of the current lookup. Then a coordinate is successfully looked up the radius value is set so that any point inside the circle defined by the coordinate and radius is guaranteed to be in the same timezone as the coordinate.

espgpstimezone's People

Contributors

abaskin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.