Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix map getFilterForCount #301

Merged
merged 1 commit into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 40 additions & 19 deletions src/contributors/MapContributor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export class MapContributor extends Contributor {
public currentExtentGeohashSet: Set<string> = new Set<string>();
public currentStringedTilesList: Array<string> = new Array<string>();
public mapExtend = [90, -180, -90, 180];
public mapRawExtent = [90, -180, -90, 180];
public zoomLevelFullData = this.getConfigValue('zoomLevelFullData');
public zoomLevelForTestCount = this.getConfigValue('zoomLevelForTestCount');
public nbMaxFeatureForCluster = this.getConfigValue('nbMaxDefautFeatureForCluster');
Expand Down Expand Up @@ -305,8 +306,9 @@ export class MapContributor extends Contributor {
this.parentGeohashesSet = new Set();
return this.fetchDataGeohashGeoaggregate(this.geohashList);
} else if (this.zoom >= this.zoomLevelForTestCount) {
const pwithin = this.mapExtend[1] + ',' + this.mapExtend[2] + ',' + this.mapExtend[3] + ',' + this.mapExtend[0];
const countFilter = this.getFilterForCount(pwithin);
const wrapExtent = this.mapExtend[1] + ',' + this.mapExtend[2] + ',' + this.mapExtend[3] + ',' + this.mapExtend[0];
const rawExtent = this.mapRawExtent[1] + ',' + this.mapRawExtent[2] + ',' + this.mapRawExtent[3] + ',' + this.mapRawExtent[0];
const countFilter = this.getFilterForCount(rawExtent, wrapExtent);
this.addFilter(countFilter, this.additionalFilter);
const count: Observable<Hits> = this.collaborativeSearcheService
.resolveButNotHits([projType.count, {}], this.collaborativeSearcheService.collaborations,
Expand Down Expand Up @@ -737,6 +739,7 @@ export class MapContributor extends Contributor {

public onMoveSimpleMode(newMove: OnMoveResult) {
this.mapExtend = newMove.extendForLoad;
this.mapRawExtent = newMove.rawExtendForLoad;
this.drawGeoSearch();
}

Expand All @@ -759,9 +762,11 @@ export class MapContributor extends Contributor {
this.fetchType = fetchType.geohash;
this.onMoveInClusterMode(precisionChanged, newMove);
} else if (newMove.zoom >= this.zoomLevelForTestCount) {
const pwithin = newMove.extendForLoad[1] + ',' + newMove.extendForLoad[2]
+ ',' + newMove.extendForLoad[3] + ',' + newMove.extendForLoad[0];
const countFilter = this.getFilterForCount(pwithin);
const wrapExtent = newMove.extendForLoad[1] + ',' + newMove.extendForLoad[2] + ','
+ newMove.extendForLoad[3] + ',' + newMove.extendForLoad[0];
const rawExtent = newMove.rawExtendForLoad[1] + ',' + newMove.rawExtendForLoad[2] + ','
+ newMove.rawExtendForLoad[3] + ',' + newMove.rawExtendForLoad[0];
const countFilter = this.getFilterForCount(rawExtent, wrapExtent);
this.addFilter(countFilter, this.additionalFilter);
const count: Observable<Hits> = this.collaborativeSearcheService
.resolveButNotHits([projType.count, {}], this.collaborativeSearcheService.collaborations,
Expand Down Expand Up @@ -800,6 +805,7 @@ export class MapContributor extends Contributor {
this.onMoveInClusterMode(precisionChanged, newMove);
}
this.mapExtend = newMove.extendForLoad;
this.mapRawExtent = newMove.rawExtendForLoad;
});
} else {
this.countExtendBus.next({
Expand Down Expand Up @@ -1007,9 +1013,9 @@ export class MapContributor extends Contributor {
*/
public fetchDataGeoSearch(includeFeaturesFields: Set<string>, sort: string,
afterParam?: string, whichPage?: PageEnum, fromParam?): Observable<FeatureCollection> {
const pwithin = this.mapExtend[1] + ',' + this.mapExtend[2]
+ ',' + this.mapExtend[3] + ',' + this.mapExtend[0];
const filter: Filter = this.getFilterForCount(pwithin);
const wrapExtent = this.mapExtend[1] + ',' + this.mapExtend[2] + ',' + this.mapExtend[3] + ',' + this.mapExtend[0];
const rawExtent = this.mapRawExtent[1] + ',' + this.mapRawExtent[2] + ',' + this.mapRawExtent[3] + ',' + this.mapRawExtent[0];
const filter: Filter = this.getFilterForCount(rawExtent, wrapExtent);
if (this.expressionFilter !== undefined) {
filter.f.push([this.expressionFilter]);
}
Expand Down Expand Up @@ -1142,18 +1148,32 @@ export class MapContributor extends Contributor {
return nbMaxFeatureForCluster;
}

public getFilterForCount(extent: string): Filter {
public getFilterForCount(rawExtend: string, wrapExtend: string): Filter {
// west, south, east, north
const extentTab = extent.trim().split(',');
const west = extentTab[0];
const east = extentTab[2];
let finalExtend = [extent.trim()];
if (parseFloat(west) > parseFloat(east)) {
finalExtend = [];
const firstExtent = extentTab[0] + ',' + extentTab[1] + ',' + '180' + ',' + extentTab[3];
const secondExtent = '-180' + ',' + extentTab[1] + ',' + extentTab[2] + ',' + extentTab[3];
finalExtend.push(firstExtent.trim());
finalExtend.push(secondExtent.trim());
const finalExtend = [];
const wrapExtentTab = wrapExtend.split(',').map(d => parseFloat(d)).map(n => Math.floor(n * 100000) / 100000);
const rawExtentTab = rawExtend.split(',').map(d => parseFloat(d)).map(n => Math.floor(n * 100000) / 100000);
const rawExtentForTest = rawExtentTab.join(',');
const wrapExtentForTest = wrapExtentTab.join(',');
if (rawExtentTab[0] < -180 && rawExtentTab[2] > 180) {
finalExtend.push('-180' + ',' + '-90' + ',' + '180' + ',' + '90');
} else if (rawExtentForTest === wrapExtentForTest) {
finalExtend.push(wrapExtend.trim());
} else {
let west = wrapExtentTab[0];
let east = wrapExtentTab[2];
if (west < 0 && east < 0) {
west = west * -1;
east = east * -1;
}
if (west > east) {
const firstExtent = wrapExtentTab[0] + ',' + wrapExtentTab[1] + ',' + '180' + ',' + wrapExtentTab[3];
const secondExtent = '-180' + ',' + wrapExtentTab[1] + ',' + wrapExtentTab[2] + ',' + wrapExtentTab[3];
finalExtend.push(firstExtent.trim());
finalExtend.push(secondExtent.trim());
} else {
finalExtend.push(wrapExtend.trim());
}
}
let filter: Filter = {};
const collaboration = this.collaborativeSearcheService.getCollaboration(this.identifier);
Expand Down Expand Up @@ -1285,6 +1305,7 @@ export class MapContributor extends Contributor {
}
}
this.mapExtend = newMove.extendForLoad;
this.mapRawExtent = newMove.rawExtendForLoad;
}
/**
* adds the second filter to the first filter
Expand Down
13 changes: 8 additions & 5 deletions src/contributors/TopoMapContributor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ export class TopoMapContributor extends MapContributor {
this.fetchType = fetchType.geohash;
return this.fetchDataGeohashGeoaggregate(this.geohashList);
} else if (this.zoom >= this.zoomLevelForTestCount) {
const pwithin = this.mapExtend[1] + ',' + this.mapExtend[2] + ',' + this.mapExtend[3] + ',' + this.mapExtend[0];
const wrapExtent = this.mapExtend[1] + ',' + this.mapExtend[2] + ',' + this.mapExtend[3] + ',' + this.mapExtend[0];
const rawExtent = this.mapRawExtent[1] + ',' + this.mapRawExtent[2] + ',' + this.mapRawExtent[3] + ',' + this.mapRawExtent[0];
const countFilter = this.getFilterForCount(rawExtent, wrapExtent);
// test for count with aggregation geoagreate interval 1 metrics cadinalitty sur le champs
const countFilter = this.getFilterForCount(pwithin);
this.addFilter(countFilter, this.additionalFilter);
const newCount = this.getTopoCardinality(this.field_cardinality, countFilter);
if (newCount) {
Expand Down Expand Up @@ -163,10 +164,12 @@ export class TopoMapContributor extends MapContributor {
this.clearData();
this.clearTiles();
}
const pwithin = newMove.extendForLoad[1] + ',' + newMove.extendForLoad[2]
+ ',' + newMove.extendForLoad[3] + ',' + newMove.extendForLoad[0];
const wrapExtent = newMove.extendForLoad[1] + ',' + newMove.extendForLoad[2] + ','
+ newMove.extendForLoad[3] + ',' + newMove.extendForLoad[0];
const rawExtent = newMove.rawExtendForLoad[1] + ',' + newMove.rawExtendForLoad[2] + ','
+ newMove.rawExtendForLoad[3] + ',' + newMove.rawExtendForLoad[0];
const countFilter = this.getFilterForCount(rawExtent, wrapExtent);
// Test for count with aggregation geoagreate interval 1 metrics cadinalitty sur le champs
const countFilter = this.getFilterForCount(pwithin);
this.addFilter(countFilter, this.additionalFilter);
const count = this.getTopoCardinality(this.field_cardinality, countFilter);
if (count) {
Expand Down
1 change: 1 addition & 0 deletions src/models/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export interface OnMoveResult {
center: any;
extend: Array<number>;
extendForLoad: Array<number>;
rawExtendForLoad: Array<number>;
extendForTest: Array<number>;
tiles: Array<{ x: number, y: number, z: number }>;
geohash: Array<string>;
Expand Down