Skip to content

Commit

Permalink
Trying to add tile filitering
Browse files Browse the repository at this point in the history
  • Loading branch information
underbluewaters committed Oct 21, 2024
1 parent 1354988 commit c03e888
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/h3-filter-ingest/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ const server = createServer(async (req, res) => {
${f.values.length > 0 ? f.where : "true"}
${
rootTile
? `AND r${h3.getResolution(
rootTile
)}_id = h3_string_to_h3('${rootTile}')`
? `AND r${h3.getResolution(rootTile)}_id = h3_string_to_h3($${
f.values.length + 1
}::varchar)::uint64`
: ""
}
)
Expand Down Expand Up @@ -236,23 +236,23 @@ const server = createServer(async (req, res) => {
) as r6
from filtered
`;

db.all(query, ...f.values, async (err: any, data: any) => {
const values = rootTile ? [...f.values, rootTile] : [...f.values];
console.log("query", query, values);
db.all(query, ...values, async (err: any, data: any) => {
console.timeEnd("query");

const count = (
await get<{ count: number }>(
`Select count(id)::int as count from cells where ${f.where}`,
f.values
)
).count;
if (err) {
console.error(err);
res.statusCode = 500;
res.setHeader("Access-Control-Allow-Origin", "*");
res.end("Error querying database");
return;
}
const count = (
await get<{ count: number }>(
`Select count(id)::int as count from cells where ${f.where}`,
f.values
)
).count;
type CellsByResolution = {
[resolution: number]: string[];
};
Expand Down

0 comments on commit c03e888

Please sign in to comment.