[英]How to find close GPS co-ordinates in large table at a given time
(This is a theoretical question for a system design I am working on - advising changes is great) I have a large table of GPS data which contains the following rows: (这是我正在研究的系统设计的理论问题-建议进行很大的更改)我有一个很大的GPS数据表,其中包含以下行:
I am trying to design a way which will allow a server to go through this dataset and check if any "users" were in a specific "place" together (eg. 50m apart) at a specific time range (2min) - eg. 我正在尝试设计一种方法,该方法将允许服务器浏览此数据集,并检查在特定时间范围(例如2分钟)内(例如相隔50m)是否有任何“用户”在一起(例如相隔50m)。 did user1 visit the same vicinity of user2 within that 2min time gap. 在此2分钟的时间间隔内,user1是否访问过user2的同一地区。
The only way I can currently think of is check each row one by one with all the rows in the same timeframe using a co-ordinate distance check algorithm. 我目前唯一想到的方法是使用坐标距离检查算法在同一时间范围内逐行检查所有行。 - But this comes up with the issue if the users are all around the world and have thousands maybe millions of rows in that 5min timeframe this would not work efficiently. -但是,如果用户遍布世界各地,并且在5分钟内有成千上万的行,这将无法有效地解决问题。
Also what if I want to know how long they were in each others vicinity? 如果我想知道他们在彼此附近多久了怎么办?
Any ideas/thoughts would be helpful. 任何想法/想法都会有所帮助。 Including the database to use? 包括数据库要用吗? I am thinking either PostgreSQL or maybe Cassandra. 我在考虑PostgreSQL或Cassandra。 And the table layout. 和表的布局。 All help appreciated. 所有帮助表示赞赏。
Divide the globe into patches, where each patch is small enough to contain only a few thousand people, say 200m by 200m, and add the patchID
as an attribute to each entry in the database. 将地球仪分成多个补丁,每个补丁足够小,只能容纳数千人,例如200m x 200m,然后将patchID
作为属性添加到数据库中的每个条目。 Note that two users cannot be in close proximity if they aren't in the same patch or in adjacent patches. 请注意,如果两个用户不在同一补丁程序中或不在相邻补丁程序中,则它们不能紧邻。 Therefore, when checking for two users in the same place at a given time, query the database for a given patchID
and the eight surrounding patchIDs
, to get a subset of the database that may contain possible collisions. 因此,在给定时间在同一位置检查两个用户时,请在数据库中查询给定的patchID
和八个周围的patchIDs
,以获取可能包含冲突的数据库子集。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.