Show HN: A Simple Server to Match Long/Lat to a TimeZone

https://news.ycombinator.com/rss Hits: 6
Summary

A Server for Matching Long/Lat to Timezone Overview This project is a fairly simple PHP project, designed to accept the GeoJSON output of the Timezone Boundary Builder Project, and provide a simple API, for matching longitude/latitude locations with timezones. Send in a long/lat, and get back a string, with the standard TZ time zone designator of the timezone that covers that point. This is the GitHub repo for this project What Problem Does This Solve? Unfortunately, time zones are not a simple "I'm at this longitude, so it must be this time." They are political constructs. Here's why we can't just do a simple longitude match: Image Source: Wikimedia Commons We address this by using the rendered result of this great project, which is an effort to build a "living document" map of all the world timezones, as a shapefile (a file that can project polygons over a digital map), and locating a geographic point, within those shapes. How This Works We provide a very basic PHP server that builds a simple database from the data in the massive shapefile (The GeoJSON variant that results from the timezone boundary builder. It can be found in any of the project releases). The database is deliberately "dumb," with a view towards making the project as flexible as possible, and lookups fast and easy. Each timezone is described in a GeoJSON polygon (or multipolygon). NOTE: We are making huge assumptions about the file. We assume that the polygons are very basic, "closed" polygons, and that multipolygons are simply aggregations of simple polygons (as opposed to making "holes," and whatnot). We build a database of polygons (breaking up multipolygons), with what we term a "domain rect." This is a rectangle that encloses the entire polygon, regardless of the shape of the polygon. The "domain rect" is used for a fast "triage" lookup. Its vertices are indexed in the database, so comparisons are zippy. We can quickly find the timezones that may contain our location, and ignore the rest. In ...

First seen: 2025-05-20 22:15

Last seen: 2025-05-21 03:17