Skip to content

Commit

Permalink
Merge pull request #171 from geolonia/lat_lng_should_return_null
Browse files Browse the repository at this point in the history
japanese addresses側でlatとlngのデータを持っていない場合はNaNでなくnullを返す。
  • Loading branch information
champierre authored May 18, 2022
2 parents 74da240 + 5369ead commit 08ac919
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/normalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ export const normalize: Normalizer = async (
addr = normalized.addr
lat = parseFloat(normalized.lat)
lng = parseFloat(normalized.lng)
if (Number.isNaN(lat) || Number.isNaN(lng)) {
lat = null
lng = null
}
}

addr = (banchiGoQueue.join('') + addr)
Expand Down
6 changes: 6 additions & 0 deletions test/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -999,5 +999,11 @@ for (const [runtime, normalize] of cases) {
const resp = await normalize(address)
expect(resp.city).toEqual('つくば市')
})

test('latとlngのデータがない場合はnullを返す', async () => {
const res = await normalize('大分県大分市田中町3丁目1-12')
expect(res.lat).toEqual(null)
expect(res.lng).toEqual(null)
})
})
}

0 comments on commit 08ac919

Please sign in to comment.