node-geocoder
Advanced tools
Comparing version 0.0.3 to 0.0.4
'use strict'; | ||
(function () { | ||
var iz = require('iz'); | ||
var Helper = require('../helper.js'); | ||
@@ -23,3 +23,3 @@ /** | ||
if (!iz.ip(value)) { | ||
if (!Helper.isIp(value)) { | ||
throw new Error('FreegeoipGeocoder suport only ip geocoding'); | ||
@@ -26,0 +26,0 @@ } |
'use strict'; | ||
(function () { | ||
var iz = require('iz'); | ||
var Helper = require('../helper.js'); | ||
@@ -23,3 +23,3 @@ /** | ||
if (iz.ip(value)) { | ||
if (Helper.isIp(value)) { | ||
throw new Error('Google Geocoder no suport geocoding ip'); | ||
@@ -26,0 +26,0 @@ } |
(function() { | ||
var Helper = require('./helper.js'); | ||
var Geocoder = require('./geocoder.js'); | ||
@@ -15,5 +17,7 @@ | ||
var HttpAdapter = new require('./httpadapter/httpadapter.js'); | ||
if (adapterName === 'http') { | ||
var HttpAdapter = new require('./httpadapter/httpadapter.js'); | ||
return new HttpAdapter(); | ||
return new HttpAdapter(); | ||
} | ||
}, | ||
@@ -26,3 +30,2 @@ _getGeocoder: function(geocoderName, adapter) { | ||
} | ||
if (geocoderName === 'freegeoip') { | ||
@@ -33,15 +36,22 @@ var FreegeoipGeocoder = new require('./geocoder/freegeoipgeocoder.js'); | ||
} | ||
if (geocoderName === 'datasciencetoolkit') { | ||
var DataScienceToolkitGeocoder = new require('./geocoder/datasciencetoolkitgeocoder.js'); | ||
return new DataScienceToolkitGeocoder(adapter); | ||
} | ||
}, | ||
getGeocoder: function(geocoderName, adapterName, geocoderOpts) { | ||
getGeocoder: function(geocoderAdapter, httpAdapter, geocoderOpts) { | ||
var adapter = null; | ||
if (adapterName !== null && adapterName !== 'undefined') { | ||
adapter = this._getHttpAdapter(adapterName); | ||
if (!httpAdapter || httpAdapter === 'undefined') { | ||
httpAdapter = 'http'; | ||
} | ||
var geocoderAdapter = null; | ||
if (geocoderName !== null && geocoderName !== 'undefined') { | ||
geocoderAdapter = this._getGeocoder(geocoderName, adapter); | ||
if (Helper.isString(httpAdapter)) { | ||
httpAdapter = this._getHttpAdapter(httpAdapter); | ||
} | ||
if (Helper.isString(geocoderAdapter)) { | ||
geocoderAdapter = this._getGeocoder(geocoderAdapter, httpAdapter); | ||
} | ||
var geocoder = new Geocoder(geocoderAdapter); | ||
@@ -48,0 +58,0 @@ |
{ | ||
"name": "node-geocoder", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "node geocoding library", | ||
@@ -23,10 +23,9 @@ "main": "lib/geocoderfactory.js", | ||
"dependencies": { | ||
"requestify": "~0.1.14", | ||
"iz": "~0.2.0", | ||
"sinon": "~1.7.3" | ||
}, | ||
"devDependencies": { | ||
"chai": "~1.7.2", | ||
"mocha": "~1.12.0" | ||
"mocha": "~1.12.0", | ||
"sinon": "~1.7.3", | ||
"requestify": "~0.1.14" | ||
} | ||
} |
@@ -7,3 +7,3 @@ # node-geocoder | ||
In development | ||
Currently in development | ||
@@ -19,2 +19,3 @@ ## instalation | ||
* `freegeoip` : FreegeoipGeocoder support ip geocoding | ||
* `datasciencetoolkit` : DataScienceToolkitGeocoder support ip v4 geocoding | ||
@@ -25,3 +26,3 @@ | ||
* `http` : This adapter use Http nodejs library (by default) | ||
* `requestify` : This adapter use Requestify library | ||
* `requestify` : This adapter use Requestify library (you need to install `requestify`) | ||
@@ -52,2 +53,4 @@ ## Usage example | ||
## More | ||
@@ -59,3 +62,12 @@ | ||
## Extending node geocoder | ||
you can add new geocoder by implementing the two method geocode & reverse : | ||
var geocoder = { | ||
geocode: function(value, callback) { }, | ||
reverse: function(lat, lng, callback) { } | ||
} | ||
## Roadmap | ||
@@ -65,2 +77,2 @@ | ||
more documentation | ||
more provider | ||
more provider |
@@ -11,3 +11,3 @@ var GoogleAdapter = require ('./lib/geocoder/googlegeocoder.js'); | ||
var adapter = require ('./index.js')('freegeoip', 'requestify'); | ||
var adapter = require ('./index.js')('datasciencetoolkit', 'requestify'); | ||
// adapter.reverse(48.8698679,2.3072976, function (err, res) { | ||
@@ -14,0 +14,0 @@ // console.log(err); |
@@ -9,2 +9,3 @@ (function() { | ||
var GeocoderFactory = require('../lib/geocoderfactory.js'); | ||
var DataScienceToolkitGeocoder = require('../lib/geocoder/datasciencetoolkitgeocoder.js'); | ||
@@ -43,2 +44,11 @@ var RequestifyAdapter = require('../lib/httpadapter/requestifyadapter.js'); | ||
}); | ||
it('called with "datasciencetoolkit" and "http" must return datasciencetoolkit geocoder with http adapter', function() { | ||
var geocoder = GeocoderFactory.getGeocoder('datasciencetoolkit', 'http'); | ||
var geocoderAdapter = geocoder.geocoder; | ||
geocoderAdapter.should.be.instanceof(DataScienceToolkitGeocoder); | ||
geocoderAdapter.httpAdapter.should.be.instanceof(HttpAdapter); | ||
}); | ||
}); | ||
@@ -45,0 +55,0 @@ }); |
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
30922
0
22
618
73
4
5
- Removediz@~0.2.0
- Removedrequestify@~0.1.14
- Removedsinon@~1.7.3
- Removedbuster-format@0.5.6(transitive)
- Removediz@0.2.0(transitive)
- Removedjquery@1.11.3(transitive)
- Removedq@0.9.7(transitive)
- Removedrequestify@0.1.17(transitive)
- Removedsinon@1.7.3(transitive)
- Removedunderscore@1.4.4(transitive)