Skip to content

Commit

Permalink
update: update to latest GeoNames data.
Browse files Browse the repository at this point in the history
  • Loading branch information
crhallberg committed Feb 3, 2023
1 parent 54fcf20 commit 831d60a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion data/loc-tree.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions test/by-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ const zips = require('../index.js');

describe('Valid locations', function() {
it('correct when spot on', function() {
let place = zips.getByZipCode('19026');
let place = zips.getByZipCode('19085');
let locPlace = zips.getByLocation(place.lat, place.long);
assert.equal('19026', locPlace.zip);
assert.equal('19085', locPlace.zip);
});
it('correct when slightly off', function() {
let place = zips.getByZipCode('19026');
let place = zips.getByZipCode('19085');
let locPlace = zips.getByLocation(place.lat + 0.000001, place.long + 0.000001);
assert.equal('19026', locPlace.zip);
assert.equal('19085', locPlace.zip);
});
it('return multiple closest when asked', function() {
let count = 3;
Expand All @@ -22,9 +22,9 @@ describe('Valid locations', function() {
// Safe band: 35 to 40 lat, -120 to -80 long
// http://www.okatlas.org/okatlas/location/usa/lat-long.gif
for (let i = 1; i <= randomLocCount; i++) {
const lat = Math.random() * 5 + 35; // 35 to 40
const long = Math.random() * 40 - 120; // -120 to -80
assert.ok(zips.getByLocation(lat, long), 'no zipcodes near ' + lat + ', ' + long);
const lat = 35 + Math.random() * 5; // 35 to 40
const long = -120 + Math.random() * 40; // -120 to -80
assert.ok(zips.getByLocation(lat, long), `no zipcodes near ${lat},${long} (${i})`);
}
});
});
Expand Down

0 comments on commit 831d60a

Please sign in to comment.