Skip to content
Snippets Groups Projects

feat: zoom on town

Merged Hugo SUBTIL requested to merge feat/map-zoom-on-town into dev
1 file
+ 18
0
Compare changes
  • Side-by-side
  • Inline
@@ -4,6 +4,7 @@ import {
Delete,
Get,
HttpException,
HttpService,
HttpStatus,
Param,
Post,
@@ -29,11 +30,28 @@ import { StructuresService } from './services/structures.service';
@Controller('structures')
export class StructuresController {
constructor(
private readonly httpService: HttpService,
private readonly structureService: StructuresService,
private readonly userService: UsersService,
private readonly tempUserService: TempUserService
) {}
/**
* Return points of given town exist.
* @param zipcode
* @returns Array of points
*/
@Get('coordinates/:zipcode')
@ApiParam({ name: 'zipcode', type: String, required: true })
public async getCoordinates(@Param('zipcode') city: string): Promise<any> {
return await this.httpService
.get(encodeURI('https://download.data.grandlyon.com/geocoding/photon-bal/api?q=' + city))
.toPromise()
.then(async (res) => res.data.features)
.then((data) => data.filter((cityPoint) => cityPoint.properties.city.toLowerCase().includes(city.toLowerCase())))
.then((data) => data.map((filteredCityPoint) => filteredCityPoint.geometry.coordinates));
}
@Post()
public async create(@Body() createStructureDto: CreateStructureDto): Promise<Structure> {
return this.structureService.create(createStructureDto.idUser, createStructureDto.structure);
Loading