Source: I did this when I wrote a library for reverse geocoding which uses a kd tree.
https://github.com/AReallyGoodName/OfflineReverseGeocode