diff --git a/backend/src/conditions/rc.controller.ts b/backend/src/conditions/rc.controller.ts index e5d5da73..815dbc70 100644 --- a/backend/src/conditions/rc.controller.ts +++ b/backend/src/conditions/rc.controller.ts @@ -23,6 +23,14 @@ export class RCController { return this.service.getWayRoadConditions(wayId, type); } + @Get('way2') + getWay2Conditions( + @Query() query: { dbId: string; type: string }, + ): Promise { + const { dbId, type } = query; + return this.service.getWay2RoadConditions(dbId, type); + } + @Get('') getConditions( @Query() diff --git a/backend/src/conditions/rc.service.ts b/backend/src/conditions/rc.service.ts index 76470506..94a487d2 100644 --- a/backend/src/conditions/rc.service.ts +++ b/backend/src/conditions/rc.service.ts @@ -3,7 +3,13 @@ import { Injectable } from '@nestjs/common'; import { InjectConnection, Knex } from 'nestjs-knex'; import { Condition, LatLngDist, WayId, WaysConditions } from 'src/models'; import groupBy from '../util'; -import { RoadConditions, Ways, ZoomConditions, Conditions2 } from '../tables'; +import { + RoadConditions, + Ways, + ZoomConditions, + Conditions2, + Conditions, +} from '../tables'; import knexPostgis = require('knex-postgis'); @@ -54,6 +60,16 @@ export class RCService { .orderBy('way_dist'); } + async getWay2RoadConditions( + dbId: string, + type: string, + ): Promise { + return Conditions(this.knex_liramap) + .select('fk_way_id', 'type', 'value', 'compute_time') + .where({ type: type, fk_way_id: dbId }) + .orderBy('compute_time'); + } + async getZoomConditions( type: string, zoom: string, diff --git a/backend/src/tables.ts b/backend/src/tables.ts index 59894e68..ad4d7b6d 100644 --- a/backend/src/tables.ts +++ b/backend/src/tables.ts @@ -33,6 +33,7 @@ export const ZoomConditions = (k: Knex) => // ekki@dtu.dk: This is for PostGIS in the LiRAMap (LiraVis) database export interface Condition_Coverage { id: string; + fk_way_id: string; type: string; value: number; section_geom: Geometry;