Package Exports
- local-reverse-geocoder
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (local-reverse-geocoder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Local Reverse Geocoder
This library provides a local reverse geocoder for Node.js that is based on GeoNames data. It is local in the sense that there are no calls to a remote service like the Google Maps API and in consequence is suitable for batch reverse geocoding. It is reverse in the sense that you give it a (list of) point(s), i.e., a latitude/longitude pair, and it returns the closest city to that point.
Installation
$ npm install local-reverse-geocoderUsage
var geocoder = require('local-reverse-geocoder');
// How many results to display at max
var maxResults = 1;
// With just one point
var point = {latitude: 42.083333, longitude: 3.1};
geocoder.lookUp(point, maxResults, function(err, res) {
console.log(JSON.stringify(res, null, 2));
});
// In batch mode with many points
var points = [
{latitude: 42.083333, longitude: 3.1},
{latitude: 48.466667, longitude: 9.133333}
];
geocoder.lookUp(points, maxResults, function(err, res) {
console.log(JSON.stringify(res, null, 2));
});A Word on Accuracy
By design, i.e., due to the granularity of the available GeoNames data, this reverse geocoder is limited to city-level, so no streets or house numbers. In many cases this is already sufficient, but obviously your actual mileage may vary. If you need street-level granularity, you are better off with a service like Google's reverse geocoding API. (Full disclosure: the author is currently employed by Google.)
License
Copyright 2014 Thomas Steiner (tomac@google.com)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Acknowledgements
This project was inspired by Richard Penman's Python reverse geocoder. It uses Ubilabs' k-d-tree implementation that was ported to Node.js by Luke Arduini.