Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-geocoder

Package Overview
Dependencies
Maintainers
1
Versions
119
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 0.4.0 to 0.5.0

5

lib/formatter/stringformatter.js

@@ -22,3 +22,6 @@ (function() {

.replace(/%P/, data[i].country)
.replace(/%p/, data[i].countryCode);
.replace(/%p/, data[i].countryCode)
.replace(/%c/, data[i].city)
.replace(/%T/, data[i].state)
.replace(/%t/, data[i].stateCode);

@@ -25,0 +28,0 @@ strings.push(str);

13

lib/geocoder/googlegeocoder.js

@@ -50,2 +50,4 @@ 'use strict';

var city = null;
var state = null;
var stateCode = null;
var zipcode = null;

@@ -64,2 +66,9 @@ var streetName = null;

}
// State
if (result.address_components[i].types.indexOf('administrative_area_level_1') >= 0) {
state = result.address_components[i].long_name;
}
if (result.address_components[i].types.indexOf('administrative_area_level_1') >= 0) {
stateCode = result.address_components[i].short_name;
}
// City

@@ -69,3 +78,3 @@ if (result.address_components[i].types.indexOf('locality') >= 0) {

}
//
// Adress
if (result.address_components[i].types.indexOf('postal_code') >= 0) {

@@ -87,2 +96,4 @@ zipcode = result.address_components[i].long_name;

'city' : city,
'state' : state,
'stateCode' : stateCode,
'zipcode' : zipcode,

@@ -89,0 +100,0 @@ 'streetName': streetName,

{
"name": "node-geocoder",
"version": "0.4.0",
"version": "0.5.0",
"description": "node geocoding library, supports google maps, mapquest, open street map, ...",

@@ -5,0 +5,0 @@ "main": "lib/geocoderfactory.js",

@@ -9,30 +9,6 @@ # node-geocoder

## instalation
## Installation
npm install node-geocoder
## Geocoder Provider
* `google` : GoogleGeocoder support adress geocoding and reverse geocoding
* `freegeoip` : FreegeoipGeocoder support ip geocoding
* `datasciencetoolkit` : DataScienceToolkitGeocoder support ip v4 geocoding
* `openstreetmap` : OpenStreetMapGeocoder support adress geocoding and reverse geocoding
* `mapquest` : MapQuestGeocoder support adress geocoding and reverse geocoding need an apiKey
## Http adapter
* `http` : This adapter use Http nodejs library (by default)
* `requestify` : This adapter use Requestify library (you need to install `requestify`)
## Formatter
* `gpx` : format result using GPX format
* `string` : format result to an String array (you need to specify `extra.formatterPattern` key)
* `%P` country
* `%p` country code
* `%n` street number
* `*S` street name
* `%z` zip code
## Usage example

@@ -63,6 +39,34 @@

streetName: 'Champs-Élysées',
streetNumber: '29'
streetNumber: '29',
state: 'Île de France',
stateCode: 'IDF'
}]
## Geocoder Provider
* `google` : GoogleGeocoder support adress geocoding and reverse geocoding
* `freegeoip` : FreegeoipGeocoder support ip geocoding
* `datasciencetoolkit` : DataScienceToolkitGeocoder support ip v4 geocoding
* `openstreetmap` : OpenStreetMapGeocoder support adress geocoding and reverse geocoding
* `mapquest` : MapQuestGeocoder support adress geocoding and reverse geocoding need an apiKey
## Http adapter
* `http` : This adapter use Http nodejs library (by default)
* `requestify` : This adapter use Requestify library (you need to install `requestify`)
## Formatter
* `gpx` : format result using GPX format
* `string` : format result to an String array (you need to specify `extra.formatterPattern` key)
* `%P` country
* `%p` country code
* `%n` street number
* `%S` street name
* `%z` zip code
* `%T` State
* `%t` state code
## More

@@ -69,0 +73,0 @@

@@ -20,3 +20,3 @@ (function() {

it('should replace pattern with correct values', function() {
var formatter = new StringFormatter('%P %p %n %S %z');
var formatter = new StringFormatter('%P %p %n %S %z %T %t');

@@ -28,3 +28,5 @@ var results = formatter.format([{

streetName: 'rue chevreul',
zipcode: '69007'
zipcode: '69007',
state: 'Rhone alpes',
stateCode: 'RA'
}]);

@@ -36,3 +38,3 @@

string.should.be.a('string');
string.should.equal('France FR 29 rue chevreul 69007');
string.should.equal('France FR 29 rue chevreul 69007 Rhone alpes RA');
});

@@ -39,0 +41,0 @@ });

@@ -78,4 +78,4 @@ (function() {

{types: ['route'], long_name: 'Champs-Élysées' },
{types: ['street_number'], long_name: '1' }
{types: ['street_number'], long_name: '1' },
{types: ['administrative_area_level_1'], long_name: 'Île-de-France', short_name: 'IDF'}
],

@@ -92,10 +92,12 @@ country_code: 'US',

results[0].should.to.deep.equal({
"latitude": 37.386,
"longitude": -122.0838,
"country": "France",
"city": "Paris",
"zipcode": "75008",
"streetName": "Champs-Élysées",
"latitude" : 37.386,
"longitude" : -122.0838,
"country" : "France",
"city" : "Paris",
"zipcode" : "75008",
"streetName" : "Champs-Élysées",
"streetNumber": "1",
"countryCode": "Fr"
"countryCode" : "Fr",
"state" : "Île-de-France",
"stateCode" : "IDF"
});

@@ -138,4 +140,6 @@ mock.verify();

{types: ['route'], long_name: 'Bedford Avenue' },
{types: ['street_number'], long_name: '277' }
{types: ['street_number'], long_name: '277' },
{types: ['administrative_area_level_1'], long_name: 'État de New York', short_name: 'NY'}
],

@@ -151,10 +155,12 @@ country_code: 'US',

results[0].should.to.deep.equal({
"latitude": 40.714232,
"longitude": -73.9612889,
"country": "United States",
"city": "Brooklyn",
"zipcode": "11211",
"streetName": "Bedford Avenue",
"latitude" : 40.714232,
"longitude" : -73.9612889,
"country" : "United States",
"city" : "Brooklyn",
"zipcode" : "11211",
"streetName" : "Bedford Avenue",
"streetNumber": "277",
"countryCode": "US"
"countryCode" : "US",
"state" : "État de New York",
"stateCode" : "NY"
});

@@ -161,0 +167,0 @@ mock.verify();

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