Right there's another gotcha with the data. They gave 15-60mph data in :30 minute increments.
"This would still identify officers blocks or get within a couple blocks of their home for those with take home cars. Would speeds of 15 miles per hour or more but only pings on the :30 minute mark, so one ping per hour from 2019 until the end of April work for you?"
Even gave them this SQL to run to get around that problem but they never got back to me, heh:
WITH immobile_pings as (
select count(*), vehicleid, round(xcoord::numeric, 3) as xcoord_rounded,
round(ycoord::numeric,3) as ycoord_rounded,date_trunc('day', datetime) as day
FROM gps_table
WHERE speed = 0
GROUP BY
vehicleid,
xcoord_rounded,
ycoord_rounded,
day
having count(*) > 1440), --4 hours
day_counts as (
select count(*), vehicleid, xcoord_rounded, ycoord_rounded
from immobile_pings
group by vehicleid, xcoord_rounded, ycoord_rounded having count(*) > 15 -- 15 days
)
select gps_table.* from gps_table s inner join day_counts i
ON i.vehicleid = s.vehicleid
AND array[round(s.xcoord::numeric, 3), round(s.ycoord::numeric, 3)] != array[i.xcoord_rounded,i.ycoord_rounded]
AND speed > 15; -- 15mph
Right there's another gotcha with the data. They gave 15-60mph data in :30 minute increments.
"This would still identify officers blocks or get within a couple blocks of their home for those with take home cars. Would speeds of 15 miles per hour or more but only pings on the :30 minute mark, so one ping per hour from 2019 until the end of April work for you?"
Even gave them this SQL to run to get around that problem but they never got back to me, heh:
select gps_table.* from gps_table s inner join day_counts i ON i.vehicleid = s.vehicleid AND array[round(s.xcoord::numeric, 3), round(s.ycoord::numeric, 3)] != array[i.xcoord_rounded,i.ycoord_rounded] AND speed > 15; -- 15mph