@mapcreator/api 0.0.0-wms.0 → 0.0.0-wms.1
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/insetMap.js +1 -1
- package/cjs/api/insetMap.js.map +1 -1
- package/cjs/api/job.d.ts +1 -0
- package/cjs/api/job.d.ts.map +1 -1
- package/cjs/api/job.js.map +1 -1
- package/cjs/api/jobResult.d.ts +1 -1
- package/cjs/api/jobResult.d.ts.map +1 -1
- package/cjs/api/jobResult.js +1 -1
- package/cjs/api/jobResult.js.map +1 -1
- package/cjs/api/jobRevision.d.ts +2 -2
- package/cjs/api/jobRevision.d.ts.map +1 -1
- package/cjs/api/jobRevision.js +1 -1
- package/cjs/api/jobRevision.js.map +1 -1
- package/cjs/api/organisation.d.ts +2 -1
- package/cjs/api/organisation.d.ts.map +1 -1
- package/cjs/api/organisation.js +1 -2
- package/cjs/api/organisation.js.map +1 -1
- package/cjs/api/resources.d.ts +1 -1
- package/cjs/api/resources.d.ts.map +1 -1
- package/cjs/api/resources.js.map +1 -1
- package/esm/api/insetMap.js +1 -1
- package/esm/api/insetMap.js.map +1 -1
- package/esm/api/job.d.ts +1 -0
- package/esm/api/job.d.ts.map +1 -1
- package/esm/api/job.js.map +1 -1
- package/esm/api/jobResult.d.ts +1 -1
- package/esm/api/jobResult.d.ts.map +1 -1
- package/esm/api/jobResult.js +1 -1
- package/esm/api/jobResult.js.map +1 -1
- package/esm/api/jobRevision.d.ts +2 -2
- package/esm/api/jobRevision.d.ts.map +1 -1
- package/esm/api/jobRevision.js +1 -1
- package/esm/api/jobRevision.js.map +1 -1
- package/esm/api/organisation.d.ts +2 -1
- package/esm/api/organisation.d.ts.map +1 -1
- package/esm/api/organisation.js +1 -2
- package/esm/api/organisation.js.map +1 -1
- package/esm/api/resources.d.ts +1 -1
- package/esm/api/resources.d.ts.map +1 -1
- package/esm/api/resources.js.map +1 -1
- package/package.json +1 -1
- package/src/api/apiCommon.ts +70 -70
- package/src/api/choropleth.ts +359 -359
- package/src/api/color.ts +22 -22
- package/src/api/dimension.ts +44 -44
- package/src/api/dimensionSet.ts +20 -20
- package/src/api/feature.ts +22 -22
- package/src/api/font.ts +49 -49
- package/src/api/fontFamily.ts +43 -43
- package/src/api/highlight.ts +87 -87
- package/src/api/insetMap.ts +96 -96
- package/src/api/job.ts +130 -129
- package/src/api/jobResult.ts +95 -95
- package/src/api/jobRevision.ts +279 -278
- package/src/api/jobShare.ts +35 -35
- package/src/api/jobType.ts +26 -26
- package/src/api/language.ts +19 -19
- package/src/api/layer.ts +38 -38
- package/src/api/layerFaq.ts +53 -53
- package/src/api/layerGroup.ts +69 -69
- package/src/api/mapstyleSet.ts +48 -48
- package/src/api/message.ts +80 -80
- package/src/api/organisation.ts +95 -95
- package/src/api/resources.ts +146 -144
- package/src/api/svg.ts +33 -33
- package/src/api/svgSet.ts +56 -56
- package/src/api/user.ts +327 -327
- package/src/index.ts +43 -43
- package/src/oauth.ts +314 -314
- package/src/utils.ts +342 -342
package/src/api/choropleth.ts
CHANGED
|
@@ -1,359 +1,359 @@
|
|
|
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';
|
|
15
|
-
|
|
16
|
-
type FieldName = 'id' | 'name' | 'description' | 'previewJson' | 'previewPath';
|
|
17
|
-
|
|
18
|
-
const processGroupData = (group: GroupChoropleth): GroupChoropleth => ({
|
|
19
|
-
...group,
|
|
20
|
-
...group.nativeParentTranslation && { nativeParentTranslation: toAppType(group.nativeParentTranslation) },
|
|
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>>;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export type ApiVectorChoropleth = {
|
|
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 = {
|
|
110
|
-
min_lat: number;
|
|
111
|
-
min_lng: number;
|
|
112
|
-
max_lat: number;
|
|
113
|
-
max_lng: number;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export type PolygonChoropleth = {
|
|
117
|
-
sml: string;
|
|
118
|
-
id: number;
|
|
119
|
-
vectorSource: string;
|
|
120
|
-
sourceLayer: string;
|
|
121
|
-
featureId: number;
|
|
122
|
-
svgPreview: string;
|
|
123
|
-
previewPath: string;
|
|
124
|
-
allowSingle: boolean;
|
|
125
|
-
properties: Record<string, unknown>;
|
|
126
|
-
boundingBox: Polygon;
|
|
127
|
-
restrictedOwnership: number[] | null;
|
|
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[];
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
export type ApiPolygonChoropleth = {
|
|
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;
|
|
176
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
177
|
-
|
|
178
|
-
export type ApiPolygonChoroplethData = Flatten<Exclude<ApiPolygonChoropleth, ApiError>['data']>;
|
|
179
|
-
|
|
180
|
-
export async function listPolygonChoropleths(
|
|
181
|
-
name: string,
|
|
182
|
-
languages: string[],
|
|
183
|
-
searchBounds?: SearchBounds,
|
|
184
|
-
withParentGroups = false,
|
|
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}`;
|
|
196
|
-
|
|
197
|
-
// Only request first 50 results
|
|
198
|
-
const headers = { ...defaultListHeader };
|
|
199
|
-
const options = { withMeta: true };
|
|
200
|
-
|
|
201
|
-
type ApiPolygonChoroplethArray = {
|
|
202
|
-
data: ApiPolygonChoroplethData[];
|
|
203
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
204
|
-
|
|
205
|
-
return request<ApiPolygonChoroplethArray, PolygonChoropleth>(path, null, headers, options)
|
|
206
|
-
.catch((error: Error) => {
|
|
207
|
-
if (error instanceof APIMeta) {
|
|
208
|
-
return (error as APIMeta<ApiPolygonChoroplethArray, PolygonChoropleth>).data;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
throw error;
|
|
212
|
-
})
|
|
213
|
-
.then(result => result.map(processPolygonData));
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export type GroupChoropleth = {
|
|
217
|
-
id: number;
|
|
218
|
-
polygonId: number;
|
|
219
|
-
relationId: number;
|
|
220
|
-
childrenCount: number;
|
|
221
|
-
sml?: string;
|
|
222
|
-
svgPreview: string;
|
|
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
|
-
}>;
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
export type ApiGroupChoropleth = {
|
|
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;
|
|
314
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
315
|
-
|
|
316
|
-
export type ApiGroupChoroplethData = Flatten<Exclude<ApiGroupChoropleth, ApiError>['data']>;
|
|
317
|
-
|
|
318
|
-
export async function listGroupChoropleths(
|
|
319
|
-
name: string,
|
|
320
|
-
languages: string[],
|
|
321
|
-
searchBounds?: SearchBounds,
|
|
322
|
-
): Promise<GroupChoropleth[]> {
|
|
323
|
-
const pathname = `/v1/choropleth/groups`;
|
|
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;
|
|
334
|
-
|
|
335
|
-
return request<ApiGroupChoroplethArray, GroupChoropleth>(path, null, headers, options)
|
|
336
|
-
.catch((error: Error) => {
|
|
337
|
-
if (error instanceof APIMeta) {
|
|
338
|
-
return (error as APIMeta<ApiGroupChoroplethArray, GroupChoropleth>).data;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
throw error;
|
|
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));
|
|
359
|
-
}
|
|
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';
|
|
15
|
+
|
|
16
|
+
type FieldName = 'id' | 'name' | 'description' | 'previewJson' | 'previewPath';
|
|
17
|
+
|
|
18
|
+
const processGroupData = (group: GroupChoropleth): GroupChoropleth => ({
|
|
19
|
+
...group,
|
|
20
|
+
...group.nativeParentTranslation && { nativeParentTranslation: toAppType(group.nativeParentTranslation) },
|
|
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>>;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type ApiVectorChoropleth = {
|
|
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 = {
|
|
110
|
+
min_lat: number;
|
|
111
|
+
min_lng: number;
|
|
112
|
+
max_lat: number;
|
|
113
|
+
max_lng: number;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export type PolygonChoropleth = {
|
|
117
|
+
sml: string;
|
|
118
|
+
id: number;
|
|
119
|
+
vectorSource: string;
|
|
120
|
+
sourceLayer: string;
|
|
121
|
+
featureId: number;
|
|
122
|
+
svgPreview: string;
|
|
123
|
+
previewPath: string;
|
|
124
|
+
allowSingle: boolean;
|
|
125
|
+
properties: Record<string, unknown>;
|
|
126
|
+
boundingBox: Polygon;
|
|
127
|
+
restrictedOwnership: number[] | null;
|
|
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[];
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export type ApiPolygonChoropleth = {
|
|
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;
|
|
176
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
177
|
+
|
|
178
|
+
export type ApiPolygonChoroplethData = Flatten<Exclude<ApiPolygonChoropleth, ApiError>['data']>;
|
|
179
|
+
|
|
180
|
+
export async function listPolygonChoropleths(
|
|
181
|
+
name: string,
|
|
182
|
+
languages: string[],
|
|
183
|
+
searchBounds?: SearchBounds,
|
|
184
|
+
withParentGroups = false,
|
|
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}`;
|
|
196
|
+
|
|
197
|
+
// Only request first 50 results
|
|
198
|
+
const headers = { ...defaultListHeader };
|
|
199
|
+
const options = { withMeta: true };
|
|
200
|
+
|
|
201
|
+
type ApiPolygonChoroplethArray = {
|
|
202
|
+
data: ApiPolygonChoroplethData[];
|
|
203
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
204
|
+
|
|
205
|
+
return request<ApiPolygonChoroplethArray, PolygonChoropleth>(path, null, headers, options)
|
|
206
|
+
.catch((error: Error) => {
|
|
207
|
+
if (error instanceof APIMeta) {
|
|
208
|
+
return (error as APIMeta<ApiPolygonChoroplethArray, PolygonChoropleth>).data;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
throw error;
|
|
212
|
+
})
|
|
213
|
+
.then(result => result.map(processPolygonData));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export type GroupChoropleth = {
|
|
217
|
+
id: number;
|
|
218
|
+
polygonId: number;
|
|
219
|
+
relationId: number;
|
|
220
|
+
childrenCount: number;
|
|
221
|
+
sml?: string;
|
|
222
|
+
svgPreview: string;
|
|
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
|
+
}>;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
export type ApiGroupChoropleth = {
|
|
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;
|
|
314
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
315
|
+
|
|
316
|
+
export type ApiGroupChoroplethData = Flatten<Exclude<ApiGroupChoropleth, ApiError>['data']>;
|
|
317
|
+
|
|
318
|
+
export async function listGroupChoropleths(
|
|
319
|
+
name: string,
|
|
320
|
+
languages: string[],
|
|
321
|
+
searchBounds?: SearchBounds,
|
|
322
|
+
): Promise<GroupChoropleth[]> {
|
|
323
|
+
const pathname = `/v1/choropleth/groups`;
|
|
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;
|
|
334
|
+
|
|
335
|
+
return request<ApiGroupChoroplethArray, GroupChoropleth>(path, null, headers, options)
|
|
336
|
+
.catch((error: Error) => {
|
|
337
|
+
if (error instanceof APIMeta) {
|
|
338
|
+
return (error as APIMeta<ApiGroupChoroplethArray, GroupChoropleth>).data;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
throw error;
|
|
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));
|
|
359
|
+
}
|