@nexgen-os/urbis 0.0.0-stage → 0.4.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 +21 -0
- package/README.md +14 -2
- package/dist/index.d.ts +22 -0
- package/dist/index.js +56 -0
- package/package.json +35 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nexgen OS contributors
|
|
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
|
+
AUTHORS 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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@nexgen-os/urbis` — the Brussels address register
|
|
2
|
+
|
|
3
|
+
The UrbIS geolocation service of Paradigm, the address register of the Brussels-Capital Region, in French or Dutch. Source `urbis`. MIT; open, no key.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { urbis } from '@nexgen-os/urbis';
|
|
7
|
+
|
|
8
|
+
const geocoder = urbis({ languages: ['fr', 'nl'] });
|
|
9
|
+
const [place] = await geocoder.search('Wetstraat 16, 1000 Brussel');
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The place is the standard shape of `@nexgen-os/core` (address, WGS 84 point,
|
|
13
|
+
precision, source); `placeFields(place)` gives the place columns of `participants` it fills.
|
|
14
|
+
Decision [0009](../../../docs/decisions/0009-what-applies-follows-the-region.md).
|
|
2
15
|
|
|
3
|
-
This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Fetch, Geocoder } from '@nexgen-os/core';
|
|
2
|
+
interface Common {
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
fetch?: Fetch;
|
|
5
|
+
}
|
|
6
|
+
export interface UrbisOptions extends Common {
|
|
7
|
+
/**
|
|
8
|
+
* The languages the register is asked in, in turn: it only matches a
|
|
9
|
+
* street name written in the language of the request. The search's own
|
|
10
|
+
* language goes first when it is one of them.
|
|
11
|
+
*/
|
|
12
|
+
languages: string[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The Brussels address register. It answers every query, inside Brussels
|
|
16
|
+
* or not, with the nearest name it has: only places whose street name it
|
|
17
|
+
* found are kept, so a search elsewhere returns nothing and the chain moves
|
|
18
|
+
* on. Its reverse lookup takes Belgian Lambert 72 only, so `reverse` answers
|
|
19
|
+
* null; Geopunt answers reverse lookups in Brussels.
|
|
20
|
+
*/
|
|
21
|
+
export declare function urbis(options: UrbisOptions): Geocoder;
|
|
22
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// UrbIS — the Brussels address register (Paradigm geolocation service) as a Geocoder
|
|
2
|
+
// of the core's shape. Open, no key.
|
|
3
|
+
/**
|
|
4
|
+
* The Brussels address register. It answers every query, inside Brussels
|
|
5
|
+
* or not, with the nearest name it has: only places whose street name it
|
|
6
|
+
* found are kept, so a search elsewhere returns nothing and the chain moves
|
|
7
|
+
* on. Its reverse lookup takes Belgian Lambert 72 only, so `reverse` answers
|
|
8
|
+
* null; Geopunt answers reverse lookups in Brussels.
|
|
9
|
+
*/
|
|
10
|
+
export function urbis(options) {
|
|
11
|
+
if (!options.languages?.length)
|
|
12
|
+
throw new Error('languages_required: UrbIS matches street names in the language it is asked in');
|
|
13
|
+
const base = trimSlash(options.baseUrl ?? 'https://geoservices.irisnet.be/localization');
|
|
14
|
+
const doFetch = options.fetch ?? globalThis.fetch;
|
|
15
|
+
return {
|
|
16
|
+
source_code: 'urbis',
|
|
17
|
+
async search(text, search = {}) {
|
|
18
|
+
const wanted = search.language?.slice(0, 2).toLowerCase();
|
|
19
|
+
const languages = wanted && options.languages.includes(wanted) ? [wanted, ...options.languages.filter((l) => l !== wanted)] : options.languages;
|
|
20
|
+
for (const language of languages) {
|
|
21
|
+
const params = new URLSearchParams({ language, spatialReference: '4326', address: text });
|
|
22
|
+
const body = (await getJson(doFetch, `${base}/Rest/Localize/getaddresses?${params}`));
|
|
23
|
+
const places = (body.result ?? []).filter((r) => r.qualificationCode.streetName === '1').map(fromUrbis);
|
|
24
|
+
if (places.length)
|
|
25
|
+
return places.slice(0, search.limit ?? 5);
|
|
26
|
+
}
|
|
27
|
+
return [];
|
|
28
|
+
},
|
|
29
|
+
async reverse() {
|
|
30
|
+
return null;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function fromUrbis(r) {
|
|
35
|
+
const s = r.address.street;
|
|
36
|
+
const found = r.qualificationCode.policeNumber === '1';
|
|
37
|
+
const street = [s.name, found ? r.address.number : null].filter(Boolean).join(' ');
|
|
38
|
+
return {
|
|
39
|
+
address: { address_line1: street, address_line2: null, postal_code: s.postCode, city: s.municipality, region: 'BE-BRU', municipality_code: null, country: 'BE' },
|
|
40
|
+
lon: r.point.x,
|
|
41
|
+
lat: r.point.y,
|
|
42
|
+
// An interpolated or missing number is placed on the street.
|
|
43
|
+
precision: found ? 'rooftop' : 'street',
|
|
44
|
+
source_code: 'urbis',
|
|
45
|
+
label: `${street}, ${s.postCode} ${s.municipality}`,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async function getJson(doFetch, url) {
|
|
49
|
+
const response = await doFetch(url, { headers: { Accept: 'application/json' } });
|
|
50
|
+
if (!response.ok)
|
|
51
|
+
throw new Error(`geocoder_unavailable: ${response.status} from ${url}`);
|
|
52
|
+
return response.json();
|
|
53
|
+
}
|
|
54
|
+
function trimSlash(url) {
|
|
55
|
+
return url.replace(/\/+$/, '');
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexgen-os/urbis",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "The Brussels address register (UrbIS) as a Nexgen OS geocoder.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/nexgen-os/nexgen-os.git",
|
|
9
|
+
"directory": "packages/connectors/urbis"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=20"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc -p tsconfig.build.json"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@nexgen-os/core": "^0.4.0"
|
|
36
|
+
}
|
|
37
|
+
}
|