1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

improving position visualisation

This commit is contained in:
Braun Patrik 2017-06-21 21:32:57 +02:00
parent 5da852b711
commit 4a96d2a0f9
3 changed files with 37 additions and 19 deletions

View File

@ -40,12 +40,7 @@ export const diskManagerTask = (input: DiskManagerTask.PoolInput, done) => {
const metadata: PhotoMetadata = <PhotoMetadata>{ const metadata: PhotoMetadata = <PhotoMetadata>{
keywords: {}, keywords: {},
cameraData: {}, cameraData: {},
positionData: { positionData: null,
GPSData: {},
country: null,
state: null,
city: null
},
size: {}, size: {},
creationDate: {} creationDate: {}
}; };
@ -63,12 +58,14 @@ export const diskManagerTask = (input: DiskManagerTask.PoolInput, done) => {
focalLength: exif.tags.FocalLength, focalLength: exif.tags.FocalLength,
lens: exif.tags.LensModel, lens: exif.tags.LensModel,
}; };
metadata.positionData.GPSData = <GPSMetadata> { if (!isNaN(exif.tags.GPSLatitude) || exif.tags.GPSLongitude || exif.tags.GPSAltitude) {
latitude: exif.tags.GPSLatitude, metadata.positionData = metadata.positionData || {};
longitude: exif.tags.GPSLongitude, metadata.positionData.GPSData = <GPSMetadata> {
altitude: exif.tags.GPSAltitude latitude: exif.tags.GPSLatitude,
longitude: exif.tags.GPSLongitude,
}; altitude: exif.tags.GPSAltitude
};
}
metadata.size = <ImageSize> {width: exif.imageSize.width, height: exif.imageSize.height}; metadata.size = <ImageSize> {width: exif.imageSize.width, height: exif.imageSize.height};
} catch (err) { } catch (err) {
@ -89,9 +86,12 @@ export const diskManagerTask = (input: DiskManagerTask.PoolInput, done) => {
return s.join(""); return s.join("");
}; };
metadata.positionData.country = iptcData.country_or_primary_location_name; if (iptcData.country_or_primary_location_name || iptcData.province_or_state || iptcData.city) {
metadata.positionData.state = iptcData.province_or_state; metadata.positionData = metadata.positionData || {};
metadata.positionData.city = iptcData.city; metadata.positionData.country = iptcData.country_or_primary_location_name;
metadata.positionData.state = iptcData.province_or_state;
metadata.positionData.city = iptcData.city;
}
metadata.keywords = <string[]> (iptcData.keywords || []).map((s: string) => decode(s)); metadata.keywords = <string[]> (iptcData.keywords || []).map((s: string) => decode(s));

View File

@ -11,7 +11,7 @@
<gallery-directory *ngFor="let directory of directories" <gallery-directory *ngFor="let directory of directories"
[directory]="directory"></gallery-directory> [directory]="directory"></gallery-directory>
<gallery-map [photos]="_galleryService.content.value.directory.photos"></gallery-map> <gallery-map *ngIf="isPhotoWithLocation" [photos]="_galleryService.content.value.directory.photos"></gallery-map>
<gallery-grid [photos]="_galleryService.content.value.directory.photos" [lightbox]="lightbox"></gallery-grid> <gallery-grid [photos]="_galleryService.content.value.directory.photos" [lightbox]="lightbox"></gallery-grid>
</div> </div>
@ -29,7 +29,7 @@
</li> </li>
</ol> </ol>
<gallery-map [photos]="_galleryService.content.value.searchResult.photos"></gallery-map> <gallery-map *ngIf="isPhotoWithLocation" [photos]="_galleryService.content.value.searchResult.photos"></gallery-map>
<div *ngFor="let directory of directories"> <div *ngFor="let directory of directories">
<gallery-directory *ngIf="directory" [directory]="directory"></gallery-directory> <gallery-directory *ngIf="directory" [directory]="directory"></gallery-directory>

View File

@ -7,6 +7,7 @@ import {GallerySearchComponent} from "./search/search.gallery.component";
import {SearchTypes} from "../../../common/entities/AutoCompleteItem"; import {SearchTypes} from "../../../common/entities/AutoCompleteItem";
import {Config} from "../../../common/config/public/Config"; import {Config} from "../../../common/config/public/Config";
import {DirectoryDTO} from "../../../common/entities/DirectoryDTO"; import {DirectoryDTO} from "../../../common/entities/DirectoryDTO";
import {SearchResultDTO} from "../../../common/entities/SearchResult";
@Component({ @Component({
selector: 'gallery', selector: 'gallery',
@ -20,6 +21,7 @@ export class GalleryComponent implements OnInit {
public showSearchBar: boolean = true; public showSearchBar: boolean = true;
public directories: DirectoryDTO[] = []; public directories: DirectoryDTO[] = [];
public isPhotoWithLocation = false;
constructor(public _galleryService: GalleryService, constructor(public _galleryService: GalleryService,
private _authService: AuthenticationService, private _authService: AuthenticationService,
@ -39,8 +41,23 @@ export class GalleryComponent implements OnInit {
const dirSorter = (a: DirectoryDTO, b: DirectoryDTO) => { const dirSorter = (a: DirectoryDTO, b: DirectoryDTO) => {
return a.name.localeCompare(b.name); return a.name.localeCompare(b.name);
}; };
const dirs = <DirectoryDTO[]>(content.searchResult || content.directory || {directories: []}).directories;
this.directories = dirs.sort(dirSorter); const tmp = <DirectoryDTO | SearchResultDTO>(content.searchResult || content.directory || {
directories: [],
photos: []
});
this.directories = tmp.directories.sort(dirSorter);
this.isPhotoWithLocation = false;
for (let i = 0; i < tmp.photos.length; i++) {
if (tmp.photos[i].metadata &&
tmp.photos[i].metadata.positionData &&
tmp.photos[i].metadata.positionData.GPSData &&
tmp.photos[i].metadata.positionData.GPSData.longitude
) {
this.isPhotoWithLocation = true;
break;
}
}
}); });
this._route.params this._route.params
@ -72,6 +89,7 @@ export class GalleryComponent implements OnInit {
} }
onLightboxLastElement() { onLightboxLastElement() {
this.grid.renderARow(); this.grid.renderARow();
} }