Socket
Socket
Sign inDemoInstall

node-geocoder

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-geocoder - npm Package Compare versions

Comparing version 3.27.0 to 3.28.0

.github/FUNDING.yml

5

CHANGELOG.md

@@ -120,1 +120,6 @@ ## 3.0.0

- Allow passing of limit parameter to opendatafrance
# 3.28.0
- Fixed GeoCodio Object with formattedAddress and country (#322)
- Support language feature for open cage (#309)

2

index.js

@@ -7,2 +7,2 @@ 'use strict';

module.exports = Exports;
module.exports = Exports;

@@ -9,7 +9,5 @@ var querystring = require('querystring'),

var GeocodioGeocoder = function GeocodioGeocoder(httpAdapter, apiKey) {
GeocodioGeocoder.super_.call(this, httpAdapter);
if (!apiKey || apiKey == 'undefined') {
throw new Error(this.constructor.name + ' needs an apiKey');

@@ -31,39 +29,46 @@ }

var _this = this;
this.httpAdapter.get(this._endpoint + '/geocode', {
'q': value,
'api_key': querystring.unescape(this.apiKey)
}, function (err, result) {
if (err) {
return callback(err);
}
if (result.error) {
return callback(new Error('Status is ' + result.error), {raw: result});
}
this.httpAdapter.get(
this._endpoint + '/geocode',
{
q: value,
api_key: querystring.unescape(this.apiKey)
},
function (err, result) {
if (err) {
return callback(err);
}
if (result.error) {
return callback(new Error('Status is ' + result.error), {
raw: result
});
}
var results = [];
var results = [];
var locations = result.results;
var locations = result.results;
for (var i = 0; i < locations.length; i++) {
results.push(_this._formatResult(locations[i]));
for (var i = 0; i < locations.length; i++) {
results.push(_this._formatResult(locations[i]));
}
results.raw = result;
callback(false, results);
}
results.raw = result;
callback(false, results);
});
);
};
GeocodioGeocoder.prototype._formatResult = function (result) {
var accuracy = (result.accuracy < 1) ? result.accuracy - 0.1 : 1;
var accuracy = result.accuracy < 1 ? result.accuracy - 0.1 : 1;
return {
'latitude': result.location.lat,
'longitude': result.location.lng,
'country': null,
'city': result.address_components.city,
'state': result.address_components.state,
'zipcode': result.address_components.zip,
'streetName': result.address_components.formatted_street,
'streetNumber': result.address_components.number,
'countryCode': null,
'extra': {
latitude: result.location.lat,
longitude: result.location.lng,
country: result.address_components.country,
formattedAddress: result.formatted_address,
city: result.address_components.city,
state: result.address_components.state,
zipcode: result.address_components.zip,
streetName: result.address_components.formatted_street,
streetNumber: result.address_components.number,
countryCode: null,
extra: {
confidence: accuracy || 0

@@ -85,22 +90,26 @@ }

this.httpAdapter.get(this._endpoint + '/reverse', {
'q': lat + ',' + lng,
'api_key': querystring.unescape(this.apiKey)
}, function (err, result) {
if (err) {
return callback(err);
}
this.httpAdapter.get(
this._endpoint + '/reverse',
{
q: lat + ',' + lng,
api_key: querystring.unescape(this.apiKey)
},
function (err, result) {
if (err) {
return callback(err);
}
var results = [];
var locations = result.results;
var results = [];
var locations = result.results;
for (var i = 0; i < locations.length; i++) {
results.push(_this._formatResult(locations[i]));
for (var i = 0; i < locations.length; i++) {
results.push(_this._formatResult(locations[i]));
}
results.raw = result;
callback(false, results);
}
results.raw = result;
callback(false, results);
});
);
};
module.exports = GeocodioGeocoder;

@@ -51,4 +51,3 @@ var util = require('util'),

params.bounds = value.bounds.join(',');
}
else {
} else {
params.bounds = value.bounds;

@@ -66,5 +65,7 @@ }

}
if (value.language) {
params.language = value.language;
}
params.q = value.address;
}
else {
} else {
params.q = value;

@@ -74,7 +75,5 @@ }

this.httpAdapter.get(this._endpoint, params, function (err, result) {
if (err) {
return callback(err);
} else {
var results = [];

@@ -91,5 +90,3 @@

}
});
};

@@ -100,13 +97,13 @@

return {
'latitude': result.geometry.lat,
'longitude': result.geometry.lng,
'country': result.components.country,
'city': result.components.city,
'state': result.components.state,
'zipcode': result.components.postcode,
'streetName': result.components.road,
'streetNumber': result.components.house_number,
'countryCode': result.components.country_code,
'county': result.components.county,
'extra': {
latitude: result.geometry.lat,
longitude: result.geometry.lng,
country: result.components.country,
city: result.components.city,
state: result.components.state,
zipcode: result.components.postcode,
streetName: result.components.road,
streetNumber: result.components.house_number,
countryCode: result.components.country_code,
county: result.components.county,
extra: {
confidence: confidence,

@@ -113,0 +110,0 @@ confidenceKM: this._ConfidenceInKM[result.confidence] || Number.NaN

{
"name": "node-geocoder",
"version": "3.27.0",
"version": "3.28.0",
"description": "Node Geocoder, node geocoding library, supports google maps, mapquest, open street map, tom tom, promise",

@@ -5,0 +5,0 @@ "main": "index.js",

# node-geocoder
[![Build Status](https://img.shields.io/travis/nchaulet/node-geocoder.svg?style=flat-square)](https://travis-ci.org/nchaulet/node-geocoder)
![Dependencycy status](https://img.shields.io/david/nchaulet/node-geocoder.svg?style=flat-square)
![Dependency status](https://img.shields.io/david/nchaulet/node-geocoder.svg?style=flat-square)
[![npm version](https://img.shields.io/npm/v/node-geocoder.svg?style=flat-square)](https://www.npmjs.com/package/node-geocoder)

@@ -79,3 +79,3 @@

'13 rue sainte catherine',
'another adress'
'another address'
]);

@@ -109,3 +109,3 @@

- `locationiq` : LocationIQGeocoder. Supports address geocoding and reverse geocoding just like openstreetmap but does require only a locationiq api key to be set.
- For `geocode` you can use simple `q` parameter or an object containing th edifferent parameters defined here: http://locationiq.org/#docs
- For `geocode` you can use simple `q` parameter or an object containing the different parameters defined here: http://locationiq.org/#docs
- For `reverse`, you can pass over `{lat, lon}` and additional parameters defined in http://locationiq.org/#docs

@@ -123,3 +123,2 @@ - No need to specify referer or email addresses, just locationiq api key, note that there are rate limits!

- Set `options.osmServer` to use custom nominatim server. Example: you can setup local nominatim server by following [these instructions](http://nominatim.org/release-docs/latest/admin/Installation/) and set `options.osmServer: http://localhost:8000` to use local server.
- `nominatimmapquest`: Same geocoder as `openstreetmap`, but queries the MapQuest servers. You need to specify `options.apiKey`
- `pickpoint`: PickPoint Geocoder. Supports address geocoding and reverse geocoding. You need to specify `options.apiKey` obtained at [PickPoint](https://pickpoint.io).

@@ -126,0 +125,0 @@ - As parameter for `geocode` function you can use a string representing an address like "13 rue sainte catherine" or an object with parameters described in [Forward Geocoding Reference](https://pickpoint.io/api-reference#forward-geocoding).

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc