diff --git a/package-lock.json b/package-lock.json index a7552ab6..5fc0761d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { - "name": "arlas-web-contributors", - "version": "12.6.0", + "name": "@gisaia-team/arlas-web-contributors", + "version": "12.7.0-dev0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/contributors/MapContributor.ts b/src/contributors/MapContributor.ts index fe499f63..6d59de78 100644 --- a/src/contributors/MapContributor.ts +++ b/src/contributors/MapContributor.ts @@ -121,6 +121,7 @@ export class MapContributor extends Contributor { public currentExtentGeohashSet: Set = new Set(); public currentStringedTilesList: Array = new Array(); 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'); @@ -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 = this.collaborativeSearcheService .resolveButNotHits([projType.count, {}], this.collaborativeSearcheService.collaborations, @@ -737,6 +739,7 @@ export class MapContributor extends Contributor { public onMoveSimpleMode(newMove: OnMoveResult) { this.mapExtend = newMove.extendForLoad; + this.mapRawExtent = newMove.rawExtendForLoad; this.drawGeoSearch(); } @@ -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 = this.collaborativeSearcheService .resolveButNotHits([projType.count, {}], this.collaborativeSearcheService.collaborations, @@ -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({ @@ -1007,9 +1013,9 @@ export class MapContributor extends Contributor { */ public fetchDataGeoSearch(includeFeaturesFields: Set, sort: string, afterParam?: string, whichPage?: PageEnum, fromParam?): Observable { - 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]); } @@ -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); @@ -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 diff --git a/src/contributors/TopoMapContributor.ts b/src/contributors/TopoMapContributor.ts index 71d8b0b8..cf390410 100644 --- a/src/contributors/TopoMapContributor.ts +++ b/src/contributors/TopoMapContributor.ts @@ -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) { @@ -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) { diff --git a/src/models/models.ts b/src/models/models.ts index ef480167..4b647cf5 100644 --- a/src/models/models.ts +++ b/src/models/models.ts @@ -73,6 +73,7 @@ export interface OnMoveResult { center: any; extend: Array; extendForLoad: Array; + rawExtendForLoad: Array; extendForTest: Array; tiles: Array<{ x: number, y: number, z: number }>; geohash: Array;