File

src/images/image.controller.ts

Prefix

images

Index

Methods

Methods

Async getDashCameraImages
getDashCameraImages(surveyId: string)
Decorators :
@Get('dash-camera/survey/:id')

Return the information of xf for a given survey

Parameters :
Name Type Optional Description
surveyId string No

the survey id

Returns : Promise<IImage[]>
Async getImagesForWays
getImagesForWays(type: string, wayIds: OSMWayId[])
Decorators :
@Post(':type/path')

Get the data indicators for specific consecutive ways.

Parameters :
Name Type Optional Description
type string No

road-surface or dash-camera

wayIds OSMWayId[] No

the ways (osm) ids

Returns : unknown
Async getRoadImagesOfASurvey
getRoadImagesOfASurvey(surveyId: string)
Decorators :
@Get('road-surface/survey/:id')

Return the information of road surface images for a given survey

Parameters :
Name Type Optional Description
surveyId string No

the survey id

Returns : Promise<IImage[]>
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { ImageService } from './image.service';
import { IImage } from '../tables';
import { OSMWayId } from '../models';

@Controller('images')
export class ImageController {
  constructor(private readonly service: ImageService) {}

  /**
   * Return the information of road surface images for a given survey
   *
   * @param surveyId the survey id
   *
   * @author Kerbourc'h
   */
  @Get('road-surface/survey/:id')
  async getRoadImagesOfASurvey(
    @Param('id') surveyId: string,
  ): Promise<IImage[]> {
    return await this.service.getRoadSurfaceImages(surveyId);
  }

  /**
   * Return the information of xf for a given survey
   *
   * @param surveyId the survey id
   *
   * @author Chen
   */
  @Get('dash-camera/survey/:id')
  async getDashCameraImages(@Param('id') surveyId: string): Promise<IImage[]> {
    return await this.service.getDashCameraImages(surveyId);
  }

  /**
   * Get the data indicators for specific consecutive ways.
   * @param type road-surface or dash-camera
   * @param wayIds the ways (osm) ids
   *
   * @author Kerbourc'h
   */
  @Post(':type/path')
  async getImagesForWays(
    @Param('type') type: string,
    @Body() wayIds: OSMWayId[],
  ) {
    const dataForWays = await Promise.all(
      wayIds.map((id: string) =>
        this.service.getWayImages(id, type === 'dash-camera'),
      ),
    );

    const data: IImage[] = [];

    let distanceFromBeginning = 0;

    for (let i = 0; i < dataForWays.length; i++) {
      data.push(
        ...dataForWays[i].images.map((image) => ({
          ...image,
          distance_way:
            i === 0
              ? image.distance_way
              : image.distance_way + distanceFromBeginning,
        })),
      );
      distanceFromBeginning += dataForWays[i].length;
    }

    return data;
  }
}

results matching ""

    No results matching ""