From 22eb0cd318d105a752576b21352fefbfd1ead5d7 Mon Sep 17 00:00:00 2001 From: regeter <2320305+regeter@users.noreply.github.com> Date: Thu, 30 Apr 2026 10:15:59 -0700 Subject: [PATCH] feat: use response location sensor for table and map --- src/Dataframe.js | 2 +- src/LogTable.js | 5 +++-- src/MapToggles.js | 12 ++++++------ src/TripLogs.js | 10 ++++++++++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/Dataframe.js b/src/Dataframe.js index 10208dfc..fdf650b0 100644 --- a/src/Dataframe.js +++ b/src/Dataframe.js @@ -11,7 +11,7 @@ const DEFAULT_COLUMN_PATHS = [ "formattedDate", "@type", "lastlocation.rawlocationsensor", - "lastlocation.locationsensor", + "lastlocationResponse.locationsensor", "response.vehiclestate", "response.state", "response.tripstatus", diff --git a/src/LogTable.js b/src/LogTable.js index b02c4edf..cc6a5ebb 100644 --- a/src/LogTable.js +++ b/src/LogTable.js @@ -245,6 +245,7 @@ function LogTable(props) { className: "logtable-cell short-column", solutionTypes: ["ODRD", "LMFS"], }, + { Header: "Sensor", accessor: "lastlocation.rawlocationsensor", @@ -257,8 +258,8 @@ function LogTable(props) { }, { Header: "Location", - accessor: "lastlocation.locationsensor", - id: "lastlocation_locationsensor", + accessor: "lastlocationResponse.locationsensor", + id: "lastlocationResponse_locationsensor", Cell: TrimCellRenderer, trim: "_LOCATION_PROVIDER", width: columnRegularWidth, diff --git a/src/MapToggles.js b/src/MapToggles.js index 7040180b..4c55c989 100644 --- a/src/MapToggles.js +++ b/src/MapToggles.js @@ -8,7 +8,7 @@ export const ALL_TOGGLES = [ id: "showGPSBubbles", name: "Location Accuracy", docLink: "https://github.com/googlemaps/fleet-debugger/blob/main/docs/GPSAccuracy.md", - columns: ["lastlocation.rawlocationaccuracy", "lastlocation.locationsensor"], + columns: ["lastlocationResponse.rawlocationaccuracy", "lastlocationResponse.locationsensor"], solutionTypes: ["ODRD", "LMFS"], }, { @@ -134,10 +134,10 @@ export function getToggleHandlers({ bubbleMapRef.current[bubbleName] = tripLogs .getLogs_(minDate, maxDate) .map((le) => { - const rawloc = le.lastlocation?.rawlocation; + const rawloc = le.lastlocationResponse?.location || le.lastlocationResponse?.rawlocation; if (rawloc && typeof rawloc.latitude === "number" && typeof rawloc.longitude === "number") { const latLng = new window.google.maps.LatLng(rawloc.latitude, rawloc.longitude); - return cb(latLng, le.lastlocation, le); + return cb(latLng, le.lastlocationResponse, le); } return null; }) @@ -147,9 +147,9 @@ export function getToggleHandlers({ }; return { - showGPSBubbles: GenerateBubbles("showGPSBubbles", (rawLocationLatLng, lastLocation) => { + showGPSBubbles: GenerateBubbles("showGPSBubbles", (rawLocationLatLng, lastlocationResponse) => { let color; - switch (lastLocation.locationsensor) { + switch (lastlocationResponse.locationsensor) { case "GPS": color = "#11FF11"; break; @@ -169,7 +169,7 @@ export function getToggleHandlers({ default: color = "#000000"; } - const accuracy = lastLocation.rawlocationaccuracy; + const accuracy = lastlocationResponse.rawlocationaccuracy; if (accuracy) { const circ = new window.google.maps.Circle({ strokeColor: color, diff --git a/src/TripLogs.js b/src/TripLogs.js index 8c2187ad..0ac64535 100644 --- a/src/TripLogs.js +++ b/src/TripLogs.js @@ -192,6 +192,16 @@ function processRawLogs(rawLogs, solutionType) { newLog.lastlocationResponse.heading = lastKnownState.responseHeading; } + const updateMask = _.get(newLog, "request.updatemask") || ""; + if ( + currentResponseLocation && + !newLog.lastlocationResponse.locationsensor && + !newLog.request?.header && + updateMask.includes("last_location") + ) { + newLog.lastlocationResponse.locationsensor = "API"; + } + // Update lastKnownState for next iterations const locToStore = currentLocation?.location || currentLocation?.rawlocation; if (locToStore) {