@mapcreator/api 5.0.0-alpha.85 → 5.0.0-alpha.87
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 +81 -4
- package/cjs/api/choropleth.d.ts.map +1 -1
- package/cjs/api/choropleth.js +26 -17
- package/cjs/api/choropleth.js.map +1 -1
- package/esm/api/choropleth.d.ts +81 -4
- package/esm/api/choropleth.d.ts.map +1 -1
- package/esm/api/choropleth.js +23 -16
- package/esm/api/choropleth.js.map +1 -1
- package/package.json +1 -1
- package/src/api/choropleth.ts +140 -44
package/cjs/api/choropleth.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { type ApiError, type ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
1
|
+
import { type ApiError, type ApiSuccess, type Flatten, type Revivers } from '../utils.js';
|
|
2
|
+
import type { RequireAtLeastOne } from 'type-fest';
|
|
2
3
|
import type { Polygon } from 'geojson';
|
|
3
|
-
|
|
4
|
+
export declare const boundingBoxRevivers: Revivers<{
|
|
5
|
+
data: {
|
|
6
|
+
bounding_box: string;
|
|
7
|
+
};
|
|
8
|
+
} & Omit<ApiSuccess, 'data'> | ApiError, {
|
|
9
|
+
boundingBox: Polygon;
|
|
10
|
+
}>;
|
|
4
11
|
export type ApiSearchPoint = {
|
|
5
12
|
lat: number;
|
|
6
13
|
lng: number;
|
|
@@ -23,12 +30,42 @@ export type GroupedArea = SingleOrGroupedAreaBase & {
|
|
|
23
30
|
};
|
|
24
31
|
export type SingleArea = SingleOrGroupedAreaBase & {
|
|
25
32
|
isGroup: false;
|
|
33
|
+
properties: Record<string, string>;
|
|
26
34
|
vectorSource: string;
|
|
27
35
|
sourceLayer: string;
|
|
28
36
|
featureId: number;
|
|
29
|
-
properties: Record<string, string>;
|
|
30
37
|
};
|
|
31
|
-
export type SingleOrGroupedArea =
|
|
38
|
+
export type SingleOrGroupedArea = {
|
|
39
|
+
id: number;
|
|
40
|
+
title: string;
|
|
41
|
+
subtitle: string;
|
|
42
|
+
svgPreview: string;
|
|
43
|
+
boundingBox: Polygon;
|
|
44
|
+
isGroup: boolean;
|
|
45
|
+
properties: Record<string, string> | null;
|
|
46
|
+
vectorSource: string | null;
|
|
47
|
+
sourceLayer: string | null;
|
|
48
|
+
featureId: number | null;
|
|
49
|
+
};
|
|
50
|
+
export type ApiSingleOrGroupedArea = {
|
|
51
|
+
data: {
|
|
52
|
+
id: number;
|
|
53
|
+
title: string;
|
|
54
|
+
subtitle: string;
|
|
55
|
+
svg_preview: string;
|
|
56
|
+
bounding_box: string;
|
|
57
|
+
is_group: boolean;
|
|
58
|
+
properties: string | null;
|
|
59
|
+
vector_source: string | null;
|
|
60
|
+
source_layer: string | null;
|
|
61
|
+
feature_id: number | null;
|
|
62
|
+
};
|
|
63
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
64
|
+
export type ApiSingleOrGroupedAreaData = Flatten<Exclude<ApiSingleOrGroupedArea, ApiError>['data']>;
|
|
65
|
+
export declare const singleOrGroupedAreaRevivers: Revivers<ApiSingleOrGroupedArea, SingleOrGroupedArea>;
|
|
66
|
+
/**
|
|
67
|
+
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
68
|
+
*/
|
|
32
69
|
export declare function searchSingleOrGroupedAreas(language: string, search: RequireAtLeastOne<{
|
|
33
70
|
searchBounds?: ApiSearchBounds;
|
|
34
71
|
query?: string;
|
|
@@ -57,5 +94,45 @@ type ApiGroupedAreaChild = {
|
|
|
57
94
|
export type ApiGroupedAreaChildData = Flatten<Exclude<ApiGroupedAreaChild, ApiError>['data']>;
|
|
58
95
|
export declare const groupedAreaChildRevivers: Revivers<ApiGroupedAreaChild, GroupedAreaChild>;
|
|
59
96
|
export declare function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]>;
|
|
97
|
+
export type MatchedGroup = {
|
|
98
|
+
id: number;
|
|
99
|
+
sml: number;
|
|
100
|
+
childrenCount: number;
|
|
101
|
+
matchField: string;
|
|
102
|
+
boundingBox: Polygon;
|
|
103
|
+
property: string;
|
|
104
|
+
name: string;
|
|
105
|
+
};
|
|
106
|
+
export type ApiMatchedGroup = {
|
|
107
|
+
data: {
|
|
108
|
+
id: number;
|
|
109
|
+
sml: number;
|
|
110
|
+
children_count: number;
|
|
111
|
+
match_field: string;
|
|
112
|
+
bounding_box: string;
|
|
113
|
+
property: string;
|
|
114
|
+
name: string;
|
|
115
|
+
};
|
|
116
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
117
|
+
export type ApiMatchedGroupData = Flatten<Exclude<ApiMatchedGroup, ApiError>['data']>;
|
|
118
|
+
export declare function getGroupsByDataSample(sample: Record<string, string[]>, language: string, rowCount: number): Promise<MatchedGroup[]>;
|
|
119
|
+
export type BoundPolygon = {
|
|
120
|
+
index: number;
|
|
121
|
+
inputName: string;
|
|
122
|
+
id: number;
|
|
123
|
+
sml: number;
|
|
124
|
+
name: string;
|
|
125
|
+
};
|
|
126
|
+
export type ApiBoundPolygon = {
|
|
127
|
+
data: {
|
|
128
|
+
index: number;
|
|
129
|
+
input_name: string;
|
|
130
|
+
id: number;
|
|
131
|
+
sml: number;
|
|
132
|
+
name: string;
|
|
133
|
+
};
|
|
134
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
135
|
+
export type ApiBoundPolygonData = Flatten<Exclude<ApiBoundPolygon, ApiError>['data']>;
|
|
136
|
+
export declare function getBoundPolygons(groupId: number, property: string, data: string[], language: string): Promise<BoundPolygon[]>;
|
|
60
137
|
export {};
|
|
61
138
|
//# sourceMappingURL=choropleth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choropleth.d.ts","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,OAAO,EAAE,QAAQ,EAA4B,MAAM,aAAa,CAAC;
|
|
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,IAAI,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,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,27 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.groupedAreaChildRevivers = void 0;
|
|
3
|
+
exports.groupedAreaChildRevivers = exports.singleOrGroupedAreaRevivers = exports.boundingBoxRevivers = void 0;
|
|
4
4
|
exports.searchSingleOrGroupedAreas = searchSingleOrGroupedAreas;
|
|
5
5
|
exports.groupedAreaChildren = groupedAreaChildren;
|
|
6
|
+
exports.getGroupsByDataSample = getGroupsByDataSample;
|
|
7
|
+
exports.getBoundPolygons = getBoundPolygons;
|
|
6
8
|
const utils_js_1 = require("../utils.js");
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
10
|
-
*/
|
|
11
|
-
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 => {
|
|
12
|
-
result.forEach(elem => {
|
|
13
|
-
elem.boundingBox = JSON.parse(elem.boundingBox);
|
|
14
|
-
if (!elem.isGroup) {
|
|
15
|
-
elem.properties = JSON.parse(elem.properties);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
return result;
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
exports.groupedAreaChildRevivers = {
|
|
9
|
+
exports.boundingBoxRevivers = {
|
|
22
10
|
boundingBox: (data) => JSON.parse(data.bounding_box),
|
|
23
|
-
properties: (data) => JSON.parse(data.properties),
|
|
24
11
|
};
|
|
12
|
+
exports.singleOrGroupedAreaRevivers = Object.assign(Object.assign({}, exports.boundingBoxRevivers), { properties: (data) => (data.properties != null ? JSON.parse(data.properties) : null) });
|
|
13
|
+
/**
|
|
14
|
+
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
15
|
+
*/
|
|
16
|
+
async function searchSingleOrGroupedAreas(language, search, mode = 'both') {
|
|
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);
|
|
22
|
+
}
|
|
23
|
+
exports.groupedAreaChildRevivers = Object.assign(Object.assign({}, exports.boundingBoxRevivers), { properties: (data) => JSON.parse(data.properties) });
|
|
25
24
|
async function groupedAreaChildren(groupId, language) {
|
|
26
25
|
const pathname = `/v1/choropleth/groups/${groupId}/children-optimized`;
|
|
27
26
|
const query = (0, utils_js_1.getSearchParams)({ language });
|
|
@@ -29,4 +28,14 @@ async function groupedAreaChildren(groupId, language) {
|
|
|
29
28
|
const options = { revivers: exports.groupedAreaChildRevivers };
|
|
30
29
|
return (0, utils_js_1.request)(path, null, null, options);
|
|
31
30
|
}
|
|
31
|
+
async function getGroupsByDataSample(sample, language, rowCount) {
|
|
32
|
+
const path = `/v1/choropleth/groups/sample`;
|
|
33
|
+
const options = { revivers: exports.boundingBoxRevivers };
|
|
34
|
+
return (0, utils_js_1.request)(path, { sample, language, row_count: rowCount }, null, options);
|
|
35
|
+
}
|
|
36
|
+
async function getBoundPolygons(groupId, property, data, language) {
|
|
37
|
+
const path = `/v1/choropleth/groups/bind`;
|
|
38
|
+
const body = { group_id: groupId, property, data, language };
|
|
39
|
+
return (0, utils_js_1.request)(path, body);
|
|
40
|
+
}
|
|
32
41
|
//# 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":";;;AAqFA,gEAyBC;AA+BD,kDAWC;AA0BD,sDAaC;AAsBD,4CAcC;AAnOD,0CAAoH;AAKvG,QAAA,mBAAmB,GAG5B;IACF,WAAW,EAAE,CAAC,IAA8B,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAY;CAC1F,CAAC;AAkEW,QAAA,2BAA2B,mCACnC,2BAAmB,KACtB,UAAU,EAAE,CAAC,IAAgC,EAAE,EAAE,CAC/C,CAAC,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAA2B,CAAC,CAAC,CAAC,IAAI,CAAC,IAC1F;AAEF;;GAEG;AACI,KAAK,UAAU,0BAA0B,CAC9C,QAAgB,EAChB,MAIE,EACF,OAAqC,MAAM;IAE3C,MAAM,QAAQ,GAAG,gCAAgC,CAAC;IAClD,MAAM,KAAK,GAAG,IAAA,0BAAe,4DAC3B,QAAQ,IACL,MAAM,CAAC,YAAY,GACnB,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,GACzC,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,KACxD,I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C1C,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAM7D,OAAO,IAAA,kBAAO,EAAqC,IAAI,EAAE,IAAI,CAAC,CAAC;AACjE,CAAC"}
|
package/esm/api/choropleth.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { type ApiError, type ApiSuccess, Flatten, Revivers } from '../utils.js';
|
|
1
|
+
import { type ApiError, type ApiSuccess, type Flatten, type Revivers } from '../utils.js';
|
|
2
|
+
import type { RequireAtLeastOne } from 'type-fest';
|
|
2
3
|
import type { Polygon } from 'geojson';
|
|
3
|
-
|
|
4
|
+
export declare const boundingBoxRevivers: Revivers<{
|
|
5
|
+
data: {
|
|
6
|
+
bounding_box: string;
|
|
7
|
+
};
|
|
8
|
+
} & Omit<ApiSuccess, 'data'> | ApiError, {
|
|
9
|
+
boundingBox: Polygon;
|
|
10
|
+
}>;
|
|
4
11
|
export type ApiSearchPoint = {
|
|
5
12
|
lat: number;
|
|
6
13
|
lng: number;
|
|
@@ -23,12 +30,42 @@ export type GroupedArea = SingleOrGroupedAreaBase & {
|
|
|
23
30
|
};
|
|
24
31
|
export type SingleArea = SingleOrGroupedAreaBase & {
|
|
25
32
|
isGroup: false;
|
|
33
|
+
properties: Record<string, string>;
|
|
26
34
|
vectorSource: string;
|
|
27
35
|
sourceLayer: string;
|
|
28
36
|
featureId: number;
|
|
29
|
-
properties: Record<string, string>;
|
|
30
37
|
};
|
|
31
|
-
export type SingleOrGroupedArea =
|
|
38
|
+
export type SingleOrGroupedArea = {
|
|
39
|
+
id: number;
|
|
40
|
+
title: string;
|
|
41
|
+
subtitle: string;
|
|
42
|
+
svgPreview: string;
|
|
43
|
+
boundingBox: Polygon;
|
|
44
|
+
isGroup: boolean;
|
|
45
|
+
properties: Record<string, string> | null;
|
|
46
|
+
vectorSource: string | null;
|
|
47
|
+
sourceLayer: string | null;
|
|
48
|
+
featureId: number | null;
|
|
49
|
+
};
|
|
50
|
+
export type ApiSingleOrGroupedArea = {
|
|
51
|
+
data: {
|
|
52
|
+
id: number;
|
|
53
|
+
title: string;
|
|
54
|
+
subtitle: string;
|
|
55
|
+
svg_preview: string;
|
|
56
|
+
bounding_box: string;
|
|
57
|
+
is_group: boolean;
|
|
58
|
+
properties: string | null;
|
|
59
|
+
vector_source: string | null;
|
|
60
|
+
source_layer: string | null;
|
|
61
|
+
feature_id: number | null;
|
|
62
|
+
};
|
|
63
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
64
|
+
export type ApiSingleOrGroupedAreaData = Flatten<Exclude<ApiSingleOrGroupedArea, ApiError>['data']>;
|
|
65
|
+
export declare const singleOrGroupedAreaRevivers: Revivers<ApiSingleOrGroupedArea, SingleOrGroupedArea>;
|
|
66
|
+
/**
|
|
67
|
+
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
68
|
+
*/
|
|
32
69
|
export declare function searchSingleOrGroupedAreas(language: string, search: RequireAtLeastOne<{
|
|
33
70
|
searchBounds?: ApiSearchBounds;
|
|
34
71
|
query?: string;
|
|
@@ -57,5 +94,45 @@ type ApiGroupedAreaChild = {
|
|
|
57
94
|
export type ApiGroupedAreaChildData = Flatten<Exclude<ApiGroupedAreaChild, ApiError>['data']>;
|
|
58
95
|
export declare const groupedAreaChildRevivers: Revivers<ApiGroupedAreaChild, GroupedAreaChild>;
|
|
59
96
|
export declare function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]>;
|
|
97
|
+
export type MatchedGroup = {
|
|
98
|
+
id: number;
|
|
99
|
+
sml: number;
|
|
100
|
+
childrenCount: number;
|
|
101
|
+
matchField: string;
|
|
102
|
+
boundingBox: Polygon;
|
|
103
|
+
property: string;
|
|
104
|
+
name: string;
|
|
105
|
+
};
|
|
106
|
+
export type ApiMatchedGroup = {
|
|
107
|
+
data: {
|
|
108
|
+
id: number;
|
|
109
|
+
sml: number;
|
|
110
|
+
children_count: number;
|
|
111
|
+
match_field: string;
|
|
112
|
+
bounding_box: string;
|
|
113
|
+
property: string;
|
|
114
|
+
name: string;
|
|
115
|
+
};
|
|
116
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
117
|
+
export type ApiMatchedGroupData = Flatten<Exclude<ApiMatchedGroup, ApiError>['data']>;
|
|
118
|
+
export declare function getGroupsByDataSample(sample: Record<string, string[]>, language: string, rowCount: number): Promise<MatchedGroup[]>;
|
|
119
|
+
export type BoundPolygon = {
|
|
120
|
+
index: number;
|
|
121
|
+
inputName: string;
|
|
122
|
+
id: number;
|
|
123
|
+
sml: number;
|
|
124
|
+
name: string;
|
|
125
|
+
};
|
|
126
|
+
export type ApiBoundPolygon = {
|
|
127
|
+
data: {
|
|
128
|
+
index: number;
|
|
129
|
+
input_name: string;
|
|
130
|
+
id: number;
|
|
131
|
+
sml: number;
|
|
132
|
+
name: string;
|
|
133
|
+
};
|
|
134
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
135
|
+
export type ApiBoundPolygonData = Flatten<Exclude<ApiBoundPolygon, ApiError>['data']>;
|
|
136
|
+
export declare function getBoundPolygons(groupId: number, property: string, data: string[], language: string): Promise<BoundPolygon[]>;
|
|
60
137
|
export {};
|
|
61
138
|
//# sourceMappingURL=choropleth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choropleth.d.ts","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,OAAO,EAAE,QAAQ,EAA4B,MAAM,aAAa,CAAC;
|
|
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,KAA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AE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EAAE,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,EAAE,CAAC,CASzB"}
|
package/esm/api/choropleth.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { getSearchParams, request } from '../utils.js';
|
|
2
|
-
export
|
|
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;
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
export const groupedAreaChildRevivers = {
|
|
2
|
+
export const boundingBoxRevivers = {
|
|
17
3
|
boundingBox: (data) => JSON.parse(data.bounding_box),
|
|
18
|
-
properties: (data) => JSON.parse(data.properties),
|
|
19
4
|
};
|
|
5
|
+
export const singleOrGroupedAreaRevivers = Object.assign(Object.assign({}, boundingBoxRevivers), { properties: (data) => (data.properties != null ? JSON.parse(data.properties) : null) });
|
|
6
|
+
/**
|
|
7
|
+
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
8
|
+
*/
|
|
9
|
+
export async function searchSingleOrGroupedAreas(language, search, mode = 'both') {
|
|
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
|
+
}
|
|
16
|
+
export const groupedAreaChildRevivers = Object.assign(Object.assign({}, boundingBoxRevivers), { properties: (data) => JSON.parse(data.properties) });
|
|
20
17
|
export async function groupedAreaChildren(groupId, language) {
|
|
21
18
|
const pathname = `/v1/choropleth/groups/${groupId}/children-optimized`;
|
|
22
19
|
const query = getSearchParams({ language });
|
|
@@ -24,4 +21,14 @@ export async function groupedAreaChildren(groupId, language) {
|
|
|
24
21
|
const options = { revivers: groupedAreaChildRevivers };
|
|
25
22
|
return request(path, null, null, options);
|
|
26
23
|
}
|
|
24
|
+
export async function getGroupsByDataSample(sample, language, rowCount) {
|
|
25
|
+
const path = `/v1/choropleth/groups/sample`;
|
|
26
|
+
const options = { revivers: boundingBoxRevivers };
|
|
27
|
+
return request(path, { sample, language, row_count: rowCount }, null, options);
|
|
28
|
+
}
|
|
29
|
+
export async function getBoundPolygons(groupId, property, data, language) {
|
|
30
|
+
const path = `/v1/choropleth/groups/bind`;
|
|
31
|
+
const body = { group_id: groupId, property, data, language };
|
|
32
|
+
return request(path, body);
|
|
33
|
+
}
|
|
27
34
|
//# 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;AAKpH,MAAM,CAAC,MAAM,mBAAmB,GAG5B;IACF,WAAW,EAAE,CAAC,IAA8B,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAY;CAC1F,CAAC;AAkEF,MAAM,CAAC,MAAM,2BAA2B,mCACnC,m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,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,wBAAwB,EAAE,CAAC;IAMvD,OAAO,OAAO,CAAgD,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC3F,CAAC;AA0BD,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAgC,EAChC,QAAgB,EAChB,QAAgB;IAEhB,MAAM,IAAI,GAAG,8BAA8B,CAAC;IAC5C,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAMlD,OAAO,OAAO,CAAqC,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACrH,CAAC;AAsBD,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;IAM7D,OAAO,OAAO,CAAqC,IAAI,EAAE,IAAI,CAAC,CAAC;AACjE,CAAC"}
|
package/package.json
CHANGED
package/src/api/choropleth.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { type ApiError, type ApiSuccess, Flatten, Revivers, getSearchParams, request } from '../utils.js';
|
|
1
|
+
import { type ApiError, type ApiSuccess, type Flatten, type Revivers, getSearchParams, request } from '../utils.js';
|
|
2
|
+
|
|
3
|
+
import type { RequireAtLeastOne } from 'type-fest';
|
|
2
4
|
import type { Polygon } from 'geojson';
|
|
3
|
-
|
|
5
|
+
|
|
6
|
+
export const boundingBoxRevivers: Revivers<
|
|
7
|
+
{ data: { bounding_box: string } } & Omit<ApiSuccess, 'data'> | ApiError,
|
|
8
|
+
{ boundingBox: Polygon }
|
|
9
|
+
> = {
|
|
10
|
+
boundingBox: (data: { bounding_box: string }) => JSON.parse(data.bounding_box) as Polygon,
|
|
11
|
+
};
|
|
4
12
|
|
|
5
13
|
export type ApiSearchPoint = {
|
|
6
14
|
lat: number;
|
|
@@ -14,23 +22,6 @@ export type ApiSearchBounds = {
|
|
|
14
22
|
max_lng: number;
|
|
15
23
|
};
|
|
16
24
|
|
|
17
|
-
type ApiSingleOrGroupedArea = {
|
|
18
|
-
id: number;
|
|
19
|
-
title: string;
|
|
20
|
-
subtitle: string;
|
|
21
|
-
svg_preview: string;
|
|
22
|
-
bounding_box: string;
|
|
23
|
-
is_group: boolean;
|
|
24
|
-
vector_source: string | null;
|
|
25
|
-
source_layer: string | null;
|
|
26
|
-
feature_id: number | null;
|
|
27
|
-
properties: Record<string, string> | null;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
type ApiSingleOrGroupedAreaArray = {
|
|
31
|
-
data: ApiSingleOrGroupedArea[];
|
|
32
|
-
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
33
|
-
|
|
34
25
|
type SingleOrGroupedAreaBase = {
|
|
35
26
|
id: number;
|
|
36
27
|
title: string;
|
|
@@ -47,14 +38,51 @@ export type GroupedArea = SingleOrGroupedAreaBase & {
|
|
|
47
38
|
// TODO don't export this once search on click is out
|
|
48
39
|
export type SingleArea = SingleOrGroupedAreaBase & {
|
|
49
40
|
isGroup: false;
|
|
41
|
+
properties: Record<string, string>;
|
|
50
42
|
vectorSource: string;
|
|
51
43
|
sourceLayer: string;
|
|
52
44
|
featureId: number;
|
|
53
|
-
properties: Record<string, string>;
|
|
54
45
|
};
|
|
55
46
|
|
|
56
|
-
export type SingleOrGroupedArea =
|
|
47
|
+
export type SingleOrGroupedArea = {
|
|
48
|
+
id: number;
|
|
49
|
+
title: string;
|
|
50
|
+
subtitle: string;
|
|
51
|
+
svgPreview: string;
|
|
52
|
+
boundingBox: Polygon;
|
|
53
|
+
isGroup: boolean;
|
|
54
|
+
properties: Record<string, string> | null;
|
|
55
|
+
vectorSource: string | null;
|
|
56
|
+
sourceLayer: string | null;
|
|
57
|
+
featureId: number | null;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type ApiSingleOrGroupedArea = {
|
|
61
|
+
data: {
|
|
62
|
+
id: number;
|
|
63
|
+
title: string;
|
|
64
|
+
subtitle: string;
|
|
65
|
+
svg_preview: string;
|
|
66
|
+
bounding_box: string;
|
|
67
|
+
is_group: boolean;
|
|
68
|
+
properties: string | null;
|
|
69
|
+
vector_source: string | null;
|
|
70
|
+
source_layer: string | null;
|
|
71
|
+
feature_id: number | null;
|
|
72
|
+
};
|
|
73
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
74
|
+
|
|
75
|
+
export type ApiSingleOrGroupedAreaData = Flatten<Exclude<ApiSingleOrGroupedArea, ApiError>['data']>;
|
|
76
|
+
|
|
77
|
+
export const singleOrGroupedAreaRevivers: Revivers<ApiSingleOrGroupedArea, SingleOrGroupedArea> = {
|
|
78
|
+
...boundingBoxRevivers,
|
|
79
|
+
properties: (data: ApiSingleOrGroupedAreaData) =>
|
|
80
|
+
(data.properties != null ? JSON.parse(data.properties) as Record<string, string> : null),
|
|
81
|
+
};
|
|
57
82
|
|
|
83
|
+
/**
|
|
84
|
+
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
85
|
+
*/
|
|
58
86
|
export async function searchSingleOrGroupedAreas(
|
|
59
87
|
language: string,
|
|
60
88
|
search: RequireAtLeastOne<{
|
|
@@ -64,29 +92,22 @@ export async function searchSingleOrGroupedAreas(
|
|
|
64
92
|
}>,
|
|
65
93
|
mode: 'polygon' | 'group' | 'both' = 'both',
|
|
66
94
|
): Promise<SingleOrGroupedArea[]> {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
...(search.query && { query: search.query }),
|
|
75
|
-
...(search.searchPoint && { point: search.searchPoint }),
|
|
76
|
-
mode,
|
|
77
|
-
})}`,
|
|
78
|
-
).then(result => {
|
|
79
|
-
result.forEach(
|
|
80
|
-
elem => {
|
|
81
|
-
elem.boundingBox = JSON.parse(elem.boundingBox as unknown as string) as Polygon;
|
|
82
|
-
if (!elem.isGroup) {
|
|
83
|
-
elem.properties = JSON.parse(elem.properties as unknown as string) as Record<string, string>;
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
return result;
|
|
95
|
+
const pathname = '/v1/choropleth/polygons/search';
|
|
96
|
+
const query = getSearchParams({
|
|
97
|
+
language,
|
|
98
|
+
...search.searchBounds,
|
|
99
|
+
...(search.query && { query: search.query }),
|
|
100
|
+
...(search.searchPoint && { point: search.searchPoint }),
|
|
101
|
+
mode,
|
|
89
102
|
});
|
|
103
|
+
const path = `${pathname}?${query}`;
|
|
104
|
+
const options = { revivers: singleOrGroupedAreaRevivers };
|
|
105
|
+
|
|
106
|
+
type ApiSingleOrGroupedAreaArray = {
|
|
107
|
+
data: ApiSingleOrGroupedAreaData[];
|
|
108
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
109
|
+
|
|
110
|
+
return request<ApiSingleOrGroupedAreaArray, SingleOrGroupedArea>(path, null, null, options);
|
|
90
111
|
}
|
|
91
112
|
|
|
92
113
|
export type GroupedAreaChild = {
|
|
@@ -114,7 +135,7 @@ type ApiGroupedAreaChild = {
|
|
|
114
135
|
export type ApiGroupedAreaChildData = Flatten<Exclude<ApiGroupedAreaChild, ApiError>['data']>;
|
|
115
136
|
|
|
116
137
|
export const groupedAreaChildRevivers: Revivers<ApiGroupedAreaChild, GroupedAreaChild> = {
|
|
117
|
-
|
|
138
|
+
...boundingBoxRevivers,
|
|
118
139
|
properties: (data: ApiGroupedAreaChildData) => JSON.parse(data.properties) as Record<string, string>,
|
|
119
140
|
};
|
|
120
141
|
|
|
@@ -130,3 +151,78 @@ export async function groupedAreaChildren(groupId: number, language: string): Pr
|
|
|
130
151
|
|
|
131
152
|
return request<ApiApiGroupedAreaChildArray, GroupedAreaChild>(path, null, null, options);
|
|
132
153
|
}
|
|
154
|
+
|
|
155
|
+
export type MatchedGroup = {
|
|
156
|
+
id: number;
|
|
157
|
+
sml: number;
|
|
158
|
+
childrenCount: number;
|
|
159
|
+
matchField: string;
|
|
160
|
+
boundingBox: Polygon;
|
|
161
|
+
property: string;
|
|
162
|
+
name: string;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export type ApiMatchedGroup = {
|
|
166
|
+
data: {
|
|
167
|
+
id: number;
|
|
168
|
+
sml: number;
|
|
169
|
+
children_count: number;
|
|
170
|
+
match_field: string;
|
|
171
|
+
bounding_box: string;
|
|
172
|
+
property: string;
|
|
173
|
+
name: string;
|
|
174
|
+
};
|
|
175
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
176
|
+
|
|
177
|
+
export type ApiMatchedGroupData = Flatten<Exclude<ApiMatchedGroup, ApiError>['data']>;
|
|
178
|
+
|
|
179
|
+
export async function getGroupsByDataSample(
|
|
180
|
+
sample: Record<string, string[]>,
|
|
181
|
+
language: string,
|
|
182
|
+
rowCount: number,
|
|
183
|
+
): Promise<MatchedGroup[]> {
|
|
184
|
+
const path = `/v1/choropleth/groups/sample`;
|
|
185
|
+
const options = { revivers: boundingBoxRevivers };
|
|
186
|
+
|
|
187
|
+
type ApiMatchedGroupArray = {
|
|
188
|
+
data: ApiMatchedGroupData[];
|
|
189
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
190
|
+
|
|
191
|
+
return request<ApiMatchedGroupArray, MatchedGroup>(path, { sample, language, row_count: rowCount }, null, options);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export type BoundPolygon = {
|
|
195
|
+
index: number;
|
|
196
|
+
inputName: string;
|
|
197
|
+
id: number;
|
|
198
|
+
sml: number;
|
|
199
|
+
name: string;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export type ApiBoundPolygon = {
|
|
203
|
+
data: {
|
|
204
|
+
index: number;
|
|
205
|
+
input_name: string;
|
|
206
|
+
id: number;
|
|
207
|
+
sml: number;
|
|
208
|
+
name: string;
|
|
209
|
+
};
|
|
210
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
211
|
+
|
|
212
|
+
export type ApiBoundPolygonData = Flatten<Exclude<ApiBoundPolygon, ApiError>['data']>;
|
|
213
|
+
|
|
214
|
+
export async function getBoundPolygons(
|
|
215
|
+
groupId: number,
|
|
216
|
+
property: string,
|
|
217
|
+
data: string[],
|
|
218
|
+
language: string,
|
|
219
|
+
): Promise<BoundPolygon[]> {
|
|
220
|
+
const path = `/v1/choropleth/groups/bind`;
|
|
221
|
+
const body = { group_id: groupId, property, data, language };
|
|
222
|
+
|
|
223
|
+
type ApiBoundPolygonArray = {
|
|
224
|
+
data: ApiBoundPolygonData[];
|
|
225
|
+
} & Omit<ApiSuccess, 'data'> | ApiError;
|
|
226
|
+
|
|
227
|
+
return request<ApiBoundPolygonArray, BoundPolygon>(path, body);
|
|
228
|
+
}
|