bugfix(#334): when selecting a date, make sure to not include any bounds (#335)

This commit is contained in:
Daniel Graf
2025-10-06 13:55:32 +02:00
committed by GitHub
parent 71b94b32cc
commit 56a98cb4fd
2 changed files with 11 additions and 21 deletions

View File

@@ -103,10 +103,13 @@ public class LocationDataApiController {
User user = userJdbcService.findById(userId)
.orElseThrow(() -> new RuntimeException("User not found"));
List<RawLocationPoint> pointsInBoxWithNeighbors = this.rawLocationPointJdbcService.findPointsInBoxWithNeighbors(user, startOfRange, endOfRange, minLat, maxLat, minLng, maxLng);
List<RawLocationPoint> pointsInBoxWithNeighbors;
if (minLat == null || maxLat == null || minLng == null || maxLng == null) {
pointsInBoxWithNeighbors = this.rawLocationPointJdbcService.findByUserAndTimestampBetweenOrderByTimestampAsc(user, startOfRange,endOfRange);
} else {
pointsInBoxWithNeighbors = this.rawLocationPointJdbcService.findPointsInBoxWithNeighbors(user, startOfRange, endOfRange, minLat, maxLat, minLng, maxLng);
}
List<List<LocationPoint>> segments = extractPathSegments(pointsInBoxWithNeighbors, minLat, maxLat, minLng, maxLng);
List<RawLocationDataResponse.Segment> result = segments.stream().map(s -> {
List<LocationPoint> simplifiedPoints = simplificationService.simplifyPoints(s, zoom);
return new RawLocationDataResponse.Segment(simplifiedPoints);
@@ -197,6 +200,9 @@ public class LocationDataApiController {
}
private boolean isPointInBox(RawLocationPoint point, Double minLat, Double maxLat, Double minLng, Double maxLng) {
if (minLat == null || maxLat == null || minLng == null || maxLng == null) {
return true;
}
return point.getLatitude() >= minLat &&
point.getLatitude() <= maxLat &&
point.getLongitude() >= minLng &&

View File

@@ -341,19 +341,16 @@
}
function loadTimelineData(startDate, endDate) {
// Load photos for the selected date or date range
if (startDate && endDate && startDate !== endDate) {
// Range mode
photoClient.updatePhotosForRange(startDate, endDate, getUserTimezone());
} else {
// Single date mode
const date = startDate || getSelectedDate();
photoClient.updatePhotosForRange(date, date, getUserTimezone());
}
// Remove pulsating markers when loading new data
removePulsatingMarkers();
// Get raw location points URL from timeline container
const timelineContainer = document.querySelectorAll('.user-timeline-section');
for (const path of rawPointPaths) {
path.remove();
@@ -367,22 +364,13 @@
const rawLocationPointsUrl = element?.dataset.rawLocationPointsUrl;
const color = element?.dataset.baseColor;
if (rawLocationPointsUrl) {
// Get current zoom level
const currentZoom = Math.round(map.getZoom());
// Get bounding box parameters
const bbox = getBoundingBoxParams();
// Build URL with zoom and bounding box parameters
const separator = rawLocationPointsUrl.includes('?') ? '&' : '?';
const urlWithParams = rawLocationPointsUrl + separator +
'zoom=' + currentZoom +
'&minLat=' + bbox.minLat +
'&minLng=' + bbox.minLng +
'&maxLat=' + bbox.maxLat +
'&maxLng=' + bbox.maxLng;
'zoom=' + currentZoom;
// Create fetch promise for raw location points with index to maintain order
const fetchPromise = fetch(urlWithParams).then(response => {
if (!response.ok) {
console.warn('Could not fetch raw location points');
@@ -400,12 +388,9 @@
}
}
// Wait for all fetch operations to complete, then update map in correct order
Promise.all(fetchPromises).then(results => {
// Sort results by original index to maintain order
results.sort((a, b) => a.index - b.index);
// Process results in order
results.forEach(result => {
const fetchBounds = updateMapWithRawPoints(result, result.color);
if (fetchBounds.isValid()) {
@@ -413,7 +398,6 @@
}
});
// Update map bounds after all fetch operations are complete
if (bounds.isValid()) {
window.originalBounds = bounds;
map.fitBounds(bounds, fitToBoundsConfig);