@mapcreator/api 5.0.0-alpha.72 → 5.0.0-alpha.74
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 +32 -196
- package/cjs/api/choropleth.d.ts.map +1 -1
- package/cjs/api/choropleth.js +21 -61
- package/cjs/api/choropleth.js.map +1 -1
- package/esm/api/choropleth.d.ts +32 -196
- package/esm/api/choropleth.d.ts.map +1 -1
- package/esm/api/choropleth.js +20 -57
- package/esm/api/choropleth.js.map +1 -1
- package/package.json +1 -1
- package/src/api/choropleth.ts +98 -330
package/cjs/api/choropleth.d.ts
CHANGED
|
@@ -1,211 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
id: number;
|
|
7
|
-
name: string;
|
|
8
|
-
description: string;
|
|
9
|
-
previewPath: string | null;
|
|
10
|
-
previewJson: FeatureCollection | null;
|
|
11
|
-
vectorSetUrl: string;
|
|
12
|
-
sourceLayerName: string;
|
|
13
|
-
lngMin: number;
|
|
14
|
-
lngMax: number;
|
|
15
|
-
latMin: number;
|
|
16
|
-
latMax: number;
|
|
17
|
-
keys: string[];
|
|
18
|
-
properties: Array<Record<string, unknown>>;
|
|
1
|
+
import type { RequireAtLeastOne } from 'type-fest';
|
|
2
|
+
import type { Polygon } from 'geojson';
|
|
3
|
+
export type ApiSearchPoint = {
|
|
4
|
+
lat: number;
|
|
5
|
+
lng: number;
|
|
19
6
|
};
|
|
20
|
-
export type
|
|
21
|
-
data: {
|
|
22
|
-
id: number;
|
|
23
|
-
name: string;
|
|
24
|
-
description: string;
|
|
25
|
-
preview_path: string | null;
|
|
26
|
-
preview_json: FeatureCollection | null;
|
|
27
|
-
vector_set_url: string;
|
|
28
|
-
source_layer_name: string;
|
|
29
|
-
lng_min: number;
|
|
30
|
-
lng_max: number;
|
|
31
|
-
lat_min: number;
|
|
32
|
-
lat_max: number;
|
|
33
|
-
keys: string[];
|
|
34
|
-
properties: Array<Record<string, unknown>>;
|
|
35
|
-
} & ApiCommonData;
|
|
36
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
37
|
-
export type ApiVectorChoroplethData = Flatten<Exclude<ApiVectorChoropleth, ApiError>['data']>;
|
|
38
|
-
export declare function listVectorChoropleths(name: string): Promise<PartialVectorChoropleth[]>;
|
|
39
|
-
export declare function getVectorChoropleth(choroplethId: number): Promise<VectorChoropleth>;
|
|
40
|
-
export type SearchBounds = {
|
|
7
|
+
export type ApiSearchBounds = {
|
|
41
8
|
min_lat: number;
|
|
42
9
|
min_lng: number;
|
|
43
10
|
max_lat: number;
|
|
44
11
|
max_lng: number;
|
|
45
12
|
};
|
|
46
|
-
|
|
47
|
-
sml: string;
|
|
13
|
+
type SingleOrGroupedAreaBase = {
|
|
48
14
|
id: number;
|
|
15
|
+
title: string;
|
|
16
|
+
subtitle: string;
|
|
17
|
+
svgPreview: string;
|
|
18
|
+
boundingBox: Polygon;
|
|
19
|
+
};
|
|
20
|
+
export type GroupedArea = SingleOrGroupedAreaBase & {
|
|
21
|
+
isGroup: true;
|
|
22
|
+
};
|
|
23
|
+
export type SingleArea = SingleOrGroupedAreaBase & {
|
|
24
|
+
isGroup: false;
|
|
49
25
|
vectorSource: string;
|
|
50
26
|
sourceLayer: string;
|
|
51
27
|
featureId: number;
|
|
52
|
-
|
|
53
|
-
previewPath: string;
|
|
54
|
-
allowSingle: boolean;
|
|
55
|
-
properties: Record<string, unknown>;
|
|
56
|
-
boundingBox: Polygon;
|
|
57
|
-
restrictedOwnership: number[] | null;
|
|
58
|
-
linkId: number | null;
|
|
59
|
-
cloning: boolean;
|
|
60
|
-
nativeTranslation: {
|
|
61
|
-
polygonId: number;
|
|
62
|
-
name: string;
|
|
63
|
-
};
|
|
64
|
-
englishTranslation?: {
|
|
65
|
-
polygonId: number;
|
|
66
|
-
name: string;
|
|
67
|
-
};
|
|
68
|
-
translations?: Array<{
|
|
69
|
-
polygonId: number;
|
|
70
|
-
language: string;
|
|
71
|
-
name: string;
|
|
72
|
-
}>;
|
|
73
|
-
parentGroups: GroupChoropleth[];
|
|
28
|
+
properties: Record<string, string>;
|
|
74
29
|
};
|
|
75
|
-
export type
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
svg_preview: string;
|
|
83
|
-
preview_path: string;
|
|
84
|
-
allow_single: boolean;
|
|
85
|
-
properties: Record<string, unknown>;
|
|
86
|
-
bounding_box: Polygon;
|
|
87
|
-
restricted_ownership: number[] | null;
|
|
88
|
-
link_id: number | null;
|
|
89
|
-
cloning: boolean;
|
|
90
|
-
native_translation: {
|
|
91
|
-
polygon_id: number;
|
|
92
|
-
name: string;
|
|
93
|
-
};
|
|
94
|
-
english_translation?: {
|
|
95
|
-
polygon_id: number;
|
|
96
|
-
name: string;
|
|
97
|
-
};
|
|
98
|
-
translations?: Array<{
|
|
99
|
-
polygon_id: number;
|
|
100
|
-
language: string;
|
|
101
|
-
name: string;
|
|
102
|
-
}>;
|
|
103
|
-
parent_groups: ApiGroupChoroplethData[];
|
|
104
|
-
} & ApiCommonData;
|
|
105
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
106
|
-
export type ApiPolygonChoroplethData = Flatten<Exclude<ApiPolygonChoropleth, ApiError>['data']>;
|
|
107
|
-
export declare function listPolygonChoropleths(name: string, languages: string[], searchBounds?: SearchBounds, withParentGroups?: boolean): Promise<PolygonChoropleth[]>;
|
|
108
|
-
export type GroupChoropleth = {
|
|
30
|
+
export type SingleOrGroupedArea = SingleArea | GroupedArea;
|
|
31
|
+
export declare function searchSingleOrGroupedAreas(language: string, search: RequireAtLeastOne<{
|
|
32
|
+
searchBounds?: ApiSearchBounds;
|
|
33
|
+
query?: string;
|
|
34
|
+
searchPoint?: ApiSearchPoint;
|
|
35
|
+
}>, mode?: 'polygon' | 'group' | 'both'): Promise<SingleOrGroupedArea[]>;
|
|
36
|
+
export type GroupedAreaChild = {
|
|
109
37
|
id: number;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
previewPath: string;
|
|
116
|
-
uniqueProperties: string[];
|
|
117
|
-
boundingBox: Polygon;
|
|
118
|
-
partialProperties: string[];
|
|
119
|
-
restrictedOwnership: number[] | null;
|
|
120
|
-
linkId: number | null;
|
|
121
|
-
cloning: boolean;
|
|
122
|
-
laravelThroughKey?: number;
|
|
123
|
-
nativeParentTranslation: {
|
|
124
|
-
polygonId: number;
|
|
125
|
-
name: string;
|
|
126
|
-
laravelThroughKey: number;
|
|
127
|
-
};
|
|
128
|
-
nativeRelationTranslation: {
|
|
129
|
-
relationId: number;
|
|
130
|
-
name: string;
|
|
131
|
-
laravelThroughKey: number;
|
|
132
|
-
};
|
|
133
|
-
englishParentTranslation?: {
|
|
134
|
-
polygonId: number;
|
|
135
|
-
name: string;
|
|
136
|
-
laravelThroughKey: number;
|
|
137
|
-
};
|
|
138
|
-
englishRelationTranslation?: {
|
|
139
|
-
relationId: number;
|
|
140
|
-
name: string;
|
|
141
|
-
laravelThroughKey: number;
|
|
142
|
-
};
|
|
143
|
-
parentTranslations?: Array<{
|
|
144
|
-
polygonId: number;
|
|
145
|
-
name: string;
|
|
146
|
-
language: string;
|
|
147
|
-
laravelThroughKey: number;
|
|
148
|
-
}>;
|
|
149
|
-
relationTranslations?: Array<{
|
|
150
|
-
relationId: number;
|
|
151
|
-
name: string;
|
|
152
|
-
language: string;
|
|
153
|
-
laravelThroughKey: number;
|
|
154
|
-
}>;
|
|
38
|
+
title: string;
|
|
39
|
+
vectorSource: string;
|
|
40
|
+
sourceLayer: string;
|
|
41
|
+
featureId: number;
|
|
42
|
+
properties: Record<string, string>;
|
|
155
43
|
};
|
|
156
|
-
export
|
|
157
|
-
data: {
|
|
158
|
-
id: number;
|
|
159
|
-
polygon_id: number;
|
|
160
|
-
relation_id: number;
|
|
161
|
-
children_count: number;
|
|
162
|
-
sml?: number;
|
|
163
|
-
svg_preview: string;
|
|
164
|
-
preview_path: string;
|
|
165
|
-
unique_properties: string[];
|
|
166
|
-
bounding_box: Polygon;
|
|
167
|
-
partial_properties: string[];
|
|
168
|
-
restricted_ownership: number[] | null;
|
|
169
|
-
link_id: number | null;
|
|
170
|
-
cloning: boolean;
|
|
171
|
-
laravel_through_key?: number;
|
|
172
|
-
native_parent_translation: {
|
|
173
|
-
polygon_id: number;
|
|
174
|
-
name: string;
|
|
175
|
-
laravel_through_key: number;
|
|
176
|
-
};
|
|
177
|
-
native_relation_translation: {
|
|
178
|
-
relation_id: number;
|
|
179
|
-
name: string;
|
|
180
|
-
laravel_through_key: number;
|
|
181
|
-
};
|
|
182
|
-
english_parent_translation?: {
|
|
183
|
-
polygon_id: number;
|
|
184
|
-
name: string;
|
|
185
|
-
laravel_through_key: number;
|
|
186
|
-
};
|
|
187
|
-
english_relation_translation?: {
|
|
188
|
-
relation_id: number;
|
|
189
|
-
name: string;
|
|
190
|
-
laravel_through_key: number;
|
|
191
|
-
};
|
|
192
|
-
parent_translations?: Array<{
|
|
193
|
-
polygon_id: number;
|
|
194
|
-
name: string;
|
|
195
|
-
language: string;
|
|
196
|
-
laravel_through_key: number;
|
|
197
|
-
}>;
|
|
198
|
-
relation_translations?: Array<{
|
|
199
|
-
relation_id: number;
|
|
200
|
-
name: string;
|
|
201
|
-
language: string;
|
|
202
|
-
laravel_through_key: number;
|
|
203
|
-
}>;
|
|
204
|
-
} & ApiCommonData;
|
|
205
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
206
|
-
export type ApiGroupChoroplethData = Flatten<Exclude<ApiGroupChoropleth, ApiError>['data']>;
|
|
207
|
-
export declare function listGroupChoropleths(name: string, languages: string[], searchBounds?: SearchBounds): Promise<GroupChoropleth[]>;
|
|
208
|
-
export declare function listChildrenGroupChoropleths(groupId: number, languages: string[]): Promise<PolygonChoropleth[]>;
|
|
44
|
+
export declare function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]>;
|
|
209
45
|
export type MatchedGroup = {
|
|
210
46
|
id: number;
|
|
211
47
|
sml: number;
|
|
@@ -222,7 +58,7 @@ export type ApiMatchedGroup = {
|
|
|
222
58
|
property: string;
|
|
223
59
|
name: string;
|
|
224
60
|
};
|
|
225
|
-
export declare function getGroupsByDataSample(sample: Record<string, string[]
|
|
61
|
+
export declare function getGroupsByDataSample(sample: Array<Record<string, string[]>>, language: string): Promise<MatchedGroup[]>;
|
|
226
62
|
export type BoundPolygon = {
|
|
227
63
|
index: number;
|
|
228
64
|
id: number;
|
|
@@ -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":"AAEA,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;AAmBF,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;CACtB,CAAC;AAGF,MAAM,MAAM,WAAW,GAAG,uBAAuB,GAAG;IAClD,OAAO,EAAE,IAAI,CAAC;CACf,CAAC;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,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,EACvC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,EAAE,CAAC,CAQzB;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,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,CASzB"}
|
package/cjs/api/choropleth.js
CHANGED
|
@@ -1,71 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.listPolygonChoropleths = listPolygonChoropleths;
|
|
6
|
-
exports.listGroupChoropleths = listGroupChoropleths;
|
|
7
|
-
exports.listChildrenGroupChoropleths = listChildrenGroupChoropleths;
|
|
3
|
+
exports.searchSingleOrGroupedAreas = searchSingleOrGroupedAreas;
|
|
4
|
+
exports.groupedAreaChildren = groupedAreaChildren;
|
|
8
5
|
exports.getGroupsByDataSample = getGroupsByDataSample;
|
|
9
6
|
exports.getBoundPolygons = getBoundPolygons;
|
|
10
7
|
const utils_js_1 = require("../utils.js");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return error.data;
|
|
24
|
-
}
|
|
25
|
-
throw error;
|
|
8
|
+
async function searchSingleOrGroupedAreas(language, search, mode = 'both') {
|
|
9
|
+
/**
|
|
10
|
+
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
11
|
+
*/
|
|
12
|
+
return (0, utils_js_1.request)(`/v1/choropleth/polygons/search?${(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 }))}`).then(result => {
|
|
13
|
+
result.forEach(elem => {
|
|
14
|
+
elem.boundingBox = JSON.parse(elem.boundingBox);
|
|
15
|
+
if (!elem.isGroup) {
|
|
16
|
+
elem.properties = JSON.parse(elem.properties);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return result;
|
|
26
20
|
});
|
|
27
21
|
}
|
|
28
|
-
async function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const path = `${pathname}?${query}`;
|
|
36
|
-
// Only request first 50 results
|
|
37
|
-
const headers = Object.assign({}, utils_js_1.defaultListHeader);
|
|
38
|
-
const options = { withMeta: true };
|
|
39
|
-
return (0, utils_js_1.request)(path, null, headers, options)
|
|
40
|
-
.catch((error) => {
|
|
41
|
-
if (error instanceof utils_js_1.APIMeta) {
|
|
42
|
-
return error.data;
|
|
43
|
-
}
|
|
44
|
-
throw error;
|
|
45
|
-
})
|
|
46
|
-
.then(result => result.map(processPolygonData));
|
|
47
|
-
}
|
|
48
|
-
async function listGroupChoropleths(name, languages, searchBounds) {
|
|
49
|
-
const pathname = `/v1/choropleth/groups`;
|
|
50
|
-
const query = (0, utils_js_1.getSearchParams)(Object.assign({ search: { name }, languages }, searchBounds));
|
|
51
|
-
const path = `${pathname}?${query}`;
|
|
52
|
-
// Only request first 50 results
|
|
53
|
-
const headers = Object.assign({}, utils_js_1.defaultListHeader);
|
|
54
|
-
const options = { withMeta: true };
|
|
55
|
-
return (0, utils_js_1.request)(path, null, headers, options)
|
|
56
|
-
.catch((error) => {
|
|
57
|
-
if (error instanceof utils_js_1.APIMeta) {
|
|
58
|
-
return error.data;
|
|
59
|
-
}
|
|
60
|
-
throw error;
|
|
61
|
-
})
|
|
62
|
-
.then(result => result.map(processGroupData));
|
|
63
|
-
}
|
|
64
|
-
async function listChildrenGroupChoropleths(groupId, languages) {
|
|
65
|
-
const pathname = `/v1/choropleth/groups/${groupId}/children`;
|
|
66
|
-
const query = (0, utils_js_1.getSearchParams)({ languages });
|
|
67
|
-
const path = `${pathname}?${query}`;
|
|
68
|
-
return (0, utils_js_1.request)(path).then(polygons => polygons.map(processPolygonData));
|
|
22
|
+
async function groupedAreaChildren(groupId, language) {
|
|
23
|
+
return (0, utils_js_1.request)(`/v1/choropleth/groups/${groupId}/children-optimized?${(0, utils_js_1.getSearchParams)({ language })}`).then(result => {
|
|
24
|
+
result.forEach(elem => {
|
|
25
|
+
elem.properties = JSON.parse(elem.properties);
|
|
26
|
+
});
|
|
27
|
+
return result;
|
|
28
|
+
});
|
|
69
29
|
}
|
|
70
30
|
async function getGroupsByDataSample(sample, language) {
|
|
71
31
|
const path = `/v1/choropleth/groups/sample`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choropleth.js","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"choropleth.js","sourceRoot":"","sources":["../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C;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC;AAoBM,KAAK,UAAU,qBAAqB,CACzC,MAAuC,EACvC,QAAgB;IAEhB,MAAM,IAAI,GAAG,8BAA8B,CAAC;IAM5C,OAAO,IAAA,kBAAO,EAAqC,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;AACjF,CAAC;AAkBM,KAAK,UAAU,gBAAgB,CACpC,OAAe,EACf,QAAgB,EAChB,IAAc,EACd,QAAgB;IAEhB,MAAM,IAAI,GAAG,4BAA4B,CAAC;IAC1C,MAAM,QAAQ,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAMjE,OAAO,IAAA,kBAAO,EAAqC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACrE,CAAC"}
|
package/esm/api/choropleth.d.ts
CHANGED
|
@@ -1,211 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
id: number;
|
|
7
|
-
name: string;
|
|
8
|
-
description: string;
|
|
9
|
-
previewPath: string | null;
|
|
10
|
-
previewJson: FeatureCollection | null;
|
|
11
|
-
vectorSetUrl: string;
|
|
12
|
-
sourceLayerName: string;
|
|
13
|
-
lngMin: number;
|
|
14
|
-
lngMax: number;
|
|
15
|
-
latMin: number;
|
|
16
|
-
latMax: number;
|
|
17
|
-
keys: string[];
|
|
18
|
-
properties: Array<Record<string, unknown>>;
|
|
1
|
+
import type { RequireAtLeastOne } from 'type-fest';
|
|
2
|
+
import type { Polygon } from 'geojson';
|
|
3
|
+
export type ApiSearchPoint = {
|
|
4
|
+
lat: number;
|
|
5
|
+
lng: number;
|
|
19
6
|
};
|
|
20
|
-
export type
|
|
21
|
-
data: {
|
|
22
|
-
id: number;
|
|
23
|
-
name: string;
|
|
24
|
-
description: string;
|
|
25
|
-
preview_path: string | null;
|
|
26
|
-
preview_json: FeatureCollection | null;
|
|
27
|
-
vector_set_url: string;
|
|
28
|
-
source_layer_name: string;
|
|
29
|
-
lng_min: number;
|
|
30
|
-
lng_max: number;
|
|
31
|
-
lat_min: number;
|
|
32
|
-
lat_max: number;
|
|
33
|
-
keys: string[];
|
|
34
|
-
properties: Array<Record<string, unknown>>;
|
|
35
|
-
} & ApiCommonData;
|
|
36
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
37
|
-
export type ApiVectorChoroplethData = Flatten<Exclude<ApiVectorChoropleth, ApiError>['data']>;
|
|
38
|
-
export declare function listVectorChoropleths(name: string): Promise<PartialVectorChoropleth[]>;
|
|
39
|
-
export declare function getVectorChoropleth(choroplethId: number): Promise<VectorChoropleth>;
|
|
40
|
-
export type SearchBounds = {
|
|
7
|
+
export type ApiSearchBounds = {
|
|
41
8
|
min_lat: number;
|
|
42
9
|
min_lng: number;
|
|
43
10
|
max_lat: number;
|
|
44
11
|
max_lng: number;
|
|
45
12
|
};
|
|
46
|
-
|
|
47
|
-
sml: string;
|
|
13
|
+
type SingleOrGroupedAreaBase = {
|
|
48
14
|
id: number;
|
|
15
|
+
title: string;
|
|
16
|
+
subtitle: string;
|
|
17
|
+
svgPreview: string;
|
|
18
|
+
boundingBox: Polygon;
|
|
19
|
+
};
|
|
20
|
+
export type GroupedArea = SingleOrGroupedAreaBase & {
|
|
21
|
+
isGroup: true;
|
|
22
|
+
};
|
|
23
|
+
export type SingleArea = SingleOrGroupedAreaBase & {
|
|
24
|
+
isGroup: false;
|
|
49
25
|
vectorSource: string;
|
|
50
26
|
sourceLayer: string;
|
|
51
27
|
featureId: number;
|
|
52
|
-
|
|
53
|
-
previewPath: string;
|
|
54
|
-
allowSingle: boolean;
|
|
55
|
-
properties: Record<string, unknown>;
|
|
56
|
-
boundingBox: Polygon;
|
|
57
|
-
restrictedOwnership: number[] | null;
|
|
58
|
-
linkId: number | null;
|
|
59
|
-
cloning: boolean;
|
|
60
|
-
nativeTranslation: {
|
|
61
|
-
polygonId: number;
|
|
62
|
-
name: string;
|
|
63
|
-
};
|
|
64
|
-
englishTranslation?: {
|
|
65
|
-
polygonId: number;
|
|
66
|
-
name: string;
|
|
67
|
-
};
|
|
68
|
-
translations?: Array<{
|
|
69
|
-
polygonId: number;
|
|
70
|
-
language: string;
|
|
71
|
-
name: string;
|
|
72
|
-
}>;
|
|
73
|
-
parentGroups: GroupChoropleth[];
|
|
28
|
+
properties: Record<string, string>;
|
|
74
29
|
};
|
|
75
|
-
export type
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
svg_preview: string;
|
|
83
|
-
preview_path: string;
|
|
84
|
-
allow_single: boolean;
|
|
85
|
-
properties: Record<string, unknown>;
|
|
86
|
-
bounding_box: Polygon;
|
|
87
|
-
restricted_ownership: number[] | null;
|
|
88
|
-
link_id: number | null;
|
|
89
|
-
cloning: boolean;
|
|
90
|
-
native_translation: {
|
|
91
|
-
polygon_id: number;
|
|
92
|
-
name: string;
|
|
93
|
-
};
|
|
94
|
-
english_translation?: {
|
|
95
|
-
polygon_id: number;
|
|
96
|
-
name: string;
|
|
97
|
-
};
|
|
98
|
-
translations?: Array<{
|
|
99
|
-
polygon_id: number;
|
|
100
|
-
language: string;
|
|
101
|
-
name: string;
|
|
102
|
-
}>;
|
|
103
|
-
parent_groups: ApiGroupChoroplethData[];
|
|
104
|
-
} & ApiCommonData;
|
|
105
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
106
|
-
export type ApiPolygonChoroplethData = Flatten<Exclude<ApiPolygonChoropleth, ApiError>['data']>;
|
|
107
|
-
export declare function listPolygonChoropleths(name: string, languages: string[], searchBounds?: SearchBounds, withParentGroups?: boolean): Promise<PolygonChoropleth[]>;
|
|
108
|
-
export type GroupChoropleth = {
|
|
30
|
+
export type SingleOrGroupedArea = SingleArea | GroupedArea;
|
|
31
|
+
export declare function searchSingleOrGroupedAreas(language: string, search: RequireAtLeastOne<{
|
|
32
|
+
searchBounds?: ApiSearchBounds;
|
|
33
|
+
query?: string;
|
|
34
|
+
searchPoint?: ApiSearchPoint;
|
|
35
|
+
}>, mode?: 'polygon' | 'group' | 'both'): Promise<SingleOrGroupedArea[]>;
|
|
36
|
+
export type GroupedAreaChild = {
|
|
109
37
|
id: number;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
previewPath: string;
|
|
116
|
-
uniqueProperties: string[];
|
|
117
|
-
boundingBox: Polygon;
|
|
118
|
-
partialProperties: string[];
|
|
119
|
-
restrictedOwnership: number[] | null;
|
|
120
|
-
linkId: number | null;
|
|
121
|
-
cloning: boolean;
|
|
122
|
-
laravelThroughKey?: number;
|
|
123
|
-
nativeParentTranslation: {
|
|
124
|
-
polygonId: number;
|
|
125
|
-
name: string;
|
|
126
|
-
laravelThroughKey: number;
|
|
127
|
-
};
|
|
128
|
-
nativeRelationTranslation: {
|
|
129
|
-
relationId: number;
|
|
130
|
-
name: string;
|
|
131
|
-
laravelThroughKey: number;
|
|
132
|
-
};
|
|
133
|
-
englishParentTranslation?: {
|
|
134
|
-
polygonId: number;
|
|
135
|
-
name: string;
|
|
136
|
-
laravelThroughKey: number;
|
|
137
|
-
};
|
|
138
|
-
englishRelationTranslation?: {
|
|
139
|
-
relationId: number;
|
|
140
|
-
name: string;
|
|
141
|
-
laravelThroughKey: number;
|
|
142
|
-
};
|
|
143
|
-
parentTranslations?: Array<{
|
|
144
|
-
polygonId: number;
|
|
145
|
-
name: string;
|
|
146
|
-
language: string;
|
|
147
|
-
laravelThroughKey: number;
|
|
148
|
-
}>;
|
|
149
|
-
relationTranslations?: Array<{
|
|
150
|
-
relationId: number;
|
|
151
|
-
name: string;
|
|
152
|
-
language: string;
|
|
153
|
-
laravelThroughKey: number;
|
|
154
|
-
}>;
|
|
38
|
+
title: string;
|
|
39
|
+
vectorSource: string;
|
|
40
|
+
sourceLayer: string;
|
|
41
|
+
featureId: number;
|
|
42
|
+
properties: Record<string, string>;
|
|
155
43
|
};
|
|
156
|
-
export
|
|
157
|
-
data: {
|
|
158
|
-
id: number;
|
|
159
|
-
polygon_id: number;
|
|
160
|
-
relation_id: number;
|
|
161
|
-
children_count: number;
|
|
162
|
-
sml?: number;
|
|
163
|
-
svg_preview: string;
|
|
164
|
-
preview_path: string;
|
|
165
|
-
unique_properties: string[];
|
|
166
|
-
bounding_box: Polygon;
|
|
167
|
-
partial_properties: string[];
|
|
168
|
-
restricted_ownership: number[] | null;
|
|
169
|
-
link_id: number | null;
|
|
170
|
-
cloning: boolean;
|
|
171
|
-
laravel_through_key?: number;
|
|
172
|
-
native_parent_translation: {
|
|
173
|
-
polygon_id: number;
|
|
174
|
-
name: string;
|
|
175
|
-
laravel_through_key: number;
|
|
176
|
-
};
|
|
177
|
-
native_relation_translation: {
|
|
178
|
-
relation_id: number;
|
|
179
|
-
name: string;
|
|
180
|
-
laravel_through_key: number;
|
|
181
|
-
};
|
|
182
|
-
english_parent_translation?: {
|
|
183
|
-
polygon_id: number;
|
|
184
|
-
name: string;
|
|
185
|
-
laravel_through_key: number;
|
|
186
|
-
};
|
|
187
|
-
english_relation_translation?: {
|
|
188
|
-
relation_id: number;
|
|
189
|
-
name: string;
|
|
190
|
-
laravel_through_key: number;
|
|
191
|
-
};
|
|
192
|
-
parent_translations?: Array<{
|
|
193
|
-
polygon_id: number;
|
|
194
|
-
name: string;
|
|
195
|
-
language: string;
|
|
196
|
-
laravel_through_key: number;
|
|
197
|
-
}>;
|
|
198
|
-
relation_translations?: Array<{
|
|
199
|
-
relation_id: number;
|
|
200
|
-
name: string;
|
|
201
|
-
language: string;
|
|
202
|
-
laravel_through_key: number;
|
|
203
|
-
}>;
|
|
204
|
-
} & ApiCommonData;
|
|
205
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
206
|
-
export type ApiGroupChoroplethData = Flatten<Exclude<ApiGroupChoropleth, ApiError>['data']>;
|
|
207
|
-
export declare function listGroupChoropleths(name: string, languages: string[], searchBounds?: SearchBounds): Promise<GroupChoropleth[]>;
|
|
208
|
-
export declare function listChildrenGroupChoropleths(groupId: number, languages: string[]): Promise<PolygonChoropleth[]>;
|
|
44
|
+
export declare function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]>;
|
|
209
45
|
export type MatchedGroup = {
|
|
210
46
|
id: number;
|
|
211
47
|
sml: number;
|
|
@@ -222,7 +58,7 @@ export type ApiMatchedGroup = {
|
|
|
222
58
|
property: string;
|
|
223
59
|
name: string;
|
|
224
60
|
};
|
|
225
|
-
export declare function getGroupsByDataSample(sample: Record<string, string[]
|
|
61
|
+
export declare function getGroupsByDataSample(sample: Array<Record<string, string[]>>, language: string): Promise<MatchedGroup[]>;
|
|
226
62
|
export type BoundPolygon = {
|
|
227
63
|
index: number;
|
|
228
64
|
id: number;
|
|
@@ -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":"AAEA,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;AAmBF,KAAK,uBAAuB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,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
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return error.data;
|
|
15
|
-
}
|
|
16
|
-
throw error;
|
|
1
|
+
import { getSearchParams, request } from '../utils.js';
|
|
2
|
+
export async function searchSingleOrGroupedAreas(language, search, mode = 'both') {
|
|
3
|
+
/**
|
|
4
|
+
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
5
|
+
*/
|
|
6
|
+
return request(`/v1/choropleth/polygons/search?${getSearchParams(Object.assign(Object.assign(Object.assign(Object.assign({ language }, search.searchBounds), (search.query && { query: search.query })), (search.searchPoint && { point: search.searchPoint })), { mode }))}`).then(result => {
|
|
7
|
+
result.forEach(elem => {
|
|
8
|
+
elem.boundingBox = JSON.parse(elem.boundingBox);
|
|
9
|
+
if (!elem.isGroup) {
|
|
10
|
+
elem.properties = JSON.parse(elem.properties);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return result;
|
|
17
14
|
});
|
|
18
15
|
}
|
|
19
|
-
export async function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const path = `${pathname}?${query}`;
|
|
27
|
-
// Only request first 50 results
|
|
28
|
-
const headers = Object.assign({}, defaultListHeader);
|
|
29
|
-
const options = { withMeta: true };
|
|
30
|
-
return request(path, null, headers, options)
|
|
31
|
-
.catch((error) => {
|
|
32
|
-
if (error instanceof APIMeta) {
|
|
33
|
-
return error.data;
|
|
34
|
-
}
|
|
35
|
-
throw error;
|
|
36
|
-
})
|
|
37
|
-
.then(result => result.map(processPolygonData));
|
|
38
|
-
}
|
|
39
|
-
export async function listGroupChoropleths(name, languages, searchBounds) {
|
|
40
|
-
const pathname = `/v1/choropleth/groups`;
|
|
41
|
-
const query = getSearchParams(Object.assign({ search: { name }, languages }, searchBounds));
|
|
42
|
-
const path = `${pathname}?${query}`;
|
|
43
|
-
// Only request first 50 results
|
|
44
|
-
const headers = Object.assign({}, defaultListHeader);
|
|
45
|
-
const options = { withMeta: true };
|
|
46
|
-
return request(path, null, headers, options)
|
|
47
|
-
.catch((error) => {
|
|
48
|
-
if (error instanceof APIMeta) {
|
|
49
|
-
return error.data;
|
|
50
|
-
}
|
|
51
|
-
throw error;
|
|
52
|
-
})
|
|
53
|
-
.then(result => result.map(processGroupData));
|
|
54
|
-
}
|
|
55
|
-
export async function listChildrenGroupChoropleths(groupId, languages) {
|
|
56
|
-
const pathname = `/v1/choropleth/groups/${groupId}/children`;
|
|
57
|
-
const query = getSearchParams({ languages });
|
|
58
|
-
const path = `${pathname}?${query}`;
|
|
59
|
-
return request(path).then(polygons => polygons.map(processPolygonData));
|
|
16
|
+
export async function groupedAreaChildren(groupId, language) {
|
|
17
|
+
return request(`/v1/choropleth/groups/${groupId}/children-optimized?${getSearchParams({ language })}`).then(result => {
|
|
18
|
+
result.forEach(elem => {
|
|
19
|
+
elem.properties = JSON.parse(elem.properties);
|
|
20
|
+
});
|
|
21
|
+
return result;
|
|
22
|
+
});
|
|
60
23
|
}
|
|
61
24
|
export async function getGroupsByDataSample(sample, language) {
|
|
62
25
|
const path = `/v1/choropleth/groups/sample`;
|
|
@@ -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,EAAkC,eAAe,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AA0DvF,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,QAAgB,EAChB,MAIE,EACF,OAAqC,MAAM;IAE3C;;OAEG;IACH,OAAO,OAAO,CACZ,kCAAkC,eAAe,2DAC/C,QAAQ,IACL,MAAM,CAAC,YAAY,GACnB,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,G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G,4BAA4B,CAAC;IAC1C,MAAM,QAAQ,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAMjE,OAAO,OAAO,CAAqC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACrE,CAAC"}
|
package/package.json
CHANGED
package/src/api/choropleth.ts
CHANGED
|
@@ -1,361 +1,129 @@
|
|
|
1
|
-
import {
|
|
2
|
-
APIMeta,
|
|
3
|
-
type ApiCommonData,
|
|
4
|
-
type ApiError,
|
|
5
|
-
type ApiSuccess,
|
|
6
|
-
type Flatten,
|
|
7
|
-
defaultListHeader,
|
|
8
|
-
ensureArray,
|
|
9
|
-
getSearchParams,
|
|
10
|
-
request,
|
|
11
|
-
toAppType,
|
|
12
|
-
} from '../utils.js';
|
|
13
|
-
import type { FeatureCollection, Polygon } from 'geojson';
|
|
14
|
-
import type { SnakeCase } from 'type-fest';
|
|
1
|
+
import { type ApiError, type ApiSuccess, getSearchParams, request } from '../utils.js';
|
|
15
2
|
|
|
16
|
-
type
|
|
3
|
+
import type { RequireAtLeastOne } from 'type-fest';
|
|
4
|
+
import type { Polygon } from 'geojson';
|
|
17
5
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
...group.nativeRelationTranslation && { nativeRelationTranslation: toAppType(group.nativeRelationTranslation) },
|
|
22
|
-
...group.englishParentTranslation && { englishParentTranslation: toAppType(group.englishParentTranslation) },
|
|
23
|
-
...group.englishRelationTranslation && { englishRelationTranslation: toAppType(group.englishRelationTranslation) },
|
|
24
|
-
...group.parentTranslations && { parentTranslations: ensureArray(group.parentTranslations).map(toAppType) },
|
|
25
|
-
...group.relationTranslations && { relationTranslations: ensureArray(group.relationTranslations).map(toAppType) },
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const processPolygonData = (polygon: PolygonChoropleth): PolygonChoropleth => ({
|
|
29
|
-
...polygon,
|
|
30
|
-
...polygon.parentGroups && { parentGroups: ensureArray(polygon.parentGroups).map(toAppType).map(processGroupData) },
|
|
31
|
-
...polygon.nativeTranslation && { nativeTranslation: toAppType(polygon.nativeTranslation) },
|
|
32
|
-
...polygon.englishTranslation && { englishTranslation: toAppType(polygon.englishTranslation) },
|
|
33
|
-
...polygon.translations && { translations: ensureArray(polygon.translations).map(toAppType) },
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export type PartialVectorChoropleth = Pick<VectorChoropleth, FieldName>;
|
|
37
|
-
|
|
38
|
-
export type VectorChoropleth = {
|
|
39
|
-
id: number;
|
|
40
|
-
name: string;
|
|
41
|
-
description: string;
|
|
42
|
-
previewPath: string | null;
|
|
43
|
-
previewJson: FeatureCollection | null;
|
|
44
|
-
|
|
45
|
-
vectorSetUrl: string;
|
|
46
|
-
sourceLayerName: string;
|
|
47
|
-
|
|
48
|
-
lngMin: number;
|
|
49
|
-
lngMax: number;
|
|
50
|
-
latMin: number;
|
|
51
|
-
latMax: number;
|
|
52
|
-
|
|
53
|
-
keys: string[];
|
|
54
|
-
properties: Array<Record<string, unknown>>;
|
|
6
|
+
export type ApiSearchPoint = {
|
|
7
|
+
lat: number;
|
|
8
|
+
lng: number;
|
|
55
9
|
};
|
|
56
10
|
|
|
57
|
-
export type
|
|
58
|
-
data: {
|
|
59
|
-
id: number;
|
|
60
|
-
name: string;
|
|
61
|
-
description: string;
|
|
62
|
-
preview_path: string | null;
|
|
63
|
-
preview_json: FeatureCollection | null;
|
|
64
|
-
|
|
65
|
-
vector_set_url: string;
|
|
66
|
-
source_layer_name: string;
|
|
67
|
-
|
|
68
|
-
lng_min: number;
|
|
69
|
-
lng_max: number;
|
|
70
|
-
lat_min: number;
|
|
71
|
-
lat_max: number;
|
|
72
|
-
|
|
73
|
-
keys: string[];
|
|
74
|
-
properties: Array<Record<string, unknown>>;
|
|
75
|
-
} & ApiCommonData;
|
|
76
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
77
|
-
|
|
78
|
-
export type ApiVectorChoroplethData = Flatten<Exclude<ApiVectorChoropleth, ApiError>['data']>;
|
|
79
|
-
|
|
80
|
-
export async function listVectorChoropleths(name: string): Promise<PartialVectorChoropleth[]> {
|
|
81
|
-
const pathname = `/v1/choropleths/vector`;
|
|
82
|
-
const query = getSearchParams({ search: { name } });
|
|
83
|
-
const path = `${pathname}?${query}`;
|
|
84
|
-
|
|
85
|
-
// Only request first 50 results
|
|
86
|
-
const headers = { ...defaultListHeader };
|
|
87
|
-
const options = { withMeta: true };
|
|
88
|
-
|
|
89
|
-
type ApiVectorChoroplethArray = {
|
|
90
|
-
data: Array<Pick<ApiVectorChoroplethData, SnakeCase<FieldName>>>;
|
|
91
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
92
|
-
|
|
93
|
-
return request<ApiVectorChoroplethArray, PartialVectorChoropleth>(path, null, headers, options)
|
|
94
|
-
.catch((error: Error) => {
|
|
95
|
-
if (error instanceof APIMeta) {
|
|
96
|
-
return (error as APIMeta<ApiVectorChoroplethArray, PartialVectorChoropleth>).data;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
throw error;
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export async function getVectorChoropleth(choroplethId: number): Promise<VectorChoropleth> {
|
|
104
|
-
const path = `/v1/choropleths/vector/${choroplethId}`;
|
|
105
|
-
|
|
106
|
-
return request<ApiVectorChoropleth, VectorChoropleth>(path);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export type SearchBounds = {
|
|
11
|
+
export type ApiSearchBounds = {
|
|
110
12
|
min_lat: number;
|
|
111
13
|
min_lng: number;
|
|
112
14
|
max_lat: number;
|
|
113
15
|
max_lng: number;
|
|
114
16
|
};
|
|
115
17
|
|
|
116
|
-
|
|
117
|
-
sml: string;
|
|
18
|
+
type ApiSingleOrGroupedArea = {
|
|
118
19
|
id: number;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
linkId: number | null;
|
|
129
|
-
cloning: boolean;
|
|
130
|
-
nativeTranslation: {
|
|
131
|
-
polygonId: number;
|
|
132
|
-
name: string;
|
|
133
|
-
};
|
|
134
|
-
englishTranslation?: {
|
|
135
|
-
polygonId: number;
|
|
136
|
-
name: string;
|
|
137
|
-
};
|
|
138
|
-
translations?: Array<{
|
|
139
|
-
polygonId: number;
|
|
140
|
-
language: string;
|
|
141
|
-
name: string;
|
|
142
|
-
}>;
|
|
143
|
-
parentGroups: GroupChoropleth[];
|
|
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;
|
|
144
29
|
};
|
|
145
30
|
|
|
146
|
-
|
|
147
|
-
data:
|
|
148
|
-
sml: string;
|
|
149
|
-
id: number;
|
|
150
|
-
vector_source: string;
|
|
151
|
-
source_layer: string;
|
|
152
|
-
feature_id: number;
|
|
153
|
-
svg_preview: string;
|
|
154
|
-
preview_path: string;
|
|
155
|
-
allow_single: boolean;
|
|
156
|
-
properties: Record<string, unknown>;
|
|
157
|
-
bounding_box: Polygon;
|
|
158
|
-
restricted_ownership: number[] | null;
|
|
159
|
-
link_id: number | null;
|
|
160
|
-
cloning: boolean;
|
|
161
|
-
native_translation: {
|
|
162
|
-
polygon_id: number;
|
|
163
|
-
name: string;
|
|
164
|
-
};
|
|
165
|
-
english_translation?: {
|
|
166
|
-
polygon_id: number;
|
|
167
|
-
name: string;
|
|
168
|
-
};
|
|
169
|
-
translations?: Array<{
|
|
170
|
-
polygon_id: number;
|
|
171
|
-
language: string;
|
|
172
|
-
name: string;
|
|
173
|
-
}>;
|
|
174
|
-
parent_groups: ApiGroupChoroplethData[];
|
|
175
|
-
} & ApiCommonData;
|
|
31
|
+
type ApiSingleOrGroupedAreaArray = {
|
|
32
|
+
data: ApiSingleOrGroupedArea[];
|
|
176
33
|
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
177
34
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
): Promise<PolygonChoropleth[]> {
|
|
186
|
-
const pathname = `/v1/choropleth/polygons`;
|
|
187
|
-
const query = getSearchParams(
|
|
188
|
-
{
|
|
189
|
-
search: { name, allow_single: true },
|
|
190
|
-
with_parent_groups: withParentGroups,
|
|
191
|
-
languages,
|
|
192
|
-
...searchBounds,
|
|
193
|
-
},
|
|
194
|
-
);
|
|
195
|
-
const path = `${pathname}?${query}`;
|
|
35
|
+
type SingleOrGroupedAreaBase = {
|
|
36
|
+
id: number;
|
|
37
|
+
title: string;
|
|
38
|
+
subtitle: string;
|
|
39
|
+
svgPreview: string;
|
|
40
|
+
boundingBox: Polygon;
|
|
41
|
+
};
|
|
196
42
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
43
|
+
// TODO don't export this once search on click is out
|
|
44
|
+
export type GroupedArea = SingleOrGroupedAreaBase & {
|
|
45
|
+
isGroup: true;
|
|
46
|
+
};
|
|
200
47
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
48
|
+
// TODO don't export this once search on click is out
|
|
49
|
+
export type SingleArea = SingleOrGroupedAreaBase & {
|
|
50
|
+
isGroup: false;
|
|
51
|
+
vectorSource: string;
|
|
52
|
+
sourceLayer: string;
|
|
53
|
+
featureId: number;
|
|
54
|
+
properties: Record<string, string>;
|
|
55
|
+
};
|
|
204
56
|
|
|
205
|
-
|
|
206
|
-
.catch((error: Error) => {
|
|
207
|
-
if (error instanceof APIMeta) {
|
|
208
|
-
return (error as APIMeta<ApiPolygonChoroplethArray, PolygonChoropleth>).data;
|
|
209
|
-
}
|
|
57
|
+
export type SingleOrGroupedArea = SingleArea | GroupedArea;
|
|
210
58
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
59
|
+
export async function searchSingleOrGroupedAreas(
|
|
60
|
+
language: string,
|
|
61
|
+
search: RequireAtLeastOne<{
|
|
62
|
+
searchBounds?: ApiSearchBounds;
|
|
63
|
+
query?: string;
|
|
64
|
+
searchPoint?: ApiSearchPoint;
|
|
65
|
+
}>,
|
|
66
|
+
mode: 'polygon' | 'group' | 'both' = 'both',
|
|
67
|
+
): Promise<SingleOrGroupedArea[]> {
|
|
68
|
+
/**
|
|
69
|
+
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
70
|
+
*/
|
|
71
|
+
return request<ApiSingleOrGroupedAreaArray, SingleOrGroupedArea>(
|
|
72
|
+
`/v1/choropleth/polygons/search?${getSearchParams({
|
|
73
|
+
language,
|
|
74
|
+
...search.searchBounds,
|
|
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;
|
|
90
|
+
});
|
|
214
91
|
}
|
|
215
92
|
|
|
216
|
-
|
|
93
|
+
type ApiGroupedAreaChild = {
|
|
217
94
|
id: number;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
previewPath: string;
|
|
224
|
-
uniqueProperties: string[];
|
|
225
|
-
boundingBox: Polygon;
|
|
226
|
-
partialProperties: string[];
|
|
227
|
-
restrictedOwnership: number[] | null;
|
|
228
|
-
linkId: number | null;
|
|
229
|
-
cloning: boolean;
|
|
230
|
-
laravelThroughKey?: number;
|
|
231
|
-
nativeParentTranslation: {
|
|
232
|
-
polygonId: number;
|
|
233
|
-
name: string;
|
|
234
|
-
laravelThroughKey: number;
|
|
235
|
-
};
|
|
236
|
-
nativeRelationTranslation: {
|
|
237
|
-
relationId: number;
|
|
238
|
-
name: string;
|
|
239
|
-
laravelThroughKey: number;
|
|
240
|
-
};
|
|
241
|
-
englishParentTranslation?: {
|
|
242
|
-
polygonId: number;
|
|
243
|
-
name: string;
|
|
244
|
-
laravelThroughKey: number;
|
|
245
|
-
};
|
|
246
|
-
englishRelationTranslation?: {
|
|
247
|
-
relationId: number;
|
|
248
|
-
name: string;
|
|
249
|
-
laravelThroughKey: number;
|
|
250
|
-
};
|
|
251
|
-
parentTranslations?: Array<{
|
|
252
|
-
polygonId: number;
|
|
253
|
-
name: string;
|
|
254
|
-
language: string;
|
|
255
|
-
laravelThroughKey: number;
|
|
256
|
-
}>;
|
|
257
|
-
relationTranslations?: Array<{
|
|
258
|
-
relationId: number;
|
|
259
|
-
name: string;
|
|
260
|
-
language: string;
|
|
261
|
-
laravelThroughKey: number;
|
|
262
|
-
}>;
|
|
95
|
+
title: string;
|
|
96
|
+
vector_source: string;
|
|
97
|
+
source_layer: string;
|
|
98
|
+
feature_id: number;
|
|
99
|
+
properties: Record<string, string>;
|
|
263
100
|
};
|
|
264
101
|
|
|
265
|
-
|
|
266
|
-
data:
|
|
267
|
-
id: number;
|
|
268
|
-
polygon_id: number;
|
|
269
|
-
relation_id: number;
|
|
270
|
-
children_count: number;
|
|
271
|
-
sml?: number;
|
|
272
|
-
svg_preview: string;
|
|
273
|
-
preview_path: string;
|
|
274
|
-
unique_properties: string[];
|
|
275
|
-
bounding_box: Polygon;
|
|
276
|
-
partial_properties: string[];
|
|
277
|
-
restricted_ownership: number[] | null;
|
|
278
|
-
link_id: number | null;
|
|
279
|
-
cloning: boolean;
|
|
280
|
-
laravel_through_key?: number;
|
|
281
|
-
native_parent_translation: {
|
|
282
|
-
polygon_id: number;
|
|
283
|
-
name: string;
|
|
284
|
-
laravel_through_key: number;
|
|
285
|
-
};
|
|
286
|
-
native_relation_translation: {
|
|
287
|
-
relation_id: number;
|
|
288
|
-
name: string;
|
|
289
|
-
laravel_through_key: number;
|
|
290
|
-
};
|
|
291
|
-
english_parent_translation?: {
|
|
292
|
-
polygon_id: number;
|
|
293
|
-
name: string;
|
|
294
|
-
laravel_through_key: number;
|
|
295
|
-
};
|
|
296
|
-
english_relation_translation?: {
|
|
297
|
-
relation_id: number;
|
|
298
|
-
name: string;
|
|
299
|
-
laravel_through_key: number;
|
|
300
|
-
};
|
|
301
|
-
parent_translations?: Array<{
|
|
302
|
-
polygon_id: number;
|
|
303
|
-
name: string;
|
|
304
|
-
language: string;
|
|
305
|
-
laravel_through_key: number;
|
|
306
|
-
}>;
|
|
307
|
-
relation_translations?: Array<{
|
|
308
|
-
relation_id: number;
|
|
309
|
-
name: string;
|
|
310
|
-
language: string;
|
|
311
|
-
laravel_through_key: number;
|
|
312
|
-
}>;
|
|
313
|
-
} & ApiCommonData;
|
|
102
|
+
type ApiGroupedAreaChildArray = {
|
|
103
|
+
data: ApiGroupedAreaChild[];
|
|
314
104
|
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
315
105
|
|
|
316
|
-
export type
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const query = getSearchParams({ search: { name }, languages, ...searchBounds });
|
|
325
|
-
const path = `${pathname}?${query}`;
|
|
326
|
-
|
|
327
|
-
// Only request first 50 results
|
|
328
|
-
const headers = { ...defaultListHeader };
|
|
329
|
-
const options = { withMeta: true };
|
|
330
|
-
|
|
331
|
-
type ApiGroupChoroplethArray = {
|
|
332
|
-
data: ApiGroupChoroplethData[];
|
|
333
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
106
|
+
export type GroupedAreaChild = {
|
|
107
|
+
id: number;
|
|
108
|
+
title: string;
|
|
109
|
+
vectorSource: string;
|
|
110
|
+
sourceLayer: string;
|
|
111
|
+
featureId: number;
|
|
112
|
+
properties: Record<string, string>;
|
|
113
|
+
};
|
|
334
114
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
115
|
+
export async function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]> {
|
|
116
|
+
return request<ApiGroupedAreaChildArray, GroupedAreaChild>(
|
|
117
|
+
`/v1/choropleth/groups/${groupId}/children-optimized?${getSearchParams({ language })}`,
|
|
118
|
+
).then(result => {
|
|
119
|
+
result.forEach(
|
|
120
|
+
elem => {
|
|
121
|
+
elem.properties = JSON.parse(elem.properties as unknown as string) as Record<string, string>;
|
|
339
122
|
}
|
|
123
|
+
);
|
|
340
124
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
.then(result => result.map(processGroupData));
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
export async function listChildrenGroupChoropleths(
|
|
347
|
-
groupId: number,
|
|
348
|
-
languages: string[],
|
|
349
|
-
): Promise<PolygonChoropleth[]> {
|
|
350
|
-
const pathname = `/v1/choropleth/groups/${groupId}/children`;
|
|
351
|
-
const query = getSearchParams({ languages });
|
|
352
|
-
const path = `${pathname}?${query}`;
|
|
353
|
-
|
|
354
|
-
type ApiPolygonChoroplethArray = {
|
|
355
|
-
data: ApiPolygonChoroplethData[];
|
|
356
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
357
|
-
|
|
358
|
-
return request<ApiPolygonChoroplethArray, PolygonChoropleth>(path).then(polygons => polygons.map(processPolygonData));
|
|
125
|
+
return result;
|
|
126
|
+
});
|
|
359
127
|
}
|
|
360
128
|
|
|
361
129
|
export type MatchedGroup = {
|
|
@@ -377,7 +145,7 @@ export type ApiMatchedGroup = {
|
|
|
377
145
|
};
|
|
378
146
|
|
|
379
147
|
export async function getGroupsByDataSample(
|
|
380
|
-
sample: Record<string, string[]
|
|
148
|
+
sample: Array<Record<string, string[]>>,
|
|
381
149
|
language: string,
|
|
382
150
|
): Promise<MatchedGroup[]> {
|
|
383
151
|
const path = `/v1/choropleth/groups/sample`;
|