@mapcreator/api 5.0.0-alpha.74 → 5.0.0-alpha.75
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/cjs/api/choropleth.d.ts +60 -19
- package/cjs/api/choropleth.d.ts.map +1 -1
- package/cjs/api/choropleth.js +28 -20
- package/cjs/api/choropleth.js.map +1 -1
- package/esm/api/choropleth.d.ts +60 -19
- package/esm/api/choropleth.d.ts.map +1 -1
- package/esm/api/choropleth.js +27 -20
- package/esm/api/choropleth.js.map +1 -1
- package/package.json +1 -1
- package/src/api/choropleth.ts +106 -85
package/cjs/api/choropleth.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ApiError, type ApiSuccess, type Flatten, type Revivers } from '../utils.js';
|
|
1
2
|
import type { RequireAtLeastOne } from 'type-fest';
|
|
2
3
|
import type { Polygon } from 'geojson';
|
|
3
4
|
export type ApiSearchPoint = {
|
|
@@ -16,18 +17,35 @@ type SingleOrGroupedAreaBase = {
|
|
|
16
17
|
subtitle: string;
|
|
17
18
|
svgPreview: string;
|
|
18
19
|
boundingBox: Polygon;
|
|
20
|
+
isGroup: boolean;
|
|
21
|
+
properties: Record<string, string> | null;
|
|
19
22
|
};
|
|
20
|
-
export type GroupedArea = SingleOrGroupedAreaBase
|
|
21
|
-
isGroup: true;
|
|
22
|
-
};
|
|
23
|
+
export type GroupedArea = SingleOrGroupedAreaBase;
|
|
23
24
|
export type SingleArea = SingleOrGroupedAreaBase & {
|
|
24
|
-
isGroup: false;
|
|
25
25
|
vectorSource: string;
|
|
26
26
|
sourceLayer: string;
|
|
27
27
|
featureId: number;
|
|
28
|
-
properties: Record<string, string>;
|
|
29
28
|
};
|
|
30
29
|
export type SingleOrGroupedArea = SingleArea | GroupedArea;
|
|
30
|
+
export type ApiSingleOrGroupedArea = {
|
|
31
|
+
data: {
|
|
32
|
+
id: number;
|
|
33
|
+
title: string;
|
|
34
|
+
subtitle: string;
|
|
35
|
+
svg_preview: string;
|
|
36
|
+
bounding_box: string;
|
|
37
|
+
is_group: boolean;
|
|
38
|
+
vector_source: string | null;
|
|
39
|
+
source_layer: string | null;
|
|
40
|
+
feature_id: number | null;
|
|
41
|
+
properties: string | null;
|
|
42
|
+
};
|
|
43
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
44
|
+
export type ApiSingleOrGroupedAreaData = Flatten<Exclude<ApiSingleOrGroupedArea, ApiError>['data']>;
|
|
45
|
+
export declare const singleOrGroupedAreaRevivers: Revivers<ApiSingleOrGroupedArea, SingleOrGroupedArea>;
|
|
46
|
+
/**
|
|
47
|
+
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
48
|
+
*/
|
|
31
49
|
export declare function searchSingleOrGroupedAreas(language: string, search: RequireAtLeastOne<{
|
|
32
50
|
searchBounds?: ApiSearchBounds;
|
|
33
51
|
query?: string;
|
|
@@ -39,8 +57,22 @@ export type GroupedAreaChild = {
|
|
|
39
57
|
vectorSource: string;
|
|
40
58
|
sourceLayer: string;
|
|
41
59
|
featureId: number;
|
|
60
|
+
boundingBox: Polygon;
|
|
42
61
|
properties: Record<string, string>;
|
|
43
62
|
};
|
|
63
|
+
type ApiGroupedAreaChild = {
|
|
64
|
+
data: {
|
|
65
|
+
id: number;
|
|
66
|
+
title: string;
|
|
67
|
+
vector_source: string;
|
|
68
|
+
source_layer: string;
|
|
69
|
+
feature_id: number;
|
|
70
|
+
bounding_box: string;
|
|
71
|
+
properties: string;
|
|
72
|
+
};
|
|
73
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
74
|
+
export type ApiGroupedAreaChildData = Flatten<Exclude<ApiGroupedAreaChild, ApiError>['data']>;
|
|
75
|
+
export declare const groupedAreaChildRevivers: Revivers<ApiGroupedAreaChild, GroupedAreaChild>;
|
|
44
76
|
export declare function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]>;
|
|
45
77
|
export type MatchedGroup = {
|
|
46
78
|
id: number;
|
|
@@ -51,28 +83,37 @@ export type MatchedGroup = {
|
|
|
51
83
|
name: string;
|
|
52
84
|
};
|
|
53
85
|
export type ApiMatchedGroup = {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
86
|
+
data: {
|
|
87
|
+
id: number;
|
|
88
|
+
sml: number;
|
|
89
|
+
children_count: number;
|
|
90
|
+
match_field: string;
|
|
91
|
+
property: string;
|
|
92
|
+
name: string;
|
|
93
|
+
};
|
|
94
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
95
|
+
export type ApiMatchedGroupData = Flatten<Exclude<ApiMatchedGroup, ApiError>['data']>;
|
|
96
|
+
export declare function getGroupsByDataSample(sample: Record<string, string[]>, language: string): Promise<MatchedGroup[]>;
|
|
62
97
|
export type BoundPolygon = {
|
|
63
98
|
index: number;
|
|
64
99
|
id: number;
|
|
65
100
|
sml: number;
|
|
66
101
|
name: string;
|
|
67
102
|
inputName: string;
|
|
103
|
+
boundingBox: Polygon;
|
|
68
104
|
};
|
|
69
105
|
export type ApiBoundPolygon = {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
106
|
+
data: {
|
|
107
|
+
index: number;
|
|
108
|
+
id: number;
|
|
109
|
+
sml: number;
|
|
110
|
+
name: string;
|
|
111
|
+
input_name: string;
|
|
112
|
+
bounding_box: string;
|
|
113
|
+
};
|
|
114
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
115
|
+
export type ApiBoundPolygonData = Flatten<Exclude<ApiBoundPolygon, ApiError>['data']>;
|
|
116
|
+
export declare const boundPolygonRevivers: Revivers<ApiBoundPolygon, BoundPolygon>;
|
|
76
117
|
export declare function getBoundPolygons(groupId: number, property: string, data: string[], language: string): Promise<BoundPolygon[]>;
|
|
77
118
|
export {};
|
|
78
119
|
//# sourceMappingURL=choropleth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choropleth.d.ts","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"choropleth.d.ts","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAA4B,MAAM,aAAa,CAAC;AAEpH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,uBAAuB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC3C,CAAC;AAGF,MAAM,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAGlD,MAAM,MAAM,UAAU,GAAG,uBAAuB,GAAG;IACjD,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,WAAW,CAAC;AA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: true });
|
|
3
|
+
exports.boundPolygonRevivers = exports.groupedAreaChildRevivers = exports.singleOrGroupedAreaRevivers = void 0;
|
|
3
4
|
exports.searchSingleOrGroupedAreas = searchSingleOrGroupedAreas;
|
|
4
5
|
exports.groupedAreaChildren = groupedAreaChildren;
|
|
5
6
|
exports.getGroupsByDataSample = getGroupsByDataSample;
|
|
6
7
|
exports.getBoundPolygons = getBoundPolygons;
|
|
7
8
|
const utils_js_1 = require("../utils.js");
|
|
9
|
+
exports.singleOrGroupedAreaRevivers = {
|
|
10
|
+
boundingBox: (data) => JSON.parse(data.bounding_box),
|
|
11
|
+
properties: (data) => (data.properties != null ? JSON.parse(data.properties) : null),
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
15
|
+
*/
|
|
8
16
|
async function searchSingleOrGroupedAreas(language, search, mode = 'both') {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
elem.boundingBox = JSON.parse(elem.boundingBox);
|
|
15
|
-
if (!elem.isGroup) {
|
|
16
|
-
elem.properties = JSON.parse(elem.properties);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
return result;
|
|
20
|
-
});
|
|
17
|
+
const pathname = '/v1/choropleth/polygons/search';
|
|
18
|
+
const query = (0, utils_js_1.getSearchParams)(Object.assign(Object.assign(Object.assign(Object.assign({ language }, search.searchBounds), (search.query && { query: search.query })), (search.searchPoint && { point: search.searchPoint })), { mode }));
|
|
19
|
+
const path = `${pathname}?${query}`;
|
|
20
|
+
const options = { revivers: exports.singleOrGroupedAreaRevivers };
|
|
21
|
+
return (0, utils_js_1.request)(path, null, null, options);
|
|
21
22
|
}
|
|
23
|
+
exports.groupedAreaChildRevivers = {
|
|
24
|
+
boundingBox: (data) => JSON.parse(data.bounding_box),
|
|
25
|
+
properties: (data) => JSON.parse(data.properties),
|
|
26
|
+
};
|
|
22
27
|
async function groupedAreaChildren(groupId, language) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
28
|
+
const pathname = `/v1/choropleth/groups/${groupId}/children-optimized`;
|
|
29
|
+
const query = (0, utils_js_1.getSearchParams)({ language });
|
|
30
|
+
const path = `${pathname}?${query}`;
|
|
31
|
+
const options = { revivers: exports.groupedAreaChildRevivers };
|
|
32
|
+
return (0, utils_js_1.request)(path, null, null, options);
|
|
29
33
|
}
|
|
30
34
|
async function getGroupsByDataSample(sample, language) {
|
|
31
35
|
const path = `/v1/choropleth/groups/sample`;
|
|
32
36
|
return (0, utils_js_1.request)(path, { sample, language });
|
|
33
37
|
}
|
|
38
|
+
exports.boundPolygonRevivers = {
|
|
39
|
+
boundingBox: (data) => JSON.parse(data.bounding_box),
|
|
40
|
+
};
|
|
34
41
|
async function getBoundPolygons(groupId, property, data, language) {
|
|
35
42
|
const path = `/v1/choropleth/groups/bind`;
|
|
36
|
-
const
|
|
37
|
-
|
|
43
|
+
const body = { group_id: groupId, property, data, language };
|
|
44
|
+
const options = { revivers: exports.boundPolygonRevivers };
|
|
45
|
+
return (0, utils_js_1.request)(path, body, null, options);
|
|
38
46
|
}
|
|
39
47
|
//# sourceMappingURL=choropleth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choropleth.js","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"choropleth.js","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":";;;AAiEA,gEAyBC;AA+BD,kDAWC;AAwBD,sDAWC;AA4BD,4CAeC;AAlND,0CAAoH;AAwDvG,QAAA,2BAA2B,GAA0D;IAChG,WAAW,EAAE,CAAC,IAAgC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAY;IAC3F,UAAU,EAAE,CAAC,IAAgC,EAAE,EAAE,C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KAAK,EAAE,CAAC;IACpC,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,gCAAwB,EAAE,CAAC;IAMvD,OAAO,IAAA,kBAAO,EAAgD,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC3F,CAAC;AAwBM,KAAK,UAAU,qBAAqB,CACzC,MAAgC,EAChC,QAAgB;IAEhB,MAAM,IAAI,GAAG,8BAA8B,CAAC;IAM5C,OAAO,IAAA,kBAAO,EAAqC,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;AACjF,CAAC;AAwBY,QAAA,oBAAoB,GAA4C;IAC3E,WAAW,EAAE,CAAC,IAAyB,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAY;CACrF,CAAC;AAEK,KAAK,UAAU,gBAAgB,CACpC,OAAe,EACf,QAAgB,EAChB,IAAc,EACd,QAAgB;IAEhB,MAAM,IAAI,GAAG,4BAA4B,CAAC;IAC1C,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC7D,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,4BAAoB,EAAE,CAAC;IAMnD,OAAO,IAAA,kBAAO,EAAqC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAChF,CAAC"}
|
package/esm/api/choropleth.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ApiError, type ApiSuccess, type Flatten, type Revivers } from '../utils.js';
|
|
1
2
|
import type { RequireAtLeastOne } from 'type-fest';
|
|
2
3
|
import type { Polygon } from 'geojson';
|
|
3
4
|
export type ApiSearchPoint = {
|
|
@@ -16,18 +17,35 @@ type SingleOrGroupedAreaBase = {
|
|
|
16
17
|
subtitle: string;
|
|
17
18
|
svgPreview: string;
|
|
18
19
|
boundingBox: Polygon;
|
|
20
|
+
isGroup: boolean;
|
|
21
|
+
properties: Record<string, string> | null;
|
|
19
22
|
};
|
|
20
|
-
export type GroupedArea = SingleOrGroupedAreaBase
|
|
21
|
-
isGroup: true;
|
|
22
|
-
};
|
|
23
|
+
export type GroupedArea = SingleOrGroupedAreaBase;
|
|
23
24
|
export type SingleArea = SingleOrGroupedAreaBase & {
|
|
24
|
-
isGroup: false;
|
|
25
25
|
vectorSource: string;
|
|
26
26
|
sourceLayer: string;
|
|
27
27
|
featureId: number;
|
|
28
|
-
properties: Record<string, string>;
|
|
29
28
|
};
|
|
30
29
|
export type SingleOrGroupedArea = SingleArea | GroupedArea;
|
|
30
|
+
export type ApiSingleOrGroupedArea = {
|
|
31
|
+
data: {
|
|
32
|
+
id: number;
|
|
33
|
+
title: string;
|
|
34
|
+
subtitle: string;
|
|
35
|
+
svg_preview: string;
|
|
36
|
+
bounding_box: string;
|
|
37
|
+
is_group: boolean;
|
|
38
|
+
vector_source: string | null;
|
|
39
|
+
source_layer: string | null;
|
|
40
|
+
feature_id: number | null;
|
|
41
|
+
properties: string | null;
|
|
42
|
+
};
|
|
43
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
44
|
+
export type ApiSingleOrGroupedAreaData = Flatten<Exclude<ApiSingleOrGroupedArea, ApiError>['data']>;
|
|
45
|
+
export declare const singleOrGroupedAreaRevivers: Revivers<ApiSingleOrGroupedArea, SingleOrGroupedArea>;
|
|
46
|
+
/**
|
|
47
|
+
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
48
|
+
*/
|
|
31
49
|
export declare function searchSingleOrGroupedAreas(language: string, search: RequireAtLeastOne<{
|
|
32
50
|
searchBounds?: ApiSearchBounds;
|
|
33
51
|
query?: string;
|
|
@@ -39,8 +57,22 @@ export type GroupedAreaChild = {
|
|
|
39
57
|
vectorSource: string;
|
|
40
58
|
sourceLayer: string;
|
|
41
59
|
featureId: number;
|
|
60
|
+
boundingBox: Polygon;
|
|
42
61
|
properties: Record<string, string>;
|
|
43
62
|
};
|
|
63
|
+
type ApiGroupedAreaChild = {
|
|
64
|
+
data: {
|
|
65
|
+
id: number;
|
|
66
|
+
title: string;
|
|
67
|
+
vector_source: string;
|
|
68
|
+
source_layer: string;
|
|
69
|
+
feature_id: number;
|
|
70
|
+
bounding_box: string;
|
|
71
|
+
properties: string;
|
|
72
|
+
};
|
|
73
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
74
|
+
export type ApiGroupedAreaChildData = Flatten<Exclude<ApiGroupedAreaChild, ApiError>['data']>;
|
|
75
|
+
export declare const groupedAreaChildRevivers: Revivers<ApiGroupedAreaChild, GroupedAreaChild>;
|
|
44
76
|
export declare function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]>;
|
|
45
77
|
export type MatchedGroup = {
|
|
46
78
|
id: number;
|
|
@@ -51,28 +83,37 @@ export type MatchedGroup = {
|
|
|
51
83
|
name: string;
|
|
52
84
|
};
|
|
53
85
|
export type ApiMatchedGroup = {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
86
|
+
data: {
|
|
87
|
+
id: number;
|
|
88
|
+
sml: number;
|
|
89
|
+
children_count: number;
|
|
90
|
+
match_field: string;
|
|
91
|
+
property: string;
|
|
92
|
+
name: string;
|
|
93
|
+
};
|
|
94
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
95
|
+
export type ApiMatchedGroupData = Flatten<Exclude<ApiMatchedGroup, ApiError>['data']>;
|
|
96
|
+
export declare function getGroupsByDataSample(sample: Record<string, string[]>, language: string): Promise<MatchedGroup[]>;
|
|
62
97
|
export type BoundPolygon = {
|
|
63
98
|
index: number;
|
|
64
99
|
id: number;
|
|
65
100
|
sml: number;
|
|
66
101
|
name: string;
|
|
67
102
|
inputName: string;
|
|
103
|
+
boundingBox: Polygon;
|
|
68
104
|
};
|
|
69
105
|
export type ApiBoundPolygon = {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
106
|
+
data: {
|
|
107
|
+
index: number;
|
|
108
|
+
id: number;
|
|
109
|
+
sml: number;
|
|
110
|
+
name: string;
|
|
111
|
+
input_name: string;
|
|
112
|
+
bounding_box: string;
|
|
113
|
+
};
|
|
114
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
115
|
+
export type ApiBoundPolygonData = Flatten<Exclude<ApiBoundPolygon, ApiError>['data']>;
|
|
116
|
+
export declare const boundPolygonRevivers: Revivers<ApiBoundPolygon, BoundPolygon>;
|
|
76
117
|
export declare function getBoundPolygons(groupId: number, property: string, data: string[], language: string): Promise<BoundPolygon[]>;
|
|
77
118
|
export {};
|
|
78
119
|
//# sourceMappingURL=choropleth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choropleth.d.ts","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"choropleth.d.ts","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAA4B,MAAM,aAAa,CAAC;AAEpH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,uBAAuB,GAAG;I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,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC;AAExC,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEtF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,eAAe,EAAE,YAAY,CAExE,CAAC;AAEF,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,EAAE,CAAC,CAUzB"}
|
package/esm/api/choropleth.js
CHANGED
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
import { getSearchParams, request } from '../utils.js';
|
|
2
|
+
export const singleOrGroupedAreaRevivers = {
|
|
3
|
+
boundingBox: (data) => JSON.parse(data.bounding_box),
|
|
4
|
+
properties: (data) => (data.properties != null ? JSON.parse(data.properties) : null),
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
8
|
+
*/
|
|
2
9
|
export async function searchSingleOrGroupedAreas(language, search, mode = 'both') {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
elem.boundingBox = JSON.parse(elem.boundingBox);
|
|
9
|
-
if (!elem.isGroup) {
|
|
10
|
-
elem.properties = JSON.parse(elem.properties);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
return result;
|
|
14
|
-
});
|
|
10
|
+
const pathname = '/v1/choropleth/polygons/search';
|
|
11
|
+
const query = getSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({ language }, search.searchBounds), (search.query && { query: search.query })), (search.searchPoint && { point: search.searchPoint })), { mode }));
|
|
12
|
+
const path = `${pathname}?${query}`;
|
|
13
|
+
const options = { revivers: singleOrGroupedAreaRevivers };
|
|
14
|
+
return request(path, null, null, options);
|
|
15
15
|
}
|
|
16
|
+
export const groupedAreaChildRevivers = {
|
|
17
|
+
boundingBox: (data) => JSON.parse(data.bounding_box),
|
|
18
|
+
properties: (data) => JSON.parse(data.properties),
|
|
19
|
+
};
|
|
16
20
|
export async function groupedAreaChildren(groupId, language) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
21
|
+
const pathname = `/v1/choropleth/groups/${groupId}/children-optimized`;
|
|
22
|
+
const query = getSearchParams({ language });
|
|
23
|
+
const path = `${pathname}?${query}`;
|
|
24
|
+
const options = { revivers: groupedAreaChildRevivers };
|
|
25
|
+
return request(path, null, null, options);
|
|
23
26
|
}
|
|
24
27
|
export async function getGroupsByDataSample(sample, language) {
|
|
25
28
|
const path = `/v1/choropleth/groups/sample`;
|
|
26
29
|
return request(path, { sample, language });
|
|
27
30
|
}
|
|
31
|
+
export const boundPolygonRevivers = {
|
|
32
|
+
boundingBox: (data) => JSON.parse(data.bounding_box),
|
|
33
|
+
};
|
|
28
34
|
export async function getBoundPolygons(groupId, property, data, language) {
|
|
29
35
|
const path = `/v1/choropleth/groups/bind`;
|
|
30
|
-
const
|
|
31
|
-
|
|
36
|
+
const body = { group_id: groupId, property, data, language };
|
|
37
|
+
const options = { revivers: boundPolygonRevivers };
|
|
38
|
+
return request(path, body, null, options);
|
|
32
39
|
}
|
|
33
40
|
//# sourceMappingURL=choropleth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choropleth.js","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"choropleth.js","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+D,eAAe,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAwDpH,MAAM,CAAC,MAAM,2BAA2B,GAA0D;IAChG,WAAW,EAAE,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BAAyB,OAAO,qBAAqB,CAAC;IACvE,MAAM,KAAK,GAAG,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,GAAG,QAAQ,IAAI,KAAK,EAAE,CAAC;IACpC,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,wBAAwB,EAAE,CAAC;IAMvD,OAAO,OAAO,CAAgD,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC3F,CAAC;AAwBD,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAgC,EAChC,QAAgB;IAEhB,MAAM,IAAI,GAAG,8BAA8B,CAAC;IAM5C,OAAO,OAAO,CAAqC,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;AACjF,CAAC;AAwBD,MAAM,CAAC,MAAM,oBAAoB,GAA4C;IAC3E,WAAW,EAAE,CAAC,IAAyB,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAY;CACrF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAe,EACf,QAAgB,EAChB,IAAc,EACd,QAAgB;IAEhB,MAAM,IAAI,GAAG,4BAA4B,CAAC;IAC1C,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC7D,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,oBAAoB,EAAE,CAAC;IAMnD,OAAO,OAAO,CAAqC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAChF,CAAC"}
|
package/package.json
CHANGED
package/src/api/choropleth.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ApiError, type ApiSuccess, getSearchParams, request } from '../utils.js';
|
|
1
|
+
import { type ApiError, type ApiSuccess, type Flatten, type Revivers, getSearchParams, request } from '../utils.js';
|
|
2
2
|
|
|
3
3
|
import type { RequireAtLeastOne } from 'type-fest';
|
|
4
4
|
import type { Polygon } from 'geojson';
|
|
@@ -15,47 +15,54 @@ export type ApiSearchBounds = {
|
|
|
15
15
|
max_lng: number;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
type ApiSingleOrGroupedArea = {
|
|
19
|
-
id: number;
|
|
20
|
-
title: string;
|
|
21
|
-
subtitle: string;
|
|
22
|
-
svg_preview: string;
|
|
23
|
-
bounding_box: string;
|
|
24
|
-
is_group: boolean;
|
|
25
|
-
vector_source: string | null;
|
|
26
|
-
source_layer: string | null;
|
|
27
|
-
feature_id: number | null;
|
|
28
|
-
properties: Record<string, string> | null;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
type ApiSingleOrGroupedAreaArray = {
|
|
32
|
-
data: ApiSingleOrGroupedArea[];
|
|
33
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
34
|
-
|
|
35
18
|
type SingleOrGroupedAreaBase = {
|
|
36
19
|
id: number;
|
|
37
20
|
title: string;
|
|
38
21
|
subtitle: string;
|
|
39
22
|
svgPreview: string;
|
|
40
23
|
boundingBox: Polygon;
|
|
24
|
+
isGroup: boolean;
|
|
25
|
+
properties: Record<string, string> | null;
|
|
41
26
|
};
|
|
42
27
|
|
|
43
28
|
// TODO don't export this once search on click is out
|
|
44
|
-
export type GroupedArea = SingleOrGroupedAreaBase
|
|
45
|
-
isGroup: true;
|
|
46
|
-
};
|
|
29
|
+
export type GroupedArea = SingleOrGroupedAreaBase;
|
|
47
30
|
|
|
48
31
|
// TODO don't export this once search on click is out
|
|
49
32
|
export type SingleArea = SingleOrGroupedAreaBase & {
|
|
50
|
-
isGroup: false;
|
|
51
33
|
vectorSource: string;
|
|
52
34
|
sourceLayer: string;
|
|
53
35
|
featureId: number;
|
|
54
|
-
properties: Record<string, string>;
|
|
55
36
|
};
|
|
56
37
|
|
|
57
38
|
export type SingleOrGroupedArea = SingleArea | GroupedArea;
|
|
58
39
|
|
|
40
|
+
export type ApiSingleOrGroupedArea = {
|
|
41
|
+
data: {
|
|
42
|
+
id: number;
|
|
43
|
+
title: string;
|
|
44
|
+
subtitle: string;
|
|
45
|
+
svg_preview: string;
|
|
46
|
+
bounding_box: string;
|
|
47
|
+
is_group: boolean;
|
|
48
|
+
vector_source: string | null;
|
|
49
|
+
source_layer: string | null;
|
|
50
|
+
feature_id: number | null;
|
|
51
|
+
properties: string | null;
|
|
52
|
+
};
|
|
53
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
54
|
+
|
|
55
|
+
export type ApiSingleOrGroupedAreaData = Flatten<Exclude<ApiSingleOrGroupedArea, ApiError>['data']>;
|
|
56
|
+
|
|
57
|
+
export const singleOrGroupedAreaRevivers: Revivers<ApiSingleOrGroupedArea, SingleOrGroupedArea> = {
|
|
58
|
+
boundingBox: (data: ApiSingleOrGroupedAreaData) => JSON.parse(data.bounding_box) as Polygon,
|
|
59
|
+
properties: (data: ApiSingleOrGroupedAreaData) =>
|
|
60
|
+
(data.properties != null ? JSON.parse(data.properties) as Record<string, string> : null),
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
65
|
+
*/
|
|
59
66
|
export async function searchSingleOrGroupedAreas(
|
|
60
67
|
language: string,
|
|
61
68
|
search: RequireAtLeastOne<{
|
|
@@ -65,43 +72,23 @@ export async function searchSingleOrGroupedAreas(
|
|
|
65
72
|
}>,
|
|
66
73
|
mode: 'polygon' | 'group' | 'both' = 'both',
|
|
67
74
|
): Promise<SingleOrGroupedArea[]> {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
...(search.query && { query: search.query }),
|
|
76
|
-
...(search.searchPoint && { point: search.searchPoint }),
|
|
77
|
-
mode,
|
|
78
|
-
})}`,
|
|
79
|
-
).then(result => {
|
|
80
|
-
result.forEach(
|
|
81
|
-
elem => {
|
|
82
|
-
elem.boundingBox = JSON.parse(elem.boundingBox as unknown as string) as Polygon;
|
|
83
|
-
if (!elem.isGroup) {
|
|
84
|
-
elem.properties = JSON.parse(elem.properties as unknown as string) as Record<string, string>;
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
return result;
|
|
75
|
+
const pathname = '/v1/choropleth/polygons/search';
|
|
76
|
+
const query = getSearchParams({
|
|
77
|
+
language,
|
|
78
|
+
...search.searchBounds,
|
|
79
|
+
...(search.query && { query: search.query }),
|
|
80
|
+
...(search.searchPoint && { point: search.searchPoint }),
|
|
81
|
+
mode,
|
|
90
82
|
});
|
|
91
|
-
}
|
|
83
|
+
const path = `${pathname}?${query}`;
|
|
84
|
+
const options = { revivers: singleOrGroupedAreaRevivers };
|
|
92
85
|
|
|
93
|
-
type
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
vector_source: string;
|
|
97
|
-
source_layer: string;
|
|
98
|
-
feature_id: number;
|
|
99
|
-
properties: Record<string, string>;
|
|
100
|
-
};
|
|
86
|
+
type ApiSingleOrGroupedAreaArray = {
|
|
87
|
+
data: ApiSingleOrGroupedAreaData[];
|
|
88
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
101
89
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
90
|
+
return request<ApiSingleOrGroupedAreaArray, SingleOrGroupedArea>(path, null, null, options);
|
|
91
|
+
}
|
|
105
92
|
|
|
106
93
|
export type GroupedAreaChild = {
|
|
107
94
|
id: number;
|
|
@@ -109,21 +96,40 @@ export type GroupedAreaChild = {
|
|
|
109
96
|
vectorSource: string;
|
|
110
97
|
sourceLayer: string;
|
|
111
98
|
featureId: number;
|
|
99
|
+
boundingBox: Polygon;
|
|
112
100
|
properties: Record<string, string>;
|
|
113
101
|
};
|
|
114
102
|
|
|
103
|
+
type ApiGroupedAreaChild = {
|
|
104
|
+
data: {
|
|
105
|
+
id: number;
|
|
106
|
+
title: string;
|
|
107
|
+
vector_source: string;
|
|
108
|
+
source_layer: string;
|
|
109
|
+
feature_id: number;
|
|
110
|
+
bounding_box: string;
|
|
111
|
+
properties: string;
|
|
112
|
+
};
|
|
113
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
114
|
+
|
|
115
|
+
export type ApiGroupedAreaChildData = Flatten<Exclude<ApiGroupedAreaChild, ApiError>['data']>;
|
|
116
|
+
|
|
117
|
+
export const groupedAreaChildRevivers: Revivers<ApiGroupedAreaChild, GroupedAreaChild> = {
|
|
118
|
+
boundingBox: (data: ApiGroupedAreaChildData) => JSON.parse(data.bounding_box) as Polygon,
|
|
119
|
+
properties: (data: ApiGroupedAreaChildData) => JSON.parse(data.properties) as Record<string, string>,
|
|
120
|
+
};
|
|
121
|
+
|
|
115
122
|
export async function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]> {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
});
|
|
123
|
+
const pathname = `/v1/choropleth/groups/${groupId}/children-optimized`;
|
|
124
|
+
const query = getSearchParams({ language });
|
|
125
|
+
const path = `${pathname}?${query}`;
|
|
126
|
+
const options = { revivers: groupedAreaChildRevivers };
|
|
127
|
+
|
|
128
|
+
type ApiApiGroupedAreaChildArray = {
|
|
129
|
+
data: ApiGroupedAreaChildData[];
|
|
130
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
131
|
+
|
|
132
|
+
return request<ApiApiGroupedAreaChildArray, GroupedAreaChild>(path, null, null, options);
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
export type MatchedGroup = {
|
|
@@ -136,22 +142,26 @@ export type MatchedGroup = {
|
|
|
136
142
|
};
|
|
137
143
|
|
|
138
144
|
export type ApiMatchedGroup = {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
data: {
|
|
146
|
+
id: number;
|
|
147
|
+
sml: number;
|
|
148
|
+
children_count: number;
|
|
149
|
+
match_field: string;
|
|
150
|
+
property: string;
|
|
151
|
+
name: string;
|
|
152
|
+
};
|
|
153
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
154
|
+
|
|
155
|
+
export type ApiMatchedGroupData = Flatten<Exclude<ApiMatchedGroup, ApiError>['data']>;
|
|
146
156
|
|
|
147
157
|
export async function getGroupsByDataSample(
|
|
148
|
-
sample:
|
|
158
|
+
sample: Record<string, string[]>,
|
|
149
159
|
language: string,
|
|
150
160
|
): Promise<MatchedGroup[]> {
|
|
151
161
|
const path = `/v1/choropleth/groups/sample`;
|
|
152
162
|
|
|
153
163
|
type ApiMatchedGroupArray = {
|
|
154
|
-
data:
|
|
164
|
+
data: ApiMatchedGroupData[];
|
|
155
165
|
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
156
166
|
|
|
157
167
|
return request<ApiMatchedGroupArray, MatchedGroup>(path, { sample, language });
|
|
@@ -163,14 +173,24 @@ export type BoundPolygon = {
|
|
|
163
173
|
sml: number;
|
|
164
174
|
name: string;
|
|
165
175
|
inputName: string;
|
|
176
|
+
boundingBox: Polygon;
|
|
166
177
|
};
|
|
167
178
|
|
|
168
179
|
export type ApiBoundPolygon = {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
180
|
+
data: {
|
|
181
|
+
index: number;
|
|
182
|
+
id: number;
|
|
183
|
+
sml: number;
|
|
184
|
+
name: string;
|
|
185
|
+
input_name: string;
|
|
186
|
+
bounding_box: string;
|
|
187
|
+
};
|
|
188
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
189
|
+
|
|
190
|
+
export type ApiBoundPolygonData = Flatten<Exclude<ApiBoundPolygon, ApiError>['data']>;
|
|
191
|
+
|
|
192
|
+
export const boundPolygonRevivers: Revivers<ApiBoundPolygon, BoundPolygon> = {
|
|
193
|
+
boundingBox: (data: ApiBoundPolygonData) => JSON.parse(data.bounding_box) as Polygon,
|
|
174
194
|
};
|
|
175
195
|
|
|
176
196
|
export async function getBoundPolygons(
|
|
@@ -180,11 +200,12 @@ export async function getBoundPolygons(
|
|
|
180
200
|
language: string,
|
|
181
201
|
): Promise<BoundPolygon[]> {
|
|
182
202
|
const path = `/v1/choropleth/groups/bind`;
|
|
183
|
-
const
|
|
203
|
+
const body = { group_id: groupId, property, data, language };
|
|
204
|
+
const options = { revivers: boundPolygonRevivers };
|
|
184
205
|
|
|
185
206
|
type ApiBoundPolygonArray = {
|
|
186
|
-
data:
|
|
207
|
+
data: ApiBoundPolygonData[];
|
|
187
208
|
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
188
209
|
|
|
189
|
-
return request<ApiBoundPolygonArray, BoundPolygon>(path,
|
|
210
|
+
return request<ApiBoundPolygonArray, BoundPolygon>(path, body, null, options);
|
|
190
211
|
}
|