Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Commit

Permalink
fix #17
Browse files Browse the repository at this point in the history
  • Loading branch information
J. T. L committed Jan 23, 2018
1 parent 15e81f5 commit d48e1cc
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 53 deletions.
24 changes: 0 additions & 24 deletions pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,6 @@ function force_urban(lat, lon, buffer) {
}
}

function force_tz(lat, lon, tzid, buffer, tile_x, tile_y) {
const tile_size = width / 4;

const x = (180 + lon) * width / 360.00000000000006 - tile_x * tile_size,
y = ( 90 - lat) * height / 180.00000000000003 - tile_y * tile_size,
z = index.indexOf(tzid) + 1;
if(z === 0) {
return;
}

const r = 10,
min_x = constrain(Math.floor(x - r ), 0, tile_size),
min_y = constrain(Math.floor(y - r ), 0, tile_size),
max_x = constrain(Math.floor(x + r + 1), 0, tile_size),
max_y = constrain(Math.floor(y + r + 1), 0, tile_size);
for(let y = min_y; y < max_y; y++) {
for(let x = min_x; x < max_x; x++) {
buffer.writeUInt16BE(z, (y * tile_size + x) * 2);
}
}
}

function fine(urban_data, urban_x, urban_y, tz_data, tz_x, tz_y, size) {
const tz_width = width / 4;
const tz_height = height / 4;
Expand Down Expand Up @@ -151,8 +129,6 @@ function coarse() {
for(let x = 0; x < 4; x++) {
read("tz_" + (y * 4 + x + 10).toString(36) + ".pgm", 21, tz_data);

force_tz(36.9147, -111.4558, "America/Phoenix", tz_data, x, y);

for(let v = 0; v < 12; v++) {
for(let u = 0; u < 12; u++) {
root[(y * 12 + v) * 48 + (x * 12 + u)] = fine(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tz-lookup",
"version": "6.1.3",
"version": "6.1.4",
"description": "fast time zone lookup",
"main": "tz.js",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion rebuild.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -e
TZ="2017a"
TZ="2017c"

# get data
curl -L \
Expand Down
24 changes: 0 additions & 24 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,13 @@ describe("tzlookup", function() {
[[-29.3372, -56.9745], "America/Argentina/Cordoba"],
[[ 82.3141, -39.1331], "America/Godthab"],
[[ 54.1241, 95.1606], "Asia/Krasnoyarsk"],
[[ 35.8970, 105.0863], "Asia/Chongqing"],
[[ -3.6445, 24.5964], "Africa/Lubumbashi"],
[[ 21.9200, 76.3888], "Asia/Kolkata"],
[[ 81.0433, -78.2488], "America/Iqaluit"],
[[ 41.4793, -2.7493], "Europe/Madrid"],
[[ 16.5041, 103.0204], "Asia/Bangkok"],
[[ 72.4750, -122.6775], "America/Yellowknife"],
[[ 64.9576, 144.3597], "Asia/Srednekolymsk"],
[[ 27.0518, 107.9761], "Asia/Chongqing"],
[[ 20.2716, 28.7996], "Africa/Khartoum"],
[[-18.6123, 137.4460], "Australia/Darwin"],
[[ 57.0724, 104.8747], "Asia/Irkutsk"],
Expand Down Expand Up @@ -194,7 +192,6 @@ describe("tzlookup", function() {
[[ 19.8781, 9.8020], "Africa/Niamey"],
[[ 65.0340, -155.4731], "America/Anchorage"],
[[ 21.2294, 102.3456], "Asia/Vientiane"],
[[ 31.3878, 97.7606], "Asia/Urumqi"],
[[ 14.6321, 74.8661], "Asia/Kolkata"],
[[ 73.9279, 56.0125], "Europe/Moscow"],
[[ 61.0509, 79.4277], "Asia/Yekaterinburg"],
Expand All @@ -206,7 +203,6 @@ describe("tzlookup", function() {
[[ 20.1117, 53.8416], "Asia/Riyadh"],
[[ 66.7761, 148.5291], "Asia/Srednekolymsk"],
[[ -5.3391, 16.3601], "Africa/Kinshasa"],
[[ 38.5756, 94.5492], "Asia/Urumqi"],
[[ 27.3337, 40.2867], "Asia/Riyadh"],
[[ 19.2194, 19.0398], "Africa/Ndjamena"],
[[ 5.0789, 34.1745], "Africa/Juba"],
Expand All @@ -223,7 +219,6 @@ describe("tzlookup", function() {
[[ 74.5094, -46.1125], "America/Godthab"],
[[-18.0039, 137.1668], "Australia/Darwin"],
[[ 3.1497, -63.0510], "America/Boa_Vista"],
[[ 36.0659, 98.8804], "Asia/Urumqi"],
[[ 48.6762, 79.7838], "Asia/Almaty"],
[[ 59.6321, 35.7763], "Europe/Moscow"],
[[ 31.9457, -89.0334], "America/Chicago"],
Expand Down Expand Up @@ -261,7 +256,6 @@ describe("tzlookup", function() {
[[ -2.6981, -73.2412], "America/Lima"],
[[ -4.9274, -65.3226], "America/Manaus"],
[[ 71.1648, -117.7618], "America/Yellowknife"],
[[ 39.9430, 95.8967], "Asia/Urumqi"],
[[ 58.5594, 34.6095], "Europe/Moscow"],
[[ 55.2956, 32.0908], "Europe/Moscow"],
[[-15.3693, 36.5350], "Africa/Maputo"],
Expand All @@ -272,13 +266,10 @@ describe("tzlookup", function() {
[[-22.7467, 130.6468], "Australia/Darwin"],
[[ 63.8349, 152.5360], "Asia/Magadan"],
[[-20.7583, 120.7570], "Australia/Perth"],
[[ 36.4171, 87.8762], "Asia/Urumqi"],
[[ 62.7709, -118.4994], "America/Yellowknife"],
[[ 21.2630, 17.5662], "Africa/Ndjamena"],
[[ 63.7417, -115.2235], "America/Yellowknife"],
[[ 44.0343, 123.8136], "Asia/Harbin"],
[[ 81.6018, -59.8101], "America/Godthab"],
[[ 51.5641, -63.8453], "America/Montreal"],
[[-38.1635, -57.7626], "America/Argentina/Buenos_Aires"],
[[ 36.1970, -107.8392], "America/Denver"],
[[ 26.0985, -105.9614], "America/Monterrey"],
Expand All @@ -290,7 +281,6 @@ describe("tzlookup", function() {
[[ 23.4918, -4.6733], "Africa/Bamako"],
[[ 23.4670, 42.9883], "Asia/Riyadh"],
[[ 64.0877, 20.1457], "Europe/Stockholm"],
[[ 29.3704, 106.9562], "Asia/Chongqing"],
[[ 73.5927, -115.9105], "America/Yellowknife"],
[[ 51.8279, -84.3882], "America/Toronto"],
[[ 56.5034, -108.7968], "America/Regina"],
Expand All @@ -317,8 +307,6 @@ describe("tzlookup", function() {
[[ 81.5336, -86.4839], "America/Rankin_Inlet"],
[[ 77.1564, -25.3151], "America/Godthab"],
[[ 40.7495, 34.3622], "Europe/Istanbul"],
[[ 34.2004, 91.9447], "Asia/Urumqi"],
[[ 43.1564, 127.0682], "Asia/Harbin"],
[[-12.6167, -54.5727], "America/Cuiaba"],
[[ 26.5547, -100.3505], "America/Monterrey"],
[[ 43.4997, 118.0167], "Asia/Shanghai"],
Expand All @@ -345,11 +333,8 @@ describe("tzlookup", function() {
[[ 54.4724, 35.8859], "Europe/Moscow"],
[[ 42.6423, 47.3439], "Europe/Moscow"],
[[ 21.3766, -9.0809], "Africa/Nouakchott"],
[[ 35.4466, 85.8077], "Asia/Urumqi"],
[[ 15.3113, 32.8385], "Africa/Khartoum"],
[[ -0.9303, -61.5420], "America/Manaus"],
[[ 65.1811, -85.3929], "America/Coral_Harbour"],
[[ 41.3979, 109.2824], "Asia/Chongqing"],
[[ 61.4208, 165.6336], "Asia/Kamchatka"],
[[ 31.5990, 110.1621], "Asia/Shanghai"],
[[-25.9807, 26.9300], "Africa/Johannesburg"],
Expand All @@ -367,7 +352,6 @@ describe("tzlookup", function() {
[[ 14.0688, -13.6619], "Africa/Dakar"],
[[ 79.5181, -25.8663], "America/Godthab"],
[[ 59.8240, 37.2919], "Europe/Moscow"],
[[ 47.2100, 122.8452], "Asia/Harbin"],
[[ 9.1754, -76.0658], "America/Bogota"],
[[ -3.3148, 38.7519], "Africa/Nairobi"],
[[-30.8390, -61.0529], "America/Argentina/Cordoba"],
Expand Down Expand Up @@ -408,7 +392,6 @@ describe("tzlookup", function() {
[[ 63.9662, 27.2907], "Europe/Helsinki"],
[[ 30.4291, -7.3296], "Africa/Casablanca"],
[[-12.6378, -57.5000], "America/Cuiaba"],
[[ 26.8727, 109.0441], "Asia/Chongqing"],
[[ -3.9646, -73.4212], "America/Lima"],
[[-18.8768, 123.5026], "Australia/Perth"],
[[ -3.2149, -60.7691], "America/Manaus"],
Expand Down Expand Up @@ -443,7 +426,6 @@ describe("tzlookup", function() {
[[ 25.2369, 115.3962], "Asia/Shanghai"],
[[ 68.4210, 152.2690], "Asia/Srednekolymsk"],
[[ 46.9954, 102.2327], "Asia/Ulaanbaatar"],
[[ 46.4199, 127.2178], "Asia/Harbin"],
[[ 7.5015, 41.0239], "Africa/Addis_Ababa"],
[[ 49.8186, 90.2840], "Asia/Hovd"],
[[ 56.5580, -104.9026], "America/Regina"],
Expand All @@ -461,7 +443,6 @@ describe("tzlookup", function() {
[[ 44.2626, 44.7455], "Europe/Moscow"],
[[ 59.8934, -129.0060], "America/Vancouver"],
[[ -0.6722, -77.7137], "America/Guayaquil"],
[[ 28.0058, 109.1947], "Asia/Chongqing"],
[[ 45.3270, -111.0269], "America/Denver"],
[[-21.4916, 18.2277], "Africa/Windhoek"],
[[ 69.8075, -36.7877], "America/Godthab"],
Expand All @@ -470,7 +451,6 @@ describe("tzlookup", function() {
[[ -5.2175, -55.5735], "America/Santarem"],
[[ 19.3533, 73.4849], "Asia/Kolkata"],
[[ 69.7972, -50.0355], "America/Godthab"],
[[ 37.2952, 90.9628], "Asia/Urumqi"],
[[ 14.7315, 20.6226], "Africa/Ndjamena"],
[[-11.9026, 19.1156], "Africa/Luanda"],
[[-19.0649, -52.4491], "America/Campo_Grande"],
Expand All @@ -497,7 +477,6 @@ describe("tzlookup", function() {
[[ 57.5957, 83.7790], "Asia/Tomsk"],
[[ 62.4294, -160.5397], "America/Anchorage"],
[[ 5.2829, 35.5583], "Africa/Juba"],
[[ 52.1639, -71.8402], "America/Montreal"],
[[ 38.9473, 90.3155], "Asia/Urumqi"],
[[ 49.7176, -120.6521], "America/Vancouver"],
[[ 25.6025, -99.0005], "America/Monterrey"],
Expand All @@ -519,7 +498,6 @@ describe("tzlookup", function() {
[[ 52.9221, 101.7918], "Asia/Irkutsk"],
[[ 18.1641, 18.4528], "Africa/Ndjamena"],
[[ 8.6146, -65.2355], "America/Caracas"],
[[ 37.3193, 102.0327], "Asia/Chongqing"],
[[ -6.6831, 22.1025], "Africa/Lubumbashi"],
[[ 64.1049, 89.7467], "Asia/Krasnoyarsk"],
[[-28.1880, 119.3906], "Australia/Perth"],
Expand All @@ -534,7 +512,6 @@ describe("tzlookup", function() {
[[ 69.5304, 85.2865], "Asia/Krasnoyarsk"],
[[ 36.6934, 113.5059], "Asia/Shanghai"],
[[ 17.4480, 49.6467], "Asia/Aden"],
[[ 46.8508, -75.1992], "America/Montreal"],
[[ 71.4531, -46.1878], "America/Godthab"],
[[ 14.5328, 20.0108], "Africa/Ndjamena"],
[[ 49.0779, 105.2610], "Asia/Ulaanbaatar"],
Expand All @@ -547,7 +524,6 @@ describe("tzlookup", function() {
[[ 8.1392, 80.1801], "Asia/Colombo"],
[[ 53.9195, 107.1539], "Asia/Irkutsk"],
[[ 29.5765, 28.8024], "Africa/Cairo"],
[[ 34.1592, 95.6204], "Asia/Urumqi"],
[[ 75.7569, -40.2910], "America/Godthab"],
[[ 54.6688, -115.0705], "America/Edmonton"],
[[ -8.8954, -38.3336], "America/Recife"],
Expand Down
4 changes: 1 addition & 3 deletions tz.js

Large diffs are not rendered by default.

0 comments on commit d48e1cc

Please sign in to comment.