Skip to content

Commit

Permalink
Merge pull request #33 from evansiroky/find-fix
Browse files Browse the repository at this point in the history
Find fix
  • Loading branch information
evansiroky authored Nov 7, 2016
2 parents 462ba1c + d9cdc11 commit ea24743
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var getTimezone = function (lat, lon) {
// exact boundaries saved in file
// parse geojson for exact boundaries
var filepath = quadPos.split('').join('/')
var data = new Pbf(fs.readFileSync('./data/' + filepath + '/geo.buf'))
var data = new Pbf(fs.readFileSync(__dirname + '/../data/' + filepath + '/geo.buf'))
var geoJson = geobuf.decode(data)

for (var i = 0; i < geoJson.features.length; i++) {
Expand Down
10 changes: 5 additions & 5 deletions lib/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ var yauzl = require('yauzl')
var indexGeoJSON = require('./createGeoIndex.js')

var TARGET_INDEX_PERCENT = 0.5
var dlFile = 'downloads/timezones.zip'
var tzFile = 'downloads/timezones.json'
var dlFile = __dirname + '/../downloads/timezones.zip'
var tzFile = __dirname + '/../downloads/timezones.json'

var downloadLatest = function (callback) {
console.log('Downloading geojson')
Expand Down Expand Up @@ -42,7 +42,7 @@ var downloadLatest = function (callback) {
rimraf(dlFile, cb)
},
mkdir: ['rm', function (results, cb) {
mkdirp('downloads', cb)
mkdirp(__dirname + '/../downloads', cb)
}],
dl: ['mkdir', 'getLatestUrl', function (results, cb) {
https.get({
Expand All @@ -69,7 +69,7 @@ module.exports = function (cfg, callback) {
}
}

var dataDir = cfg.dataDir || './data'
var dataDir = cfg.dataDir || __dirname + '/../data'

async.auto({
// download latest geojson data
Expand Down Expand Up @@ -108,7 +108,7 @@ module.exports = function (cfg, callback) {
})
}],
createIndex: ['deleteIndexFoldersAndFiles', 'unzipGeoJson', function (results, cb) {
indexGeoJSON(require('../' + tzFile), dataDir, TARGET_INDEX_PERCENT, cb)
indexGeoJSON(require(tzFile), dataDir, TARGET_INDEX_PERCENT, cb)
}]
}, callback)
}
2 changes: 2 additions & 0 deletions tests/find.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ var assert = require('chai').assert

var geoTz = require('../index.js')

process.chdir('/tmp')

describe('find tests', function () {
it('should find the timezone name for a valid coordinate', function () {
var tz = geoTz.tz(47.650499, -122.350070)
Expand Down
4 changes: 2 additions & 2 deletions tests/geoIndex.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var util = require('./util.js')

var createGeoIndex = require('../lib/createGeoIndex.js')

var TEST_DATA_DIR = './data-test-geoindex'
var TEST_DATA_DIR = __dirname + '/../data-test-geoindex'
var testTzData = require('./data/largeTz.json')
var expectedIndexData = require('./data/expectedIndexData.json')

Expand All @@ -30,7 +30,7 @@ describe('geoindex', function () {
function (err) {
assert.isNotOk(err)

var generatedIndex = require('.' + TEST_DATA_DIR + '/index.json')
var generatedIndex = require(TEST_DATA_DIR + '/index.json')

assert.deepEqual(generatedIndex, expectedIndexData)

Expand Down
2 changes: 1 addition & 1 deletion tests/update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var util = require('./util.js')
var update = require('../lib/update.js')

var TEST_DATA_DIR = './data-test-update'
var LOCAL_FOLDER = './tests/data/'
var LOCAL_FOLDER = __dirname + '/../tests/data/'

describe('data update', function () {
this.timeout(4000)
Expand Down

0 comments on commit ea24743

Please sign in to comment.