Skip to content

Commit 791b0f4

Browse files
committed
worldjumping
1 parent afe033d commit 791b0f4

File tree

3 files changed

+2
-43
lines changed

3 files changed

+2
-43
lines changed

src/App.svelte

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,17 @@
33
import Map from "./lib/Map.svelte";
44
import SlidingPane from "./lib/SlidingPane.svelte";
55
import { getGeoEntriesInBounds, getUniqueByGeoHash } from "./lib/geodata";
6-
import { Mixin } from "leaflet";
76
87
let markers = [];
98
109
let dataStatus = "not started";
11-
let mapBounds = {
12-
northEast: { lat: 0, lon: 0 },
13-
southWest: { lat: 0, lon: 0 },
14-
};
1510
1611
// State to control the sliding pane
1712
let isPaneOpen = false;
1813
let wikiPage = "";
1914
2015
// State for selected marker
2116
let selectedMarker = null;
22-
let mapCenter = [51.508056, -0.076111];
2317
let mapZoom = 1;
2418
2519
// Add a target location state
@@ -84,24 +78,21 @@
8478
async function handleBoundsChange(event) {
8579
const center = event.detail.center;
8680
mapZoom = event.detail.zoom;
87-
console.log("mapZoom", mapZoom);
88-
mapCenter = [center.lat, center.lon];
81+
console.log(event.detail.center);
8982
const bounds = {
9083
minLat: event.detail.bounds._southWest.lat,
9184
maxLat: event.detail.bounds._northEast.lat,
9285
minLon: event.detail.bounds._southWest.lng,
9386
maxLon: event.detail.bounds._northEast.lng,
9487
};
9588
const entries = await getGeoEntriesInBounds(bounds);
96-
console.log(mapZoom, Math.max(1, Math.min(8, mapZoom / 2)));
9789
const hashlevel = Math.max(1, Math.min(8, mapZoom / 2));
9890
const uniqueEntries = getUniqueByGeoHash({
9991
entries,
10092
hashLength: hashlevel,
10193
scoreField: "page_len",
10294
});
10395
addCosmeticsToEntries(uniqueEntries, hashlevel);
104-
console.log("Unique entries:", uniqueEntries);
10596
markers = uniqueEntries;
10697
}
10798
onMount(async () => {
@@ -110,18 +101,6 @@
110101
</script>
111102

112103
<main>
113-
<div class="status-bar">
114-
<span>Status: {dataStatus}</span>
115-
<span>
116-
Bounds: NE({mapBounds.northEast.lat.toFixed(4)},
117-
{mapBounds.northEast.lon.toFixed(4)}) - SE({mapBounds.southWest.lat.toFixed(
118-
4
119-
)},
120-
{mapBounds.southWest.lon.toFixed(4)})</span
121-
>
122-
<button on:click={() => openWikiPane("London")}>Open Wikipedia</button>
123-
</div>
124-
125104
<Map
126105
{markers}
127106
targetLocation={targetMapLocation}

src/lib/Map.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
// Initialize the map
8383
map = L.map(mapElement, {
8484
zoomControl: false, // Disable default zoom control
85+
worldCopyJump: true,
8586
}).setView([0, 0], 1);
8687
flyTo(targetLocation);
8788

src/lib/geodata.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export async function loadCsvGzFile(url) {
6464
try {
6565
// Make sure URL starts with correct path
6666
const fullUrl = url.startsWith('/') ? url : `/${url}`;
67-
console.log(`Fetching from: ${fullUrl}`);
6867

6968
// Fetch the gzipped CSV file
7069
const response = await fetch(fullUrl);
@@ -76,7 +75,6 @@ export async function loadCsvGzFile(url) {
7675
// Parse CSV directly from response text
7776
const csvText = await response.text();
7877
const rows = parseCsv(csvText);
79-
console.log(`Loaded data from ${fullUrl} with ${rows.length} rows`);
8078

8179
return rows;
8280
} catch (error) {
@@ -100,15 +98,8 @@ function parseCsv(csvText) {
10098
}
10199

102100
const lines = csvText.trim().split('\n');
103-
console.log(`CSV has ${lines.length} lines. First line: ${lines[0]}`);
104101

105102
const headers = lines[0].split('\t').map(h => h.trim());
106-
console.log(`Found headers: ${headers.join(', ')}`);
107-
108-
if (lines.length === 1) {
109-
console.warn("CSV only has a header line, no data");
110-
return [];
111-
}
112103

113104
// Pre-allocate array for better performance
114105
const rows = new Array(lines.length - 1);
@@ -128,12 +119,6 @@ function parseCsv(csvText) {
128119
rows[i-1] = row;
129120
}
130121

131-
const endTime = performance.now();
132-
console.log(`Successfully parsed ${rows.length} rows from CSV in ${(endTime - startTime).toFixed(2)}ms`);
133-
if (rows.length > 0) {
134-
console.log(`Sample row: ${JSON.stringify(rows[0])}`);
135-
}
136-
137122
return rows;
138123
} catch (error) {
139124
console.error("Error parsing CSV:", error);
@@ -153,7 +138,6 @@ export async function addDataFromUrl(url) {
153138
// Add the new rows to the collection
154139
geoCollection.insert(newRows);
155140

156-
console.log(`Updated geodata collection now has ${geoCollection.count()} rows`);
157141
return newRows;
158142
}
159143

@@ -165,7 +149,6 @@ export async function addDataFromUrl(url) {
165149
export async function getGeoEntriesInBounds({minLat, maxLat, minLon, maxLon}) {
166150
// Handle possible null/undefined bounds
167151
const geohashes_1 = ngeohash.bboxes(minLat, minLon, maxLat, maxLon, 1);
168-
console.log({geohashes_1})
169152

170153
if (!Array.isArray(geohashes_1) || geohashes_1.length === 0) {
171154
console.warn("No geohashes found for the current bounds");
@@ -200,7 +183,6 @@ export async function getGeoEntriesInBounds({minLat, maxLat, minLon, maxLon}) {
200183
// Download and ingest any new geohash files that haven't been processed yet
201184
// Use consistent path format without leading dot or slash
202185
const needDownload = geohashes_1.filter(g => !ingestedFiles.includes(`_geodata/${g}.csv.gz`));
203-
console.log({needDownload})
204186

205187
if (needDownload.length > 0) {
206188
// needDownload all rows first before doing a single bulk insert
@@ -225,10 +207,7 @@ export async function getGeoEntriesInBounds({minLat, maxLat, minLon, maxLon}) {
225207

226208
// Do a single bulk insert with all rows
227209
if (allRows.length > 0) {
228-
console.time('bulk_insert');
229210
geoCollection.insert(allRows);
230-
console.timeEnd('bulk_insert');
231-
console.log('Collection size:', geoCollection.count());
232211
}
233212
}
234213

0 commit comments

Comments
 (0)