Giter Site home page Giter Site logo

country-iso's Introduction

country-iso

Travis CI Codecov npm npm version npm dependencies npm dev dependencies

🗺 Get ISO 3166-1 alpha-3 country code from geographic coordinates.

Click on the map to see a live preview.

Synopsis

Given the latitude and longitude coordinates this package returns the country code of the country in which the coordinates fall into.

The package internally uses @geo-maps/countries-maritime map with 10m resolution to give you the right country code. The accuracy of the map has been tested with 23785 cities but the demo allows you to actually test it manually by just clicking on the map to see what it returns.

Do you believe that this is useful? If so, support us with a ⭐️!

Install

$ npm install --save country-iso

Usage

You can query any (lat,lng) pair on the earth. It also works for territorial waters and disputed countries.

const countryIso = require('country-iso');

// Query a point in Italy.
countryIso.get(41.9028, 12.4964);
// => ['ITA']

// Query a disputed country.
countryIso.get(24, -14);
// => ['ESH', 'MAR']

// Query a point somewhere in Atlantic Ocean.
countryIso.get(40, -40);
// => []

API

get(lat, lng) ⇒ Array.<string>

Searches for every country which contains the point (lat, lng).

Returns: Array.<string> - Array of ISO 3166 alpha-3 country code for the geographic coordinates.

Param Type Description
lat number The latitude of the point.
lng number The longitude of the point.

Related

  • is-sea: 🌊 Check whether a geographic coordinate is in the sea or not on the earth.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details.

country-iso's People

Contributors

chq-matteo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

country-iso's Issues

Test.js

  • replace mkdirSync with ensureFolder (fs-extra package)
  • ./test/out' shold be in a variable
  • replace writeFileSync with writeJson (fs-extra)
  • console.log with test.log
  • rename failed-get-country to failed.geo.json
  • rename out folder to report
  • rename bad var to failed
  • fix wrong file path in log message

extent for cities?

This looks very nice! Will try it in a project soon!

I was wondering: how difficult is it to extent this for cities? So results will be land & city (if any)?

Index.js

  • Rename package from get-country to country-codes
  • Rename getCountryCodes to get
  • Change get external interface to get(lat, lng)
  • Remove worldGeojson initialization
  • Improve JSDoc for get
  • Improve JSDoc for use
  • Add license file for cities.json
  • Remove cities.json license notice from readme
  • Add API section to readme
  • Add usage section to readme
  • Add author section to readme
  • Add yourself as author
  • Remove utils and tools from .npmignore
  • add renane test.js to test in .npmignore (file to folder)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.