Giter Site home page Giter Site logo

countrydata's Introduction

CountryData

Build status NuGet Status NuGet Status

Provides a .net wrapper around the GeoNames Data. Also exposes the data as per country json files.

Support is available via a Tidelift Subscription.

Contents

NuGet packages

The NuGets contain a static copy of all data. This data is embedded as resources inside the assembly. No network calls are done by the assembly. To get the latests version of the data do a NuGet update. There are several options to help keep a NuGet update:

Usage

// All country info. This is only the country metadata
// and not all locationData.
var allCountryInfo = CountryLoader.CountryInfo;
var costaRicaInfo = allCountryInfo.Single(x => x.Iso == "CR");

// Loads all location data for a specific country
var australiaData = CountryLoader.LoadAustraliaLocationData();
var name = australiaData.Name;
var state = australiaData.States.First();
var province = state.Provinces.First();
var community = province.Communities.First();
var place = community.Places.First();
var postCode = place.PostCode;
var placeName = place.Name;
var latitude = place.Location.Latitude;
var longitude = place.Location.Longitude;

snippet source | anchor

Bogus Usage

var faker = new Faker<Target>()
    .RuleFor(
        property: u => u.RandomCountryName,
        setter: (f, u) => f.Country().Name())
    .RuleFor(
        property: u => u.RandomCountryCurrency,
        setter: (f, u) => f.Country().CurrencyCode())
    .RuleFor(
        property: u => u.AustralianCapital,
        setter: (f, u) => f.Country().Australia().Capital)
    .RuleFor(
        property: u => u.RandomIrelandState,
        setter: (f, u) => f.Country().Ireland().State().Name)
    .RuleFor(
        property: u => u.RandomIcelandPostCode,
        setter: (f, u) => f.Country().Iceland().PostCode());
var targetInstance = faker.Generate();

snippet source | anchor

Json Files

Country Codes

List of country codes: https://raw.githubusercontent.com/SimonCropp/CountryData/master/Data/countrycodes.txt

https://raw.githubusercontent.com/SimonCropp/CountryData/master/Data/PostCodes/[CountryCode].json.txt

Country Information

https://github.com/SimonCropp/CountryData/blob/master/Data/countryInfo.json.txt

Country Location Data

For example the url for Australia (AU) is:

https://raw.githubusercontent.com/SimonCropp/CountryData/master/Data/PostCodes/AU.json.txt

Structure

The GeoNames data is structured as:

Country > State > Province > Community > Place

However many countries do not have data for every level.

Security contact information

To report a security vulnerability, use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

Icon

World designed by Pedro Santos from The Noun Project.

countrydata's People

Contributors

dependabot-preview[bot] avatar simoncropp avatar dependabot[bot] avatar dependabot-support avatar actions-user avatar ryanjmcgowan avatar guiorgy avatar

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.