Skip to content

Typescript definition with attributes for Comuni (Cities), Province (Provinces) and Regioni (Regions) in Italy

License

Notifications You must be signed in to change notification settings

veeso/comuni-province-regioni

Repository files navigation

Comuni, Province, Regioni

NPM CI

Introduction

This simple Typescript library contains all the definitions for the Italian administrative entities:

  • Comune
  • Provincia
  • Regione

with all the entries and some helpers, such as

  • get region for comune
  • get provincia for comune
  • get provinces for a region
  • get region from a province

List of cities

The list of cities in Italy is periodically retrieved and auto-generated by a Python script which fetches the cities from Istat from https://www.istat.it/storage/codici-unita-amministrative/Elenco-comuni-italiani.csv.

The tool can be found at tools/comuni.py

Get started

With NPM

npm install comuni-province-regioni

or with Yarn

yarn add comuni-province-regioni

Examples

Get City attributes

import City, { CITIES_ATTRIBUTES } from 'comuni-province-regioni/lib/city';

const attrs = CITIES_ATTRIBUTES[City.MOIMACCO_030060];
console.log(attrs.name, attrs.province, attrs.region);

Get province region and viceversa

import Province, { PROVINCES_BY_REGION, REGION_BY_PROVINCE, provinceToString } from 'comuni-province-regioni/lib/province';
import Region from 'comuni-province-regioni/lib/region';

const regionProvinces = PROVINCES_BY_REGION[Region.PIEMONTE];
for (const province of regionProvinces) {
  console.log(provinceToString(province));
  // ...
}

const regionOfPordenone = REGION_BY_PROVINCE[Province.PORDENONE];

License

comuni-province-regioni is licensed under MIT.

See full license HERE.

About

Typescript definition with attributes for Comuni (Cities), Province (Provinces) and Regioni (Regions) in Italy

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages