next() Packaged Middleware

    zipcodes-nearby

    0.1.4 • Public • Published

    Build Status Coverage Status NPM Downloads NPM Version Dependencies License

    Zipcodes near by

    Find a list of zipcodes within a certain distance of a given zipcode.

    Installation

    npm install zipcodes-nearby
    

    Usage

    The method near(zipcode|coordinates, distance[, options]) takes 2 to 3 arguments.

    • First is the zipcode or geo-coordinates (long/lat) to search around
    • Second is the distance (in meters) to search within
    • Third is an optional object with the following attributes:
      • datafile: name for the CSV file containing zipcodes coordinates. By default it looks for a file zipcodes.csv in the same folder
      • zipcode: name of the column in the CSV file containing the zipcode. By default it is Zipcode
      • long: name of the column in the CSV file containing the zipcode longitude. By default it is Long
      • lat: name of the column in the CSV file containing the zipcode latitude. By default it is 'Lat'

    For examples:

    var zipcodes = require('zipcodes-nearby');
    
    // find zipcodes within 10km from 95020 using the default datafile "zipcodes.csv"
    nearby = zipcodes.near('95020', 10000);
    
    // find zipcodes within 10km from a location given by geo-coordinates using the default datafile "zipcodes.csv"
    nearby = zipcodes.near({ longitude: 78.8, latitude: 48.3 }, 10000);
    
    // find zipcodes within 10km from 95020 using the datafile "newzipcodes.csv"
    nearby = zipcodes.near('95020', 10000, { datafile: 'newzipcodes.csv' });
    
    

    Data file

    The data file with zipcodes coordinates must be supplied. We have include one for USA to use. It can be replaced by zipcodes (or postal codes) from any country as long as the file contains the zipcode, the longitude, and the latitude.

    You can download an updated file for the USA at http://federalgovernmentzipcodes.us/

    License

    MIT

    Author Information

    Quoc Vu

    Install

    npm i zipcodes-nearby

    DownloadsWeekly Downloads

    84

    Version

    0.1.4

    License

    MIT

    Unpacked Size

    4.29 MB

    Total Files

    10

    Last publish

    Collaborators

    • quocvu