Skip to content
Snippets Groups Projects
Commit 7eec8f16 authored by Hugo SUBTIL's avatar Hugo SUBTIL Committed by Antonin COQUET
Browse files

feat: zoom on town

parent 48eb4460
No related branches found
No related tags found
2 merge requests!96release V1.10.0,!62Dev
...@@ -4,6 +4,7 @@ import { ...@@ -4,6 +4,7 @@ import {
Delete, Delete,
Get, Get,
HttpException, HttpException,
HttpService,
HttpStatus, HttpStatus,
Param, Param,
Post, Post,
...@@ -29,11 +30,28 @@ import { StructuresService } from './services/structures.service'; ...@@ -29,11 +30,28 @@ import { StructuresService } from './services/structures.service';
@Controller('structures') @Controller('structures')
export class StructuresController { export class StructuresController {
constructor( constructor(
private readonly httpService: HttpService,
private readonly structureService: StructuresService, private readonly structureService: StructuresService,
private readonly userService: UsersService, private readonly userService: UsersService,
private readonly tempUserService: TempUserService 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() @Post()
public async create(@Body() createStructureDto: CreateStructureDto): Promise<Structure> { public async create(@Body() createStructureDto: CreateStructureDto): Promise<Structure> {
return this.structureService.create(createStructureDto.idUser, createStructureDto.structure); return this.structureService.create(createStructureDto.idUser, createStructureDto.structure);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment