From 8a31efc651e9ca849bef4b483fd59ffee7ebcebd Mon Sep 17 00:00:00 2001 From: Chad Burt Date: Fri, 25 Oct 2024 10:31:16 -0700 Subject: [PATCH] WIP --- packages/h3-filter-ingest/add-geohashes.ts | 15 ++++++++------- packages/h3-filter-ingest/src/server.ts | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/h3-filter-ingest/add-geohashes.ts b/packages/h3-filter-ingest/add-geohashes.ts index bdaa5ff2..b283f183 100644 --- a/packages/h3-filter-ingest/add-geohashes.ts +++ b/packages/h3-filter-ingest/add-geohashes.ts @@ -9,9 +9,9 @@ import * as cliProgress from "cli-progress"; import { stops, Stop } from "./src/stops"; const tilebelt = require("@mapbox/tilebelt"); -const BATCH_SIZE = 5000; // Define the batch size for processing +const BATCH_SIZE = 50_000; // Define the batch size for processing const zoomLevel = 7; -const limits = { min_zoom: zoomLevel, max_zoom: zoomLevel }; +// const limits = { min_zoom: zoomLevel, max_zoom: zoomLevel }; // Define the CLI options const argv = yargs(process.argv.slice(2)) @@ -66,10 +66,10 @@ async function processBatch( const valuesStatements: string[] = []; // Process each geometry in the batch for (const row of result) { - const geohashes: string[] = tileCover.indexes( - JSON.parse(row.geojson), - limits - ); + const geohashes: string[] = tileCover.indexes(JSON.parse(row.geojson), { + min_zoom: stop.zoomLevel, + max_zoom: stop.zoomLevel, + }); // console.log("\n"); @@ -161,7 +161,8 @@ async function prepare() { (async () => { await prepare(); - for (const stop of stops.reverse()) { + const steps = stops.reverse().slice(0, stops.length - 1); + for (const stop of steps) { await processAllRows(stop); } connection.close(); diff --git a/packages/h3-filter-ingest/src/server.ts b/packages/h3-filter-ingest/src/server.ts index 8c53dd55..f1471534 100644 --- a/packages/h3-filter-ingest/src/server.ts +++ b/packages/h3-filter-ingest/src/server.ts @@ -53,7 +53,7 @@ app.get("/mvt/:z/:x/:y", async (c, next) => { const query = ` with ids as ( select - id, + distinct(id), from geohashes where