New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

csvgeocode

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csvgeocode - npm Package Compare versions

Comparing version

to
2.2.0

5

package.json
{
"name": "csvgeocode",
"version": "2.1.0",
"version": "2.2.0",
"description": "Bulk geocode addresses in a CSV.",

@@ -38,3 +38,6 @@ "main": "index.js",

"yargs": "^3.0.4"
},
"devDependencies": {
"dotenv": "^1.2.0"
}
}

21

README.md
csvgeocode
==========
For when you have a CSV with addresses and you want a lat/lng for every row. Bulk geocode addresses a CSV with a few lines of code.
For when you have a CSV with addresses and you want a lat/lng for every row. Bulk geocode addresses a CSV with a few lines of code.
The defaults are configured for [Google's geocoder](https://developers.google.com/maps/documentation/geocoding/) but it can be configured to work with any other similar geocoding service. There are built-in response handlers for [Google](https://developers.google.com/maps/documentation/geocoding/), [Mapbox](https://www.mapbox.com/developers/api/geocoding/), and [Texas A & M's](http://geoservices.tamu.edu/Services/Geocode/WebService/) geocoders (details below).
The defaults are configured for [Google's geocoder](https://developers.google.com/maps/documentation/geocoding/) but it can be configured to work with any other similar geocoding service. There are built-in response handlers for [Google](https://developers.google.com/maps/documentation/geocoding/), [Mapbox](https://www.mapbox.com/developers/api/geocoding/), [OSM Nominatim](http://nominatim.openstreetmap.org/), [Mapzen](https://mapzen.com/projects/search), and [Texas A & M's](http://geoservices.tamu.edu/Services/Geocode/WebService/) geocoders (details below).

@@ -50,2 +50,4 @@ Make sure that you use this in compliance with the relevant API's terms of service.

http://geoservices.tamu.edu/Services/Geocode/WebService/GeocoderWebServiceHttpNonParsed_V04_01.aspx?apiKey=MY_API_KEY&version=4.01&streetAddress={{address}}&city={{city}}&state={{state}}
https://search.mapzen.com/v1/search?api_key=MY_API_KEY&text={{address}}
```

@@ -55,3 +57,3 @@

What handler function to process the API response with. Current built-in handlers are `"google"`, `"mapbox"`, and `"tamu"`. Contributions of handlers for other geocoders are welcome! You can define a custom handler when using this as a Node module (see below).
What handler function to process the API response with. Current built-in handlers are `"google"`, `"mapbox"`, `"mapzen"`, `"osm"`, and `"tamu"`. Contributions of handlers for other geocoders are welcome! You can define a custom handler when using this as a Node module (see below).

@@ -62,2 +64,4 @@ Examples:

$ csvgeocode input.csv --url 'https://search.mapzen.com/v1/search?api_key=123ABC&text={{MY_ADDRESS_COLUMN_NAME}}' --handler mapzen
$ csvgeocode input.csv --url "http://geoservices.tamu.edu/Services/Geocode/WebService/GeocoderWebServiceHttpNonParsed_V04_01.aspx?version=4.01&streetAddress={{ADDR}}&city={{CITY}}&state={{STATE}}&apiKey=123ABC" --handler tamu

@@ -222,2 +226,11 @@ ```

## Contributing/tests
The tests for the Mapbox and TAMU geocoders both require API keys. To run those tests, you need those API keys in a `.env` file in the project's root folder that defines two environment variables like so:
```
MAPBOX_API_KEY=123ABC
TAMU_API_KEY=123ABC
```
## Some Alternatives

@@ -245,2 +258,2 @@

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@@ -38,2 +38,18 @@ var csv = require("dsv")(",");

},
mapzen: function(body) {
var response = JSON.parse(body);
if (response.features === undefined) {
return response.message;
} else if (!response.features.length) {
return "NO MATCH";
}
return {
lat: response.features[0].geometry.coordinates[1],
lng: response.features[0].geometry.coordinates[0]
};
},
tamu: function(body) {

@@ -95,2 +111,2 @@

}
};
};
var assert = require("assert"),
geocode = require("../"),
queue = require("queue-async");
queue = require("queue-async")(1);
queue(1)
.defer(basicTest)
.defer(norwegianTest)
.defer(requiredTest)
.defer(cacheTest)
.defer(columnNamesTest)
.defer(addColumnsTest)
.defer(handlerTest)
.defer(mapboxTest)
.defer(throwTest)
.defer(tamuTest)
.awaitAll(function(){});
// Load API keys
require("dotenv").load();
// Test URLs
var googleTestUrl = "https://maps.googleapis.com/maps/api/geocode/json?address={{address}}",
googleNorwegianTestUrl = "https://maps.googleapis.com/maps/api/geocode/json?address={{Bosatt}},Norway",
mapboxTestUrl = "http://api.tiles.mapbox.com/v4/geocode/mapbox.places/{{address}}.json?access_token=" + process.env.MAPBOX_API_KEY,
tamuTestUrl = "http://geoservices.tamu.edu/Services/Geocode/WebService/GeocoderWebServiceHttpNonParsed_V04_01.aspx?apiKey=" + process.env.TAMU_API_KEY + "&version=4.01&streetAddress={{street}}&city={{city}}&state={{state}}";
queue.defer(basicTest)
.defer(norwegianTest)
.defer(requiredTest)
.defer(cacheTest)
.defer(columnNamesTest)
.defer(addColumnsTest)
.defer(handlerTest)
.defer(throwTest);
if (process.env.MAPBOX_API_KEY) {
queue.defer(mapboxTest);
}
if (process.env.TAMU_API_KEY) {
queue.defer(tamuTest);
}
queue.awaitAll(function(){});
function basicTest(cb) {

@@ -22,3 +37,3 @@

test: true,
url: process.env.TEST_URL
url: googleTestUrl
})

@@ -55,3 +70,3 @@ .on("row",function(err,row){

test: true,
url: process.env.TEST_NORWEGIAN_URL
url: googleNorwegianTestUrl
})

@@ -93,3 +108,3 @@ .on("row",function(err,row){

test: true,
url: process.env.TEST_URL
url: googleTestUrl
})

@@ -115,3 +130,3 @@ .on("row",function(err,row){

test: true,
url: process.env.TEST_URL
url: googleTestUrl
})

@@ -137,3 +152,3 @@ .on("row",function(err,row){

test: true,
url: process.env.TEST_URL
url: googleTestUrl
})

@@ -154,3 +169,3 @@ .on("row",function(err,row){

force: true,
url: process.env.TEST_URL,
url: googleTestUrl,
handler: function(body) {

@@ -176,3 +191,3 @@ return "CUSTOM ERROR";

test: true,
url: process.env.TEST_URL,
url: googleTestUrl,
handler: "dumb string"

@@ -197,3 +212,3 @@ });

handler: "mapbox",
url: process.env.MAPBOX_TEST_URL,
url: mapboxTestUrl,
test: true

@@ -219,3 +234,3 @@ })

handler: "tamu",
url: process.env.TAMU_TEST_URL,
url: tamuTestUrl,
test: true

@@ -222,0 +237,0 @@ })

Sorry, the diff of this file is not supported yet