node-geocoder
Advanced tools
Comparing version 3.6.0 to 3.6.2
@@ -185,1 +185,13 @@ # Changelog | ||
* Teleport Geocoder | ||
## 3.6.0 | ||
* Support search object for mapquest geocoder | ||
## 3.6.1 | ||
* Fix opencage callback error | ||
* Fix opencage confidence | ||
var util = require('util'), | ||
AbstractGeocoder = require('./abstractgeocoder'); | ||
// http://geocoder.opencagedata.com/api.html#confidence | ||
var ConfidenceInKM = { | ||
10: 0.25, | ||
9: 0.5, | ||
8: 1, | ||
7: 5, | ||
6: 7.5, | ||
5: 10, | ||
4: 15, | ||
3: 20, | ||
2: 25, | ||
1: Number.POSITIVE_INFINITY, | ||
0: Number.NaN | ||
}; | ||
/** | ||
@@ -18,2 +33,3 @@ * Constructor | ||
this._endpoint = 'http://api.opencagedata.com/geocode/v1/json'; | ||
this._ConfidenceInKM = ConfidenceInKM; // In case we need to support v1/v2 and this changes | ||
}; | ||
@@ -23,28 +39,2 @@ | ||
var openCageRequestConfidence = { | ||
0.9: 10, // < .25km | ||
0.8: 8, // < 1km | ||
0.7: 7, // < 5km | ||
0.6: 5, // < 10km | ||
0.5: 4, // < 15km | ||
0.4: 2, // < 25km | ||
0.3: 1, // > 25km | ||
0.2: 1, // > 25km | ||
0.1: 1, // > 25km | ||
0: 0 // NA | ||
}; | ||
var openCageResultConfidence = { | ||
10: 0.9, // < .25km | ||
9: 0.8, // < .5km | ||
8: 0.8, // < 1km | ||
7: 0.7, // < 5km | ||
6: 0.6, // < 7.5km | ||
5: 0.6, // < 10km | ||
4: 0.5, // < 15km | ||
3: 0.4, // < 15km | ||
2: 0.4, // < 25km | ||
1: 0.3, // > 25km | ||
0: 0 // NA | ||
}; | ||
/** | ||
@@ -75,3 +65,3 @@ * Geocode | ||
if (value.minConfidence) { | ||
params.min_confidence = openCageRequestConfidence[value.minConfidence] || value.minConfidence; | ||
params.min_confidence = value.minConfidence; | ||
} | ||
@@ -107,2 +97,3 @@ params.q = value.address; | ||
OpenCageGeocoder.prototype._formatResult = function (result) { | ||
var confidence = result.confidence || 0; | ||
return { | ||
@@ -120,3 +111,4 @@ 'latitude': result.geometry.lat, | ||
'extra': { | ||
confidence: openCageResultConfidence[result.confidence] || 0 | ||
confidence: confidence, | ||
confidenceKM: this._ConfidenceInKM[result.confidence] || Number.NaN | ||
} | ||
@@ -142,3 +134,3 @@ }; | ||
if (err) { | ||
throw err; | ||
callback(err); | ||
} else { | ||
@@ -145,0 +137,0 @@ var results = []; |
{ | ||
"name": "node-geocoder", | ||
"version": "3.6.0", | ||
"version": "3.6.2", | ||
"description": "Node Geocoder, node geocoding library, supports google maps, mapquest, open street map, tom tom, promise", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83054
2102