Skip to content

Commit

Permalink
Cost surface tile endpoint cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yulia-bel committed Oct 11, 2023
1 parent e908c83 commit b7d57b8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Get,
Inject,
Param,
ParseIntPipe,
ParseUUIDPipe,
Patch,
Post,
Expand Down Expand Up @@ -49,7 +48,6 @@ import {
import { ensureShapefileHasRequiredFiles } from '@marxan-api/utils/file-uploads.utils';
import { UpdateCostSurfaceDto } from '@marxan-api/modules/cost-surface/dto/update-cost-surface.dto';
import { CostSurfaceSerializer } from '@marxan-api/modules/cost-surface/dto/cost-surface.serializer';
import { TilesOpenApi } from '@marxan/tiles';
import { Response } from 'express';
import { ProxyService } from '@marxan-api/modules/proxy/proxy.service';
import {
Expand Down Expand Up @@ -273,15 +271,30 @@ export class ProjectCostSurfaceController {
name: 'projectId',
description: 'The id of the Project that the Cost Surface is associated to',
})
@Get(':projectId/cost-surface/:costSurfaceId/preview/tiles/:z/:x/:y.mvt')
@ApiParam({
name: 'z',
description: 'The zoom level ranging from 0 - 20',
type: Number,
required: true,
})
@ApiParam({
name: 'x',
description: 'The tile x offset on Mercator Projection',
type: Number,
required: true,
})
@ApiParam({
name: 'y',
description: 'The tile y offset on Mercator Projection',
type: Number,
required: true,
})
@Get(':projectId/cost-surfaces/:costSurfaceId/preview/tiles/:z/:x/:y.mvt')
async proxyCostSurfaceTile(
@Req() req: RequestWithAuthenticatedUser,
@Res() response: Response,
@Param('projectId', ParseUUIDPipe) projectId: string,
@Param('costSurfaceId', ParseUUIDPipe) costSurfaceId: string,
@Param('z', ParseIntPipe) z: number,
@Param('x', ParseIntPipe) x: number,
@Param('y', ParseIntPipe) y: number,
): Promise<void> {
const checkCostSurfaceForProject = await this.costSurfaceService.checkProjectCostSurfaceVisibility(
req.user.id,
Expand All @@ -293,8 +306,8 @@ export class ProjectCostSurfaceController {
}

req.url = req.url.replace(
`projects/${projectId}/cost-surface/`,
`cost-surfaces/`,
`projects/${projectId}/`,
``,
);

return await this.proxyService.proxyTileRequest(req, response);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import {
Controller,
Get,
Header,
Logger,
Param,
Query,
Res,
} from '@nestjs/common';
import { apiGlobalPrefixes } from '@marxan-geoprocessing/api.config';
import {
ApiBadRequestResponse,
ApiOperation,
ApiParam,
ApiQuery,
} from '@nestjs/swagger';
import { BBox } from 'geojson';

import { Response } from 'express';
import { setTileResponseHeadersForSuccessfulRequests } from '@marxan/tiles';
Expand All @@ -32,37 +27,6 @@ export class CostSurfaceController {
@ApiOperation({
description: 'Get tile for a cost surface by id.',
})
@ApiParam({
name: 'z',
description: 'The zoom level ranging from 0 - 20',
type: Number,
required: true,
})
@ApiParam({
name: 'x',
description: 'The tile x offset on Mercator Projection',
type: Number,
required: true,
})
@ApiParam({
name: 'y',
description: 'The tile y offset on Mercator Projection',
type: Number,
required: true,
})
@ApiParam({
name: 'id',
description: 'Specific id of the cost surface',
type: String,
required: true,
})
@ApiQuery({
name: 'bbox',
description: 'Bounding box of the project',
type: [Number],
required: false,
example: [-1, 40, 1, 42],
})
@Get(':costSurfaceId/preview/tiles/:z/:x/:y.mvt')
@ApiBadRequestResponse()
async getTile(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { Injectable, Logger, Inject } from '@nestjs/common';
import { TileService } from '@marxan-geoprocessing/modules/tile/tile.service';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { IsArray, IsNumber, IsString, IsOptional } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { BBox } from 'geojson';
import { antimeridianBbox, nominatim2bbox } from '@marxan/utils/geo';

import { TileRequest } from '@marxan/tiles';

import { CostSurfacePuDataEntity } from '@marxan/cost-surfaces';
Expand All @@ -34,8 +31,6 @@ export class CostSurfaceService {
private readonly logger: Logger = new Logger(CostSurfaceService.name);

constructor(
@InjectRepository(CostSurfacePuDataEntity)
private readonly costSurfaceDataRepository: Repository<CostSurfacePuDataEntity>,
private readonly tileService: TileService,
) {}

Expand Down

1 comment on commit b7d57b8

@vercel
Copy link

@vercel vercel bot commented on b7d57b8 Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

marxan – ./

marxan-vizzuality1.vercel.app
marxan-git-develop-vizzuality1.vercel.app
marxan23.vercel.app

Please sign in to comment.