Add reverse geocoding and show asset location on map in detail view (#43)

* Added reserve geocoding, location in search suggestion, and search by location
* Added mapbox sdk to app
* Added mapbox to image detailed view
This commit is contained in:
Alex 2022-03-10 16:09:03 -06:00 committed by GitHub
parent 251c92ff1e
commit 026f3c24e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 12112 additions and 184 deletions

View file

@ -249,7 +249,7 @@ export class AssetService {
const possibleSearchTerm = new Set<String>();
const rows = await this.assetRepository.query(
`
select distinct si.tags, e.orientation, e."lensModel", e.make, e.model , a.type
select distinct si.tags, e.orientation, e."lensModel", e.make, e.model , a.type, e.city, e.state, e.country
from assets a
left join exif e on a.id = e."assetId"
left join smart_info si on a.id = si."assetId"
@ -274,6 +274,11 @@ export class AssetService {
// Make and model
possibleSearchTerm.add(row['make']?.toLowerCase());
possibleSearchTerm.add(row['model']?.toLowerCase());
// Location
possibleSearchTerm.add(row['city']?.toLowerCase());
possibleSearchTerm.add(row['state']?.toLowerCase());
possibleSearchTerm.add(row['country']?.toLowerCase());
});
return Array.from(possibleSearchTerm).filter((x) => x != null);

View file

@ -61,6 +61,15 @@ export class ExifEntity {
@Column({ type: 'float', nullable: true })
longitude: number;
@Column({ nullable: true })
city: string;
@Column({ nullable: true })
state: string;
@Column({ nullable: true })
country: string;
@OneToOne(() => AssetEntity, { onDelete: 'CASCADE', nullable: true })
@JoinColumn({ name: 'assetId', referencedColumnName: 'id' })
asset: ExifEntity;

View file

@ -1,9 +1,14 @@
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { AuthUserDto, GetAuthUser } from '../../decorators/auth-user.decorator';
import { JwtAuthGuard } from '../../modules/immich-jwt/guards/jwt-auth.guard';
import { ServerInfoService } from './server-info.service';
import mapboxGeocoding, { GeocodeService } from '@mapbox/mapbox-sdk/services/geocoding';
import { MapiResponse } from '@mapbox/mapbox-sdk/lib/classes/mapi-response';
@Controller('server-info')
export class ServerInfoController {
constructor(private readonly serverInfoService: ServerInfoService) {}
constructor(private readonly serverInfoService: ServerInfoService, private readonly configService: ConfigService) {}
@Get()
async getServerInfo() {
@ -16,4 +21,13 @@ export class ServerInfoController {
res: 'pong',
};
}
@UseGuards(JwtAuthGuard)
@Get('/mapbox')
async getMapboxInfo() {
return {
isEnable: this.configService.get('ENABLE_MAPBOX'),
mapboxSecret: this.configService.get('MAPBOX_KEY'),
};
}
}

View file

@ -6,29 +6,4 @@ import { UpdateUserDto } from './dto/update-user.dto';
@Controller('user')
export class UserController {
constructor(private readonly userService: UserService) {}
@Post()
create(@Body() createUserDto: CreateUserDto) {
return this.userService.create(createUserDto);
}
@Get()
findAll() {
return this.userService.findAll();
}
@Get(':id')
findOne(@Param('id') id: string) {
return this.userService.findOne(+id);
}
@Patch(':id')
update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) {
return this.userService.update(+id, updateUserDto);
}
@Delete(':id')
remove(@Param('id') id: string) {
return this.userService.remove(+id);
}
}

View file

@ -11,22 +11,4 @@ export class UserService {
@InjectRepository(UserEntity)
private userRepository: Repository<UserEntity>,
) {}
create(createUserDto: CreateUserDto) {
return 'This action adds a new user';
}
async findAll() {}
findOne(id: number) {
return `This action returns a #${id} user`;
}
update(id: number, updateUserDto: UpdateUserDto) {
return `This action updates a #${id} user`;
}
remove(id: number) {
return `This action removes a #${id} user`;
}
}