Skip to content
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

Reduce pagination threshold for BAG panden #192

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions frontend/src/services/bag2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,18 @@ export async function fetchBag2dPanden(boundingBox: LatLngBounds, startIndex = 0

const json = await response.json() as ResponseBody

// Recursively fetch the next page.
//
// There seems no consistent indication of whether there are more results.
// We assume this is the last page if there are less than 900 results.
// We assume this is the last page if there are less results than below.
const paginationThreshold = 800

// Recursively fetch the next page.
//
// There is sometimes overlap between the last items of the previous page
// and the first items of the next page.
// We remove these duplicates by using a Map.
return json.features.reduce((map, feature) => {
return map.set(BigInt(feature.properties.identificatie), feature)
}, json.features.length > 900 ? await fetchBag2dPanden(boundingBox, startIndex + json.features.length) : new Map<BigInt, Bag2DPand>())
}, json.features.length > paginationThreshold ? await fetchBag2dPanden(boundingBox, startIndex + json.features.length) : new Map<BigInt, Bag2DPand>())
}

// definitie van de Nederlandse coördinatenstelsel
Expand Down
Loading