Skip to content

Commit d4d05e9

Browse files
committed
Remove unused functions
1 parent d932593 commit d4d05e9

File tree

2 files changed

+1
-85
lines changed

2 files changed

+1
-85
lines changed

src/components/SlippyMap/index.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
unclusterLabelLayer,
2929
unclusterPointLayer,
3030
} from './layers'
31-
import { transformMapOptions, transformSourceOptions } from './options'
31+
import { getResolutionForZoom, transformMapOptions, transformSourceOptions } from './options'
3232
import type { ClusteredMarkers } from '../../lib/generate-clusters'
3333

3434
const MAPBOX_TOKEN = 'pk.eyJ1IjoiZGFuYWN0aXZlIiwiYSI6ImNreHhqdXkwdjcyZnEzMHBmNzhiOWZsc3QifQ.gCRigL866hVF6GNHoGoyRg'
@@ -64,16 +64,6 @@ export default function SlippyMap({
6464
const prevCoordsRef = useRef<[number, number]>([0, 0])
6565
const prevZoomRef = useRef<number>(metaZoom)
6666

67-
// Track current zoom resolution (not every zoom tick, only when crossing thresholds)
68-
// Update the resolution helper to match new resolutions
69-
const getResolutionForZoom = (z: number): string => {
70-
if (z >= 17) return '100m'
71-
if (z >= 14) return '300m'
72-
if (z >= 10) return '1.5km'
73-
if (z >= 6) return '5km'
74-
return '10km'
75-
}
76-
7767
const [currentResolution, setCurrentResolution] = useState(() =>
7868
getResolutionForZoom(zoom),
7969
)

src/components/SlippyMap/options.ts

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -165,77 +165,3 @@ export function getResolutionForZoom(zoom: number): ResolutionKey {
165165
if (zoom >= 6) return '5km' // province/state level
166166
return '10km' // country/region level
167167
}
168-
169-
/**
170-
* Calculate most common labels at multiple resolutions
171-
* Items are sorted by frequency (most common first) for better Mapbox clustering
172-
*/
173-
function calculateMultiResolutionLabels(items: Item[]): MultiResolutionLabels {
174-
const RESOLUTION_TO_METERS: Record<ResolutionKey, number> = {
175-
'100m': 1000,
176-
'300m': 300,
177-
'1.5km': 67,
178-
'5km': 20,
179-
'10km': 10,
180-
}
181-
182-
const labels = new Map<string, Map<ResolutionKey, string>>()
183-
const itemFrequency = new Map<string, number>()
184-
185-
// Process each resolution
186-
Object.entries(RESOLUTION_TO_METERS).forEach(([resolution, multiplier]) => {
187-
const resKey = resolution as ResolutionKey
188-
189-
// Group items by this resolution's grid
190-
const grouped = items.reduce((acc, item) => {
191-
const { latitude, longitude, isInvalidPoint } = validatePoint(item.coordinates)
192-
if (isInvalidPoint) return acc
193-
194-
const gridKey = `${Math.round(latitude * multiplier) / multiplier},${Math.round(longitude * multiplier) / multiplier}`
195-
if (!acc[gridKey]) acc[gridKey] = []
196-
acc[gridKey].push(item)
197-
return acc
198-
}, {} as Record<string, Item[]>)
199-
200-
// For each grid cell, find most common label
201-
Object.entries(grouped).forEach(([gridKey, group]) => {
202-
const labelCounts: Record<string, number> = {}
203-
group.forEach(item => {
204-
// Use resolution-appropriate label
205-
const label = getLabelForResolution(item, resKey)
206-
if (label && label !== 'Unknown') {
207-
labelCounts[label] = (labelCounts[label] || 0) + 1
208-
}
209-
})
210-
211-
const mostCommon = Object.entries(labelCounts)
212-
.sort(([, a], [, b]) => b - a)[0]?.[0] || 'Unknown'
213-
214-
// Store how frequent each item's label is in this grid (for sorting)
215-
group.forEach(item => {
216-
const { latitude, longitude } = validatePoint(item.coordinates)
217-
const coordKey = `${Math.round(latitude * multiplier) / multiplier},${Math.round(longitude * multiplier) / multiplier}`
218-
219-
// Use resolution-appropriate label for frequency counting too
220-
const itemLabel = getLabelForResolution(item, resKey)
221-
const frequency = labelCounts[itemLabel] || 0
222-
223-
// Track max frequency across all resolutions
224-
const currentFreq = itemFrequency.get(coordKey) || 0
225-
if (frequency > currentFreq) {
226-
itemFrequency.set(coordKey, frequency)
227-
}
228-
229-
// Initialize map if needed
230-
if (!labels.has(coordKey)) {
231-
labels.set(coordKey, new Map<ResolutionKey, string>())
232-
}
233-
234-
// Store label for this resolution
235-
labels.get(coordKey)!.set(resKey, mostCommon)
236-
})
237-
})
238-
})
239-
240-
return { labels, itemFrequency }
241-
}

0 commit comments

Comments
 (0)