arlas-web-core 19.3.0-dev0 → 20.0.0-beta.4
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/index.d.ts +6 -0
- package/{src/index.ts → index.js} +4 -7
- package/index.js.map +1 -0
- package/models/collaboration.d.ts +29 -0
- package/{src/models/collaboration.ts → models/collaboration.js} +6 -30
- package/models/collaboration.js.map +1 -0
- package/models/contributor.d.ts +57 -0
- package/models/contributor.js +116 -0
- package/models/contributor.js.map +1 -0
- package/models/projections.d.ts +35 -0
- package/models/projections.js +38 -0
- package/models/projections.js.map +1 -0
- package/package.json +3 -9
- package/patches/url+0.11.0.patch +12 -0
- package/services/collaborativesearch.service.d.ts +353 -0
- package/{src/services/collaborativesearch.service.ts → services/collaborativesearch.service.js} +178 -366
- package/services/collaborativesearch.service.js.map +1 -0
- package/services/config.service.d.ts +31 -0
- package/{src/services/config.service.ts → services/config.service.js} +11 -15
- package/services/config.service.js.map +1 -0
- package/utils/utils.d.ts +22 -0
- package/utils/utils.js +63 -0
- package/utils/utils.js.map +1 -0
- package/.editorconfig +0 -13
- package/.gitlab-ci.yml +0 -19
- package/.travis.yml +0 -27
- package/CHANGELOG.md +0 -446
- package/CONTRIBUTING.md +0 -48
- package/LICENSE.txt +0 -201
- package/NOTICE.txt +0 -10
- package/README-NPM.md +0 -78
- package/README.md +0 -78
- package/arlas-web-core-19.3.0-dev0.tgz +0 -0
- package/build.sh +0 -9
- package/jsconfig.json +0 -13
- package/mkDocs.sh +0 -18
- package/package-release.json +0 -25
- package/release.sh +0 -429
- package/src/models/contributor.ts +0 -161
- package/src/models/projections.ts +0 -58
- package/src/utils/utils.ts +0 -80
- package/tsconfig-build.json +0 -21
- package/tsconfig.json +0 -15
- package/tslint.json +0 -116
package/{src/services/collaborativesearch.service.ts → services/collaborativesearch.service.js}
RENAMED
|
@@ -1,101 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
* Licensed to Gisaïa under one or more contributor
|
|
3
|
-
* license agreements. See the NOTICE.txt file distributed with
|
|
4
|
-
* this work for additional information regarding copyright
|
|
5
|
-
* ownership. Gisaïa licenses this file to you under
|
|
6
|
-
* the Apache License, Version 2.0 (the "License"); you may
|
|
7
|
-
* not use this file except in compliance with the License.
|
|
8
|
-
* You may obtain a copy of the License at
|
|
9
|
-
*
|
|
10
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing,
|
|
13
|
-
* software distributed under the License is distributed on an
|
|
14
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
* KIND, either express or implied. See the License for the
|
|
16
|
-
* specific language governing permissions and limitations
|
|
17
|
-
* under the License.
|
|
18
|
-
*/
|
|
19
|
-
import {
|
|
20
|
-
Aggregation, AggregationResponse, AggregationsRequest,
|
|
21
|
-
CollectionReferenceDescription, Count, ExploreApi, Expression,
|
|
22
|
-
FeatureCollection, Filter, Hits, Search, Metric, Page, Form, ComputationRequest, ComputationResponse
|
|
23
|
-
} from 'arlas-api';
|
|
24
|
-
import { Observable, Subject, from, zip } from 'rxjs';
|
|
1
|
+
import { Subject, from, zip } from 'rxjs';
|
|
25
2
|
import { map } from 'rxjs/operators';
|
|
26
|
-
import { fromEntries
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import { GeohashAggregation, TiledSearch, projType, GeoTileAggregation } from '../models/projections';
|
|
30
|
-
import { ConfigService } from './config.service';
|
|
31
|
-
|
|
3
|
+
import { fromEntries } from '../utils/utils';
|
|
4
|
+
import { OperationEnum } from '../models/collaboration';
|
|
5
|
+
import { projType } from '../models/projections';
|
|
32
6
|
export class CollaborativesearchService {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
*/
|
|
73
|
-
public totalSubscribe = 0;
|
|
74
|
-
/**
|
|
75
|
-
* Bus of Error.
|
|
76
|
-
*/
|
|
77
|
-
public collaborationErrorBus: Subject<Error> = new Subject<Error>();
|
|
78
|
-
/**
|
|
79
|
-
* ARLAS SERVER Explore Api used by the collaborativesearchService.
|
|
80
|
-
*/
|
|
81
|
-
private exploreApi: ExploreApi;
|
|
82
|
-
/**
|
|
83
|
-
* Configuration Service used by the collaborativesearchService.
|
|
84
|
-
*/
|
|
85
|
-
private configService: ConfigService;
|
|
86
|
-
/**
|
|
87
|
-
* Configuration object of fetch call. By default all credentials are included.
|
|
88
|
-
*/
|
|
89
|
-
private fetchOptions: {
|
|
90
|
-
credentials: string,
|
|
91
|
-
signal?: any,
|
|
92
|
-
responseType?: string,
|
|
93
|
-
referrerPolicy?: string
|
|
94
|
-
} = {
|
|
7
|
+
constructor() {
|
|
8
|
+
/**
|
|
9
|
+
* Bus of CollaborationEvent.
|
|
10
|
+
*/
|
|
11
|
+
this.collaborationBus = new Subject();
|
|
12
|
+
/**
|
|
13
|
+
* Bus of CollaborationEvent.
|
|
14
|
+
*/
|
|
15
|
+
this.contribFilterBus = new Subject();
|
|
16
|
+
/**
|
|
17
|
+
* Registry of Collaborations, Map of contributor identifier,Collaboration.
|
|
18
|
+
*/
|
|
19
|
+
this.collaborations = new Map();
|
|
20
|
+
/**
|
|
21
|
+
* Registry of Contributor, Map of contributor identifier,Contributor.
|
|
22
|
+
*/
|
|
23
|
+
this.registry = new Map();
|
|
24
|
+
/** ARLAS SERVER collections that declared in the contributos */
|
|
25
|
+
this.collections = new Set();
|
|
26
|
+
/**
|
|
27
|
+
* ARLAS SERVER max age cache used by the collaborativesearchService.
|
|
28
|
+
*/
|
|
29
|
+
this.max_age = 60;
|
|
30
|
+
/**
|
|
31
|
+
* Bus number of ongoing subscribe to the collaborativesearchService
|
|
32
|
+
*/
|
|
33
|
+
this.ongoingSubscribe = new Subject();
|
|
34
|
+
/**
|
|
35
|
+
* Bus number of ongoing subscribe to the collaborativesearchService
|
|
36
|
+
*/
|
|
37
|
+
this.totalSubscribe = 0;
|
|
38
|
+
/**
|
|
39
|
+
* Bus of Error.
|
|
40
|
+
*/
|
|
41
|
+
this.collaborationErrorBus = new Subject();
|
|
42
|
+
/**
|
|
43
|
+
* Configuration object of fetch call. By default all credentials are included.
|
|
44
|
+
*/
|
|
45
|
+
this.fetchOptions = {
|
|
95
46
|
credentials: 'include',
|
|
96
47
|
referrerPolicy: 'origin'
|
|
97
48
|
};
|
|
98
|
-
constructor() {
|
|
99
49
|
/**
|
|
100
50
|
* Subscribe ongoingSubscribe bus to know how many subscribe are on going.
|
|
101
51
|
*/
|
|
@@ -110,7 +60,8 @@ export class CollaborativesearchService {
|
|
|
110
60
|
if (collaborationEvent.operation === OperationEnum.remove) {
|
|
111
61
|
if (collaborationEvent.all) {
|
|
112
62
|
this.collaborations.clear();
|
|
113
|
-
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
114
65
|
this.collaborations.delete(collaborationEvent.id);
|
|
115
66
|
}
|
|
116
67
|
}
|
|
@@ -120,56 +71,55 @@ export class CollaborativesearchService {
|
|
|
120
71
|
* Return options used to fetch call.
|
|
121
72
|
* @returns Object.
|
|
122
73
|
*/
|
|
123
|
-
|
|
74
|
+
getFetchOptions() {
|
|
124
75
|
return this.fetchOptions;
|
|
125
76
|
}
|
|
126
77
|
/**
|
|
127
78
|
* Set the fetch options.
|
|
128
79
|
* @param fetchOptions : Object.
|
|
129
80
|
*/
|
|
130
|
-
|
|
81
|
+
setFetchOptions(fetchOptions) {
|
|
131
82
|
this.fetchOptions = fetchOptions;
|
|
132
83
|
}
|
|
133
84
|
/**
|
|
134
85
|
* Return the ARLAS Explore API.
|
|
135
86
|
* @returns ExploreApi.
|
|
136
87
|
*/
|
|
137
|
-
|
|
88
|
+
getExploreApi() {
|
|
138
89
|
return this.exploreApi;
|
|
139
90
|
}
|
|
140
91
|
/**
|
|
141
92
|
* Set the ARLAS Explore API.
|
|
142
93
|
* @param api : ExploreApi.
|
|
143
94
|
*/
|
|
144
|
-
|
|
95
|
+
setExploreApi(exploreApi) {
|
|
145
96
|
this.exploreApi = exploreApi;
|
|
146
97
|
}
|
|
147
98
|
/**
|
|
148
99
|
* Return the Configuraion Service.
|
|
149
100
|
* @returns ConfigService.
|
|
150
101
|
*/
|
|
151
|
-
|
|
102
|
+
getConfigService() {
|
|
152
103
|
return this.configService;
|
|
153
104
|
}
|
|
154
105
|
/**
|
|
155
106
|
* Set the Configuraion Service.
|
|
156
107
|
* @param configService ConfigService.
|
|
157
108
|
*/
|
|
158
|
-
|
|
109
|
+
setConfigService(configService) {
|
|
159
110
|
this.configService = configService;
|
|
160
111
|
}
|
|
161
112
|
/**
|
|
162
113
|
* Register contributor with its identifier in the map contributor registry.
|
|
163
114
|
*/
|
|
164
|
-
|
|
115
|
+
register(identifier, contributor) {
|
|
165
116
|
this.registry.set(identifier, contributor);
|
|
166
117
|
this.registerCollections(contributor);
|
|
167
118
|
}
|
|
168
|
-
|
|
169
119
|
/**
|
|
170
120
|
* Register collections of the given contributor in a collections registry.
|
|
171
121
|
*/
|
|
172
|
-
|
|
122
|
+
registerCollections(contributor) {
|
|
173
123
|
if (contributor.collections) {
|
|
174
124
|
contributor.collections.forEach(cf => {
|
|
175
125
|
this.collections.add(cf.collectionName);
|
|
@@ -179,16 +129,15 @@ export class CollaborativesearchService {
|
|
|
179
129
|
this.collections.add(contributor.collection);
|
|
180
130
|
}
|
|
181
131
|
}
|
|
182
|
-
|
|
183
132
|
/**
|
|
184
133
|
* Add Filter setted by a contributor in the registry of collaboration, notify the collaborationBus of a changement.
|
|
185
134
|
* @param contributorId Sting identifier of contributor.
|
|
186
135
|
* @param collaboration Collaboration added by the contributor.
|
|
187
136
|
*/
|
|
188
|
-
|
|
137
|
+
setFilter(contributorId, collaboration) {
|
|
189
138
|
collaboration.enabled = true;
|
|
190
139
|
this.collaborations.set(contributorId, collaboration);
|
|
191
|
-
const collaborationEvent
|
|
140
|
+
const collaborationEvent = {
|
|
192
141
|
id: contributorId,
|
|
193
142
|
operation: OperationEnum.add,
|
|
194
143
|
all: false
|
|
@@ -200,9 +149,9 @@ export class CollaborativesearchService {
|
|
|
200
149
|
* @param contributorId Sting identifier of contributor.
|
|
201
150
|
* @param collaboration Collaboration added by the contributor.
|
|
202
151
|
*/
|
|
203
|
-
|
|
152
|
+
removeFilter(contributorId) {
|
|
204
153
|
this.collaborations.delete(contributorId);
|
|
205
|
-
const collaborationEvent
|
|
154
|
+
const collaborationEvent = {
|
|
206
155
|
id: contributorId,
|
|
207
156
|
operation: OperationEnum.remove,
|
|
208
157
|
all: false
|
|
@@ -212,34 +161,33 @@ export class CollaborativesearchService {
|
|
|
212
161
|
/**
|
|
213
162
|
* Remove all the collaborations filters, notify the collaborationBus of a all removing changement.
|
|
214
163
|
*/
|
|
215
|
-
|
|
164
|
+
removeAll() {
|
|
216
165
|
this.collaborations.clear();
|
|
217
|
-
const collaborationEvent
|
|
166
|
+
const collaborationEvent = {
|
|
218
167
|
id: 'all',
|
|
219
168
|
operation: OperationEnum.remove,
|
|
220
169
|
all: true
|
|
221
170
|
};
|
|
222
171
|
this.collaborationBus.next(collaborationEvent);
|
|
223
172
|
}
|
|
224
|
-
|
|
225
|
-
public dataModelBuilder(filter: string): Object {
|
|
173
|
+
dataModelBuilder(filter) {
|
|
226
174
|
const dataModel = JSON.parse(filter);
|
|
227
175
|
/** transform "filters" object to Map */
|
|
228
176
|
Object.keys(dataModel).forEach(key => {
|
|
229
177
|
const collab = dataModel['' + key];
|
|
230
178
|
if (!!collab && !!collab.filters) {
|
|
231
179
|
collab.filters = new Map(Object.entries(collab.filters));
|
|
232
|
-
}
|
|
180
|
+
}
|
|
181
|
+
else if (!!collab && !collab.filters && !!collab.filter) {
|
|
233
182
|
/** retrocompatibility code to transform an pre-18 collaboration structure to 18 one */
|
|
234
|
-
collab.filters = new Map
|
|
183
|
+
collab.filters = new Map();
|
|
235
184
|
collab.filters.set(this.defaultCollection, [Object.assign({}, collab.filter)]);
|
|
236
185
|
delete collab.filter;
|
|
237
186
|
}
|
|
238
187
|
});
|
|
239
188
|
return dataModel;
|
|
240
189
|
}
|
|
241
|
-
|
|
242
|
-
public urlBuilder(): string {
|
|
190
|
+
urlBuilder() {
|
|
243
191
|
const dataModel = {};
|
|
244
192
|
Array.from(this.collaborations.keys()).forEach(identifier => {
|
|
245
193
|
dataModel[identifier] = Object.assign({}, this.collaborations.get(identifier));
|
|
@@ -248,43 +196,43 @@ export class CollaborativesearchService {
|
|
|
248
196
|
dataModel[identifier].filters = {};
|
|
249
197
|
dataModel[identifier].filters[this.defaultCollection] = [Object.assign({}, dataModel[identifier].filter)];
|
|
250
198
|
delete dataModel[identifier].filter;
|
|
251
|
-
}
|
|
199
|
+
}
|
|
200
|
+
else if (!!dataModel[identifier].filters) {
|
|
252
201
|
dataModel[identifier].filters = fromEntries(dataModel[identifier].filters);
|
|
253
202
|
}
|
|
254
203
|
});
|
|
255
204
|
const url = 'filter=' + JSON.stringify(dataModel);
|
|
256
205
|
return url;
|
|
257
206
|
}
|
|
258
|
-
|
|
259
207
|
/**
|
|
260
208
|
* Initialize all the contributor in the state of dataModel.
|
|
261
209
|
* @param dataModel
|
|
262
210
|
*/
|
|
263
|
-
|
|
211
|
+
setCollaborations(dataModel) {
|
|
264
212
|
this.collaborations.clear();
|
|
265
213
|
Array.from(this.registry.keys()).forEach(identifier => {
|
|
266
214
|
if (dataModel[identifier] !== undefined) {
|
|
267
|
-
const collaboration
|
|
215
|
+
const collaboration = dataModel[identifier];
|
|
268
216
|
this.collaborations.set(identifier, collaboration);
|
|
269
217
|
}
|
|
270
218
|
});
|
|
271
|
-
const collaborationEvent
|
|
219
|
+
const collaborationEvent = {
|
|
272
220
|
id: 'url',
|
|
273
221
|
operation: OperationEnum.add,
|
|
274
222
|
all: true
|
|
275
223
|
};
|
|
276
224
|
this.collaborationBus.next(collaborationEvent);
|
|
277
225
|
}
|
|
278
|
-
|
|
279
226
|
/**
|
|
280
227
|
* Retrieve the collaboration from a contributor identifier.
|
|
281
228
|
* @param contributorId Identifier of a contributor.
|
|
282
229
|
* @returns Collaboration.
|
|
283
230
|
*/
|
|
284
|
-
|
|
231
|
+
getCollaboration(contributorId) {
|
|
285
232
|
if (this.collaborations.get(contributorId)) {
|
|
286
233
|
return this.collaborations.get(contributorId);
|
|
287
|
-
}
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
288
236
|
return null;
|
|
289
237
|
}
|
|
290
238
|
}
|
|
@@ -298,11 +246,7 @@ export class CollaborativesearchService {
|
|
|
298
246
|
* @param max_age Duration of browser cache.
|
|
299
247
|
* @returns ARLAS Server observable.
|
|
300
248
|
*/
|
|
301
|
-
|
|
302
|
-
[projType.search, Search]
|
|
303
|
-
| [projType.count, Count], collaborations: Map<string, Collaboration>, collection,
|
|
304
|
-
contributorId?: string, filter?: Filter, isFlat?: boolean, max_age = this.max_age
|
|
305
|
-
): Observable<Hits> {
|
|
249
|
+
resolveButNotHits(projection, collaborations, collection, contributorId, filter, isFlat, max_age = this.max_age) {
|
|
306
250
|
return this.resolveButNot(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
|
|
307
251
|
}
|
|
308
252
|
/**
|
|
@@ -314,14 +258,9 @@ export class CollaborativesearchService {
|
|
|
314
258
|
* @param max_age Duration of browser cache.
|
|
315
259
|
* @returns ARLAS Server observable.
|
|
316
260
|
*/
|
|
317
|
-
|
|
318
|
-
[projType.search, Search]
|
|
319
|
-
| [projType.count, Count], collaborations: Map<string, Collaboration>, collection,
|
|
320
|
-
contributorId?: string, filter?: Filter, isFlat?: boolean, max_age = this.max_age
|
|
321
|
-
): Observable<Hits> {
|
|
261
|
+
resolveHits(projection, collaborations, collection, contributorId, filter, isFlat, max_age = this.max_age) {
|
|
322
262
|
return this.resolve(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
|
|
323
263
|
}
|
|
324
|
-
|
|
325
264
|
/**
|
|
326
265
|
* Resolve an ARLAS Server Search or Count request for an array of filter.
|
|
327
266
|
* @param projection Type of projection of ARLAS Server request :Search or Count .
|
|
@@ -330,14 +269,9 @@ export class CollaborativesearchService {
|
|
|
330
269
|
* @param max_age Duration of browser cache.
|
|
331
270
|
* @returns ARLAS Server observable.
|
|
332
271
|
*/
|
|
333
|
-
|
|
334
|
-
[projType.search, Search]
|
|
335
|
-
| [projType.count, Count],
|
|
336
|
-
filters: Array<Filter>, collection, isFlat?: boolean, max_age = this.max_age
|
|
337
|
-
): Observable<Hits> {
|
|
272
|
+
resolveComputeHits(projection, filters, collection, isFlat, max_age = this.max_age) {
|
|
338
273
|
return this.computeResolve(projection, filters, collection, isFlat, max_age);
|
|
339
274
|
}
|
|
340
|
-
|
|
341
275
|
/**
|
|
342
276
|
* Resolve an ARLAS Server Geosearch or Geoaggregate request with all the collaborations enabled in the collaboration registry
|
|
343
277
|
except for the contributor given in second optionnal parameter.
|
|
@@ -348,34 +282,13 @@ export class CollaborativesearchService {
|
|
|
348
282
|
* @param max_age Duration of browser cache.
|
|
349
283
|
* @returns ARLAS Server observable.
|
|
350
284
|
*/
|
|
351
|
-
|
|
352
|
-
[projType.geosearch, Search]
|
|
353
|
-
| [projType.tiledgeosearch, TiledSearch]
|
|
354
|
-
| [projType.geohashgeoaggregate, GeohashAggregation]
|
|
355
|
-
| [projType.geotilegeoaggregate, GeoTileAggregation]
|
|
356
|
-
| [projType.geoaggregate, Array<Aggregation>], collaborations: Map<string, Collaboration>, collection, isFlat = true,
|
|
357
|
-
contributorId?: string, filter?: Filter, max_age = this.max_age
|
|
358
|
-
): Observable<FeatureCollection> {
|
|
285
|
+
resolveButNotFeatureCollection(projection, collaborations, collection, isFlat = true, contributorId, filter, max_age = this.max_age) {
|
|
359
286
|
return this.resolveButNot(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
|
|
360
287
|
}
|
|
361
|
-
|
|
362
|
-
public resolveButNotShapefile(projection:
|
|
363
|
-
[projType.shapeaggregate, Array<Aggregation>]
|
|
364
|
-
| [projType.shapesearch, Search], collaborations: Map<string, Collaboration>, collection, isFlat = true,
|
|
365
|
-
contributorId?: string, filter?: Filter, max_age = this.max_age
|
|
366
|
-
): Observable<ArrayBuffer> {
|
|
288
|
+
resolveButNotShapefile(projection, collaborations, collection, isFlat = true, contributorId, filter, max_age = this.max_age) {
|
|
367
289
|
return this.resolveButNot(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
|
|
368
290
|
}
|
|
369
|
-
|
|
370
|
-
public resolveButNotFeatureCollectionWithAbort(projection:
|
|
371
|
-
[projType.geosearch, Search]
|
|
372
|
-
| [projType.tiledgeosearch, TiledSearch]
|
|
373
|
-
| [projType.geohashgeoaggregate, GeohashAggregation]
|
|
374
|
-
| [projType.geotilegeoaggregate, GeoTileAggregation]
|
|
375
|
-
| [projType.geoaggregate, Array<Aggregation>], collaborations: Map<string, Collaboration>,
|
|
376
|
-
collection, isFlat = true, abortableSignal,
|
|
377
|
-
contributorId?: string, filter?: Filter, max_age = this.max_age,
|
|
378
|
-
): Observable<FeatureCollection> {
|
|
291
|
+
resolveButNotFeatureCollectionWithAbort(projection, collaborations, collection, isFlat = true, abortableSignal, contributorId, filter, max_age = this.max_age) {
|
|
379
292
|
const fetchOptions = Object.assign({}, this.fetchOptions);
|
|
380
293
|
fetchOptions.signal = abortableSignal;
|
|
381
294
|
return this.resolveButNot(projection, collaborations, collection, contributorId, filter, isFlat, max_age, fetchOptions);
|
|
@@ -390,14 +303,7 @@ export class CollaborativesearchService {
|
|
|
390
303
|
* @param max_age Duration of browser cache.
|
|
391
304
|
* @returns ARLAS Server observable.
|
|
392
305
|
*/
|
|
393
|
-
|
|
394
|
-
[projType.geosearch, Search]
|
|
395
|
-
| [projType.tiledgeosearch, TiledSearch]
|
|
396
|
-
| [projType.geohashgeoaggregate, GeohashAggregation]
|
|
397
|
-
| [projType.geotilegeoaggregate, GeoTileAggregation]
|
|
398
|
-
| [projType.geoaggregate, Array<Aggregation>], isFlat = true, collaborations: Map<string, Collaboration>, collection,
|
|
399
|
-
contributorId?: string, filter?: Filter, max_age = this.max_age
|
|
400
|
-
): Observable<FeatureCollection> {
|
|
306
|
+
resolveFeatureCollection(projection, isFlat = true, collaborations, collection, contributorId, filter, max_age = this.max_age) {
|
|
401
307
|
return this.resolve(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
|
|
402
308
|
}
|
|
403
309
|
/**
|
|
@@ -410,10 +316,7 @@ export class CollaborativesearchService {
|
|
|
410
316
|
* @param max_age Duration of browser cache.
|
|
411
317
|
* @returns ARLAS Server observable.
|
|
412
318
|
*/
|
|
413
|
-
|
|
414
|
-
[projType.aggregate, Array<Aggregation>], collaborations: Map<string, Collaboration>, collection,
|
|
415
|
-
contributorId?: string, filter?: Filter, isFlat?: boolean, max_age = this.max_age
|
|
416
|
-
): Observable<AggregationResponse> {
|
|
319
|
+
resolveButNotAggregation(projection, collaborations, collection, contributorId, filter, isFlat, max_age = this.max_age) {
|
|
417
320
|
return this.resolveButNot(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
|
|
418
321
|
}
|
|
419
322
|
/**
|
|
@@ -425,10 +328,7 @@ export class CollaborativesearchService {
|
|
|
425
328
|
* @param max_age Duration of browser cache.
|
|
426
329
|
* @returns ARLAS Server observable.
|
|
427
330
|
*/
|
|
428
|
-
|
|
429
|
-
[projType.aggregate, Array<Aggregation>], collaborations: Map<string, Collaboration>, collection,
|
|
430
|
-
contributorId?: string, filter?: Filter, isFlat?: boolean, max_age = this.max_age
|
|
431
|
-
): Observable<AggregationResponse> {
|
|
331
|
+
resolveAggregation(projection, collaborations, collection, contributorId, filter, isFlat, max_age = this.max_age) {
|
|
432
332
|
return this.resolve(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
|
|
433
333
|
}
|
|
434
334
|
/**
|
|
@@ -442,96 +342,81 @@ export class CollaborativesearchService {
|
|
|
442
342
|
* @param max_age Duration of browser cache.
|
|
443
343
|
* @returns ARLAS Server observable.
|
|
444
344
|
*/
|
|
445
|
-
|
|
446
|
-
[projType.compute, ComputationRequest], collaborations: Map<string, Collaboration>, collection,
|
|
447
|
-
contributorId?: string, filter?: Filter, isFlat?: boolean, max_age = this.max_age
|
|
448
|
-
): Observable<ComputationResponse> {
|
|
345
|
+
resolveButNotComputation(projection, collaborations, collection, contributorId, filter, isFlat, max_age = this.max_age) {
|
|
449
346
|
return this.resolveButNot(projection, collaborations, collection, contributorId, filter, isFlat, max_age);
|
|
450
347
|
}
|
|
451
348
|
/**
|
|
452
349
|
* Enable a contributor collaboration from its identifier.
|
|
453
350
|
*/
|
|
454
|
-
|
|
351
|
+
enable(contributorId) {
|
|
455
352
|
this.setEnable(true, contributorId);
|
|
456
353
|
}
|
|
457
354
|
/**
|
|
458
355
|
* Disable a contributor collaboration from its identifier.
|
|
459
356
|
*/
|
|
460
|
-
|
|
357
|
+
disable(contributorId) {
|
|
461
358
|
this.setEnable(false, contributorId);
|
|
462
359
|
}
|
|
463
360
|
/**
|
|
464
361
|
* Retrieve all the contributor identifiers.
|
|
465
362
|
* @returns List of contributor idenfiers.
|
|
466
363
|
*/
|
|
467
|
-
|
|
364
|
+
getAllContributors() {
|
|
468
365
|
return Array.from(this.collaborations.keys());
|
|
469
366
|
}
|
|
470
367
|
/**
|
|
471
368
|
* Retrieve the contributor identifiers for which the collaboration is enabled.
|
|
472
369
|
* @returns List of contributor idenfiers.
|
|
473
370
|
*/
|
|
474
|
-
|
|
371
|
+
getEnableContributors() {
|
|
475
372
|
return Array.from(this.collaborations.keys()).filter(x => this.collaborations.get(x).enabled);
|
|
476
373
|
}
|
|
477
374
|
/**
|
|
478
375
|
* Retrieve the contributor identifiers for which the collaboration is disabled.
|
|
479
376
|
* @returns List of contributor idenfiers.
|
|
480
377
|
*/
|
|
481
|
-
|
|
378
|
+
getDisableContributors() {
|
|
482
379
|
return Array.from(this.collaborations.keys()).filter(x => !this.collaborations.get(x).enabled);
|
|
483
380
|
}
|
|
484
381
|
/**
|
|
485
382
|
* Retrieve enabled parameter of collaboration from a contributor identifier.
|
|
486
383
|
* @returns Contributor collaboration enabled properties.
|
|
487
384
|
*/
|
|
488
|
-
|
|
385
|
+
isEnable(contributorId) {
|
|
489
386
|
return this.collaborations.get(contributorId).enabled;
|
|
490
387
|
}
|
|
491
388
|
/**
|
|
492
389
|
* Update countAll property.
|
|
493
390
|
*/
|
|
494
|
-
|
|
391
|
+
setCountAll(collaborations) {
|
|
495
392
|
this.countAll = zip(...Array.from(this.collections).map(c => {
|
|
496
393
|
return this.resolveButNot([projType.count, {}], collaborations, c);
|
|
497
394
|
})).pipe(map(l => {
|
|
498
|
-
return l.map(count => ({count: count.totalnb, collection: count.collection}));
|
|
395
|
+
return l.map(count => ({ count: count.totalnb, collection: count.collection }));
|
|
499
396
|
}));
|
|
500
397
|
}
|
|
501
|
-
|
|
502
398
|
/**
|
|
503
399
|
* Build query parameters from aggregation and filters
|
|
504
400
|
* @return Url encoded string
|
|
505
401
|
*/
|
|
506
|
-
|
|
507
|
-
projection: [
|
|
508
|
-
projType.geoaggregate | projType.geosearch | projType.aggregate | projType.shapeaggregate | projType.shapesearch |
|
|
509
|
-
projType.count | projType.geohashgeoaggregate | projType.geotilegeoaggregate | projType.search | projType.tiledgeosearch,
|
|
510
|
-
Array<Aggregation>
|
|
511
|
-
],
|
|
512
|
-
filters: Array<Filter>, max_age = this.max_age): string {
|
|
513
|
-
|
|
402
|
+
getUrl(projection, filters, max_age = this.max_age) {
|
|
514
403
|
const finalFilter = this.getFinalFilter(filters);
|
|
515
|
-
let aggregationRequest
|
|
516
|
-
let aggregationsForGet
|
|
517
|
-
|
|
404
|
+
let aggregationRequest;
|
|
405
|
+
let aggregationsForGet;
|
|
518
406
|
const fForGet = this.buildFilterFieldGetParam('f', finalFilter);
|
|
519
407
|
const qForGet = this.buildFilterFieldGetParam('q', finalFilter);
|
|
520
|
-
|
|
521
408
|
const queryParameters = new URLSearchParams();
|
|
522
|
-
aggregationRequest =
|
|
409
|
+
aggregationRequest = {
|
|
523
410
|
filter: finalFilter,
|
|
524
411
|
aggregations: projection[1]
|
|
525
412
|
};
|
|
526
413
|
aggregationsForGet = this.buildAggGetParam(aggregationRequest);
|
|
527
|
-
|
|
528
414
|
if (aggregationsForGet
|
|
529
415
|
&& (projection[0] === projType.geoaggregate
|
|
530
416
|
|| projection[0] === projType.aggregate
|
|
531
417
|
|| projection[0] === projType.geohashgeoaggregate
|
|
532
418
|
|| projection[0] === projType.geotilegeoaggregate
|
|
533
|
-
|| projection[0] === projType.shapeaggregate)
|
|
534
|
-
) {
|
|
419
|
+
|| projection[0] === projType.shapeaggregate)) {
|
|
535
420
|
aggregationsForGet.filter(element => element !== undefined).forEach(function (element) {
|
|
536
421
|
queryParameters.append('agg', element);
|
|
537
422
|
});
|
|
@@ -550,22 +435,20 @@ export class CollaborativesearchService {
|
|
|
550
435
|
}
|
|
551
436
|
if (finalFilter.dateformat !== undefined) {
|
|
552
437
|
queryParameters.set('dateformat', finalFilter.dateformat.toString());
|
|
553
|
-
|
|
554
438
|
}
|
|
555
439
|
return queryParameters.toString();
|
|
556
440
|
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
const
|
|
560
|
-
const
|
|
561
|
-
const
|
|
562
|
-
const
|
|
563
|
-
const gi: Array<Array<string>> = new Array<Array<string>>();
|
|
564
|
-
|
|
441
|
+
getFinalFilter(filters) {
|
|
442
|
+
const finalFilter = {};
|
|
443
|
+
const f = new Array();
|
|
444
|
+
const q = new Array();
|
|
445
|
+
const p = new Array();
|
|
446
|
+
const gi = new Array();
|
|
565
447
|
const dateformats = new Set(filters.map(filter => filter.dateformat));
|
|
566
448
|
if (dateformats.size > 1) {
|
|
567
|
-
this.collaborationErrorBus.next(
|
|
568
|
-
}
|
|
449
|
+
this.collaborationErrorBus.next(new Error('Dateformats must be equals for each filters'));
|
|
450
|
+
}
|
|
451
|
+
else if (dateformats.size === 1) {
|
|
569
452
|
finalFilter.dateformat = dateformats[0];
|
|
570
453
|
}
|
|
571
454
|
filters.forEach(filter => {
|
|
@@ -584,7 +467,6 @@ export class CollaborativesearchService {
|
|
|
584
467
|
}
|
|
585
468
|
});
|
|
586
469
|
}
|
|
587
|
-
|
|
588
470
|
}
|
|
589
471
|
});
|
|
590
472
|
if (f.length > 0) {
|
|
@@ -595,43 +477,36 @@ export class CollaborativesearchService {
|
|
|
595
477
|
}
|
|
596
478
|
return finalFilter;
|
|
597
479
|
}
|
|
598
|
-
|
|
599
480
|
/**
|
|
600
481
|
* Describe the structure and the content of the given collection.
|
|
601
482
|
* @param collection collection name
|
|
602
483
|
* @param pretty Whether pretty print or not
|
|
603
484
|
* @param max_age Duration of browser cache.s
|
|
604
485
|
*/
|
|
605
|
-
|
|
606
|
-
const result =
|
|
607
|
-
this.exploreApi.describe(collection, pretty, max_age, this.fetchOptions)
|
|
608
|
-
);
|
|
486
|
+
describe(collection, pretty, max_age = this.max_age) {
|
|
487
|
+
const result = from(this.exploreApi.describe(collection, pretty, max_age, this.fetchOptions));
|
|
609
488
|
return result;
|
|
610
489
|
}
|
|
611
|
-
|
|
612
490
|
/**
|
|
613
491
|
* Lists the collections configured in ARLAS.
|
|
614
492
|
* @param pretty Whether pretty print or not
|
|
615
493
|
*/
|
|
616
|
-
|
|
617
|
-
const result =
|
|
618
|
-
this.exploreApi.list(pretty, this.max_age, this.fetchOptions)
|
|
619
|
-
);
|
|
494
|
+
list(pretty = false) {
|
|
495
|
+
const result = from(this.exploreApi.list(pretty, this.max_age, this.fetchOptions));
|
|
620
496
|
return result;
|
|
621
497
|
}
|
|
622
|
-
|
|
623
498
|
/**
|
|
624
499
|
* Set enabled value of a collaboration from a contributor identifier.
|
|
625
500
|
* @param enabled Enabled collaboration value.
|
|
626
501
|
* @param contributorId Contributor identifier.
|
|
627
502
|
*/
|
|
628
|
-
|
|
503
|
+
setEnable(enabled, contributorId) {
|
|
629
504
|
const collaboration = this.collaborations.get(contributorId);
|
|
630
505
|
if (collaboration) {
|
|
631
506
|
collaboration.enabled = enabled;
|
|
632
507
|
}
|
|
633
508
|
this.collaborations.set(contributorId, collaboration);
|
|
634
|
-
const collaborationEvent
|
|
509
|
+
const collaborationEvent = {
|
|
635
510
|
id: contributorId,
|
|
636
511
|
operation: OperationEnum.add,
|
|
637
512
|
all: true
|
|
@@ -646,19 +521,9 @@ export class CollaborativesearchService {
|
|
|
646
521
|
* @param isFlat Boolean option to flat output geojson properties.
|
|
647
522
|
* @returns ARLAS Server observable.
|
|
648
523
|
*/
|
|
649
|
-
|
|
650
|
-
| [projType.search, Search]
|
|
651
|
-
| [projType.geoaggregate, Array<Aggregation>]
|
|
652
|
-
| [projType.geohashgeoaggregate, GeohashAggregation]
|
|
653
|
-
| [projType.geotilegeoaggregate, GeoTileAggregation]
|
|
654
|
-
| [projType.geosearch, Search]
|
|
655
|
-
| [projType.tiledgeosearch, TiledSearch]
|
|
656
|
-
| [projType.count, Count]
|
|
657
|
-
| [projType.compute, ComputationRequest], collaborations: Map<string, Collaboration>, collection,
|
|
658
|
-
contributorId?: string, filter?: Filter, isFlat?: boolean, max_age = this.max_age, fetchOptions = this.fetchOptions
|
|
659
|
-
): Observable<any> {
|
|
524
|
+
resolve(projection, collaborations, collection, contributorId, filter, isFlat, max_age = this.max_age, fetchOptions = this.fetchOptions) {
|
|
660
525
|
try {
|
|
661
|
-
const filters
|
|
526
|
+
const filters = new Array();
|
|
662
527
|
if (contributorId) {
|
|
663
528
|
const collaboration = collaborations.get(contributorId);
|
|
664
529
|
if (collaboration !== undefined) {
|
|
@@ -676,8 +541,9 @@ export class CollaborativesearchService {
|
|
|
676
541
|
filters.push(filter);
|
|
677
542
|
}
|
|
678
543
|
return this.computeResolve(projection, filters, collection, isFlat, max_age, fetchOptions);
|
|
679
|
-
}
|
|
680
|
-
|
|
544
|
+
}
|
|
545
|
+
catch (ex) {
|
|
546
|
+
this.collaborationErrorBus.next(ex);
|
|
681
547
|
}
|
|
682
548
|
}
|
|
683
549
|
/**
|
|
@@ -690,21 +556,9 @@ export class CollaborativesearchService {
|
|
|
690
556
|
* @param max_age Duration of browser cache.
|
|
691
557
|
* @returns ARLAS Server observable.
|
|
692
558
|
*/
|
|
693
|
-
|
|
694
|
-
| [projType.search, Search]
|
|
695
|
-
| [projType.geoaggregate, Array<Aggregation>]
|
|
696
|
-
| [projType.geohashgeoaggregate, GeohashAggregation]
|
|
697
|
-
| [projType.geotilegeoaggregate, GeoTileAggregation]
|
|
698
|
-
| [projType.geosearch, Search]
|
|
699
|
-
| [projType.tiledgeosearch, TiledSearch]
|
|
700
|
-
| [projType.count, Count]
|
|
701
|
-
| [projType.compute, ComputationRequest]
|
|
702
|
-
| [projType.shapeaggregate, Array<Aggregation>]
|
|
703
|
-
| [projType.shapesearch, Search], collaborations: Map<string, Collaboration>, collection,
|
|
704
|
-
contributorId?: string, filter?: Filter, isFlat?: boolean, max_age = this.max_age, fetchOptions = this.fetchOptions
|
|
705
|
-
): Observable<any> {
|
|
559
|
+
resolveButNot(projection, collaborations, collection, contributorId, filter, isFlat, max_age = this.max_age, fetchOptions = this.fetchOptions) {
|
|
706
560
|
try {
|
|
707
|
-
const filters
|
|
561
|
+
const filters = new Array();
|
|
708
562
|
if (contributorId) {
|
|
709
563
|
collaborations.forEach((collab, c) => {
|
|
710
564
|
if (c !== contributorId && collab.enabled) {
|
|
@@ -714,11 +568,13 @@ export class CollaborativesearchService {
|
|
|
714
568
|
filters.push(collabFilters[0]);
|
|
715
569
|
}
|
|
716
570
|
}
|
|
717
|
-
}
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
718
573
|
return;
|
|
719
574
|
}
|
|
720
575
|
});
|
|
721
|
-
}
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
722
578
|
collaborations.forEach((collab, c) => {
|
|
723
579
|
if (collab.enabled) {
|
|
724
580
|
if (collab.filters && collab.filters.get(collection)) {
|
|
@@ -734,11 +590,11 @@ export class CollaborativesearchService {
|
|
|
734
590
|
filters.push(filter);
|
|
735
591
|
}
|
|
736
592
|
return this.computeResolve(projection, filters, collection, isFlat, max_age, fetchOptions);
|
|
737
|
-
}
|
|
738
|
-
|
|
593
|
+
}
|
|
594
|
+
catch (ex) {
|
|
595
|
+
this.collaborationErrorBus.next(ex);
|
|
739
596
|
}
|
|
740
597
|
}
|
|
741
|
-
|
|
742
598
|
/**
|
|
743
599
|
* Build an ARLAS Server request from an Array of Filter
|
|
744
600
|
* @param projection Type of projection of ARLAS Server request.
|
|
@@ -746,30 +602,18 @@ export class CollaborativesearchService {
|
|
|
746
602
|
* @param isFlat Boolean option to flat output geojson properties.
|
|
747
603
|
* @returns ARLAS Server observable.
|
|
748
604
|
*/
|
|
749
|
-
|
|
750
|
-
| [projType.search, Search]
|
|
751
|
-
| [projType.geoaggregate, Array<Aggregation>]
|
|
752
|
-
| [projType.geohashgeoaggregate, GeohashAggregation]
|
|
753
|
-
| [projType.geotilegeoaggregate, GeoTileAggregation]
|
|
754
|
-
| [projType.geosearch, Search]
|
|
755
|
-
| [projType.tiledgeosearch, TiledSearch]
|
|
756
|
-
| [projType.count, Count]
|
|
757
|
-
| [projType.compute, ComputationRequest]
|
|
758
|
-
| [projType.shapeaggregate, Array<Aggregation>]
|
|
759
|
-
| [projType.shapesearch, Search], filters: Array<Filter>, collection, isFlat?: boolean, max_age = this.max_age,
|
|
760
|
-
fetchOptions = this.fetchOptions
|
|
761
|
-
): Observable<any> {
|
|
605
|
+
computeResolve(projection, filters, collection, isFlat, max_age = this.max_age, fetchOptions = this.fetchOptions) {
|
|
762
606
|
const finalFilter = this.getFinalFilter(filters);
|
|
763
607
|
const dateformat = finalFilter.dateformat;
|
|
764
|
-
let aggregationRequest
|
|
765
|
-
let aggregationsForGet
|
|
766
|
-
let includes
|
|
767
|
-
let excludes
|
|
768
|
-
let returned_geometries
|
|
608
|
+
let aggregationRequest;
|
|
609
|
+
let aggregationsForGet;
|
|
610
|
+
let includes = [];
|
|
611
|
+
let excludes = [];
|
|
612
|
+
let returned_geometries;
|
|
769
613
|
let result;
|
|
770
614
|
const fForGet = this.buildFilterFieldGetParam('f', finalFilter);
|
|
771
615
|
const qForGet = this.buildFilterFieldGetParam('q', finalFilter);
|
|
772
|
-
let search
|
|
616
|
+
let search;
|
|
773
617
|
let pretty = false;
|
|
774
618
|
let flat = false;
|
|
775
619
|
let pageAfter;
|
|
@@ -779,7 +623,7 @@ export class CollaborativesearchService {
|
|
|
779
623
|
let pageSort;
|
|
780
624
|
if (projection[0] === projType.search.valueOf() || projection[0] === projType.geosearch.valueOf() ||
|
|
781
625
|
projection[0] === projType.tiledgeosearch.valueOf() || projection[0] === projType.shapesearch.valueOf()) {
|
|
782
|
-
search = projection[0] === projType.tiledgeosearch.valueOf() ?
|
|
626
|
+
search = projection[0] === projType.tiledgeosearch.valueOf() ? projection[1].search : projection[1];
|
|
783
627
|
includes = [];
|
|
784
628
|
excludes = [];
|
|
785
629
|
if (search.projection !== undefined) {
|
|
@@ -791,12 +635,13 @@ export class CollaborativesearchService {
|
|
|
791
635
|
}
|
|
792
636
|
}
|
|
793
637
|
returned_geometries = search.returned_geometries;
|
|
794
|
-
const form
|
|
795
|
-
const page
|
|
638
|
+
const form = search.form;
|
|
639
|
+
const page = search.page;
|
|
796
640
|
if (form !== undefined) {
|
|
797
641
|
if (form.flat !== undefined) {
|
|
798
642
|
flat = form.flat;
|
|
799
|
-
}
|
|
643
|
+
}
|
|
644
|
+
else {
|
|
800
645
|
if (isFlat !== undefined && isFlat !== null) {
|
|
801
646
|
flat = isFlat;
|
|
802
647
|
}
|
|
@@ -804,7 +649,8 @@ export class CollaborativesearchService {
|
|
|
804
649
|
if (form.pretty !== undefined) {
|
|
805
650
|
pretty = form.pretty;
|
|
806
651
|
}
|
|
807
|
-
}
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
808
654
|
if (isFlat !== undefined && isFlat !== null) {
|
|
809
655
|
flat = isFlat;
|
|
810
656
|
}
|
|
@@ -829,123 +675,86 @@ export class CollaborativesearchService {
|
|
|
829
675
|
}
|
|
830
676
|
switch (projection[0]) {
|
|
831
677
|
case projType.aggregate.valueOf():
|
|
832
|
-
aggregationRequest =
|
|
678
|
+
aggregationRequest = {
|
|
833
679
|
filter: finalFilter,
|
|
834
680
|
aggregations: projection[1]
|
|
835
681
|
};
|
|
836
682
|
aggregationsForGet = this.buildAggGetParam(aggregationRequest);
|
|
837
|
-
result =
|
|
838
|
-
this.exploreApi.aggregate(collection, aggregationsForGet,
|
|
839
|
-
fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions)
|
|
840
|
-
);
|
|
683
|
+
result = from(this.exploreApi.aggregate(collection, aggregationsForGet, fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions));
|
|
841
684
|
break;
|
|
842
685
|
case projType.geoaggregate.valueOf():
|
|
843
|
-
aggregationRequest =
|
|
686
|
+
aggregationRequest = {
|
|
844
687
|
filter: finalFilter,
|
|
845
688
|
aggregations: projection[1]
|
|
846
689
|
};
|
|
847
690
|
aggregationsForGet = this.buildAggGetParam(aggregationRequest);
|
|
848
|
-
result =
|
|
849
|
-
this.exploreApi.geoaggregate(collection, aggregationsForGet,
|
|
850
|
-
fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions)
|
|
851
|
-
);
|
|
691
|
+
result = from(this.exploreApi.geoaggregate(collection, aggregationsForGet, fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions));
|
|
852
692
|
break;
|
|
853
693
|
case projType.shapeaggregate.valueOf():
|
|
854
|
-
aggregationRequest =
|
|
694
|
+
aggregationRequest = {
|
|
855
695
|
filter: finalFilter,
|
|
856
696
|
aggregations: projection[1]
|
|
857
697
|
};
|
|
858
698
|
aggregationsForGet = this.buildAggGetParam(aggregationRequest);
|
|
859
699
|
fetchOptions.responseType = 'arraybuffer';
|
|
860
|
-
result =
|
|
861
|
-
this.exploreApi.shapeaggregate(collection, aggregationsForGet,
|
|
862
|
-
fForGet, qForGet, dateformat, false, max_age, fetchOptions).then(re => Promise.resolve(re.arrayBuffer()))
|
|
863
|
-
);
|
|
700
|
+
result = from(this.exploreApi.shapeaggregate(collection, aggregationsForGet, fForGet, qForGet, dateformat, false, max_age, fetchOptions).then(re => Promise.resolve(re.arrayBuffer())));
|
|
864
701
|
break;
|
|
865
702
|
case projType.shapesearch.valueOf():
|
|
866
703
|
fetchOptions.responseType = 'arraybuffer';
|
|
867
|
-
result =
|
|
868
|
-
this.exploreApi.shapesearch(collection, fForGet, qForGet
|
|
869
|
-
, dateformat, false, includes, excludes, returned_geometries, pageSize,
|
|
870
|
-
pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions).then(re => Promise.resolve(re.arrayBuffer()))
|
|
871
|
-
);
|
|
704
|
+
result = from(this.exploreApi.shapesearch(collection, fForGet, qForGet, dateformat, false, includes, excludes, returned_geometries, pageSize, pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions).then(re => Promise.resolve(re.arrayBuffer())));
|
|
872
705
|
break;
|
|
873
706
|
case projType.geohashgeoaggregate.valueOf():
|
|
874
|
-
const aggregationsGeohash
|
|
875
|
-
const geohash =
|
|
876
|
-
aggregationRequest =
|
|
707
|
+
const aggregationsGeohash = projection[1].aggregations;
|
|
708
|
+
const geohash = projection[1].geohash;
|
|
709
|
+
aggregationRequest = {
|
|
877
710
|
filter: finalFilter,
|
|
878
711
|
aggregations: aggregationsGeohash
|
|
879
712
|
};
|
|
880
713
|
aggregationsForGet = this.buildAggGetParam(aggregationRequest);
|
|
881
|
-
result =
|
|
882
|
-
this.exploreApi.geohashgeoaggregate(collection, geohash, aggregationsForGet,
|
|
883
|
-
fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions)
|
|
884
|
-
);
|
|
714
|
+
result = from(this.exploreApi.geohashgeoaggregate(collection, geohash, aggregationsForGet, fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions));
|
|
885
715
|
break;
|
|
886
716
|
case projType.geotilegeoaggregate.valueOf():
|
|
887
|
-
const aggregationsGeoTile
|
|
888
|
-
aggregationRequest =
|
|
717
|
+
const aggregationsGeoTile = projection[1].aggregations;
|
|
718
|
+
aggregationRequest = {
|
|
889
719
|
filter: finalFilter,
|
|
890
720
|
aggregations: aggregationsGeoTile
|
|
891
721
|
};
|
|
892
722
|
aggregationsForGet = this.buildAggGetParam(aggregationRequest);
|
|
893
|
-
const xGeotile =
|
|
894
|
-
const yGeotile =
|
|
895
|
-
const zGeotile =
|
|
896
|
-
result =
|
|
897
|
-
this.exploreApi.geotilegeoaggregate(collection, zGeotile, xGeotile, yGeotile, aggregationsForGet,
|
|
898
|
-
fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions)
|
|
899
|
-
);
|
|
723
|
+
const xGeotile = projection[1].x;
|
|
724
|
+
const yGeotile = projection[1].y;
|
|
725
|
+
const zGeotile = projection[1].z;
|
|
726
|
+
result = from(this.exploreApi.geotilegeoaggregate(collection, zGeotile, xGeotile, yGeotile, aggregationsForGet, fForGet, qForGet, dateformat, false, isFlat, max_age, fetchOptions));
|
|
900
727
|
break;
|
|
901
728
|
case projType.count.valueOf():
|
|
902
|
-
result =
|
|
903
|
-
this.exploreApi.count(collection, fForGet, qForGet, dateformat, false, max_age, fetchOptions));
|
|
729
|
+
result = from(this.exploreApi.count(collection, fForGet, qForGet, dateformat, false, max_age, fetchOptions));
|
|
904
730
|
break;
|
|
905
731
|
case projType.search.valueOf():
|
|
906
|
-
result =
|
|
907
|
-
this.exploreApi.search(collection, fForGet, qForGet
|
|
908
|
-
, dateformat, false, flat, includes, excludes, returned_geometries, pageSize,
|
|
909
|
-
pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions)
|
|
910
|
-
);
|
|
732
|
+
result = from(this.exploreApi.search(collection, fForGet, qForGet, dateformat, false, flat, includes, excludes, returned_geometries, pageSize, pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions));
|
|
911
733
|
break;
|
|
912
734
|
case projType.geosearch.valueOf():
|
|
913
|
-
result =
|
|
914
|
-
this.exploreApi.geosearch(collection, fForGet, qForGet
|
|
915
|
-
, dateformat, false, flat, includes, excludes, returned_geometries, pageSize,
|
|
916
|
-
pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions)
|
|
917
|
-
);
|
|
735
|
+
result = from(this.exploreApi.geosearch(collection, fForGet, qForGet, dateformat, false, flat, includes, excludes, returned_geometries, pageSize, pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions));
|
|
918
736
|
break;
|
|
919
737
|
case projType.tiledgeosearch.valueOf():
|
|
920
|
-
const x =
|
|
921
|
-
const y =
|
|
922
|
-
const z =
|
|
923
|
-
result =
|
|
924
|
-
this.exploreApi.tiledgeosearch(collection, x, y, z
|
|
925
|
-
, fForGet, qForGet
|
|
926
|
-
, dateformat, false, flat, includes, excludes, returned_geometries,
|
|
927
|
-
pageSize, pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions)
|
|
928
|
-
);
|
|
738
|
+
const x = projection[1].x;
|
|
739
|
+
const y = projection[1].y;
|
|
740
|
+
const z = projection[1].z;
|
|
741
|
+
result = from(this.exploreApi.tiledgeosearch(collection, x, y, z, fForGet, qForGet, dateformat, false, flat, includes, excludes, returned_geometries, pageSize, pageFrom, pageSort, pageAfter, pageBefore, max_age, fetchOptions));
|
|
929
742
|
break;
|
|
930
743
|
case projType.compute.valueOf():
|
|
931
|
-
const field =
|
|
932
|
-
const metric =
|
|
933
|
-
result =
|
|
934
|
-
this.exploreApi.compute(collection, field, metric.toString().toLowerCase(), fForGet,
|
|
935
|
-
qForGet, dateformat, false, max_age, fetchOptions)
|
|
936
|
-
);
|
|
744
|
+
const field = projection[1].field;
|
|
745
|
+
const metric = projection[1].metric;
|
|
746
|
+
result = from(this.exploreApi.compute(collection, field, metric.toString().toLowerCase(), fForGet, qForGet, dateformat, false, max_age, fetchOptions));
|
|
937
747
|
break;
|
|
938
748
|
}
|
|
939
749
|
return result;
|
|
940
750
|
}
|
|
941
|
-
|
|
942
751
|
/**
|
|
943
752
|
* Build an AggregationsRequest String[] for get mode request
|
|
944
753
|
* @param aggregationRequest AggregationsRequest arlas object use in post request.
|
|
945
754
|
* @returns aggregations as string[].
|
|
946
755
|
*/
|
|
947
|
-
|
|
948
|
-
const aggregations
|
|
756
|
+
buildAggGetParam(aggregationRequest) {
|
|
757
|
+
const aggregations = [];
|
|
949
758
|
aggregationRequest.aggregations.forEach(agg => {
|
|
950
759
|
let aggregation = agg.type + ':' + agg.field;
|
|
951
760
|
if (agg.interval !== undefined) {
|
|
@@ -960,7 +769,7 @@ export class CollaborativesearchService {
|
|
|
960
769
|
aggregation += ':format-' + agg.format;
|
|
961
770
|
}
|
|
962
771
|
if (agg.metrics) {
|
|
963
|
-
agg.metrics.filter((m
|
|
772
|
+
agg.metrics.filter((m) => (m.collect_field && m.collect_fct)).forEach(m => {
|
|
964
773
|
aggregation += ':collect_field-' + m.collect_field + ':collect_fct-' + m.collect_fct;
|
|
965
774
|
});
|
|
966
775
|
}
|
|
@@ -980,7 +789,8 @@ export class CollaborativesearchService {
|
|
|
980
789
|
aggregation += ':raw_geometries-' + agg.raw_geometries.map(rg => {
|
|
981
790
|
if (rg.sort) {
|
|
982
791
|
return rg.geometry + '(' + rg.sort + ')';
|
|
983
|
-
}
|
|
792
|
+
}
|
|
793
|
+
else {
|
|
984
794
|
return rg.geometry;
|
|
985
795
|
}
|
|
986
796
|
}).join(';');
|
|
@@ -1001,16 +811,15 @@ export class CollaborativesearchService {
|
|
|
1001
811
|
});
|
|
1002
812
|
return aggregations;
|
|
1003
813
|
}
|
|
1004
|
-
|
|
1005
814
|
/**
|
|
1006
815
|
* Build an filter String[] or string for get mode request
|
|
1007
816
|
* @param field
|
|
1008
817
|
* @param filter
|
|
1009
818
|
* @returns aggregations as string[].
|
|
1010
819
|
*/
|
|
1011
|
-
|
|
820
|
+
buildFilterFieldGetParam(field, filter) {
|
|
1012
821
|
if (field === 'f') {
|
|
1013
|
-
const f
|
|
822
|
+
const f = [];
|
|
1014
823
|
if (filter.f !== undefined) {
|
|
1015
824
|
filter.f.forEach(e => {
|
|
1016
825
|
let union = '';
|
|
@@ -1021,8 +830,9 @@ export class CollaborativesearchService {
|
|
|
1021
830
|
});
|
|
1022
831
|
}
|
|
1023
832
|
return f;
|
|
1024
|
-
}
|
|
1025
|
-
|
|
833
|
+
}
|
|
834
|
+
else {
|
|
835
|
+
const f = [];
|
|
1026
836
|
if (filter[field] !== undefined) {
|
|
1027
837
|
filter[field].forEach(e => {
|
|
1028
838
|
let union = '';
|
|
@@ -1032,9 +842,11 @@ export class CollaborativesearchService {
|
|
|
1032
842
|
f.push(union.substring(0, union.length - 1));
|
|
1033
843
|
});
|
|
1034
844
|
return f;
|
|
1035
|
-
}
|
|
845
|
+
}
|
|
846
|
+
else {
|
|
1036
847
|
return undefined;
|
|
1037
848
|
}
|
|
1038
849
|
}
|
|
1039
850
|
}
|
|
1040
851
|
}
|
|
852
|
+
//# sourceMappingURL=collaborativesearch.service.js.map
|