체류 지점 방문 내역 합산 표시

This commit is contained in:
seo
2026-07-12 13:28:44 +09:00
parent 1238d80397
commit 4074d6f991
2 changed files with 40 additions and 10 deletions
+39 -9
View File
@@ -479,6 +479,7 @@ const PLAYBACK_SPEEDS = [2, 5, 10, 20, 50, 100, 500];
const PLAYBACK_MIN_VISIBLE_STEPS = 80;
const PLAYBACK_TICK_MS = 160;
const STAY_MIN_SECONDS = 10 * 60;
const STAY_GROUP_RADIUS_M = 100;
const FALLBACK_BACK_TARGET = 'https://chaegeon.com/';
const BACK_HISTORY_KEY = 'chaegeon.backHistory.v1';
@@ -1707,12 +1708,11 @@ function filterHistoryOutliers(points) {
function buildStayPoints(points) {
const stays = [];
let start = 0;
const radius = 100;
for (let i = 1; i <= points.length; i++) {
const base = points[start];
const current = points[i];
const outside = !current || distanceMeters(base, current) > radius;
const outside = !current || distanceMeters(base, current) > STAY_GROUP_RADIUS_M;
if (!outside) continue;
const end = points[Math.max(start, i - 1)];
@@ -1725,19 +1725,43 @@ function buildStayPoints(points) {
start = Math.max(0, i - 1);
continue;
}
stays.push({
lat,
lng,
latlng: new naver.maps.LatLng(lat, lng),
const visit = {
startTime: base.time,
endTime: end.time,
duration,
points: slice.length,
});
};
const existing = stays.find(stay => distanceMeters(stay, { lat, lng }) <= STAY_GROUP_RADIUS_M);
if (existing) {
const oldPoints = existing.points || 1;
const nextPoints = oldPoints + slice.length;
existing.lat = ((existing.lat * oldPoints) + (lat * slice.length)) / nextPoints;
existing.lng = ((existing.lng * oldPoints) + (lng * slice.length)) / nextPoints;
existing.latlng = new naver.maps.LatLng(existing.lat, existing.lng);
existing.startTime = toTimestamp(existing.startTime) <= toTimestamp(visit.startTime) ? existing.startTime : visit.startTime;
existing.endTime = toTimestamp(existing.endTime) >= toTimestamp(visit.endTime) ? existing.endTime : visit.endTime;
existing.duration += duration;
existing.points = nextPoints;
existing.visits.push(visit);
} else {
stays.push({
lat,
lng,
latlng: new naver.maps.LatLng(lat, lng),
startTime: base.time,
endTime: end.time,
duration,
points: slice.length,
visits: [visit],
});
}
}
start = Math.max(0, i - 1);
}
stays.forEach(stay => {
stay.visits.sort((a, b) => toTimestamp(a.startTime) - toTimestamp(b.startTime));
});
return stays;
}
@@ -1986,11 +2010,17 @@ function buildHistoryInfoContent(point, type, label) {
function buildStayInfoContent(stay) {
const t = translations[langCode] || translations.ko;
const visits = Array.isArray(stay.visits) && stay.visits.length
? stay.visits
: [{ startTime: stay.startTime, endTime: stay.endTime, duration: stay.duration }];
const visitRows = visits.map((visit, index) => `
<span>${index + 1}. ${formatDateTime(visit.startTime)} - ${formatDateTime(visit.endTime)} · ${formatDuration(Math.round(visit.duration))} 체류</span>
`).join('');
return `
<div class="history-info-window history-info-stay">
<strong>${t.historyStay}</strong>
<span>${formatDuration(Math.round(stay.duration))}</span>
<span>${formatDateTime(stay.startTime)} - ${formatDateTime(stay.endTime)}</span>
<span>${formatDuration(Math.round(stay.duration))}</span>
${visitRows}
<span>${Number(stay.lat).toFixed(6)}, ${Number(stay.lng).toFixed(6)}</span>
</div>
`;