I have vehicles gps information in my real time traffic application. Averaging that information I know the speed of every road at any time. The problem is that is too much data to send back to the devices, so I need a way to group that speed data into classes so I can to simplify the problem.
Right now I have something like this:
road_id time speed
1 09:00 45
1 10:00 47
1 11:00 38
2 09:00 78
2 10:00 77
2 11:00 61
3 09:00 51
3 10:00 48
3 11:00 41
As you can see:
- when close to 12pm more cars are in the roads so the speed decrease.
- road 1 and road 3 has a similar behavior probably both are regular street.
- road 2 is faster, maybe a highway.
So instead of save the speed for each road for each hour. I just want define general road behavior for the day and say that road is that type.
So I will have a table for roads
and another for road_type
road_id name type_id
1 A street 1
2 B Highway 2
3 C street 1
type_id spd_09-10 spd_10-11 spd_11-12 ....
1 50 50 40
2 80 80 60
So I need an algorithm to create those types efficiently and reducing the error with the original data. I understand if I increase the number of types the error will decrease.
My guess is there is something already related to this problem just don't know how is called, and I don't want invent the wheel again.