-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[api] Cost surfaces tiles endpoint [MRXN23-118] #1539
[api] Cost surfaces tiles endpoint [MRXN23-118] #1539
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
e4ad039
to
7d8893f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @yulia-bel, overall all is good and it works as expected as far as I could check.
Besides adding OpenAPI docs decorators to the main API (because that's what FE devs use as reference - in theory we could even drop openapi docs from the geoprocessing service altogether!), my only other comment is about something happening even with the newest simplification algorithm backported from Alicia's recent implementation - I'm getting simplification artifacts for a tile such as 6/34/34 for an Okavango test project: the end result looks kind of neat, but it's not what users will expect:
@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], | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should have this OpenAPI documentation in the api controller, besides what is there already
const { z, x, y, costSurfaceId } = tileSpecification; | ||
const simplificationLevel = 360 / (Math.pow(2, z + 1) * 100); | ||
const attributes = 'cost'; | ||
const table = `(SELECT ST_RemoveRepeatedPoints((st_dump(the_geom)).geom, ${simplificationLevel}) AS the_geom, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
about my earlier comment on simplification artifacts - maybe we could avoid applying simplification altogether here? what do you think @aagm?
in a way, we're dealing with one single set of geometries, those of a project's grid, and so I think this is less crucial than when dealing with features, where each can have their own intricated and extensive geometries. In the case of regular (hex/square) grids, geometries will end up being quite simple overall (though we may have very many, in some cases); in the case of user-uploaded grids, things can indeed be more complicated, though.
@yulia-bel if you end up doing more changes (bbox, openapi docs, whatnot), please give a final cleanup (unused imports or parameters) - no need to touch these if you're not going to make any other changes (so that we don't have to wait for CI to run again - or if you do cosmetic cleanups only, let's consider the latest good CI run as good enough as in, we can assume that cosmetic changes won't break anything 😬) |
@@ -263,7 +263,6 @@ export class ProjectCostSurfaceController { | |||
|
|||
@ImplementsAcl() | |||
@UseGuards(JwtAuthGuard) | |||
@TilesOpenApi() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yulia-bel apologies, I had completely missed that this decorator was in place (and I had actually completely forgotten about it even existing). This was correct, we had all the params documented via this decorator. I just meant that we would not necessarily need OpenAPI docs for the geoprocessing endpoint, but here all was correct - sorry!
The only glitch here is that @TilesOpenApi()
includes the @ApiQuery
decorator for bbox
, which we may not want here. If we wanted to optionally exclude the bbox param (so that we don't have to touch any of the existing uses of the @TilesOpenApi()
decorator), we could change the decorator with something like the patch below
diff --git a/api/libs/tiles/src/tiles-api-doc.ts b/api/libs/tiles/src/tiles-api-doc.ts
index 7beb84368..965d0ca5f 100644
--- a/api/libs/tiles/src/tiles-api-doc.ts
+++ b/api/libs/tiles/src/tiles-api-doc.ts
@@ -7,7 +7,16 @@ import {
ApiUnauthorizedResponse,
} from '@nestjs/swagger';
-export const TilesOpenApi = () =>
+export const TilesOpenApi = (excludeBbox: boolean) => {
+ const bboxDecorator = excludeBbox ? [] : [
+ ApiQuery({
+ name: 'bbox',
+ description: 'Bounding box of the project [xMin, xMax, yMin, yMax]',
+ type: [Number],
+ required: false,
+ example: [-1, 40, 1, 42],
+ }),
+ ];
applyDecorators(
...[
ApiParam({
@@ -35,13 +44,6 @@ export const TilesOpenApi = () =>
required: false,
example: 'e5c3b978-908c-49d3-b1e3-89727e9f999c',
}),
- ApiQuery({
- name: 'bbox',
- description: 'Bounding box of the project [xMin, xMax, yMin, yMax]',
- type: [Number],
- required: false,
- example: [-1, 40, 1, 42],
- }),
ApiOkResponse({
description: 'Binary protobuffer mvt tile',
type: String,
@@ -49,4 +51,6 @@ export const TilesOpenApi = () =>
ApiBadRequestResponse(),
ApiUnauthorizedResponse(),
],
- );
+ ...bboxDecorator
+ );
+ };
a3c2a37
to
582fec6
Compare
Add Cost surfaces tiles endpoint
Overview
New endpoint in ProjectCostSurfaceController to retrieve Cost Surface tiles.
Implementation is similar to the endpoint for tiles for Geo Features
Designs
Link to the related design prototypes (if applicable)
Testing instructions
Please explain how to test the PR: ID of a dataset, steps to reach the feature, etc.
Feature relevant tickets
Link to the related task manager tickets
Checklist before submitting
develop
.deploying to staging/production, please add brief testing instructions
to the deploy checklist (
docs/deployment-checklist.md
)