A method for detecting synchronous movement patterns of buses at large temporal and spatial scales
By designing distance mapping functions and hybrid index trees, combined with the parallel processing of Spark's big data engine, the problems of poor adaptability and low computing efficiency of existing technology when detecting the phenomenon of bus series in large-scale bus scenarios are solved, and efficient bus series detection and data processing are achieved.
Patent Information
- Application Number
- CN202411599591.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-11-11
AI Technical Summary
When detecting the phenomenon of catching trains in large-scale bus scenarios, the prior art has poor adaptability, difficulty in capturing the behavior of catching trains for duration, low computing efficiency and limited data processing capabilities.
A method for synchronous movement mode detection of buses for large space-time scales is proposed. By designing a special distance mapping function, GPS trajectory is mapped to two-dimensional space, using the inclination angle and the index of the smallest external rectangle for rapid filtering, and is implemented in parallel on the big data engine Spark.
Real-time detection of the phenomenon of sletting the train is realized, and the instantaneous and duration sletting the train mode can be identified, which significantly reduces the time cost of mode detection, improves data processing efficiency, and can effectively process the GPS trajectory data of thousands of buses.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a bus synchronous movement mode detection method for a large temporal and spatial scale, and belongs to the technical field of GPS track synchronous movement mode mining. Background Art
[0002] In large and medium-sized cities, tens of thousands of buses provide travel services for urban residents every day. The bus system, subway system and taxi constitute the modern urban public transportation system. Due to the open road network and large-area spatial coverage, the management of buses is more difficult than subways and taxis. How to effectively supervise a large number of buses is the primary problem faced by operators. The detection of synchronous mode is the basis for the identification of bus entanglement. Bus entanglement refers to the phenomenon that different buses on the same route arrive at the same station almost at the same time due to various factors during operation, resulting in the phenomenon that the distance between buses is too close or even overlaps. This phenomenon is particularly obvious during peak hours, mainly due to the combined effects of factors such as uneven boarding and alighting times, traffic light control, and traffic congestion. The bus entanglement phenomenon not only causes the waiting time of passengers to be significantly inconsistent with expectations, causing anxiety for passengers and reducing the travel experience of passengers, but also affects the overall operating efficiency and service quality of the bus system and increases operating costs. Therefore, how to quickly and effectively detect bus entanglement is the basis for improving and enhancing the quality of bus services.
[0003] At present, the research methods can be divided into three categories: detection methods based on headway, methods based on rules and thresholds, and methods based on moving object trajectory clustering.
[0004] Although these solutions also solve the technical requirements in their respective scenarios, there are still two shortcomings:
[0005] (1) Poor adaptability: These methods rely on rules of fixed locations or specific thresholds, lack adaptability to complex and dynamic public transportation systems, and are difficult to detect vehicle-to-vehicle collisions in real time at any spatial location.
[0006] (2) Lack of ability to capture persistent vehicle jams: These methods cannot effectively assess the duration of vehicle jams and can only identify transient states, making it difficult to identify long-term or regular vehicle jams.
[0007] (3) Low computational efficiency: The method based on trajectory clustering has high computational complexity and is very time-consuming to process, which makes it unsuitable for large-scale GPS trajectory dataset detection scenarios.
[0008] (4) Limitations in data processing capabilities: Most existing methods are oriented towards small-scale datasets and single-node solutions, which are difficult to scale to the massive bus GPS trajectory data in large and medium-sized cities, such as the GPS trajectories generated by thousands of buses.
[0009] The Chinese patent "CN110580251B" uses a density-based clustering method and an auxiliary index KD-Tree to study the group movement trajectory accompanying pattern analysis, specific group activity monitoring, and traffic hotspot route discovery. It uses a highly complex and time-consuming algorithm.
[0010] Similarly, the Chinese patent "CN111046968A" also uses a clustering method to improve the road network trajectory clustering of the DPC algorithm. This method is suitable for fields such as transportation and logistics, especially when it is necessary to analyze and mine the trajectory data of moving objects in the road network, and can effectively identify and cluster trajectories with similar behavior patterns. The Chinese patent "CN109241126A" uses a spatiotemporal trajectory clustering method based on R* tree index. The above methods use trajectory clustering methods, which have high time complexity and are time-consuming, and cannot meet the needs of large-scale GPS trajectory data processing. Summary of the invention
[0011] The problem to be solved by the present invention is to provide a bus synchronous movement mode detection method for large temporal and spatial scales, which is used to solve the detection of vehicle stringing status in large-scale bus scenarios and further improve the operation quality of buses.
[0012] The technical solution of the present invention is: Based on the above analysis, a bus synchronous movement mode detection method for large spatiotemporal scales is proposed. This method proposes a series of optimization algorithms. Compared with the common clustering method, the time complexity is significantly reduced and the data processing efficiency is significantly improved; and the method uses big data technology for parallelization, and its scalability can effectively handle large-scale data set scenarios. Specifically, the process of this aspect is as follows:
[0013] First, we designed a special distance mapping function to map longitude and latitude information into a one-dimensional distance indicator. With the help of the mapping function, the three-dimensional GPS trajectory of the bus is mapped into a two-dimensional space, reducing the complexity of subsequent calculations. Next, we divide the two-dimensional space into windows and construct indexes based on the inclination angle and MBR for the trajectory segments within the window, effectively organizing the trajectory collection. Secondly, by using the difference in inclination angle and the intersection of MBR segments, we can quickly filter out irrelevant trajectory segments and speed up the calculation of pattern detection. Finally, we implemented the solution on the big data engine Spark to further improve the scalability and data processing capabilities of the solution.
[0014] The specific steps of a bus synchronous movement mode detection method for large temporal and spatial scales are as follows:
[0015] Step 1: Obtain GPS signal records of all buses in a certain period of time in a public transportation system within a certain city area;
[0016] Step 2: Group the GPS signal records by license plate number, sort each group by time, and obtain the GPS track of each bus, thereby obtaining the GPS track set of all buses;
[0017] Step 3: Traverse all bus GPS tracks, cut the GPS tracks according to the bus routes, and form a set of trips corresponding to each bus;
[0018] Step 4: Calculate the road segment sequence corresponding to each bus route based on the bus GPS trajectory and the underlying road network;
[0019] Step 5: Traverse the road segment sequence corresponding to each bus line, and calculate the distance of each reference point in the road segment relative to the starting station of the bus line based on the distance mapping function to form a reference point distance mapping table;
[0020] Step 6: Traverse each point in the GPS track corresponding to each bus trip, and use the distance mapping function to map the coordinates of the GPS track to between 0 and 1 based on the distance mapping table corresponding to each bus route;
[0021] Step 7: Group the GPS track set by route. The GPS tracks corresponding to all buses on each bus route form a GPS track subset. Process the GPS track subset corresponding to each bus route, convert the three-dimensional GPS track into a two-dimensional GPS track, and obtain the two-dimensional GPS track set corresponding to each route.
[0022] Step 8: Traverse the two-dimensional GPS trajectory set, and use the time window to divide the two-dimensional GPS trajectory into multiple different GPS trajectory segments. Within each time window, multiple GPS trajectory segments are formed;
[0023] Step 9: In each time window, traverse the GPS track segments, calculate the inclination angle and minimum bounding rectangle corresponding to each GPS track segment, and generate a hybrid index tree using the inclination angles and minimum bounding rectangles corresponding to all GPS track segments;
[0024] Step 10: In each time window, traverse the hybrid index tree, filter out invalid segment candidate pairs, generate segment candidate pairs of GPS trajectory segments, and obtain a segment candidate pair set;
[0025] Step 11: Traverse the candidate fragment pairs in the set, perform verification and filtering, calculate whether the candidate fragment pairs meet the rules of the synchronous movement mode, and generate candidate synchronous movement modes;
[0026] Step 12: traverse and generate candidate synchronous movement patterns, merge the synchronous movement patterns, and return the synchronous movement patterns;
[0027] Step 13: Implement Step 1 to Step 12 in parallel on the big data computing engine Spark.
[0028] Specifically, the relevant definitions of the present invention are as follows:
[0029] A bus route manages multiple buses. The set of buses belonging to the same route is defined as:
[0030] (1)
[0031] In formula (1), For buses, ;
[0032] There are bus stops on the bus routes. Different bus routes have different bus stop sequences. The bus stop set is defined as:
[0033] (2)
[0034] In formula (2), The bus stops on the bus route. ;
[0035] In the urban public transportation system, multiple bus routes are operated simultaneously. The definition of the bus route set is:
[0036] (3)
[0037] In formula (3), bus routes, ;
[0038] All buses are equipped with GPS positioning devices, which will generate GPS records regularly. The GPS records contain three fields: timestamp, longitude and latitude. The three fields constitute a time-space point, which is defined as:
[0039] (4)
[0040] In formula (4), Represents the GPS timestamp, represents the longitude of the point, represents the latitude of the point;
[0041] The bus GPS trajectory describes a series of time-ordered GPS records generated when the bus is traveling along the scheduled route. The vehicle operation trajectory is defined as:
[0042] (5)
[0043] In formula (5), , represents a series of space-time points generated by the bus in chronological order;
[0044] The route trajectory set contains the trajectory set generated by all buses on a specific route, which records the specific location information of each bus in detail. The definition is as follows:
[0045] (6)
[0046] In formula (6), For the line trajectory, ;
[0047] After map matching of the GPS track of each bus, each GPS point will be associated with a road section number. After map matching, the GPS track fragment format is as follows:
[0048] (7)
[0049] In formula (7), is the GPS point of the bus, , Number the road sections of the map road network;
[0050] Each bus line runs along a specific route. Each line consists of a road segment sequence. After the bus GPS track map is matched, the track is converted into a road segment sequence. The form of the road segment sequence is as follows:
[0051] (8)
[0052] In formula (8), For bus routes, is the road section number, ;
[0053] The map road network is composed of many routes, which are divided into many sections. Each section is composed of many reference points. Each reference point is composed of a set of longitude and latitude coordinates. The organization of the sections is as follows:
[0054] (9)
[0055] In formula (9), is the reference point on the road section, ;
[0056] The cluster of buses running in sequence on a certain route is defined as follows:
[0057] (10)
[0058] In formula (10), the subscripts represent the relative positions of the buses on the road. For bus clusters, ;
[0059] A bus tandem is defined as:
[0060] (11)
[0061] exist Within the time range, the following definitions are met:
[0062]
[0063] (12)
[0064] In formula (11) and formula (12), Represents a bus cluster and bus clusters The distance in the space-time dimension, in the car-in-car mode, the number of vehicles is greater than or equal to , the distance between any adjacent vehicles is less than d, and the pattern duration is greater than t.
[0065] Specifically, the distance mapping function in Step 5 is defined as follows:
[0066] The distance between the benchmark points of the road section is used to calculate the mileage of the bus line. The calculation formula is:
[0067]
[0068] (13)
[0069] In formula (13), is the distance between the starting point of the bus line and the nearest reference point of the bus in the direction of travel. is the distance between the last reference point and the terminal station in the travel direction of the line. is the distance between two reference points in the line;
[0070] Using the distance mapping formula, the calculation formula for calculating the distance from the GPS point to the starting point of the road is:
[0071] (14)
[0072] In formula (14), for The last nearest benchmark point, for To route origin distance;
[0073] The latitude and longitude coordinates corresponding to the GPS points in the bus trajectory are reduced in dimension and mapped to [0,1]. The specific mapping formula is:
[0074] (15)
[0075] In formula (15), L represents the total length of the bus route corresponding to the bus;
[0076] The formula for calculating the distance between two GPS points is:
[0077] (16)
[0078] (17)
[0079] (18)
[0080] In formula (16), formula (17) and formula (18), is the radian value of the latitude difference between the two points, is the radian value of the longitude difference between the two points, and are the radians of the latitudes of the two points, is the mean radius of the Earth, Represents the distance between two GPS points in kilometers.
[0081] Specifically, the Step 5 is as follows:
[0082] Step5.1: Input the road segment sequence roadSegList corresponding to a bus route;
[0083] Step 5.2: Initialize the distance mapping table distMappingTable<point,distance> , initialize the distance corresponding to the first reference point to distance 0, and specify the first reference point as point;
[0084] Step 5.3: Initialize the variable i to 1 to traverse each road segment in roadSegList;
[0085] Step 5.4: Determine the relationship between i and the number of road segments in the road segment sequence roadSegList.len; if i<=roadSegList.len, get the current road segment currentSeg= roadSegList[i]; otherwise, go to Step 5.11;
[0086] Step 5.5: Initialize the variable j to 1 to traverse each reference point in currentSeg;
[0087] Step 5.6: Determine the relationship between j and the number of reference points in the road segment currentSeg.len; if j<=currentSeg.len, get the current reference point currPoint= currentSeg[j]; otherwise, go to Step 5.10;
[0088] Step 5.7: Calculate the distance between the current reference point currPoint and the previous reference point point according to formulas (16), (17), and (18) in order, and save the result in currDist;
[0089] Step 5.8: distMappingTable.insert(currPoint, currDist), add the current point and its corresponding distance to the distance mapping table;
[0090] Step5.9: Assign the current reference point currPoint to the previous reference point point, point=currPoint;
[0091] Step 5.10: Variable j increases by 1, j=j+1, pointing to the next reference point of the current road section;
[0092] Step 5.11: The variable i is incremented by 1, i=i+1, pointing to the next section of the current sequence;
[0093] Step5.12: Return the distance mapping table distMappingTable.
[0094] Specifically, the step 6 is as follows:
[0095] Step 6.1: Input the GPS track rawTR corresponding to a bus and the distance mapping table distMappingTable;
[0096] Step 6.2: Initialize the key value type data structure resTR<time, distance> , where resTR is the trajectory in two-dimensional space, time represents the timestamp, and distance represents the relative distance of the longitude and latitude coordinates from the starting point, with a value between 0 and 1;
[0097] Step 6.3: Initialize the variable i to 1 to traverse each GPS point in rawTR;
[0098] Step 6.4: Determine the relationship between i and rawTR.len. If i<=rawTR.len, get the current GPS point currPoint= rawTR[i]; otherwise, go to Step 6.12;
[0099] Step 6.5: According to the current GPS point, find the reference point closest to the current point in the corresponding road section sequence, wPoint=getRefPoint(currPoint);
[0100] Step 6.6: According to the reference point wPoint, obtain the absolute distance of the reference point from the origin through the distance mapping table, refDistance = getDistanceFromTable (distMappingTable, wPoint);
[0101] Step 6.7: Calculate the distance between the current reference point currPoint and the reference point wPoint according to formulas (16), (17), and (18) in order, and save the result in comDistance;
[0102] Step 6.8: Calculate the sum of the absolute distances between the current GPS point and the corresponding route starting point, solDistance = refDistance + comDistance;
[0103] Step 6.9: Map the latitude and longitude coordinates of the current GPS point to between 0 and 1. The specific calculation formula is relativeDistance=(solDistance / L), where L is the length of the entire route in kilometers;
[0104] Step6.10: Construct the point newPoint(currPoint.time,relativeDistance) in two-dimensional space;
[0105] Step6.11: Insert the point newPoint in the two-dimensional space into the two-dimensional trajectory, resTR.insert(newPoint);
[0106] Step 6.12: Variable i increases by 1, i=i+1, pointing to the next GPS point of the trajectory;
[0107] Step 6.13: Return to the two-dimensional space trajectory resTR.
[0108] Specifically, the Step 9 is as follows:
[0109] Step 9.1: Input the two-dimensional trajectory segment set segSet corresponding to a single time window of a bus line, where each member represents a trajectory segment generated by a bus, segSet={Seg1, Seg 2, …, Seg n};
[0110] Step 9.2: Initialize the data structure, HybridTree(angle, (MBR, TRseg)), where angle represents the angle between the trajectory and the horizontal axis, MBR represents the minimum enclosing rectangle corresponding to the trajectory, and TRseg represents the trajectory;
[0111] Step9.3: Initialize the variable i to 1 to traverse each trajectory segment in segSet;
[0112] Step 9.4: Determine the relationship between i and segSet.len. If i<=r segSet.len, get the current trajectory segment currSeg= segSet [i]; otherwise, go to Step 9.9;
[0113] Step 9.5: Get the starting point and end point of the current trajectory segment, startPoint = currSeg.getStartPoint, endPoint = currSeg.getEndPoint;
[0114] Step 9.6: angle = getAngleWithHorizontal(startPoint, endPoint), calculate the angle between the current trajectory segment and the horizontal axis based on the start point and end point;
[0115] Step 9.7: MBR = calculateMBR (currSeg), calculate the minimum bounding rectangle corresponding to the current trajectory segment;
[0116] Step 9.8: HybridTree.Insert(angle,(MBR, currSeg)), insert angle and MBR into the hybrid index;
[0117] Step 9.9: Variable i increases by 1, i=i+1, pointing to the next trajectory segment in the set;
[0118] Step 9.10: Return the hybrid index tree HybridTree.
[0119] Specifically, the Step 10 is as follows:
[0120] In the process of generating candidate pairs, it is determined whether the MBRs corresponding to the trajectory segments have intersections. The formula for calculating the intersection is as follows:
[0121]
[0122] (19)
[0123] In formula (19), and Represent the minimum time of trajectory 1 and trajectory 2 respectively, and Represent the maximum time of trajectory 1 and trajectory 2 respectively, and Represent the minimum distance between track 1 and track 2, and Represent the maximum distances of trajectory 1 and trajectory 2 respectively, is a Boolean variable. If If the value of is true, it means that the two MBRs intersect; otherwise, the two MBRs do not intersect;
[0124] The specific execution process of generating candidate pairs is as follows:
[0125] Step 10.1: Input the hybrid index tree HybridTree(angle, (MBR,TRseg) ) corresponding to a single time window of a bus line, and input the tilt angle distance threshold θ;
[0126] Step 10.2: Initialize the data structure, resCandidatePair(TRseg,TRseg), to save the candidate trajectory pairs;
[0127] Step 10.3: Initialize the variable i to 1 to traverse each trajectory segment in the HybridTree;
[0128] Step 10.4: Determine the relationship between i and the number of elements in the hybrid index HybridTree.len. If i is less than HybridTree.len, get the current currItem=HybridTree(i); otherwise, execute Step 10.17;
[0129] Step 10.5: Initialize the variable index to i+1, index=i+1, index represents the subscript of the next element;
[0130] Step 10.6: Get the next element, testItem = HybridTree(index);
[0131] Step 10.7: Calculate the angle difference between currItem and testItem, diff = testItem.angle - currItem.angle;
[0132] Step 10.8: Determine the relationship between diff and θ. If diff is less than or equal to θ, go to the next step; otherwise, go to Step 10.11;
[0133] Step 10.9: Determine the relationship between the MBRs corresponding to the elements currItem and testItem. If there is an intersection, go to the next step; otherwise, go to Step 10.11;
[0134] Step 10.10: Add the candidate pair to the result set, resCandidatePair.insert(currItem,testItem);
[0135] Step 10.11: The variable index increases by 1, index=index+1;
[0136] Step 10.12: Determine the relationship between index and HybridTree.len. If index is less than or equal to HybridTree.len, go to the next step; otherwise, go to Step 10.15;
[0137] Step 10.13: Calculate the angle difference between currItem and testItem, diff = testItem.angle - currItem.angle;
[0138] Step 10.14: Repeat the steps from Step 10.8 to Step 10.13;
[0139] Step 10.15: The variable i is incremented by 1, i=i+1, pointing to the next element of the mixed index;
[0140] Step10.16: Repeat the steps from Step10.4 to Step10.15;
[0141] Step 10.17: Return the candidate result set resCandidatePair.
[0142] Specifically, the method of generating candidate synchronous movement patterns and merging synchronous movement patterns is as follows: in Step 10, a candidate pair of vehicles in series resCandidatePair is selected, and then filtering and verification are performed according to Step 11 and Step 12, which is divided into four steps:
[0143] (1) Linear distance measurement and calculation: traverse the trajectory of each vehicle to form a trajectory pair, extract the starting point and end point of the trajectory in the trajectory pair, form a vector of the trajectory containing the starting point and end point respectively, calculate the slope and intercept parameters of the straight line formed by the starting point and end point of the trajectory, then calculate the vertical distance from the starting point and end point in the trajectory vector to the straight line, and take the maximum vertical distance as the linear distance of the trajectory pair;
[0144] The function interface for calculating the point to line is:
[0145] (20)
[0146] In formula (20), represents a straight line, Representative point;
[0147] The formula for calculating the distance from a point to a line is:
[0148] (twenty one)
[0149] In formula (21), , are the coordinates of the point, is the slope of the straight line, is the intercept of the straight line;
[0150] (2) Track pair screening and event recording: Check the maximum vertical distance of the candidate track pairs. If it is less than the set threshold condition, the detected event is recorded, including the relevant track information and time data.
[0151] After filtering the trajectory pairs, merge the car-in-train events across time windows. The calculation function interface is as follows:
[0152] (twenty two)
[0153] (3) Traverse each event record and check whether the duration is less than the set threshold. If the duration is less than the threshold, check whether the vehicle corresponding to the trajectory also has a car-crossing in the next time window. If the trajectory pair also has a car-crossing, merge the duration of the event and save the events whose duration meets the set threshold in the merged result set;
[0154] (4) Calculate the number of vehicles that are in contact with each other for all candidate trajectory pairs After that, it is further determined whether there are candidate pairs that need to be merged. If vehicle 1 and vehicle 2 are in series, or vehicle 2 and vehicle 3 are in series, it is necessary to further determine whether the three vehicles meet the series definition of formula (11). If so, it is determined that the three vehicles are in series with each other. Similarly, it is necessary to determine the series of three or more vehicle clusters. In order to perform fast detection and merging, a graph-based fast merging method is used. The merging principle is as follows:
[0155] The interface for detecting multiple vehicles in series is:
[0156] (twenty three)
[0157] In formula (23), for After grouping the data by time window and line number, the data structure and Consistency;
[0158] In the interface, the conditions for serial connection must meet the following two points at the same time:
[0159] Condition 1: If there are two bus groups A and B, and the number of buses in the bus group is greater than or equal to 2, one or more buses in A appear in B;
[0160] Condition 2: The time difference between the maximum string start time and the minimum string end time of the two string groups A and B is greater than a certain time threshold;
[0161] Under the above conditions, an undirected graph is used to quickly detect the situation of multiple vehicles in series. The data in is input, and the license plate numbers of TR1 and TR2 of each column of trajectory pair data are inserted into the graph as the values of the graph nodes, and the rest of the information is recorded in the edges. The form of the undirected graph is as follows:
[0162] (twenty four)
[0163] In formula (24), V is a set of nodes, and the form of V is as follows:
[0164] (25)
[0165] In formula (25), is a collection of different bus license plate numbers;
[0166] is a set of edges, representing The connection relationship between each node in The form is as follows:
[0167] (26)
[0168] In formula (26), , all correspond to a record in TandemPair, in the form of:
[0169] (27)
[0170] The condition for e to exist is that the serial vehicle records still meet the time condition after merging, as described by the following formula:
[0171] (28)
[0172] In formula (28), and Respectively represent and The maximum meeting time and minimum departure time of two trajectory points, Indicates the minimum time for judging a vehicle as a string of vehicles.
[0173] Specifically, the Step 11 is as follows:
[0174] Step 11.1: Input the candidate pair of buses in a bus line, lineCandidatePair(Trseg,TRseg), the distance threshold DIS, and the time threshold T;
[0175] Step 11.2: Initialize the data structure tandemBusPairs(startT,endT,TRseg,TRseg) to save the calculation results of bus pairs; initialize the data structure tandemBusTRs(startT,endT,List[TRseg]) to save the results of multiple bus series;
[0176] Step 11.3: Initialize the variable i to 1 to traverse the candidate pairs of vehicles in series;
[0177] Step 11.4: Determine the relationship between i and the number of candidate pairs lineCandidatePair.len. If i<=lineCandidatePair.len, set (track1, track2) = lineCandidatePair[i]; if i>lineCandidatePair.len, go to Step 11.11;
[0178] Step 11.5: Get the straight line L that connects the start point and end point of track1, and get the start point p1, midpoint p2, and end point p3 of track2;
[0179] Step 11.6: Use the function described in formula (20) to calculate the distances from the three points of track2 to the line L respectively, and return the maximum distance maxDis;
[0180] Step 11.7: If maxDis<=DIS, get the start time startTime and end time endTime of the train connection of track1 and track2. Otherwise, go to Step 11.11;
[0181] Step 11.8: Calculate the connection time of track1 and track2, tandamTime = endTime - startTime;
[0182] Step 11.9: Determine the relationship between tandemTime and T. If tandemTime>=T, add the track pair to the result set of tandem bus track pairs, tandemBusPairs.insert(startT,endT,track1,track2). Otherwise, go to Step 11.10.
[0183] Step 11.10: Variable i increases by 1, i=i+1, pointing to the next trajectory pair of the candidate pair of vehicles in series;
[0184] Step 11.12: Initialize the variable j to 1, which is used to traverse the bus string pairs, and initialize the variable Graph (V, E) as shown in formula (24) to quickly organize the route data into a graph structure, so as to detect multiple bus strings;
[0185] Step 11.13: Determine the relationship between j and tandemBusPairs.len. If j <= tandemBusPairs.len, set (Tra1, Tra2) = tandemBusPairs[j]. Otherwise, go to Step 11.16.
[0186] Step 11.14: Add an edge to the graph Graph.addEdge(Tra1, Tra2), and add a node to the graph Graph.addNode(Tra1.id, Tra2.id);
[0187] Step 11.15: Variable j increases by 1, j=j+1, pointing to the next track pair of the serial vehicle pair;
[0188] Step 11.16: Traverse the graph structure Graph, obtain all the tandem links List [tandemLLines(V,E)], and perform the following operations on each tandem link;
[0189] Step11.17: Initialize the variable k to 1 for traversing the tandem vehicle link;
[0190] Step11.18: Determine the relationship between k and tandemLLines.len. If k <= tandemLLines.len, store the current edge in the variable e = tandemLLines.getEdge[k]; otherwise, go to Step11.22;
[0191] Step11.19: Let tStart and tEnd be the tandem vehicle start time and tandem vehicle end time of the trajectory pair in e respectively. If tEnd - tStart > T, update the start time and end time of the trajectory pairs TR1 and TR2 in the edge e to tStart and tEnd;
[0192] Step11.20: Use the variables realST and realET to save the tandem vehicle start time and end time of tandemBusTRs. If realST < tStart, realST = tStart; if realET > tEnd, realET = tEnd;
[0193] Step11.21: tandemBusTRs.add(realST, realET, list{TR1, TR2}), add the trajectory pair corresponding to the current number to the line tandem vehicle result and update the tandem vehicle time, then go to Step11.23;
[0194] Step11.22: Increment the variable k by 1, k = k + 1, to point to the next set of data in the tandem vehicle link;
[0195] Step11.23: Remove duplicates from the duplicate trajectories in tandemBusTRs, and return the tandem vehicle detection result tandemBusTRs.
[0196] Specifically, the detailed steps of Step13 are as follows:
[0197] Step13.1: Load data from HDFS through load(...), generating an initial RDD[(id, point)];
[0198] Step13.2: Use groupByKey() to group the data by vehicle number and time, generating a trajectory RDD[(id, TR)];
[0199] Step13.3: Use mapValues(udfDistProject) for distance mapping, generating an RDD[(id, DTR)] with distance attributes;
[0200] Step 13.4: Repartition the trajectory by route through partitionBy(udfRepartition) to generate the repartitioned RDD[(id, TR)];
[0201] Step 13.5: Apply mapValues(udfHybridIndex) to generate a hybrid index and obtain RDD[(id, w,HybridIndex)], where w is the time window and HybridIndex is the sequence number of the hybrid index;
[0202] Step 13.6: Filter invalid trajectory pairs through mapValues(udfFilter) to generate RDD[(id, segA, segB, ..., segF)] containing the retained trajectory segments;
[0203] Step 13.7: Use mapValues(udfRefine) to verify the candidate trajectory pairs and generate RDD[(id, w, A, B, C)], where w is the time window in which the synchronous mobility pattern occurs, and A, B, C are the vehicles in which the synchronous mobility pattern occurs;
[0204] Step 13.8: The data is saved back to the text file in HDFS through collect(...) and save(...) operations.
[0205] The beneficial effects of the present invention are:
[0206] (1) Compared with the traditional method, the spatial distance mapping and window division method proposed in the present invention can detect not only the instantaneous vehicle-to-vehicle crossover pattern but also the continuous vehicle-to-vehicle crossover pattern, which is more powerful.
[0207] (2) The hybrid index tree and filtering verification method proposed in the present invention avoid time-consuming trajectory clustering, reduce the time cost of pattern detection, and make pattern detection more efficient and time-saving;
[0208] (3) The present invention implements the scheme in a parallel manner on the big data computing engine Spark. The data processing capability of the present invention far exceeds that of existing methods and can meet the needs of detecting vehicle clusters of thousands of buses. BRIEF DESCRIPTION OF THE DRAWINGS
[0209] Figure 1 It is the technical roadmap of the present invention;
[0210] Figure 2 To map the intent for the benchmark;
[0211] Figure 3 Schematic diagram of time window division;
[0212] Figure 4 Build a schematic diagram for hybrid indexing;
[0213] Figure 5 Graph for parallelization of algorithms and elastic distributed dataset transformation. DETAILED DESCRIPTION
[0214] The bus GPS trajectory data used in this article comes from the operation data of Shenzhen on January 4, 2019. The dataset contains 478 buses, involving 8,412 vehicles, 25,245,719 GPS records, and a total data volume of 2.33GB. Each GPS record contains the fields of timestamp, bus ID, longitude, latitude, and route number.
[0215] The present invention is implemented on a high-performance computing server, which is configured with 64 cores, 128GB memory, and 20TB hard disk. The version numbers of the relevant software are as follows: operating system Centos7.9; Python3.11; Hadoop3.1.1; Spark 2.4.0.
[0216] The present invention will be further described below in conjunction with the accompanying drawings and specific implementation methods based on the description.
[0217] Figure 1 The technical route of the entire invention is described. The trajectory data collection part in the figure corresponds to Step 1 to Step 4 of the above steps, and its function is to obtain the bus travel trajectory set required for Step 6 to perform spatial distance mapping of the trajectory data and the road network corresponding to the bus travel and the road network section sequence. Figure 1 The trajectory data partition part corresponds to Step 5 to Step 8 of the above steps, and its function is to generate the set of trajectory segments partitioned according to the time window required for Step 9 to build the index tree, among which the spatial distance mapping corresponds to Step 5 and Step 6. Figure 1 The detection and evaluation part corresponds to Step 10 to Step 12. Its function is to quickly filter irrelevant data based on the hybrid index tree, and then use the detection algorithm to obtain the final string of vehicles result.
[0218] Example 1: Figure 1 The method for detecting a bus synchronous movement mode at a large temporal and spatial scale shown in the figure comprises the following steps:
[0219] Step 1: Obtain GPS signal records of 8,412 buses on 478 routes in Shenzhen’s public transportation system on January 4, 2019;
[0220] Step 2: Group the GPS records by license plate number and sort them by time within the group to obtain the GPS track of each bus. The GPS tracks of 8412 buses constitute the track set.
[0221] Step 3: Traverse all bus GPS tracks, cut the tracks according to the bus routes, and form a set of trips corresponding to each bus;
[0222] Step 4: Calculate the road segment sequence corresponding to each bus line based on the bus GPS trajectory and the underlying road network;
[0223] Step 5: Traverse the road segment sequence corresponding to each bus route, and based on a distance mapping function, calculate the distance of each reference point in the road segment relative to the starting station of the route to form a reference point distance mapping table. Each bus route corresponds to a different distance mapping table, and a total of 478 distance mapping tables corresponding to bus routes are generated;
[0224] Step 6: For each bus trip on each route, traverse each point in the GPS track, and use the distance mapping function to map the GPS coordinates to between 0 and 1 based on the distance mapping table corresponding to the bus route. For example, taking bus route M2333 as an example, a total of 143,532 GPS points are mapped, which takes 21.8 seconds;
[0225] Step 7: The GPS track set is grouped by route, and the GPS tracks corresponding to all buses on each bus route form a GPS track subset. The GPS track subset corresponding to each bus route is processed, and the GPS track in three-dimensional space is converted into the GPS track in two-dimensional space to obtain the two-dimensional GPS track set corresponding to each route;
[0226] The original trajectory data Tra is shown in formula (5). Each of its trajectory points is a triplet of the form (time, lat, lon). After distance mapping, its trajectory point becomes a binary tuple of the form (time, norDistance). norDistance is a real number between 0 and 1, which is the relative distance between the GPS point and the starting point of the route.
[0227] Step 8: Use time windows to divide the two-dimensional trajectory. Divide the 24-hour time period into 4-minute time windows, generating a total of 360 time windows. The 360 time windows divide the GPS trajectory of each vehicle into multiple trajectory segments. There are multiple trajectory segments from different vehicles in each time window.
[0228] Step 9: In each time window, traverse the trajectory segments of each bus, calculate the inclination angle and minimum bounding rectangle MBR corresponding to each trajectory segment, and use the inclination angles and MBRs corresponding to all trajectory segments to generate a hybrid index tree. Taking the trajectory segment of bus BS0003X as an example, obtain the trajectory segment TR1 of this bus, obtain the starting point and end point of TR1 and connect them to obtain the straight line L1, then calculate the minimum bounding rectangle MBR1 of L1, and then calculate the angle between L1 and the horizontal line , and then insert the car's data into the index tree, HybridTree.insert( ,(MBR1,TR1));
[0229] Step 10: Set the angle threshold is 3. In each time window, the hybrid index tree is traversed to filter invalid candidate pairs of segments, to form valid candidate pairs of trajectory segments, and to form a candidate pair set. , (MBR1, TR1) and the index data of bus BS0009X ( , (MBR2, TR2) as an example, first calculate the horizontal angle difference between the two trajectories ,if , then determine whether MBR1 and MBR2 have an intersection. If there is an intersection, add the two trajectory pairs to the candidate result set resCandidatePair.insert(TR1,TR2); if Or if MBR1 and MBR2 have no intersection, the next set of trajectory pairs is judged.
[0230] Step 11: Take bus BS0003X and bus BS0009X as examples to set the time threshold Set the distance threshold to 4 minutes is 0.01, which means the maximum distance difference between vehicles is 10 meters. Get the trajectory segments TR1 and TR2 of the two buses from the candidate result set resCandidatePair, take out the starting point and the end point of TR1 and connect them to get the straight line L, take out the starting point, the middle point and the end point of the trajectory segment TR2, calculate the vertical distance between these three points and the straight line L according to the function interface of formula (20), and return the maximum distance maxDis. If , bus BS0003X and bus BS0009X are connected in the current time window. Repeat the above steps to calculate the After calculating the data of all time windows, the data in tandemWinPair are grouped according to the route name and driving direction, and then the trajectory segments that appear in adjacent windows are merged. If the merging time is greater than , insert the trajectory pair into the tandem bus result set tandemBusPairs.add(startT,endT,TR1,TR2), where startT and endT are the start and end times of the tandem bus.
[0231] Step 12: Take bus BS0003X and bus BS0009X and bus BS0005X as examples. If the bus connection record of BS0003X and bus BS0009X is (ST1, ET1, TR1, TR2), and the bus connection record of BS0009X and bus BS0005X is (ST2, ET2, TR2, TR3), BS0009X appears in both different bus connection records. If min(ET1, ET2)-max(ST1, ST2)>= It is considered that there are three buses in a row at the same time. The same judgment applies to more than three buses. In order to detect the row of buses more quickly, we designed a graph method to quickly detect the result of multiple buses in a row. The function interface is shown in formula (23). Finally, we loop through tandemBusPairs and obtain the multiple bus row detection result tandemBusTRs.
[0232] Figure 2 For the purpose of benchmark point mapping, there is a corresponding distance mapping table for each driving direction of each route. The generation process of the benchmark point mapping table is as follows: based on the road network data of the bus route and its road section sequence, the benchmark points on the road section (including the sequence number and the latitude and longitude of the benchmark points) are taken out in sequence, starting from the first benchmark point, the distance between every two adjacent benchmark points is calculated, and the distance from each benchmark point to the starting point of the bus route is calculated according to the method described in formula (14), and finally the benchmark point distance mapping table of each route is generated.
[0233] like Figure 2As shown in the figure, based on the mapping table, the process of distance mapping for a certain GPS point is as follows: First, determine the bus route to which it belongs based on the license plate number information in the GPS record. Then, determine whether the current trip is up or down. With the route and up and down information, we can obtain the benchmark point mapping table for the corresponding route. Next, based on the section number information of the GPS point, take out the benchmark point data with the same section number from the mapping table, then determine which two benchmark points the GPS point belongs to, calculate the distance distance1 between the previous benchmark point and the GPS point, and obtain the distance distance2 from the previous benchmark point to the origin. Therefore, the distance from the GPS point to the starting point of the road is distance=distance1+distance2. The length L of the route is obtained in the benchmark point mapping table, and then the distance can be mapped to [0,1] according to formula (15).
[0234] Table 1 GPS track distance mapping time comparison table
[0235]
[0236] Table 1 shows the performance comparison before and after using the reference point distance mapping table. The second row describes the time consumption of directly mapping the GPS point sequence, and the third row describes the time consumption of using the distance mapping table. Taking a route with 26 buses as an example, the execution time of direct calculation is 977 seconds, while the execution time of using the reference point distance mapping table to map the GPS point sequence is 8.61 seconds, which is less than one hundredth of the time of the former. The experimental results show that the time cost of directly calculating with the GPS point sequence without using the reference point distance mapping table is very high. Therefore, it can be clearly seen from the experimental results that the distance mapping table greatly improves the data processing performance.
[0237] Figure 3 This is a schematic diagram of time window division. Since the startup time and sampling frequency of GPS devices of different buses are different, only the GPS location information of some vehicles is collected at any specific moment. We cannot calculate the exact similarity or distance of the trajectory through a sparse point sequence. Therefore, the present invention uses a time window to segment the trajectory of buses on the same route for subsequent analysis. In this article, the measurement form of the time window is as follows:
[0238] (29)
[0239] In formula (29), Indicated in Within time, A collection of trajectories.
[0240] When using time windows to segment trajectories, the integrity of trajectories that cross the time window segmentation line is destroyed. Therefore, misjudgment may occur. In algorithm design, we need to consider this situation. For a certain time window, if a vehicle is detected to have a string of vehicles, but it does not meet the duration we set. We need to save this state as an intermediate result and participate in the calculation of the next window. Figure 3 middle Within the time range, bus2 and bus3 are in a row, but the duration we set is not met. The last position of these two vehicles in the current window is very close to the window boundary line, which is less than the set threshold. Therefore, we save this information as an intermediate result and participate in the calculation of the next time window to further verify the duration of the car-traffic phenomenon. Figure 3 middle If bus2 and bus3 also have a car-to-car collision within the time range, and the cumulative time spanning the time window is greater than the time threshold we set, the algorithm determines that the two vehicles have a car-to-car collision.
[0241] Figure 4 To construct a schematic diagram for the hybrid index, first, we calculate the minimum bounding rectangle MBR of the trajectory segment, then obtain the starting point and end point of the trajectory segment, connect the starting point and end point to get the straight line L, and obtain the angle between L and the horizontal line , the original trajectory sequence in the time window in chronological order Become a HybridIndex , by calculating the two trajectory pairs The difference is less than the set angle threshold and the MBR of the two track pairs are judged whether they intersect, so as to quickly filter the data.
[0242] Figure 5 The diagram shows the parallelization of the algorithm and the transformation to the resilient distributed dataset (RDD), which shows that Step 13 implements the parallelization of Step 1 to Step 12 on the big data computing engine Spark.
[0243] After setting up the experimental environment, the specific process of parallelizing Step 1 to Step 12 on the big data computing engine Spark is as follows:
[0244] Step 13.1: Call the load() operator to load data from HDFS and generate the initial RDD[(id, point)];
[0245] Step 13.2: Define the function udfDistProject as in Step 3, group the data by vehicle number and time, call the groupByKey(udfDistProject) operator, and generate the trajectory RDD[(id, TR)];
[0246] Step 13.3: Define the function udfPointMapping in the algorithm flow of Step 5 and Step 6, call the mapValues(udfPointMapping) operator, and generate an RDD[(id, DTR)] with distance attributes;
[0247] Step 13.4: Partition the data by route, and then repartition the trajectory by route through partitionBy(udfRepartition) to generate the repartitioned RDD[(id, TR)];
[0248] Step 13.5: Define the function udfHybridIndex as in Step 9, then call mapValues(udfHybridIndex) to generate a hybrid index and obtain RDD[(id, w, HybridIndex)], where w is the time window and HybridIndex is the serial number of the hybrid index.
[0249] Step 13.6: udfFilter is a custom function similar to the process described in Step 10 and Step 11, which is used to filter invalid trajectory pairs. The trajectory data is filtered through mapValues(udfFilter) to generate an RDD[(id, segA, segB, ..., segF)] containing the retained trajectory segments;
[0250] Step 13.7: udfRefine is a custom function similar to the process described in Step 11 and Step 12. We use mapValues(udfRefine) to calculate the string of vehicles and generate RDD[(id, w, A, B, C)], where w is the time window in which the synchronous movement mode occurs, and A, B, C are the vehicles in which the synchronous movement mode occurs;
[0251] Step 13.8: Finally, the data is saved back to the text file in HDFS through the operators collect() and save().
[0252] To verify the scalability of our proposed method, we tested different datasets (20 lines, 40 lines, 80 lines, and 160 lines) on a high-performance computing server and compared the time consumption of our method with the baseline R-Tree method.
[0253] Table 2 The time consumption of hybrid index and R-Tree in different data scale scenarios
[0254]
[0255] Table 2 shows the time consumption comparison between the R-Tree method and the hybrid index method in a multi-threaded environment. It can be seen that as the number of bus routes increases, the advantages of the hybrid index method over the R-Tree method become more and more obvious.
[0256] Specifically, when processing a data set of 80 lines, the hybrid index method only takes 134.45 seconds, while the R-Tree method takes 359.09 seconds, with a speedup ratio of 2.67 times. This trend is more significant when processing larger data sets. When processing a data set of 160 lines, the hybrid index method only takes 249.85 seconds, while the R-Tree method takes 664.59 seconds, with a speedup ratio of 2.65 times. Therefore, the hybrid index method has obvious advantages in processing large-scale data sets and is a more efficient choice.
[0257] In summary, compared with the existing car-in-line detection method, the detection scheme of the present invention can meet the duration of car-in-line mode detection through spatial distance mapping, distance mapping table design, hybrid index construction, rapid filtering and verification of trajectory data, etc., which improves the scope of application of the algorithm; on the other hand, it greatly reduces the amount of calculation and complexity of calculation, and the time cost required for detection is significantly reduced. By using Spark technology for parallelization, the data processing capability is significantly improved, and the GPS trajectory processing needs of thousands of buses can be efficiently processed.
[0258] The specific implementation modes of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above implementation modes, and various changes can be made within the knowledge scope of ordinary technicians in this field without departing from the purpose of the present invention.
Claims
1. A bus synchronous movement mode detection method for large temporal and spatial scales, characterized by: Step 1: Obtain GPS signal records of all buses in a certain period of time in a public transportation system within a certain city area; Step 2: Group the GPS signal records by license plate number, sort each group by time, and obtain the GPS track of each bus, thereby obtaining the GPS track set of all buses; Step 3: Traverse all bus GPS tracks, cut the GPS tracks according to the bus routes, and form a set of trips corresponding to each bus; Step 4: Calculate the road segment sequence corresponding to each bus route based on the bus GPS trajectory and the underlying road network; Step 5: Traverse the road segment sequence corresponding to each bus line, and calculate the distance of each reference point in the road segment relative to the starting station of the bus line based on the distance mapping function to form a reference point distance mapping table; Step 6: Traverse each point in the GPS track corresponding to each bus trip, and use the distance mapping function to map the coordinates of the GPS track to between 0 and 1 based on the distance mapping table corresponding to each bus route; Step 7: Group the GPS track set by route. The GPS tracks corresponding to all buses on each bus route form a GPS track subset. Process the GPS track subset corresponding to each bus route, convert the three-dimensional GPS track into a two-dimensional GPS track, and obtain the two-dimensional GPS track set corresponding to each route. Step 8: Traverse the two-dimensional GPS trajectory set, and use the time window to divide the two-dimensional GPS trajectory into multiple different GPS trajectory segments. Within each time window, multiple GPS trajectory segments are formed; Step 9: In each time window, traverse the GPS track segments, calculate the inclination angle and minimum bounding rectangle corresponding to each GPS track segment, and generate a hybrid index tree using the inclination angles and minimum bounding rectangles corresponding to all GPS track segments; Step 10: In each time window, traverse the hybrid index tree, filter out invalid segment candidate pairs, generate segment candidate pairs of GPS trajectory segments, and obtain a segment candidate pair set; Step 11: Traverse the candidate fragment pairs in the set, perform verification and filtering, calculate whether the candidate fragment pairs meet the rules of the synchronous movement mode, and generate candidate synchronous movement modes; Step 12: traverse and generate candidate synchronous movement patterns, merge the synchronous movement patterns, and return the synchronous movement patterns; Step 13: Implement Step 1 to Step 12 in parallel on the big data computing engine Spark; The distance mapping function in Step 5 is defined as follows: The distance between the benchmark points of the road section is used to calculate the mileage of the bus line. The calculation formula is: (13); In formula (13), is the distance between the starting point of the bus line and the nearest reference point of the bus in the direction of travel. is the distance between the last reference point and the terminal station in the travel direction of the line. is the distance between two reference points in the line; Using the distance mapping formula, the calculation formula for calculating the distance from the GPS point to the starting point of the road is: (14); In formula (14), for The last nearest benchmark point, for To route origin distance; The latitude and longitude coordinates corresponding to the GPS points in the bus trajectory are reduced in dimension and mapped to [0,1]. The specific mapping formula is: (15); In formula (15), L represents the total length of the bus route corresponding to the bus; The formula for calculating the distance between two GPS points is: (16); (17); (18); In formula (16), formula (17) and formula (18), is the radian value of the latitude difference between the two points, is the radian value of the longitude difference between the two points, and are the radians of the latitudes of the two points, is the mean radius of the Earth, Represents the distance between two GPS points in kilometers; The Step 9 is specifically as follows: Step 9.1: Input the two-dimensional trajectory segment set segSet corresponding to a single time window of a bus line, where each member represents a trajectory segment generated by a bus, segSet={Seg1, Seg 2, …, Seg n}; Step 9.2: Initialize the data structure, HybridTree(angle, (MBR, TRseg)), where angle represents the angle between the trajectory and the horizontal axis, MBR represents the minimum enclosing rectangle corresponding to the trajectory, and TRseg represents the trajectory; Step9.3: Initialize the variable i to 1 to traverse each trajectory segment in segSet; Step 9.4: Determine the relationship between i and segSet.len. If i<=r segSet.len, get the current trajectory segment currSeg= segSet [i]; otherwise, go to Step 9.9; Step 9.5: Get the starting point and end point of the current trajectory segment, startPoint = currSeg.getStartPoint, endPoint = currSeg.getEndPoint; Step 9.6: angle = getAngleWithHorizontal(startPoint, endPoint), calculate the angle between the current trajectory segment and the horizontal axis based on the start point and end point; Step 9.7: MBR = calculateMBR (currSeg), calculate the minimum bounding rectangle corresponding to the current trajectory segment; Step 9.8: HybridTree.Insert(angle,(MBR, currSeg)), insert angle and MBR into the hybrid index; Step 9.9: Variable i increases by 1, i=i+1, pointing to the next trajectory segment in the set; Step 9.10: Return the hybrid index tree HybridTree; The Step 10 is specifically as follows: In the process of generating candidate pairs, it is determined whether the MBRs corresponding to the trajectory segments have intersections. The formula for calculating the intersection is as follows: (19); In formula (19), and Represent the minimum time of trajectory 1 and trajectory 2 respectively, and Represent the maximum time of trajectory 1 and trajectory 2 respectively, and Represent the minimum distance between track 1 and track 2, and Represent the maximum distances of trajectory 1 and trajectory 2 respectively, is a Boolean variable. If If the value of is true, it means that the two MBRs intersect; otherwise, the two MBRs do not intersect; The specific execution process of generating candidate pairs is as follows: Step 10.1: Input the hybrid index tree HybridTree(angle, (MBR,TRseg) ) corresponding to a single time window of a bus line, and input the tilt angle distance threshold θ; Step 10.2: Initialize the data structure, resCandidatePair(TRseg,TRseg), to save the candidate trajectory pairs; Step 10.3: Initialize the variable i to 1 to traverse each trajectory segment in the HybridTree; Step 10.4: Determine the relationship between i and the number of elements in the hybrid index HybridTree.len. If i is less than HybridTree.len, get the current currItem=HybridTree(i); otherwise, execute Step 10.17; Step 10.5: Initialize the variable index to i+1, index=i+1, index represents the subscript of the next element; Step 10.6: Get the next element, testItem = HybridTree(index); Step 10.7: Calculate the angle difference between currItem and testItem, diff = testItem.angle - currItem.angle; Step 10.8: Determine the relationship between diff and θ. If diff is less than or equal to θ, go to the next step. Otherwise, go to Step 10.11; Step 10.9: Determine the relationship between the MBRs corresponding to the elements currItem and testItem. If there is an intersection, go to the next step; Otherwise, go to Step 10.11; Step 10.10: Add the candidate pair to the result set, resCandidatePair.insert(currItem,testItem); Step 10.11: The variable index increases by 1, index=index+1; Step 10.12: Determine the relationship between index and HybridTree.len. If index is less than or equal to HybridTree.len, go to the next step; Otherwise, go to Step 10.15; Step 10.13: Calculate the angle difference between currItem and testItem, diff = testItem.angle - currItem.angle; Step 10.14: Repeat the steps from Step 10.8 to Step 10.13; Step 10.15: The variable i is incremented by 1, i=i+1, pointing to the next element of the mixed index; Step10.16: Repeat the steps from Step10.4 to Step10.15; Step 10.17: Return the candidate result set resCandidatePair; The method for generating candidate synchronous movement patterns and merging synchronous movement patterns is specifically as follows: in Step 10, a candidate pair of vehicles in series resCandidatePair is selected, and then filtering and verification are performed according to Step 11 and Step 12, which is divided into four steps: (1) Linear distance measurement and calculation: traverse the trajectory of each vehicle to form a trajectory pair, extract the starting point and end point of the trajectory in the trajectory pair, form a vector of the trajectory containing the starting point and end point respectively, calculate the slope and intercept parameters of the straight line formed by the starting point and end point of the trajectory, then calculate the vertical distance from the starting point and end point in the trajectory vector to the straight line, and take the maximum vertical distance as the linear distance of the trajectory pair; The function interface for calculating the point to line is: (20); In formula (20), represents a straight line, Representative point; The formula for calculating the distance from a point to a line is: (21); In formula (21), , are the coordinates of the point, is the slope of the straight line, is the intercept of the straight line; (2) Track pair screening and event recording: Check the maximum vertical distance of the candidate track pairs. If it is less than the set threshold condition, the detected event is recorded, including the relevant track information and time data. After filtering the trajectory pairs, merge the car-in-train events across time windows. The calculation function interface is as follows: (22); (3) Traverse each event record and check whether the duration is less than the set threshold. If the duration is less than the threshold, check whether the vehicle corresponding to the trajectory also has a car-crossing in the next time window. If the trajectory pair also has a car-crossing, merge the duration of the event and save the events whose duration meets the set threshold in the merged result set; (4) Calculate the number of vehicles that are in contact with each other for all candidate trajectory pairs After that, it is further determined whether there are candidate pairs that need to be merged. If vehicle 1 and vehicle 2 are in series, or vehicle 2 and vehicle 3 are in series, it is necessary to further determine whether the three vehicles meet the series definition of formula (11). If so, it is determined that the three vehicles are in series with each other. Similarly, it is necessary to determine the series of three or more vehicle clusters. In order to perform fast detection and merging, a graph-based fast merging method is used. The merging principle is as follows: The interface for detecting multiple vehicles in series is: (23); In formula (23), for After grouping the data by time window and line number, the data structure and Consistency; In the interface, the conditions for serial connection must meet the following two points at the same time: Condition 1: If there are two bus groups A and B, and the number of buses in the bus group is greater than or equal to 2, one or more buses in A appear in B; Condition 2: The time difference between the maximum string start time and the minimum string end time of the two string groups A and B is greater than a certain time threshold; Under the above conditions, an undirected graph is used to quickly detect the situation of multiple vehicles in series. The data in is input, and the license plate numbers of TR1 and TR2 of each column of trajectory pair data are inserted into the graph as the values of the graph nodes. The rest of the information is recorded in the edges. The form of the undirected graph is as follows: Graph =( V , E )(24); In formula (24), V is a set of nodes, and the form of V is as follows: (25); In formula (25), is a collection of different bus license plate numbers; is a set of edges, representing The connection relationship between each node in The form is as follows: (26); In formula (26), , all correspond to a record in TandemPair, in the form of: (27); The condition for e to exist is that the serial vehicle records still meet the time condition after merging, as described by the following formula: (28); In formula (28), and Respectively represent and The maximum meeting time and minimum departure time of two trajectory points, Indicates the minimum time for judging as a car string; The Step 11 is specifically as follows: Step 11.1: Input the candidate pair of buses in a bus line, lineCandidatePair(Trseg,TRseg), the distance threshold DIS, and the time threshold T; Step 11.2: Initialize the data structure tandemBusPairs(startT,endT,TRseg,TRseg) to save the calculation results of bus pairs; initialize the data structure tandemBusTRs(startT,endT,List[TRseg]) to save the results of multiple bus series; Step 11.3: Initialize the variable i to 1 to traverse the candidate pairs of vehicles in series; Step 11.4: Determine the relationship between i and the number of candidate pairs lineCandidatePair.len. If i<=lineCandidatePair.len, set (track1, track2) = lineCandidatePair[i]; if i>lineCandidatePair.len, go to Step 11.11; Step 11.5: Get the straight line L that connects the start point and end point of track1, and get the start point p1, midpoint p2, and end point p3 of track2; Step 11.6: Use the function described in formula (20) to calculate the distances from the three points of track2 to the line L respectively, and return the maximum distance maxDis; Step 11.7: If maxDis<=DIS, get the start time startTime and end time endTime of the train connection of track1 and track2, otherwise go to Step 11.11; Step 11.8: Calculate the connection time of track1 and track2, tandamTime = endTime - startTime; Step 11.9: Determine the relationship between tandemTime and T. If tandemTime>=T, add the track pair to the result set of tandem bus track pairs, tandemBusPairs.insert(startT,endT,track1,track2). Otherwise, go to Step 11.
10. Step 11.10: Variable i increases by 1, i=i+1, pointing to the next trajectory pair of the candidate pair of vehicles in series; Step 11.12: Initialize the variable j to 1, which is used to traverse the bus string pairs, and initialize the variable Graph (V, E) as shown in formula (24) to quickly organize the route data into a graph structure, so as to detect multiple bus strings; Step 11.13: Determine the relationship between j and tandemBusPairs.len. If j <= tandemBusPairs.len, set (Tra1, Tra2) = tandemBusPairs[j]. Otherwise, go to Step 11.
16. Step 11.14: Add an edge to the graph Graph.addEdge(Tra1, Tra2), and add a node to the graph Graph.addNode(Tra1.id, Tra2.id); Step 11.15: Variable j increases by 1, j=j+1, pointing to the next track pair of the serial vehicle pair; Step 11.16: Traverse the graph structure Graph, obtain all the tandem links List [tandemLLines(V,E)], and perform the following operations on each tandem link; Step 11.17: Initialize the variable k to 1 to traverse the serial link; Step 11.18: Determine the relationship between k and tandemLLines.len. If k <= tandemLLines.len, store the current edge in variable e = tandemLLines.getEdge[k]. Otherwise, go to Step 11.
22. Step11.19: tStart and tEnd are respectively the starting time and ending time of the train formation for the track pair in e. If tEnd - tStart > T, update the starting time and ending time of the track pairs TR1 and TR2 in edge e to tStart and tEnd; Step11.20: The variables realST and realET are used to save the starting time and ending time of the train formation of tandemBusTRs. If realST < tStart, then realST = tStart; if realET > tEnd, then realET = tEnd; Step11.21: tandemBusTRs.add(realST, realET, list{TR1, TR2}), add the track pair corresponding to the current number to the train formation result of the line and update the train formation time, then go to Step11.23; Step11.22: Increment the variable k by 1, k = k + 1, to point to the next set of data in the train formation link; Step11.23: Remove duplicates from the duplicate tracks in tandemBusTRs, and return the train formation detection result tandemBusTRs of multiple buses.
2. The method for detecting bus synchronous movement patterns at large temporal and spatial scales according to claim 1 is characterized in that: The relevant definitions are as follows: One bus line manages multiple buses. The set of bus vehicles belonging to the same line is defined as: (1); In formula (1), For buses, ; There are bus stops on the line where the bus travels. Different bus lines have different sequences of bus stops. The definition of the set of bus stops is: (2); In formula (2), The bus stops on the bus route. ; In the urban public transportation system, multiple bus lines operate simultaneously. The definition of the set of bus lines is: (3); In formula (3), bus routes, ; All buses are equipped with GPS positioning devices, and the devices will generate GPS records at regular intervals. The GPS records contain three fields: timestamp, longitude, and latitude. The three fields form a spatio-temporal point. The definition of the spatio-temporal point is: (4); In formula (4), Represents the GPS timestamp, represents the longitude of the point, represents the latitude of the point; The GPS track of a bus describes a series of chronologically ordered GPS records generated during the bus's travel along a predetermined line. The definition of the vehicle's travel track is: (5); In formula (5), , represents a series of space-time points generated by the bus in chronological order; The line track set contains the track sets generated by all buses on a specific route, and details the specific location information of each bus's travel. The definition is as follows: (6); In formula (6), For the line trajectory, ; After map matching the GPS track of each bus, each GPS point will be associated with a section number. The form of the GPS track segment after map matching is as follows: (7); In formula (7), is the GPS point of the bus, , Number the road sections of the map road network; Each bus line travels along a specific route, and each line is composed of a sequence of sections. After map matching the GPS track of the bus, the track is transformed into a sequence of sections. The form of the section sequence is as follows: (8); In formula (8), For bus routes, is the road section number, ; The map road network is composed of many lines. The lines are divided into many sections by each other, and each section is composed of many reference points. Each reference point is composed of a set of longitude and latitude coordinates. The organizational form of the section is as follows: (9); In formula (9), is the reference point on the road section, ; Define the bus clusters that travel successively on a certain line as follows: (10); In formula (10), the subscripts represent the relative positions of the buses on the road. For bus clusters, ; The definition of bus bunching is: (11); exist Within the time range, the following definitions are met: ; (12); In formula (11) and formula (12), Represents a bus cluster and bus clusters The distance in the space-time dimension, in the car-in-car mode, the number of vehicles is greater than or equal to , the distance between any adjacent vehicles is less than d, and the pattern duration is greater than t.
3. According to claim 1, a bus synchronous movement mode detection method for large temporal and spatial scales is characterized in that: The specific content of the said Step5 is: Step5.1: Input the section sequence roadSegList corresponding to a certain bus line; Step 5.2: Initialize the distance mapping table distMappingTable<point,distance> , initialize the distance corresponding to the first reference point to distance 0, and specify the first reference point as point; Step 5.3: Initialize the variable i to 1 to traverse each road segment in roadSegList; Step 5.4: Determine the relationship between i and the number of road segments in the road segment sequence roadSegList.len; If i<=roadSegList.len, get the current road segment currentSeg= roadSegList[i]; otherwise, go to Step 5.11; Step 5.5: Initialize the variable j to 1 to traverse each reference point in currentSeg; Step 5.6: Determine the relationship between j and the number of reference points in the road segment, currentSeg.len; If j<=currentSeg.len, get the current reference point currPoint= currentSeg[j]; Otherwise, go to Step 5.10; Step 5.7: Calculate the distance between the current reference point currPoint and the previous reference point point according to formulas (16), (17), and (18) in order, and save the result in currDist; Step 5.8: distMappingTable.insert(currPoint, currDist), add the current point and its corresponding distance to the distance mapping table; Step5.9: Assign the current reference point currPoint to the previous reference point point, point=currPoint; Step 5.10: Variable j increases by 1, j=j+1, pointing to the next reference point of the current road section; Step 5.11: The variable i is incremented by 1, i=i+1, pointing to the next section of the current sequence; Step5.12: Return the distance mapping table distMappingTable.
4. The method for detecting bus synchronous movement patterns at large temporal and spatial scales according to claim 1 is characterized in that: The step 6 is specifically as follows: Step 6.1: Input the GPS track rawTR corresponding to a bus and the distance mapping table distMappingTable; Step 6.2: Initialize the key value type data structure resTR<time, distance> , where resTR is the trajectory in two-dimensional space, time represents the timestamp, and distance represents the relative distance of the longitude and latitude coordinates from the starting point, with a value between 0 and 1; Step 6.3: Initialize the variable i to 1 to traverse each GPS point in rawTR; Step 6.4: Determine the relationship between i and rawTR.len. If i<=rawTR.len, get the current GPS point currPoint=rawTR[i]; otherwise, go to Step 6.12; Step 6.5: According to the current GPS point, find the reference point closest to the current point in the corresponding road section sequence, wPoint=getRefPoint(currPoint); Step 6.6: According to the reference point wPoint, obtain the absolute distance of the reference point from the origin through the distance mapping table, refDistance = getDistanceFromTable (distMappingTable, wPoint); Step 6.7: Calculate the distance between the current reference point currPoint and the reference point wPoint according to formulas (16), (17), and (18) in order, and save the result in comDistance; Step 6.8: Calculate the sum of the absolute distances between the current GPS point and the corresponding route starting point, solDistance = refDistance + comDistance; Step 6.9: Map the latitude and longitude coordinates of the current GPS point to between 0 and 1. The specific calculation formula is relativeDistance=(solDistance / L), where L is the length of the entire route in kilometers; Step6.10: Construct the point newPoint(currPoint.time, relativeDistance) in two-dimensional space; Step6.11: Insert the point newPoint in the two-dimensional space into the two-dimensional trajectory, resTR.insert(newPoint); Step 6.12: Variable i increases by 1, i=i+1, pointing to the next GPS point of the trajectory; Step 6.13: Return to the two-dimensional space trajectory resTR.
5. The method for detecting bus synchronous movement patterns at large temporal and spatial scales according to claim 1, characterized in that: The Step 13 is specifically as follows: Step 13.1: Load data from HDFS through load(...) to generate the initial RDD[(id, point)]; Step 13.2: Use groupByKey() to group the data by vehicle number and time, and generate trajectory RDD [(id, TR)]; Step 13.3: Use mapValues(udfDistProject) to perform distance mapping and generate RDD[(id, DTR)] with distance attributes; Step 13.4: Repartition the trajectory by route through partitionBy(udfRepartition) to generate the repartitioned RDD[(id, TR)]; Step 13.5: Apply mapValues(udfHybridIndex) to generate a hybrid index and obtain RDD[(id, w,HybridIndex)], where w is the time window and HybridIndex is the sequence number of the hybrid index; Step 13.6: Filter invalid trajectory pairs through mapValues(udfFilter) to generate RDD[(id, segA, segB, ..., segF)] containing the retained trajectory segments; Step 13.7: Use mapValues(udfRefine) to verify the candidate trajectory pairs and generate RDD[(id, w, A, B, C)], where w is the time window in which the synchronous mobility pattern occurs, and A, B, C are the vehicles in which the synchronous mobility pattern occurs; Step 13.8: The data is saved back to the text file in HDFS through collect(...) and save(...) operations.
Citation Information
Patent Citations
A Spatio-temporal Trajectory Clustering Pattern Mining Algorithm Based on R * Tree Index
CN109241126A
A method and system for online analysis of group trajectory accompaniment patterns in a big data environment
CN110580251B
Road network trajectory clustering analysis method based on improved DPC algorithm
CN111046968A
System and method for drawing driving track on basis of vehicle data
CN105716617A
Road segment matching method and system for bus GPS data
CN108831180A
Cited By
Bus synchronous movement mode detection method for large spatial-temporal scale based on GPU cluster
CN121210582A
A GPU cluster-based bus synchronous moving pattern detection method for large space-time scale
CN121210582B