Rename to more generic vars for coordinates
MODIFY
src/server/rest/service/ChargingStationService.ts
src/server/rest/service/ChargingStationService.ts
@@ -1162,8 +1162,8 @@ export default class ChargingStationService {
// Get Charging Stations
const chargingStations = await ChargingStationStorage.getChargingStations(req.user.tenantID,
{
- userGPSCoordinates: filteredRequest.UserGPSCoordinates,
- userGPSMaxDistanceMeters: filteredRequest.UserGPSMaxDistanceMeters,
+ posCoordinates: filteredRequest.PosCoordinates,
+ posMaxDistanceMeters: filteredRequest.PosMaxDistanceMeters,
search: filteredRequest.Search,
withNoSiteArea: filteredRequest.WithNoSiteArea,
withSite: filteredRequest.WithSite,

MODIFY
src/server/rest/service/security/ChargingStationSecurity.ts
src/server/rest/service/security/ChargingStationSecurity.ts
@@ -323,15 +323,15 @@ export default class ChargingStationSecurity {
filteredRequest.ConnectorType = sanitize(request.ConnectorType);
filteredRequest.IncludeDeleted = UtilsSecurity.filterBoolean(request.IncludeDeleted);
filteredRequest.ErrorType = sanitize(request.ErrorType);
- if (Utils.containsGPSCoordinates([request.UserGPSLongitude, request.UserGPSLatitude])) {
- filteredRequest.UserGPSCoordinates = [
- Utils.convertToFloat(sanitize(request.UserGPSLongitude)),
- Utils.convertToFloat(sanitize(request.UserGPSLatitude))
+ if (Utils.containsGPSCoordinates([request.PosLongitude, request.PosLatitude])) {
+ filteredRequest.PosCoordinates = [
+ Utils.convertToFloat(sanitize(request.PosLongitude)),
+ Utils.convertToFloat(sanitize(request.PosLatitude))
];
- if (request.UserGPSMaxDistanceMeters) {
- request.UserGPSMaxDistanceMeters = Utils.convertToInt(sanitize(request.UserGPSMaxDistanceMeters));
- if (request.UserGPSMaxDistanceMeters > 0) {
- filteredRequest.UserGPSMaxDistanceMeters = request.UserGPSMaxDistanceMeters;
+ if (request.PosMaxDistanceMeters) {
+ request.PosMaxDistanceMeters = Utils.convertToInt(sanitize(request.PosMaxDistanceMeters));
+ if (request.PosMaxDistanceMeters > 0) {
+ filteredRequest.PosMaxDistanceMeters = request.PosMaxDistanceMeters;
}
}
}

MODIFY
src/storage/mongodb/ChargingStationStorage.ts
src/storage/mongodb/ChargingStationStorage.ts
@@ -114,7 +114,7 @@ export default class ChargingStationStorage {
search?: string; chargingStationIDs?: string[]; siteAreaIDs?: string[]; withNoSiteArea?: boolean;
connectorStatuses?: string[]; connectorTypes?: string[]; statusChangedBefore?: Date;
siteIDs?: string[]; withSite?: boolean; includeDeleted?: boolean; offlineSince?: Date; issuer?: boolean;
- userGPSCoordinates?: number[]; userGPSMaxDistanceMeters?: number;
+ posCoordinates?: number[]; posMaxDistanceMeters?: number;
},
dbParams: DbParams, projectFields?: string[]): Promise<DataResult<ChargingStation>> {
// Debug
@@ -128,15 +128,15 @@ export default class ChargingStationStorage {
// Create Aggregation
const aggregation = [];
// User coordinates
- if (Utils.containsGPSCoordinates(params.userGPSCoordinates)) {
+ if (Utils.containsGPSCoordinates(params.posCoordinates)) {
aggregation.push({
$geoNear: {
near: {
type: 'Point',
- coordinates: params.userGPSCoordinates
+ coordinates: params.posCoordinates
},
distanceField: 'distanceMeters',
- maxDistance: params.userGPSMaxDistanceMeters > 0 ? params.userGPSMaxDistanceMeters : Constants.MAX_GPS_DISTANCE_METERS,
+ maxDistance: params.posMaxDistanceMeters > 0 ? params.posMaxDistanceMeters : Constants.MAX_GPS_DISTANCE_METERS,
spherical: true
}
});

MODIFY
src/types/requests/HttpChargingStationRequest.ts
src/types/requests/HttpChargingStationRequest.ts
@@ -32,8 +32,8 @@ export interface HttpChargingStationsRequest extends HttpDatabaseRequest {
SiteAreaID?: string;
IncludeDeleted?: boolean;
ErrorType?: string;
- UserGPSCoordinates?: number[];
- UserGPSMaxDistanceMeters?: number;
+ PosCoordinates?: number[];
+ PosMaxDistanceMeters?: number;
}
export interface HttpChargingStationParamsUpdateRequest {

Rename to more generic vars for coordinates