commit
7a93cb30a0
@ -1,17 +1,17 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { MonumentMarkerComponent } from './monument-marker.component';
|
import { PinMarkerComponent } from './pin-marker.component';
|
||||||
|
|
||||||
describe('MonumentmarkerComponent', () => {
|
describe('PinmarkerComponent', () => {
|
||||||
let component: MonumentMarkerComponent;
|
let component: PinMarkerComponent;
|
||||||
let fixture: ComponentFixture<MonumentMarkerComponent>;
|
let fixture: ComponentFixture<PinMarkerComponent>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
imports: [MonumentMarkerComponent],
|
imports: [PinMarkerComponent],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
|
|
||||||
fixture = TestBed.createComponent(MonumentMarkerComponent);
|
fixture = TestBed.createComponent(PinMarkerComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
@ -1,32 +0,0 @@
|
|||||||
import { Monument } from '../model/Monument';
|
|
||||||
|
|
||||||
export const monuments: Monument[] = [
|
|
||||||
{
|
|
||||||
coords: [48.85837, 2.294481],
|
|
||||||
name: 'Tour Eiffel',
|
|
||||||
images: [
|
|
||||||
'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQGGib245tSFiK1Qcx0cB0dZsoVyJElwsY3kA&s',
|
|
||||||
'https://encrypted-tbn2.gstatic.com/licensed-image?q=tbn:ANd9GcTLB9B0j50rJbcSbdja9_hySHS6_KATbhTK_iCeWeNKtA92hTmTX5nTW3udjjovZrnU1JxqAjMS_VqHnMwHGhTs35-sU-7B29_X_T3uLV8',
|
|
||||||
],
|
|
||||||
description: 'Visité en 2020 avec la famille, un moment inoubliable.',
|
|
||||||
visited: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
coords: [43.296482, 5.36978],
|
|
||||||
name: 'Vieux Port de Marseille',
|
|
||||||
images: [
|
|
||||||
'https://upload.wikimedia.org/wikipedia/commons/thumb/7/74/Marseille_Old_Port.jpg/390px-Marseille_Old_Port.jpg',
|
|
||||||
],
|
|
||||||
description:
|
|
||||||
"Découvert lors d'un week-end ensoleillé en 2019 avec @John-Doe.",
|
|
||||||
visited: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
coords: [48.636063, -1.511457],
|
|
||||||
name: 'Mont Saint-Michel',
|
|
||||||
images: [],
|
|
||||||
description: '',
|
|
||||||
visited: false,
|
|
||||||
},
|
|
||||||
// ...
|
|
||||||
];
|
|
@ -0,0 +1,16 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { ExifService } from './exif.service';
|
||||||
|
|
||||||
|
describe('ExifService', () => {
|
||||||
|
let service: ExifService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
service = TestBed.inject(ExifService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,87 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import exifr from 'exifr';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class ExifService {
|
||||||
|
|
||||||
|
private getExifData(file: File): Promise<any> {
|
||||||
|
// console.log('getExifData(file)');
|
||||||
|
// return new Promise((resolve, reject) => {
|
||||||
|
// console.log('getExifData(file) -> Promise');
|
||||||
|
// const reader = new FileReader();
|
||||||
|
// console.log('getExifData(file) -> Promise -> reader');
|
||||||
|
// reader.onload = (event: any) => {
|
||||||
|
// console.log('getExifData(file) -> Promise -> reader -> onload');
|
||||||
|
// EXIF.getData(event.target.result, function() {
|
||||||
|
// console.log('getExifData(file) -> Promise -> reader -> onload -> EXIF.getData');
|
||||||
|
// const allExifData = EXIF.getAllTags(this);
|
||||||
|
// console.log('getExifData(file) -> Promise -> reader -> onload -> EXIF.getData -> getAllTags');
|
||||||
|
// resolve(allExifData);
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
// reader.onerror = (error) => reject(error);
|
||||||
|
// reader.readAsArrayBuffer(file);
|
||||||
|
// });
|
||||||
|
return exifr.parse(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getAllExifData(file: File): Promise<any> {
|
||||||
|
try {
|
||||||
|
return await this.getExifData(file);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error reading EXIF data:', error);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async getOrientation(file: File): Promise<number | undefined> {
|
||||||
|
try {
|
||||||
|
const exifData = await this.getExifData(file);
|
||||||
|
return exifData.Orientation;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error reading EXIF data:', error);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async getDeviceModel(file: File): Promise<string | undefined> {
|
||||||
|
try {
|
||||||
|
const exifData = await this.getExifData(file);
|
||||||
|
return exifData.Model;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error reading EXIF data:', error);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async getLocation(file: File): Promise<{ latitude?: number; longitude?: number }> {
|
||||||
|
try {
|
||||||
|
const exifData = await this.getExifData(file);
|
||||||
|
return {
|
||||||
|
latitude: exifData.GPSLatitude ? this.convertToDecimal(exifData.GPSLatitude, exifData.GPSLatitudeRef) : undefined,
|
||||||
|
longitude: exifData.GPSLongitude ? this.convertToDecimal(exifData.GPSLongitude, exifData.GPSLongitudeRef) : undefined
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error reading EXIF data:', error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async getDateTime(file: File): Promise<string | boolean> {
|
||||||
|
try {
|
||||||
|
const exifData = await this.getExifData(file);
|
||||||
|
return exifData.DateTime;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error reading EXIF data:', error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private convertToDecimal(coordinate: number[], direction: string): number {
|
||||||
|
if (!coordinate || coordinate.length !== 3) return NaN;
|
||||||
|
const decimal = coordinate[0] + coordinate[1] / 60 + coordinate[2] / 3600;
|
||||||
|
return (direction === 'S' || direction === 'W') ? -decimal : decimal;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
export interface Monument {
|
export interface Pin {
|
||||||
|
id: string;
|
||||||
location: number[];
|
location: number[];
|
||||||
title: string;
|
title: string;
|
||||||
files: string[];
|
files: string[];
|
Loading…
Reference in new issue