Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MaGOs92 committed Oct 1, 2024
1 parent 3a00cae commit 1149548
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/app/api/deploiement-stats/[z]/[x]/[y].pbf/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getCachedData } from '@/utils/cache'
import geojsonVt from 'geojson-vt'
import vtpbf from 'vt-pbf'

const used = process.memoryUsage().heapUsed / 1024 / 1024
const getMemoryUsage = () => Math.round(process.memoryUsage().heapUsed / 1024 / 1024 * 100) / 100

const computeTiles = async () => {
const statsData = await getCachedData('stats-data', fetchStatsData)
Expand All @@ -13,11 +13,11 @@ const computeTiles = async () => {
}

export async function GET(_request: Request, { params }: { params: { x: string, y: string, z: string } }) {
console.log(`Before getting cache ${Math.round(used * 100) / 100} MB`)
console.log(`Before getting cache ${getMemoryUsage()} MB`)

const tiles = await getCachedData('deploiement-tiles', computeTiles)

console.log(`After getting cache ${Math.round(used * 100) / 100} MB`)
console.log(`After getting cache ${getMemoryUsage()} MB`)

const z = Number.parseInt(params.z, 10)
const x = Number.parseInt(params.x, 10)
Expand All @@ -31,7 +31,7 @@ export async function GET(_request: Request, { params }: { params: { x: string,

const pbf = vtpbf.fromGeojsonVt({ communes: tile })

console.log(`After generating PBF ${Math.round(used * 100) / 100} MB`)
console.log(`After generating PBF ${getMemoryUsage()} MB`)

return new Response(pbf, { headers: { 'Content-Type': 'application/x-protobuf' } })
}

0 comments on commit 1149548

Please sign in to comment.