2024-07-29 18:17:26 -04:00
|
|
|
import { Controller, Get, HttpCode, HttpStatus, Query } from '@nestjs/common';
|
2025-11-13 08:18:43 -05:00
|
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
|
|
|
import { Endpoint, HistoryBuilder } from 'src/decorators';
|
2024-05-29 17:51:01 +02:00
|
|
|
import { AuthDto } from 'src/dtos/auth.dto';
|
2024-07-29 18:17:26 -04:00
|
|
|
import {
|
|
|
|
|
MapMarkerDto,
|
|
|
|
|
MapMarkerResponseDto,
|
|
|
|
|
MapReverseGeocodeDto,
|
|
|
|
|
MapReverseGeocodeResponseDto,
|
|
|
|
|
} from 'src/dtos/map.dto';
|
2025-11-11 17:01:14 -05:00
|
|
|
import { ApiTag } from 'src/enum';
|
2024-05-29 17:51:01 +02:00
|
|
|
import { Auth, Authenticated } from 'src/middleware/auth.guard';
|
|
|
|
|
import { MapService } from 'src/services/map.service';
|
|
|
|
|
|
2025-11-11 17:01:14 -05:00
|
|
|
@ApiTags(ApiTag.Map)
|
2024-05-29 17:51:01 +02:00
|
|
|
@Controller('map')
|
|
|
|
|
export class MapController {
|
|
|
|
|
constructor(private service: MapService) {}
|
|
|
|
|
|
|
|
|
|
@Get('markers')
|
|
|
|
|
@Authenticated()
|
2025-11-13 08:18:43 -05:00
|
|
|
@Endpoint({
|
2025-11-11 17:01:14 -05:00
|
|
|
summary: 'Retrieve map markers',
|
|
|
|
|
description: 'Retrieve a list of latitude and longitude coordinates for every asset with location data.',
|
2025-11-13 08:18:43 -05:00
|
|
|
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
2025-11-11 17:01:14 -05:00
|
|
|
})
|
2024-05-29 17:51:01 +02:00
|
|
|
getMapMarkers(@Auth() auth: AuthDto, @Query() options: MapMarkerDto): Promise<MapMarkerResponseDto[]> {
|
|
|
|
|
return this.service.getMapMarkers(auth, options);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-29 18:17:26 -04:00
|
|
|
@Authenticated()
|
|
|
|
|
@Get('reverse-geocode')
|
|
|
|
|
@HttpCode(HttpStatus.OK)
|
2025-11-13 08:18:43 -05:00
|
|
|
@Endpoint({
|
2025-11-11 17:01:14 -05:00
|
|
|
summary: 'Reverse geocode coordinates',
|
|
|
|
|
description: 'Retrieve location information (e.g., city, country) for given latitude and longitude coordinates.',
|
2025-11-13 08:18:43 -05:00
|
|
|
history: new HistoryBuilder().added('v1').beta('v1').stable('v2'),
|
2025-11-11 17:01:14 -05:00
|
|
|
})
|
2024-07-29 18:17:26 -04:00
|
|
|
reverseGeocode(@Query() dto: MapReverseGeocodeDto): Promise<MapReverseGeocodeResponseDto[]> {
|
|
|
|
|
return this.service.reverseGeocode(dto);
|
|
|
|
|
}
|
2024-05-29 17:51:01 +02:00
|
|
|
}
|