فهرست منبع

Review suggestions

Matthias Rupp 2 سال پیش
والد
کامیت
3e47ca3815

+ 2 - 2
server/apps/immich/src/api-v1/asset/response-dto/map-marker-response.dto.ts

@@ -1,5 +1,5 @@
 import { AssetEntity } from '@app/infra/entities';
-import { roundToDecimals } from '../../../utils/coordinate.util';
+import { round } from 'lodash';
 
 export type MapMarkerResponseDto = [
   // latitude
@@ -14,7 +14,7 @@ export function mapAssetMapMarker(asset: AssetEntity, preload: boolean): MapMark
   const lat = asset.exifInfo?.latitude || 0;
   const lon = asset.exifInfo?.longitude || 0;
 
-  const response = [roundToDecimals(lat, 5), roundToDecimals(lon, 5)] as MapMarkerResponseDto;
+  const response: MapMarkerResponseDto = [round(lat, 5), round(lon, 5)];
 
   if (!preload) {
     response.push(asset.id);

+ 0 - 17
server/apps/immich/src/utils/coordinate.util.spec.ts

@@ -1,17 +0,0 @@
-import { roundToDecimals } from './coordinate.util';
-
-describe('Coordinate utils roundToDecimals test', () => {
-  it('should round latitude and longitude to 5 digits', () => {
-    const lat = 49.533547;
-    const lon = 10.703075;
-
-    const latRounded = roundToDecimals(lat, 5);
-    const lonRounded = roundToDecimals(lon, 5);
-
-    expect(latRounded).toBeCloseTo(lat, 4);
-    expect(lonRounded).toBeCloseTo(lon, 4);
-
-    expect(`${latRounded}`.split('.')[1]).toHaveLength(5);
-    expect(`${lonRounded}`.split('.')[1]).toHaveLength(5);
-  });
-});

+ 0 - 4
server/apps/immich/src/utils/coordinate.util.ts

@@ -1,4 +0,0 @@
-export function roundToDecimals(num: number, digits: number): number {
-  const factor = 10 ** digits;
-  return Math.round(num * factor + Number.EPSILON) / factor;
-}