@mapcreator/api 5.0.0-alpha.72 → 5.0.0-alpha.73
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/LICENSE +29 -29
- package/README.md +86 -86
- package/cjs/api/choropleth.d.ts +31 -227
- package/cjs/api/choropleth.d.ts.map +1 -1
- package/cjs/api/choropleth.js +21 -72
- package/cjs/api/choropleth.js.map +1 -1
- package/esm/api/choropleth.d.ts +31 -227
- package/esm/api/choropleth.d.ts.map +1 -1
- package/esm/api/choropleth.js +20 -66
- package/esm/api/choropleth.js.map +1 -1
- package/package.json +80 -80
- package/src/README.md +126 -126
- package/src/api/choropleth.ts +92 -388
package/LICENSE
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
BSD 3-Clause License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024, Mapcreator
|
|
4
|
-
All rights reserved.
|
|
5
|
-
|
|
6
|
-
Redistribution and use in source and binary forms, with or without
|
|
7
|
-
modification, are permitted provided that the following conditions are met:
|
|
8
|
-
|
|
9
|
-
* Redistributions of source code must retain the above copyright notice, this
|
|
10
|
-
list of conditions and the following disclaimer.
|
|
11
|
-
|
|
12
|
-
* Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
-
this list of conditions and the following disclaimer in the documentation
|
|
14
|
-
and/or other materials provided with the distribution.
|
|
15
|
-
|
|
16
|
-
* Neither the name of the copyright holder nor the names of its
|
|
17
|
-
contributors may be used to endorse or promote products derived from
|
|
18
|
-
this software without specific prior written permission.
|
|
19
|
-
|
|
20
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Mapcreator
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
* Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
# Mapcreator Javascript API
|
|
2
|
-
|
|
3
|
-
The Mapcreator API is a powerful mapping service built for our front-end applications. This library is released to
|
|
4
|
-
provide a painless way of talking to the api using Javascript. See the LICENSE file for licensing information. Api
|
|
5
|
-
tokens can be granted through support requests.
|
|
6
|
-
|
|
7
|
-
## Table of contents
|
|
8
|
-
|
|
9
|
-
* [Installation](#installation)
|
|
10
|
-
* [Quick start](#quick-start)
|
|
11
|
-
* [Common usage](#common-usage)
|
|
12
|
-
* [Publishing](#publishing)
|
|
13
|
-
|
|
14
|
-
### Installation
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install @mapcreator/api --save
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### Quick start
|
|
21
|
-
|
|
22
|
-
```javascript
|
|
23
|
-
import { authenticate, initImplicitFlow } from '@mapcreator/api/oauth';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* You need to initialize the authentication module.
|
|
27
|
-
* This is an important step that should be completed as soon as possible after general application init.
|
|
28
|
-
*
|
|
29
|
-
* @param {string} apiUrl - Full API URL, like 'https://api.mapcreator.io'
|
|
30
|
-
* @param {string} clientId - OAuth client id, issued for particular application
|
|
31
|
-
* @param {string} [redirectUrl] - Callback URL, typically your application URL
|
|
32
|
-
* @param {string[]} [scopes] - A list of required scopes, like ['mapcreator']
|
|
33
|
-
*/
|
|
34
|
-
initImplicitFlow(
|
|
35
|
-
import.meta.env.VITE_API_HOST,
|
|
36
|
-
import.meta.env.VITE_API_CLIENT_ID,
|
|
37
|
-
import.meta.env.VITE_API_REDIRECT_URL,
|
|
38
|
-
['mapcreator'],
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
// ...
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The subsequent command should lead to two scenarios.
|
|
45
|
-
* If the initialization function was able to obtain the token from the local storage or from the address bar,
|
|
46
|
-
* then this command is NO-OP. If the token is not found or has expired, then a redirect will be made to the
|
|
47
|
-
* authentication page (the application will unload), but when it redirects back again (see the parameter above),
|
|
48
|
-
* this method won't do anything and the application will be able to continue its work.
|
|
49
|
-
*/
|
|
50
|
-
authenticate();
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### Common usage
|
|
54
|
-
|
|
55
|
-
The library exports independent methods for accessing the API. The recommended pattern for importing and using methods
|
|
56
|
-
looks like this:
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
import { updateJob } from '@mapcreator/api/job';
|
|
60
|
-
|
|
61
|
-
await updateJob(someJobId, newJobTitle);
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
You can also import methods by specifying only the package name, but this results in the use of a common file with
|
|
65
|
-
re-exports and can negatively affect the size of the resulting code if you do not need some parts of the API.
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
import { type LayerFaq, listLayerFaqs } from '@mapcreator/api';
|
|
69
|
-
|
|
70
|
-
const layerFaqs: LayerFaq = await listLayerFaqs();
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
TypeScript types are also exposed, and you can use them whenever needed.
|
|
74
|
-
|
|
75
|
-
Please consult the contents of the library. All API access files (they are located in `api` sub-folder and each file
|
|
76
|
-
generally describes methods for accessing specific entity) describe both the API type and the data type returned
|
|
77
|
-
to the application. We sincerely hope this helps you make your app development easier.
|
|
78
|
-
|
|
79
|
-
## Publishing
|
|
80
|
-
```shell
|
|
81
|
-
npm version patch # minor | major
|
|
82
|
-
npm publish
|
|
83
|
-
```
|
|
84
|
-
Until the contents of the package are stabilized, it is suggested to use the scheme with the **alpha** or **beta**
|
|
85
|
-
suffixes. And therefore the call to the first command should be replaced by manual modification of the `package.json`
|
|
86
|
-
and `package-lock.json` files (will need to change in three places).
|
|
1
|
+
# Mapcreator Javascript API
|
|
2
|
+
|
|
3
|
+
The Mapcreator API is a powerful mapping service built for our front-end applications. This library is released to
|
|
4
|
+
provide a painless way of talking to the api using Javascript. See the LICENSE file for licensing information. Api
|
|
5
|
+
tokens can be granted through support requests.
|
|
6
|
+
|
|
7
|
+
## Table of contents
|
|
8
|
+
|
|
9
|
+
* [Installation](#installation)
|
|
10
|
+
* [Quick start](#quick-start)
|
|
11
|
+
* [Common usage](#common-usage)
|
|
12
|
+
* [Publishing](#publishing)
|
|
13
|
+
|
|
14
|
+
### Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @mapcreator/api --save
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Quick start
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
import { authenticate, initImplicitFlow } from '@mapcreator/api/oauth';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* You need to initialize the authentication module.
|
|
27
|
+
* This is an important step that should be completed as soon as possible after general application init.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} apiUrl - Full API URL, like 'https://api.mapcreator.io'
|
|
30
|
+
* @param {string} clientId - OAuth client id, issued for particular application
|
|
31
|
+
* @param {string} [redirectUrl] - Callback URL, typically your application URL
|
|
32
|
+
* @param {string[]} [scopes] - A list of required scopes, like ['mapcreator']
|
|
33
|
+
*/
|
|
34
|
+
initImplicitFlow(
|
|
35
|
+
import.meta.env.VITE_API_HOST,
|
|
36
|
+
import.meta.env.VITE_API_CLIENT_ID,
|
|
37
|
+
import.meta.env.VITE_API_REDIRECT_URL,
|
|
38
|
+
['mapcreator'],
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// ...
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The subsequent command should lead to two scenarios.
|
|
45
|
+
* If the initialization function was able to obtain the token from the local storage or from the address bar,
|
|
46
|
+
* then this command is NO-OP. If the token is not found or has expired, then a redirect will be made to the
|
|
47
|
+
* authentication page (the application will unload), but when it redirects back again (see the parameter above),
|
|
48
|
+
* this method won't do anything and the application will be able to continue its work.
|
|
49
|
+
*/
|
|
50
|
+
authenticate();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Common usage
|
|
54
|
+
|
|
55
|
+
The library exports independent methods for accessing the API. The recommended pattern for importing and using methods
|
|
56
|
+
looks like this:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { updateJob } from '@mapcreator/api/job';
|
|
60
|
+
|
|
61
|
+
await updateJob(someJobId, newJobTitle);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
You can also import methods by specifying only the package name, but this results in the use of a common file with
|
|
65
|
+
re-exports and can negatively affect the size of the resulting code if you do not need some parts of the API.
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { type LayerFaq, listLayerFaqs } from '@mapcreator/api';
|
|
69
|
+
|
|
70
|
+
const layerFaqs: LayerFaq = await listLayerFaqs();
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
TypeScript types are also exposed, and you can use them whenever needed.
|
|
74
|
+
|
|
75
|
+
Please consult the contents of the library. All API access files (they are located in `api` sub-folder and each file
|
|
76
|
+
generally describes methods for accessing specific entity) describe both the API type and the data type returned
|
|
77
|
+
to the application. We sincerely hope this helps you make your app development easier.
|
|
78
|
+
|
|
79
|
+
## Publishing
|
|
80
|
+
```shell
|
|
81
|
+
npm version patch # minor | major
|
|
82
|
+
npm publish
|
|
83
|
+
```
|
|
84
|
+
Until the contents of the package are stabilized, it is suggested to use the scheme with the **alpha** or **beta**
|
|
85
|
+
suffixes. And therefore the call to the first command should be replaced by manual modification of the `package.json`
|
|
86
|
+
and `package-lock.json` files (will need to change in three places).
|
package/cjs/api/choropleth.d.ts
CHANGED
|
@@ -1,242 +1,46 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
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 { Polygon } from 'geojson';
|
|
2
|
+
import { RequireAtLeastOne } from 'type-fest';
|
|
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;
|
|
48
|
-
id: number;
|
|
49
|
-
vectorSource: string;
|
|
50
|
-
sourceLayer: string;
|
|
51
|
-
featureId: number;
|
|
52
|
-
svgPreview: string;
|
|
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[];
|
|
74
|
-
};
|
|
75
|
-
export type ApiPolygonChoropleth = {
|
|
76
|
-
data: {
|
|
77
|
-
sml: string;
|
|
78
|
-
id: number;
|
|
79
|
-
vector_source: string;
|
|
80
|
-
source_layer: string;
|
|
81
|
-
feature_id: number;
|
|
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 = {
|
|
13
|
+
type SingleOrGroupedAreaBase = {
|
|
109
14
|
id: number;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
childrenCount: number;
|
|
113
|
-
sml?: string;
|
|
15
|
+
title: string;
|
|
16
|
+
subtitle: string;
|
|
114
17
|
svgPreview: string;
|
|
115
|
-
previewPath: string;
|
|
116
|
-
uniqueProperties: string[];
|
|
117
18
|
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
|
-
}>;
|
|
155
19
|
};
|
|
156
|
-
export type
|
|
157
|
-
|
|
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[]>;
|
|
209
|
-
export type MatchedGroup = {
|
|
210
|
-
id: number;
|
|
211
|
-
sml: number;
|
|
212
|
-
childrenCount: number;
|
|
213
|
-
matchField: string;
|
|
214
|
-
property: string;
|
|
215
|
-
name: string;
|
|
20
|
+
export type GroupedArea = SingleOrGroupedAreaBase & {
|
|
21
|
+
isGroup: true;
|
|
216
22
|
};
|
|
217
|
-
export type
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
export declare function
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
inputName: string;
|
|
232
|
-
};
|
|
233
|
-
export type ApiBoundPolygon = {
|
|
234
|
-
index: number;
|
|
23
|
+
export type SingleArea = SingleOrGroupedAreaBase & {
|
|
24
|
+
isGroup: false;
|
|
25
|
+
vectorSource: string;
|
|
26
|
+
sourceLayer: string;
|
|
27
|
+
featureId: number;
|
|
28
|
+
properties: Record<string, string>;
|
|
29
|
+
};
|
|
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 = {
|
|
235
37
|
id: number;
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
38
|
+
title: string;
|
|
39
|
+
vectorSource: string;
|
|
40
|
+
sourceLayer: string;
|
|
41
|
+
featureId: number;
|
|
42
|
+
properties: Record<string, string>;
|
|
239
43
|
};
|
|
240
|
-
export declare function
|
|
44
|
+
export declare function groupedAreaChildren(groupId: number, language: string): Promise<GroupedAreaChild[]>;
|
|
241
45
|
export {};
|
|
242
46
|
//# sourceMappingURL=choropleth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choropleth.d.ts","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"choropleth.d.ts","sourceRoot":"","sources":["../../src/api/choropleth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,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;AAGF,MAAM,MAAM,UAAU,GAAG,uBAAuB,GAAG;IACjD,OAAO,EAAE,KAAK,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,WAAW,CAAC;AAE3D,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,iBAAiB,CAAC;IACxB,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B,CAAC,EACF,IAAI,GAAE,SAAS,GAAG,OAAO,GAAG,MAAe,GAC1C,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAwBhC;AAeD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAYxG"}
|
package/cjs/api/choropleth.js
CHANGED
|
@@ -1,79 +1,28 @@
|
|
|
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;
|
|
8
|
-
exports.getGroupsByDataSample = getGroupsByDataSample;
|
|
9
|
-
exports.getBoundPolygons = getBoundPolygons;
|
|
3
|
+
exports.searchSingleOrGroupedAreas = searchSingleOrGroupedAreas;
|
|
4
|
+
exports.groupedAreaChildren = groupedAreaChildren;
|
|
10
5
|
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;
|
|
6
|
+
async function searchSingleOrGroupedAreas(language, search, mode = 'both') {
|
|
7
|
+
/**
|
|
8
|
+
* TODO When SAGA search on click is implemented, remove mode and make searchBounds required
|
|
9
|
+
*/
|
|
10
|
+
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 => {
|
|
11
|
+
result.forEach(elem => {
|
|
12
|
+
elem.boundingBox = JSON.parse(elem.boundingBox);
|
|
13
|
+
if (!elem.isGroup) {
|
|
14
|
+
elem.properties = JSON.parse(elem.properties);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return result;
|
|
26
18
|
});
|
|
27
19
|
}
|
|
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));
|
|
69
|
-
}
|
|
70
|
-
async function getGroupsByDataSample(sample, language) {
|
|
71
|
-
const path = `/v1/choropleth/groups/sample`;
|
|
72
|
-
return (0, utils_js_1.request)(path, { sample, language });
|
|
73
|
-
}
|
|
74
|
-
async function getBoundPolygons(groupId, property, data, language) {
|
|
75
|
-
const path = `/v1/choropleth/groups/bind`;
|
|
76
|
-
const postBody = { group_id: groupId, property, data, language };
|
|
77
|
-
return (0, utils_js_1.request)(path, postBody);
|
|
20
|
+
async function groupedAreaChildren(groupId, language) {
|
|
21
|
+
return (0, utils_js_1.request)(`/v1/choropleth/groups/${groupId}/children-optimized?${(0, utils_js_1.getSearchParams)({ language })}`).then(result => {
|
|
22
|
+
result.forEach(elem => {
|
|
23
|
+
elem.properties = JSON.parse(elem.properties);
|
|
24
|
+
});
|
|
25
|
+
return result;
|
|
26
|
+
});
|
|
78
27
|
}
|
|
79
28
|
//# 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":";;AAyDA,gEAgCC;AAwBD,kDAYC;AA7HD,0CAAuF;AAyDhF,KAAK,UAAU,0BAA0B,CAC9C,QAAgB,EAChB,MAIE,EACF,OAAqC,MAAM;IAE3C;;OAEG;IACH,OAAO,IAAA,kBAAO,EACZ,kCAAkC,IAAA,0BAAe,4DAC/C,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,IAAI,IACJ,EAAE,CACL,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACd,MAAM,CAAC,OAAO,CACZ,IAAI,CAAC,EAAE;YACL,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAgC,CAAY,CAAC;YAChF,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAA+B,CAA2B,CAAC;YAC/F,CAAC;QACH,CAAC,CACF,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC;AAwBM,KAAK,UAAU,mBAAmB,CAAC,OAAe,EAAE,QAAgB;IACzE,OAAO,IAAA,kBAAO,EACZ,yBAAyB,OAAO,uBAAuB,IAAA,0BAAe,EAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CACvF,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACd,MAAM,CAAC,OAAO,CACZ,IAAI,CAAC,EAAE;YACL,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAA+B,CAA2B,CAAC;QAC/F,CAAC,CACF,CAAC;QAEF,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC"}
|