@geospatial-sdk/geocoding 0.0.5-alpha.8 → 0.0.5-dev.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geospatial-sdk/geocoding",
3
- "version": "0.0.5-alpha.8+8eeb557",
3
+ "version": "0.0.5-dev.0+97d2685",
4
4
  "description": "Geocoding-related components",
5
5
  "keywords": [
6
6
  "geocoding"
@@ -32,5 +32,5 @@
32
32
  "bugs": {
33
33
  "url": "https://github.com/jahow/geospatial-sdk/issues"
34
34
  },
35
- "gitHead": "8eeb557170b5af3e8ab5f25fdfa850a3edd09c21"
35
+ "gitHead": "97d2685498a9b6208d833a15480a5a9ca804e12f"
36
36
  }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=data-gouv-fr.provider.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-gouv-fr.provider.test.d.ts","sourceRoot":"","sources":["../../lib/providers/data-gouv-fr.provider.test.ts"],"names":[],"mappings":""}
@@ -1,89 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { queryDataGouvFr } from "./data-gouv-fr.provider";
11
- const RESULTS_FIXTURE = {
12
- type: "FeatureCollection",
13
- version: "draft",
14
- features: [
15
- {
16
- type: "Feature",
17
- geometry: {
18
- type: "Point",
19
- coordinates: [2.290084, 49.897443],
20
- },
21
- properties: {
22
- label: "8 Boulevard du Port 80000 Amiens",
23
- score: 0.49159121588068583,
24
- housenumber: "8",
25
- id: "80021_6590_00008",
26
- type: "housenumber",
27
- name: "8 Boulevard du Port",
28
- postcode: "80000",
29
- citycode: "80021",
30
- x: 648952.58,
31
- y: 6977867.25,
32
- city: "Amiens",
33
- context: "80, Somme, Hauts-de-France",
34
- importance: 0.6706612694243868,
35
- street: "Boulevard du Port",
36
- },
37
- },
38
- ],
39
- attribution: "BAN",
40
- licence: "ODbL 1.0",
41
- query: "8 bd du port",
42
- limit: 1,
43
- };
44
- global.fetch = vi.fn(() => Promise.resolve({
45
- json: () => Promise.resolve(RESULTS_FIXTURE),
46
- }));
47
- describe("queryDataGouvFr", () => {
48
- let results;
49
- beforeEach(() => {
50
- vi.clearAllMocks();
51
- });
52
- describe("results parsing", () => {
53
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
54
- results = yield queryDataGouvFr("hello");
55
- }));
56
- it("produces geometries, removes html tags from labels", () => {
57
- expect(results).toEqual([
58
- {
59
- geom: {
60
- type: "Point",
61
- coordinates: [2.290084, 49.897443],
62
- },
63
- label: "8 Boulevard du Port 80000 Amiens",
64
- },
65
- ]);
66
- });
67
- });
68
- describe("default options", () => {
69
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
70
- results = yield queryDataGouvFr("hello world");
71
- }));
72
- it("uses default options", () => {
73
- expect(global.fetch).toHaveBeenCalledWith("https://api-adresse.data.gouv.fr/search/?q=hello+world");
74
- });
75
- });
76
- describe("custom options", () => {
77
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
78
- results = yield queryDataGouvFr("hello world", {
79
- type: "street",
80
- limit: 32,
81
- cityCode: "12345",
82
- postCode: "00000",
83
- });
84
- }));
85
- it("uses given options", () => {
86
- expect(global.fetch).toHaveBeenCalledWith("https://api-adresse.data.gouv.fr/search/?q=hello+world&limit=32&type=street&postcode=00000&citycode=12345");
87
- });
88
- });
89
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=geoadmin.provider.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"geoadmin.provider.test.d.ts","sourceRoot":"","sources":["../../lib/providers/geoadmin.provider.test.ts"],"names":[],"mappings":""}
@@ -1,162 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { queryGeoadmin } from "./geoadmin.provider";
11
- const RESULTS_FIXTURE = {
12
- type: "FeatureCollection",
13
- bbox: [8.446892, 47.319034, 8.627209, 47.43514],
14
- features: [
15
- {
16
- geometry: {
17
- type: "Point",
18
- coordinates: [8.446892, 47.319034],
19
- },
20
- properties: {
21
- origin: "gazetteer",
22
- geom_quadindex: "021300220330313020221",
23
- weight: 1,
24
- zoomlevel: 10,
25
- lon: 7.459799289703369,
26
- detail: "wabern koeniz",
27
- rank: 5,
28
- lat: 46.925777435302734,
29
- num: 1,
30
- y: 601612.0625,
31
- x: 197186.8125,
32
- label: "<i>Populated Place</i> <b>Wabern</b> (BE) - Köniz",
33
- id: 215754,
34
- },
35
- type: "Feature",
36
- id: 215754,
37
- bbox: [8.446892, 47.319034, 8.627209, 47.43514],
38
- },
39
- {
40
- geometry: {
41
- type: "Point",
42
- coordinates: [8.446892, 47.319034],
43
- },
44
- properties: {
45
- origin: "gg25",
46
- geom_quadindex: "030003",
47
- weight: 6,
48
- zoomlevel: 4294967295,
49
- lon: 8.527311325073242,
50
- detail: "zurigo zh",
51
- rank: 2,
52
- lat: 47.37721252441406,
53
- num: 1,
54
- x: 8.527311325073242,
55
- y: 47.37721252441406,
56
- label: "<b>Zurigo (ZH)</b>",
57
- id: 153,
58
- featureId: "261",
59
- },
60
- type: "Feature",
61
- id: 153,
62
- bbox: [8.446892, 47.319034, 8.627209, 47.43514],
63
- },
64
- ],
65
- };
66
- global.fetch = vi.fn(() => Promise.resolve({
67
- json: () => Promise.resolve(RESULTS_FIXTURE),
68
- }));
69
- describe("queryGeoadmin", () => {
70
- let results;
71
- beforeEach(() => {
72
- vi.clearAllMocks();
73
- });
74
- describe("results parsing", () => {
75
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
76
- results = yield queryGeoadmin("hello");
77
- }));
78
- it("produces geometries, removes html tags from labels", () => {
79
- expect(results).toEqual([
80
- {
81
- geom: {
82
- coordinates: [
83
- [
84
- [8.446892, 47.319034],
85
- [8.446892, 47.43514],
86
- [8.627209, 47.43514],
87
- [8.627209, 47.319034],
88
- [8.446892, 47.319034],
89
- ],
90
- ],
91
- type: "Polygon",
92
- },
93
- label: "Populated Place Wabern (BE) - Köniz",
94
- },
95
- {
96
- geom: {
97
- coordinates: [
98
- [
99
- [8.446892, 47.319034],
100
- [8.446892, 47.43514],
101
- [8.627209, 47.43514],
102
- [8.627209, 47.319034],
103
- [8.446892, 47.319034],
104
- ],
105
- ],
106
- type: "Polygon",
107
- },
108
- label: "Zurigo (ZH)",
109
- },
110
- ]);
111
- });
112
- });
113
- describe("default options", () => {
114
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
115
- results = yield queryGeoadmin("hello world");
116
- }));
117
- it("uses default options", () => {
118
- expect(global.fetch).toHaveBeenCalledWith("https://api3.geo.admin.ch/rest/services/api/SearchServer?geometryFormat=geojson&type=locations&searchText=hello+world&lang=en&sr=4326&origins=zipcode%2Cgg25");
119
- });
120
- });
121
- describe("locations search", () => {
122
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
123
- results = yield queryGeoadmin("hello world", {
124
- type: "locations",
125
- lang: "de",
126
- origins: ["district", "address"],
127
- limit: 32,
128
- sr: "21781",
129
- });
130
- }));
131
- it("uses given options", () => {
132
- expect(global.fetch).toHaveBeenCalledWith("https://api3.geo.admin.ch/rest/services/api/SearchServer?geometryFormat=geojson&type=locations&searchText=hello+world&lang=de&sr=21781&limit=32&origins=district%2Caddress");
133
- });
134
- });
135
- describe("feature search", () => {
136
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
137
- results = yield queryGeoadmin("hello world", {
138
- type: "featuresearch",
139
- lang: "de",
140
- features: ["abc", "def"],
141
- limit: 32,
142
- sr: "21781",
143
- });
144
- }));
145
- it("uses given options", () => {
146
- expect(global.fetch).toHaveBeenCalledWith("https://api3.geo.admin.ch/rest/services/api/SearchServer?geometryFormat=geojson&type=featuresearch&searchText=hello+world&lang=de&sr=21781&limit=32&features=abc%2Cdef");
147
- });
148
- });
149
- describe("layers search", () => {
150
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
151
- results = yield queryGeoadmin("hello world", {
152
- type: "layers",
153
- lang: "de",
154
- limit: 32,
155
- sr: "21781",
156
- });
157
- }));
158
- it("uses given options", () => {
159
- expect(global.fetch).toHaveBeenCalledWith("https://api3.geo.admin.ch/rest/services/api/SearchServer?geometryFormat=geojson&type=layers&searchText=hello+world&lang=de&sr=21781&limit=32");
160
- });
161
- });
162
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=geonames.provider.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"geonames.provider.test.d.ts","sourceRoot":"","sources":["../../lib/providers/geonames.provider.test.ts"],"names":[],"mappings":""}
@@ -1,120 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { queryGeonames } from "./geonames.provider";
11
- import { describe } from "vitest";
12
- const MOCK_DATA = {
13
- totalResultsCount: 35,
14
- geonames: [
15
- {
16
- adminCode1: "ZH",
17
- lng: "8.55",
18
- geonameId: 2657896,
19
- toponymName: "Zürich",
20
- countryId: "2658434",
21
- fcl: "P",
22
- population: 341730,
23
- countryCode: "CH",
24
- name: "Zurich",
25
- fclName: "city, village...",
26
- adminCodes1: { ISO3166_2: "ZH" },
27
- countryName: "Switzerland",
28
- fcodeName: "seat of a first-order administrative division",
29
- adminName1: "Zurich",
30
- lat: "47.36667",
31
- fcode: "PPLA"
32
- },
33
- {
34
- adminCode1: "ZH",
35
- lng: "8.66667",
36
- geonameId: 2657895,
37
- toponymName: "Kanton Zürich",
38
- countryId: "2658434",
39
- fcl: "A",
40
- population: 1553423,
41
- countryCode: "CH",
42
- name: "Zurich",
43
- fclName: "country, state, region...",
44
- adminCodes1: { ISO3166_2: "ZH" },
45
- countryName: "Switzerland",
46
- fcodeName: "first-order administrative division",
47
- adminName1: "Zurich",
48
- lat: "47.41667",
49
- fcode: "ADM1"
50
- }
51
- ]
52
- };
53
- vi.stubGlobal('fetch', vi.fn(() => Promise.resolve({
54
- ok: true, // Ensure the mock reflects a successful response
55
- json: () => Promise.resolve(MOCK_DATA),
56
- })));
57
- describe("queryGeonames", () => {
58
- let results;
59
- beforeEach(() => {
60
- vi.clearAllMocks();
61
- });
62
- describe("results parsing", () => {
63
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
64
- results = yield queryGeonames("Zurich");
65
- }));
66
- it("correctly processes Geonames API response", () => {
67
- expect(results).toEqual([
68
- {
69
- label: "Zurich",
70
- geom: {
71
- type: "Point",
72
- coordinates: [8.55, 47.36667],
73
- },
74
- },
75
- {
76
- label: "Zurich",
77
- geom: {
78
- type: "Point",
79
- coordinates: [8.66667, 47.41667],
80
- },
81
- },
82
- ]);
83
- });
84
- });
85
- describe("default options", () => {
86
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
87
- results = yield queryGeonames("Zurich");
88
- }));
89
- it("uses default options", () => {
90
- expect(global.fetch).toHaveBeenCalledWith(expect.stringContaining("https://secure.geonames.org/searchJSON?q=Zurich&username=gn_ui&maxRows=10"));
91
- });
92
- });
93
- describe("custom options", () => {
94
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
95
- results = yield queryGeonames("Zurich", {
96
- lang: "de",
97
- maxRows: 5,
98
- country: "CH",
99
- username: "customUser",
100
- });
101
- }));
102
- it("uses given options for custom search", () => {
103
- expect(global.fetch).toHaveBeenCalledWith(expect.stringContaining("https://secure.geonames.org/searchJSON?q=Zurich&username=customUser&maxRows=5&country=CH&lang=de&style=FULL&type=json"));
104
- });
105
- });
106
- describe("bounding box search", () => {
107
- beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
108
- results = yield queryGeonames("Zurich", {
109
- east: 10,
110
- west: 5,
111
- north: 50,
112
- south: 45,
113
- username: "customUser",
114
- });
115
- }));
116
- it("uses given options for bounding box search", () => {
117
- expect(global.fetch).toHaveBeenCalledWith(expect.stringContaining("https://secure.geonames.org/searchJSON?q=Zurich&username=customUser&maxRows=10&lang=en&style=FULL&type=json&east=10&west=5&north=50&south=45"));
118
- });
119
- });
120
- });