Skip to content

Commit

Permalink
Fix #168 but only writing tables to files if there are any batch reco…
Browse files Browse the repository at this point in the history
…rds to speak of.
  • Loading branch information
Benjamin Clark committed Oct 2, 2024
1 parent df8678f commit 999499a
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions site/src/nav/DownloadButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,25 @@ function DownloadButton({ mode, zoom, setZoom, visibleTypes}) {
}).then((tableReads) => Promise.all(tableReads)
.then((wasmTables) => {
wasmTables.map(wasmTable => {
//Create a blob
// const binaryDataForDownload = writeGeoParquet(wasmTable);
const binaryDataForDownload = writeGeoJSON(wasmTable.reader);
if (wasmTable?.reader?.numBatches > 0) {
const binaryDataForDownload = writeGeoJSON(wasmTable.reader);

let blerb = new Blob([binaryDataForDownload], {
type: "application/octet-stream",
});

//Download the blob
// window.open(URL.createObjectURL(blerb));

const url = URL.createObjectURL(blerb);
var downloadLink = document.createElement("a");
downloadLink.href = url;

const center = myMap.getCenter();
const zoom = myMap.getZoom();
downloadLink.download = `overture-${wasmTable.type}-${zoom}-${center.lat}-${center.lng}.geojson`;

document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
let blerb = new Blob([binaryDataForDownload], {
type: "application/octet-stream",
});

const url = URL.createObjectURL(blerb);
var downloadLink = document.createElement("a");
downloadLink.href = url;

const center = myMap.getCenter();
const zoom = myMap.getZoom();
downloadLink.download = `overture-${wasmTable.type}-${zoom}-${center.lat}-${center.lng}.geojson`;

document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
}
})
}).then(() => {
setLoading(false);
Expand Down

0 comments on commit 999499a

Please sign in to comment.