Skip to content

Commit

Permalink
move elevation to constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Nov 23, 2023
1 parent a7469f7 commit 594a128
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/geo-sqlite",
"version": "5.0.0",
"version": "5.0.1",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"keywords": [
"hebcal"
Expand Down
12 changes: 5 additions & 7 deletions src/geodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,14 @@ export class GeoDb {
const zip = result.ZipCode;
const tzid = Location.getUsaTzid(result.State, result.TimeZone, result.DayLightSaving);
const cityDescr = `${result.CityMixedCase}, ${result.State} ${zip}`;
const location = new Location(result.Latitude, result.Longitude, false, tzid, cityDescr, 'US', zip);
const elevation = result?.Elevation > 0 ? result.Elevation : 0;
const location = new Location(result.Latitude, result.Longitude, false, tzid, cityDescr,
'US', zip, elevation);
location.admin1 = location.state = result.State;
location.stateName = stateNames[location.state];
location.geo = 'zip';
location.zip = zip;
location.population = result.Population;
if (result.Elevation && result.Elevation > 0) {
location.elevation = result.Elevation;
}
return location;
}

Expand Down Expand Up @@ -282,6 +281,7 @@ export class GeoDb {
const country = result.country || '';
const admin1 = result.admin1 || '';
const cityDescr = GeoDb.geonameCityDescr(result.name, admin1, country);
const elevation = result?.elevation > 0 ? result.elevation : 0;
const location = new Location(
result.latitude,
result.longitude,
Expand All @@ -290,6 +290,7 @@ export class GeoDb {
cityDescr,
result.cc,
geonameid,
elevation,
);
location.geo = 'geoname';
location.geonameid = geonameid;
Expand All @@ -303,9 +304,6 @@ export class GeoDb {
if (result.population) {
location.population = result.population;
}
if (result.elevation && result.elevation > 0) {
location.elevation = result.elevation;
}
return location;
}

Expand Down

0 comments on commit 594a128

Please sign in to comment.