Skip to content

Commit

Permalink
Merge pull request #5 from hyubs/develop
Browse files Browse the repository at this point in the history
v1.1.1
  • Loading branch information
hubertursua committed Apr 24, 2020
2 parents b3ebe36 + a09036c commit 10ebc89
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 66 deletions.
62 changes: 62 additions & 0 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
declare interface ISO3166CitiesMunicipality {
name: string;
fullName: string;
altName?: string;
province: string;
classification: 'Mun' | 'CC' | 'ICC' | 'HUC';
isCapital: boolean;
}

declare interface ISO3166Province {
code: string;
name: string;
altName?: string;
nameTL: string;
region: string;
}

declare interface ISO3166Region {
code: string;
name: string;
altName?: string;
nameTL: string;
}

declare interface PSGCCitiesMunicipality {
code: string;
name: string;
fullName: string;
altName?: string;
province: string;
classification: 'MUNICIPALITY' | 'CITY';
isCapital: boolean;
}

declare interface PSGCProvince {
code: string;
name: string;
altName?: string;
region: string;
}

declare interface PSGCRegion {
code: string;
name: string;
altName?: string;
}

declare module 'ph-locations' {
export var citiesMunicipalities: ISO3166CitiesMunicipality[];
export var provinces: ISO3166Province[];
export var regions: ISO3166Region[];
export var iso3166: {
citiesMunicipalities: ISO3166CitiesMunicipality[];
provinces: ISO3166Province[];
regions: ISO3166Region[];
};
export var psgc: {
citiesMunicipalities: PSGCCitiesMunicipality[];
provinces: PSGCProvince[];
regions: PSGCRegion[];
};
}
81 changes: 66 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,64 @@ yarn add ph-locations

### Import

**Default (ISO 3166)**

```js
// CommonJS
const {
regions,
provinces,
citiesMunicipalities,
} = require('ph-locations');

// ES6
import {
regions,
provinces,
citiesMunicipalities,
} from 'ph-locations';
```

**PSGC**

```js
// CommonJS
const {
regions,
provinces,
citiesMunicipalities,
} = require('ph-locations').psgc;

// ES6
import { psgc } from 'ph-locations';
const {
regions,
provinces,
citiesMunicipalities,
} = psgc;

```

**ISO 3166 (same result as default)**

```js
// CommonJS
const regions = require('ph-locations/json/iso3166/regions');
const provinces = require('ph-locations/json/iso3166/provinces');
const citiesMunicipalities = require('ph-locations/json/iso3166/citiesMunicipalities');
const {
regions,
provinces,
citiesMunicipalities,
} = require('ph-locations').iso3166;

// ES6
import regions from 'ph-locations/json/iso3166/regions';
import provinces from 'ph-locations/json/iso3166/provinces';
import citiesMunicipalities from 'ph-locations/json/iso3166/citiesMunicipalities';
import { iso3166 } from 'ph-locations';
const {
regions,
provinces,
citiesMunicipalities,
} = iso3166;
```

## Source
## Sources

### ISO 3166 & Wikipedia

Expand All @@ -47,20 +92,22 @@ import citiesMunicipalities from 'ph-locations/json/iso3166/citiesMunicipalities
* [Provinces](https://psa.gov.ph/classification/psgc/?q=psgc/provinces)
* Cities (e.g. [Camarines Sur](https://psa.gov.ph/classification/psgc/?q=psgc/citimuni/051700000))

### Automatic Checking
## Automatic Checking

GitHub Actions ([ISO 3166](https://github.com/hyubs/ph-locations/actions?query=workflow%3A%22Data+Updated+ISO3166%22), [PSGC](https://github.com/hyubs/ph-locations/actions?query=workflow%3A%22Data+Updated+PSGC%22)) automatically runs everyday to check if the data is updated.

A [GitHub Action](https://github.com/hyubs/ph-locations/actions?query=workflow%3A%22Data+Updated%22) automatically checks everyday if the data is updated.
## Properties

## Regions
### Regions

| Property | Description | ISO 3166 | PSGC |
| - | - | :-: | :-: |
| code | ISO 3166 or PSGC code |||
| name | English name |||
| nameTL | Tagalog name |||
| acronym | Acronym or roman number |||
| altName | Alternative name, often the roman number or acronym of the region |||

## Provinces
### Provinces

| Property | Description | ISO 3166 | PSGC |
| - | - | :-: | :-: |
Expand All @@ -70,7 +117,7 @@ A [GitHub Action](https://github.com/hyubs/ph-locations/actions?query=workflow%3
| nameTL | Tagalog name |||
| region | ISO 3166 or PSGC code of the province's region |||

## Cities and Municipalities
### Cities and Municipalities

| Property | Description | ISO 3166 | PSGC |
| - | - | :-: | :-: |
Expand All @@ -82,7 +129,7 @@ A [GitHub Action](https://github.com/hyubs/ph-locations/actions?query=workflow%3
| classification | Classification of the city or municipality (see below) |||
| isCapital | Is the city or municipality the capital of the province |||

### Classification
#### Classification

**ISO 3166**

Expand All @@ -98,4 +145,8 @@ A [GitHub Action](https://github.com/hyubs/ph-locations/actions?query=workflow%3
| Value | Description |
| - | - |
| MUNICIPALITY | Municipality |
| CITY | City |
| CITY | City |

## License

Licensed under [MIT License](https://github.com/hyubs/ph-locations/blob/master/LICENSE)
21 changes: 21 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* eslint-disable global-require */

const iso3166 = {
citiesMunicipalities: require('./json/iso3166/citiesMunicipalities.json'),
provinces: require('./json/iso3166/provinces.json'),
regions: require('./json/iso3166/regions.json'),
};

const psgc = {
citiesMunicipalities: require('./json/psgc/citiesMunicipalities.json'),
provinces: require('./json/psgc/provinces.json'),
regions: require('./json/psgc/regions.json'),
};

module.exports = {
citiesMunicipalities: iso3166.citiesMunicipalities,
provinces: iso3166.provinces,
regions: iso3166.regions,
iso3166,
psgc,
};
34 changes: 17 additions & 17 deletions json/iso3166/regions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,102 +3,102 @@
"code": "PH-14",
"name": "Autonomous Region in Muslim Mindanao",
"nameTL": "Nagsasariling Rehiyon ng Muslim sa Mindanaw",
"acronym": "ARMM"
"altName": "ARMM"
},
{
"code": "PH-05",
"name": "Bicol",
"nameTL": "Rehiyon ng Bikol",
"acronym": "V"
"altName": "V"
},
{
"code": "PH-02",
"name": "Cagayan Valley",
"nameTL": "Rehiyon ng Lambak ng Kagayan",
"acronym": "II"
"altName": "II"
},
{
"code": "PH-40",
"name": "Calabarzon",
"nameTL": "Rehiyon ng Calabarzon",
"acronym": "IV-A"
"altName": "IV-A"
},
{
"code": "PH-13",
"name": "Caraga",
"nameTL": "Rehiyon ng Karaga",
"acronym": "XIII"
"altName": "XIII"
},
{
"code": "PH-03",
"name": "Central Luzon",
"nameTL": "Rehiyon ng Gitnang Luson",
"acronym": "III"
"altName": "III"
},
{
"code": "PH-07",
"name": "Central Visayas",
"nameTL": "Rehiyon ng Gitnang Bisaya",
"acronym": "VII"
"altName": "VII"
},
{
"code": "PH-15",
"name": "Cordillera Administrative Region",
"nameTL": "Rehiyon ng Administratibo ng Kordilyera",
"acronym": "CAR"
"altName": "CAR"
},
{
"code": "PH-11",
"name": "Davao",
"nameTL": "Rehiyon ng Dabaw",
"acronym": "XI"
"altName": "XI"
},
{
"code": "PH-08",
"name": "Eastern Visayas",
"nameTL": "Rehiyon ng Silangang Bisaya",
"acronym": "VIII"
"altName": "VIII"
},
{
"code": "PH-01",
"name": "Ilocos",
"nameTL": "Rehiyon ng Iloko",
"acronym": "I"
"altName": "I"
},
{
"code": "PH-41",
"name": "Mimaropa",
"nameTL": "Rehiyon ng Mimaropa",
"acronym": "IV-B"
"altName": "IV-B"
},
{
"code": "PH-00",
"name": "National Capital Region",
"nameTL": "Pambansang Punong Rehiyon",
"acronym": "NCR"
"altName": "NCR"
},
{
"code": "PH-10",
"name": "Northern Mindanao",
"nameTL": "Rehiyon ng Hilagang Mindanaw",
"acronym": "X"
"altName": "X"
},
{
"code": "PH-12",
"name": "Soccsksargen",
"nameTL": "Rehiyon ng Soccsksargen",
"acronym": "XII"
"altName": "XII"
},
{
"code": "PH-06",
"name": "Western Visayas",
"nameTL": "Rehiyon ng Kanlurang Bisaya",
"acronym": "VI"
"altName": "VI"
},
{
"code": "PH-09",
"name": "Zamboanga Peninsula",
"nameTL": "Rehiyon ng Tangway ng Sambuwangga",
"acronym": "IX"
"altName": "IX"
}
]
Loading

0 comments on commit 10ebc89

Please sign in to comment.