Skip to content

Commit 732d099

Browse files
Robin BuschmannRobin Buschmann
authored andcommitted
group count added for on the fly location clusters
1 parent 32b24af commit 732d099

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

services/ChargingLocationService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class ChargingLocationService {
147147

148148
if(chargingLocations.length > 400) {
149149

150-
return <any>this.geoService.getLocationClusters(chargingLocations, epsilon);
150+
return <any>this.geoService.getLocationClusters(chargingLocations, epsilon, null, true);
151151
}
152152

153153
return chargingLocations;

services/GeoService.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class GeoService {
1010
* If one cluster consists of one coordinate, this coordinate
1111
* will be returned as it is
1212
*/
13-
getLocationClusters(chargingLocations: IChargingLocation[], epsilon: number, idObject?: {id: number}): Promise<ILocationCluster[]> {
13+
getLocationClusters(chargingLocations: IChargingLocation[], epsilon: number, idObject?: {id: number}, addGroupCount = false): Promise<ILocationCluster[]> {
1414

1515
return new Promise<ILocationCluster[]>((resolve, reject) => {
1616

@@ -98,7 +98,7 @@ export class GeoService {
9898
* coordinates, if list contains only one element,
9999
* this element will be returned
100100
*/
101-
private getLocationCluster(chargingLocations: IChargingLocation[], epsilon: number, idObject?: {id:number}): ILocationCluster {
101+
private getLocationCluster(chargingLocations: IChargingLocation[], epsilon: number, idObject?: {id:number}, addGroupCount = false): ILocationCluster {
102102

103103
const id = idObject ? idObject.id++ : null;
104104

@@ -138,12 +138,19 @@ export class GeoService {
138138
let centralSquareRoot = Math.sqrt(x * x + y * y);
139139
let centralLatitude = Math.atan2(z, centralSquareRoot);
140140

141-
return {
141+
const locationCluster: ILocationCluster = {
142142
id,
143143
latitude: centralLatitude * 180 / Math.PI,
144144
longitude: centralLongitude * 180 / Math.PI,
145145
epsilon,
146146
chargingLocations
147147
};
148+
149+
if(addGroupCount) {
150+
151+
locationCluster.groupCount = total;
152+
}
153+
154+
return locationCluster;
148155
}
149156
}

0 commit comments

Comments
 (0)