@aprestmo/norway-geodata 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +288 -0
- package/data/fylker-2025.json +77 -0
- package/data/kommuner-2025.json +24802 -0
- package/data/postal-codes-2025.json +25687 -0
- package/dist/esm/index.d.ts +207 -0
- package/dist/esm/index.js +397 -0
- package/dist/esm/types.d.ts +111 -0
- package/dist/esm/types.js +2 -0
- package/dist/index.d.ts +207 -0
- package/dist/index.js +433 -0
- package/dist/types.d.ts +111 -0
- package/dist/types.js +3 -0
- package/package.json +95 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Alexander Prestmo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHERS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
# 🇳🇴 Norway Geodata
|
|
2
|
+
|
|
3
|
+
📍 Complete administrative geographic data for Norway (2025) with TypeScript support - municipalities, counties, postal codes, and 35+ utility functions.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@aprestmo/norway-geodata)
|
|
6
|
+
[](https://www.npmjs.com/package/@aprestmo/norway-geodata)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
|
|
10
|
+
## ✨ Features
|
|
11
|
+
|
|
12
|
+
- 🏛️ **Complete 2025 data** - All Norwegian municipalities and counties
|
|
13
|
+
- 🔒 **TypeScript first** - Full type safety and IntelliSense support
|
|
14
|
+
- 🚀 **Zero dependencies** - Lightweight and fast
|
|
15
|
+
- 🔍 **Rich search API** - 25+ functions for filtering and statistics
|
|
16
|
+
- 📦 **Multiple registries** - Available on npm and GitHub Packages
|
|
17
|
+
|
|
18
|
+
## 📦 Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @aprestmo/norway-geodata
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
<details>
|
|
25
|
+
<summary>Alternative: GitHub Packages</summary>
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Configure npm for GitHub Packages
|
|
29
|
+
npm config set @aprestmo:registry https://npm.pkg.github.com
|
|
30
|
+
npm config set //npm.pkg.github.com/:_authToken YOUR_GITHUB_TOKEN
|
|
31
|
+
|
|
32
|
+
# Install
|
|
33
|
+
npm install @aprestmo/norway-geodata
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
> Requires a [GitHub personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) with `read:packages` permission.
|
|
37
|
+
|
|
38
|
+
</details>
|
|
39
|
+
|
|
40
|
+
## 🚀 Quick Start
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import {
|
|
44
|
+
getMunicipalities,
|
|
45
|
+
getCounties,
|
|
46
|
+
getMunicipalityById,
|
|
47
|
+
getMunicipalitiesByName,
|
|
48
|
+
getAllPostalCodes,
|
|
49
|
+
type Municipality,
|
|
50
|
+
type County
|
|
51
|
+
} from '@aprestmo/norway-geodata';
|
|
52
|
+
|
|
53
|
+
// Get all municipalities
|
|
54
|
+
const municipalities = getMunicipalities();
|
|
55
|
+
console.log(`Found ${municipalities.length} municipalities`);
|
|
56
|
+
|
|
57
|
+
// Find Oslo
|
|
58
|
+
const oslo = getMunicipalityById('0301');
|
|
59
|
+
console.log('Oslo population:', oslo?.k_population);
|
|
60
|
+
|
|
61
|
+
// Search municipalities
|
|
62
|
+
const bergMunicipalities = getMunicipalitiesByName('berg');
|
|
63
|
+
console.log('Found:', bergMunicipalities.length);
|
|
64
|
+
|
|
65
|
+
// Get all postal codes
|
|
66
|
+
const postalCodes = getAllPostalCodes();
|
|
67
|
+
console.log(`Found ${postalCodes.length} postal codes`);
|
|
68
|
+
|
|
69
|
+
// Get postal codes with details
|
|
70
|
+
const detailedCodes = getAllPostalCodes(true);
|
|
71
|
+
console.log('First postal code:', detailedCodes[0]);
|
|
72
|
+
// Output: { zip: "0001", place: "Oslo", municipalityId: "0301", municipalityName: "Oslo" }
|
|
73
|
+
|
|
74
|
+
// Get all counties
|
|
75
|
+
const counties = getCounties();
|
|
76
|
+
console.log(`Found ${counties.length} counties`);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Working with Postal Codes
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import {
|
|
83
|
+
getPostalCodes,
|
|
84
|
+
getPostalCodeByCode,
|
|
85
|
+
getPostalCodesByPlace,
|
|
86
|
+
getPostalCodesByMunicipalityId,
|
|
87
|
+
getUniquePostalPlaces,
|
|
88
|
+
isValidPostalCode,
|
|
89
|
+
type PostalCode
|
|
90
|
+
} from '@aprestmo/norway-geodata';
|
|
91
|
+
|
|
92
|
+
// Get all postal codes
|
|
93
|
+
const allPostalCodes = getPostalCodes();
|
|
94
|
+
console.log(`Total postal codes: ${allPostalCodes.length}`);
|
|
95
|
+
|
|
96
|
+
// Find a specific postal code
|
|
97
|
+
const osloCenter = getPostalCodeByCode('0001');
|
|
98
|
+
console.log(osloCenter);
|
|
99
|
+
// Output: { k_postal_code: "0001", k_postal_place: "Oslo", k_id: "0301" }
|
|
100
|
+
|
|
101
|
+
// Search by place name (case-insensitive partial match)
|
|
102
|
+
const bergensPostalCodes = getPostalCodesByPlace('bergen');
|
|
103
|
+
console.log(`Bergen postal codes: ${bergensPostalCodes.length}`);
|
|
104
|
+
|
|
105
|
+
// Get postal codes for a municipality
|
|
106
|
+
const osloPostalCodes = getPostalCodesByMunicipalityId('0301');
|
|
107
|
+
console.log(`Oslo has ${osloPostalCodes.length} postal codes`);
|
|
108
|
+
|
|
109
|
+
// Check if postal code exists
|
|
110
|
+
const isValid = isValidPostalCode('0001');
|
|
111
|
+
console.log(`0001 is valid: ${isValid}`);
|
|
112
|
+
|
|
113
|
+
// Get unique postal places
|
|
114
|
+
const uniquePlaces = getUniquePostalPlaces();
|
|
115
|
+
console.log(`Unique places: ${uniquePlaces.length}`);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## API Reference
|
|
119
|
+
|
|
120
|
+
### Core Functions
|
|
121
|
+
|
|
122
|
+
- `getVersion()` - Get library version
|
|
123
|
+
- `getMunicipalities()` - Get all municipalities
|
|
124
|
+
- `getCounties()` - Get all counties
|
|
125
|
+
|
|
126
|
+
### Municipality Functions
|
|
127
|
+
|
|
128
|
+
- `getMunicipalityById(id: string)` - Get municipality by ID
|
|
129
|
+
- `getMunicipalitiesByName(name: string, options?: MunicipalitySearchOptions)` - Search by name with options
|
|
130
|
+
- `getMunicipalitiesByCounty(countyId: string)` - Get municipalities in county
|
|
131
|
+
- `getMunicipalityByPostalCode(postalCode: string | number)` - Get municipality by postal code
|
|
132
|
+
- `getPostalCodesByMunicipality(municipalityId: string)` - Get postal codes for municipality
|
|
133
|
+
- `getAllPostalCodes(includeDetails?: boolean)` - Get all postal codes, optionally with place names and municipality info
|
|
134
|
+
- `getMunicipalitiesByPopulation(ascending?: boolean)` - Sort by population
|
|
135
|
+
- `getMunicipalitiesByArea(ascending?: boolean)` - Sort by area
|
|
136
|
+
- `getMunicipalitiesByLanguage(language: LanguageStatus)` - Filter by language status
|
|
137
|
+
- `getMunicipalitiesFiltered(options: MunicipalityFilterOptions)` - Advanced filtering
|
|
138
|
+
- `getMunicipalitiesByPopulationDensity(min?: number, max?: number)` - Filter by density
|
|
139
|
+
- `getLargestMunicipalities(count?: number)` - Get largest by population
|
|
140
|
+
- `getSmallestMunicipalities(count?: number)` - Get smallest by population
|
|
141
|
+
|
|
142
|
+
### County Functions
|
|
143
|
+
|
|
144
|
+
- `getCountyById(id: string)` - Get county by ID
|
|
145
|
+
- `getCountyByName(name: string, exactMatch?: boolean)` - Search county by name
|
|
146
|
+
|
|
147
|
+
### Postal Code Functions
|
|
148
|
+
|
|
149
|
+
- `getPostalCodes()` - Get all postal codes with metadata
|
|
150
|
+
- `getPostalCodeByCode(code: string)` - Get postal code information by code
|
|
151
|
+
- `getPostalCodesByPlace(place: string, options?: PostalCodeSearchOptions)` - Search by postal place name
|
|
152
|
+
- `getPostalCodesByMunicipalityId(municipalityId: string)` - Get postal codes for municipality
|
|
153
|
+
- `getPostalCodesByMunicipalityName(municipalityName: string, exactMatch?: boolean)` - Get postal codes by municipality name
|
|
154
|
+
- `getUniquePostalPlaces()` - Get all unique postal place names
|
|
155
|
+
- `getPostalCodesInRange(startCode: string, endCode: string)` - Get postal codes within range
|
|
156
|
+
- `getPostalCodesSorted(ascending?: boolean)` - Get sorted postal codes
|
|
157
|
+
- `getPostalCodesStats()` - Get postal codes statistics
|
|
158
|
+
- `isValidPostalCode(code: string)` - Check if postal code exists
|
|
159
|
+
|
|
160
|
+
### Statistics Functions
|
|
161
|
+
|
|
162
|
+
- `getTotalPopulation(): number` - Total population of Norway
|
|
163
|
+
- `getTotalArea(): number` - Total area of Norway
|
|
164
|
+
- `getPopulationDensityStats(): PopulationDensityStats` - Population density statistics
|
|
165
|
+
|
|
166
|
+
### Type Exports
|
|
167
|
+
|
|
168
|
+
All TypeScript interfaces and types are exported:
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
import type {
|
|
172
|
+
Municipality,
|
|
173
|
+
County,
|
|
174
|
+
PostalCode,
|
|
175
|
+
LanguageStatus,
|
|
176
|
+
PopulationDensityStats,
|
|
177
|
+
MunicipalitySearchOptions,
|
|
178
|
+
MunicipalityFilterOptions,
|
|
179
|
+
PostalCodeSearchOptions
|
|
180
|
+
} from '@aprestmo/norway-geodata';
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## 🎯 TypeScript Support
|
|
184
|
+
|
|
185
|
+
Full TypeScript support with strict type safety:
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
import type {
|
|
189
|
+
Municipality,
|
|
190
|
+
County,
|
|
191
|
+
LanguageStatus,
|
|
192
|
+
MunicipalitySearchOptions,
|
|
193
|
+
MunicipalityFilterOptions
|
|
194
|
+
} from '@aprestmo/norway-geodata';
|
|
195
|
+
|
|
196
|
+
// Type-safe operations
|
|
197
|
+
const oslo: Municipality | undefined = getMunicipalityById('0301');
|
|
198
|
+
if (oslo) {
|
|
199
|
+
// Full IntelliSense support
|
|
200
|
+
console.log(oslo.k_name); // string
|
|
201
|
+
console.log(oslo.k_population); // number
|
|
202
|
+
console.log(oslo.k_postal_codes); // readonly number[]
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## 📊 Data Types
|
|
207
|
+
|
|
208
|
+
### Municipality
|
|
209
|
+
```typescript
|
|
210
|
+
interface Municipality {
|
|
211
|
+
readonly k_id: string; // "0301" (Oslo)
|
|
212
|
+
readonly k_name: string; // "Oslo"
|
|
213
|
+
readonly k_name_no: string; // "Oslo"
|
|
214
|
+
readonly k_adm_center: string; // "Oslo"
|
|
215
|
+
readonly k_population: number; // 709037
|
|
216
|
+
readonly k_area: number; // 454.07
|
|
217
|
+
readonly k_language: LanguageStatus; // "Nøytral"
|
|
218
|
+
readonly k_url: string; // "https://oslo.kommune.no"
|
|
219
|
+
readonly k_postal_codes: readonly number[]; // [179, 180, 181, ...]
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### County
|
|
224
|
+
```typescript
|
|
225
|
+
interface County {
|
|
226
|
+
readonly f_id: string; // "03" (Oslo)
|
|
227
|
+
readonly f_name: string; // "Oslo"
|
|
228
|
+
readonly f_url: string; // "https://oslo.fylkeskommune.no"
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### PostalCode
|
|
233
|
+
```typescript
|
|
234
|
+
interface PostalCode {
|
|
235
|
+
readonly k_postal_code: string; // "0001"
|
|
236
|
+
readonly k_postal_place: string; // "Oslo"
|
|
237
|
+
readonly k_id: string; // "0301" (municipality ID)
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Options
|
|
242
|
+
```typescript
|
|
243
|
+
interface MunicipalitySearchOptions {
|
|
244
|
+
readonly includeAllNames?: boolean; // Search both EN/NO names
|
|
245
|
+
readonly caseSensitive?: boolean; // Case sensitive
|
|
246
|
+
readonly exactMatch?: boolean; // Exact match only
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
interface MunicipalityFilterOptions {
|
|
250
|
+
readonly minPopulation?: number;
|
|
251
|
+
readonly maxPopulation?: number;
|
|
252
|
+
readonly minArea?: number; // km²
|
|
253
|
+
readonly maxArea?: number; // km²
|
|
254
|
+
readonly language?: LanguageStatus;
|
|
255
|
+
readonly countyId?: string;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
interface PostalCodeSearchOptions {
|
|
259
|
+
readonly caseSensitive?: boolean; // Case sensitive search
|
|
260
|
+
readonly exactMatch?: boolean; // Exact match only
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
type LanguageStatus = 'Nøytral' | 'Bokmål' | 'Nynorsk';
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
## 🤝 Contributing
|
|
267
|
+
|
|
268
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for detailed guidelines.
|
|
269
|
+
|
|
270
|
+
### Quick Start
|
|
271
|
+
1. Fork the repository
|
|
272
|
+
2. Create a feature branch
|
|
273
|
+
3. Make your changes
|
|
274
|
+
4. Create a pull request
|
|
275
|
+
|
|
276
|
+
All contributions go through automated validation and testing.
|
|
277
|
+
|
|
278
|
+
## 📄 License
|
|
279
|
+
|
|
280
|
+
MIT License - see [LICENSE](./LICENSE) file for details.
|
|
281
|
+
|
|
282
|
+
## 📊 Package Info
|
|
283
|
+
|
|
284
|
+
- **npm**: [@aprestmo/norway-geodata](https://www.npmjs.com/package/@aprestmo/norway-geodata)
|
|
285
|
+
- **GitHub**: [aprestmo/norway-geodata](https://github.com/aprestmo/norway-geodata)
|
|
286
|
+
- **Data**: Norwegian administrative data (2025)
|
|
287
|
+
- **License**: MIT
|
|
288
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"f_id": "03",
|
|
4
|
+
"f_name": "Oslo",
|
|
5
|
+
"f_url": "www.oslo.kommune.no"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"f_id": "11",
|
|
9
|
+
"f_name": "Rogaland",
|
|
10
|
+
"f_url": "www.rogfk.no"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"f_id": "15",
|
|
14
|
+
"f_name": "Møre og Romsdal",
|
|
15
|
+
"f_url": "www.mrfylke.no"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"f_id": "18",
|
|
19
|
+
"f_name": "Nordland",
|
|
20
|
+
"f_url": "www.nfk.no"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"f_id": "31",
|
|
24
|
+
"f_name": "Østfold",
|
|
25
|
+
"f_url": "www.ofk.no"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"f_id": "32",
|
|
29
|
+
"f_name": "Akershus",
|
|
30
|
+
"f_url": "www.afk.no"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"f_id": "33",
|
|
34
|
+
"f_name": "Buskerud",
|
|
35
|
+
"f_url": "www.bfk.no"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"f_id": "34",
|
|
39
|
+
"f_name": "Innlandet",
|
|
40
|
+
"f_url": "www.innlandetfylke.no"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"f_id": "39",
|
|
44
|
+
"f_name": "Vestfold",
|
|
45
|
+
"f_url": "www.vestfoldfylke.no"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"f_id": "40",
|
|
49
|
+
"f_name": "Telemark",
|
|
50
|
+
"f_url": "www.telemarkfylke.no"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"f_id": "42",
|
|
54
|
+
"f_name": "Agder",
|
|
55
|
+
"f_url": "www.agderfk.no"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"f_id": "46",
|
|
59
|
+
"f_name": "Vestland",
|
|
60
|
+
"f_url": "www.vestlandfylke.no"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"f_id": "50",
|
|
64
|
+
"f_name": "Trøndelag",
|
|
65
|
+
"f_url": "www.trondelagfylke.no"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"f_id": "55",
|
|
69
|
+
"f_name": "Troms",
|
|
70
|
+
"f_url": "www.tromsfylke.no"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"f_id": "56",
|
|
74
|
+
"f_name": "Finnmark",
|
|
75
|
+
"f_url": "www.ffk.no"
|
|
76
|
+
}
|
|
77
|
+
]
|