comuni-province-regioni
v0.4.3
Published
a package containing definitions for all the entities recognised as "Comune", "Provincia" and "Regione" in Italy
Downloads
62
Readme
Comuni, Province, Regioni
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.