Comments (4)
The new weather data provider is DarkSky.net (#33), the JSON response for a weather query also returns the timezone (both named and as an hour offset) for the GPS coordinates -- this could be used to determine the local time and it saves us the trouble of implementing our own timezone mapping service.
from activitylog2.
Found this on Google+, but with Google+ going away, it seems prudent to save the comment here. The original link is at:
https://plus.google.com/u/0/+BradFitzpatrick/posts/XVyy1bAzkZd
Fun with rendering timezones. (with #golang , naturally)
Goal: map (lat, long) -> timezone name, with minimal memory footprint. Camlistore needs this, to know the actual time of a photo when EXIF only has local time and GPS, but not timezone (which approximately 0 cameras on the market populate). Without knowing the actual time, it's impossible to sort your photos in the web UI with respect to related foursquare checkins, tweets, etc.
I started going down the route of using S2 geometry to do this properly, but rendering a map and doing a lat-long -> pixel -> color lookup works well enough.
But keeping a 10800 x 5400 pixel image is 111 MB of memory uncompressed for our "lookup table". Or storing 9 bits per pixel (tricky) is still ~65 MB of memory. We can do better.
Most the world isn't interesting. We only need to keep memory resident for the tricky areas.
How to find the tricky areas?
-
get timezone data files from http://efele.net/maps/tz/world/
-
parse them with http://github.com/jonas-p/go-shp
-
render the polygons with +Nigel Tao's http://godoc.org/code.google.com/p/freetype-go/freetype/raster and its MonochromePainter so there are hard-edges. the color is the RGBA CRC32 of the timezone name ("America/Los_Angeles") with the alpha set to 0xff. There are no conflicts in the 408 zones.
-
cut up the world into 100x100 pixels, then 50x50, then 25x25, then 10x10, looking for regions that are all the same color (or ocean, which doesn't count). note that region is all one zone.
-
Instead, store in memory only the pixel data for the tricky borders
Now, instead of 111 MB of pixel data to keep around in memory, I can keep 280 KB of pixel data and about a half MB of hashmap data for the 28722 regions of various sizes.
Zoom in on this image to see more detail.
/cc +Mathieu Lonjaret, +Brett Slatkin
Edit: now available at https://github.com/bradfitz/latlong
from activitylog2.
NOTE: the linked commits are intended for issue #7
from activitylog2.
This was implemented, see referenced commit.
from activitylog2.
Related Issues (20)
- In Linux, when creating a new database, an incorrect dialog (open) appears instead of correct one (save). HOT 3
- division by zero HOT 1
- Lap swimming: TRACKPOINTS are linked to wrong LENGTHS HOT 19
- bug: "bsearch: unbound identifier" HOT 2
- Contract violation in edit-lab-swim.rkt HOT 3
- Heart rate data is lost after joining or splitting a swim lap. HOT 3
- HR data is missing in Lap Summary HOT 4
- Linux: ActivityLog2 freezes HOT 6
- Error in Edit Swim lap HOT 2
- Workout files don't appear anymore on the watch after copying to Newfiles HOT 2
- Humindex HOT 2
- Make a linux build HOT 3
- crashing in charts for open water swimming activity HOT 7
- Add Garmin devices HOT 1
- Wishlist: Open water swimming data series HOT 3
- gdi32.dll on win 7 HOT 2
- CombinedPedalSmoothness XDATA Howto HOT 7
- Failed to import: #(struct:exn:fail fit-file: bad file CRC #<continuation-mark-set>) HOT 3
- Fix overflowing text boxes on MacOS HOT 2
- extract-round: contract violation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from activitylog2.