mirror of
https://github.com/dedicatedcode/reitti.git
synced 2026-01-09 17:37:57 -05:00
This commit is contained in:
@@ -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 &&
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user