Method and device for determining public transport vehicle taken by user
Technical Field
The invention belongs to the technical field of intelligent transportation, and particularly relates to a method and a device for determining a public transport vehicle taken by a user.
Background
In many scenarios of bus-related operations, it is often necessary to know which bus the user is riding. For example, complaints of users about buses are processed, the users lose things on the buses, or friends in the same row appoint to take the same bus at different bus-boarding stations for going out, and the like.
Currently, there is no method for automatically determining whether a user is riding a vehicle, and generally, the user is required to input the riding vehicle by himself or select the riding vehicle by the user from a vehicle list. In addition, a possible technical scheme is that a vehicle taken by a user is determined through data of card swiping on the bus, but due to the existence of a data island, card swiping data of the user is difficult to obtain in many scenes, and most bus card swiping data are not uploaded to a server in real time. In addition, due to the diversity of bus payment modes, if the user adopts cash payment and does not have card swiping information, the bus taken by the user cannot be determined.
In conclusion, the license plate number of the bus is input in a manual mode, the operation of a user is needed, time and labor are wasted, the user is likely to forget or remember by mistake, and the user is also required to get off to check the license plate number when forgetting; information islands exist in the card swiping data, and the user riding vehicle data cannot be acquired in a cash payment mode.
Disclosure of Invention
In order to overcome the problems of time and labor waste, high error probability and low universality of the existing method for determining the bus taken by the user or at least partially solve the problems, the embodiment of the invention provides a method and a device for determining the bus taken by the user.
According to a first aspect of embodiments of the present invention, there is provided a method of determining a public transport vehicle in which a user is riding, comprising:
the method comprises the steps of obtaining a route of a public transport vehicle taken by a user, and obtaining all operated public transport vehicles on the route;
calculating the distance between each operated public transport vehicle and the user, taking the operated public transport vehicles corresponding to the distance smaller than a first preset threshold value as alternative vehicles, and taking the set of all the alternative vehicles as a vehicle alternative set;
judging whether the distance between a unique candidate vehicle and the user is smaller than a second preset threshold value or not in the vehicle candidate set, and judging whether the distances between other candidate vehicles except the unique candidate vehicle in the vehicle candidate set and the user are larger than or equal to a third preset threshold value or not, if so, taking the unique candidate vehicle as a bus vehicle taken by the user; wherein the third preset threshold is greater than the second preset threshold.
According to a second aspect of the embodiments of the present invention, there is provided an apparatus for determining a public transportation vehicle taken by a user, including:
the system comprises an acquisition module, a display module and a control module, wherein the acquisition module is used for acquiring a route of the public transport vehicles taken by a user and acquiring all operated public transport vehicles on the route;
the calculation module is used for calculating the distance between each operated public transport vehicle and the user, taking the operated public transport vehicle corresponding to the distance smaller than a first preset threshold value as an alternative vehicle, and taking the set of all the alternative vehicles as a vehicle alternative set;
the determining module is used for judging whether the distance between the user and a unique candidate vehicle exists in the vehicle candidate set or not, and the distances between the user and other candidate vehicles in the vehicle candidate set except the unique candidate vehicle are larger than or equal to a third preset threshold, if yes, the unique candidate vehicle is taken as a public transport vehicle taken by the user; wherein the third preset threshold is greater than the second preset threshold.
According to a third aspect of the embodiments of the present invention, there is also provided an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor invokes the program instructions to perform the method for determining a public transportation vehicle occupied by a user provided in any one of the various possible implementations of the first aspect.
According to a fourth aspect of embodiments of the present invention, there is also provided a non-transitory computer readable storage medium storing computer instructions for causing a computer to perform a method of determining a public transportation vehicle occupied by a user as provided in any one of the various possible implementations of the first aspect.
The embodiment of the invention provides a method and a device for determining a bus taken by a user, wherein the method comprises the steps of acquiring a route of the bus taken by the user when the user takes the bus, acquiring all operated buses on the route, screening out alternative vehicles according to the distance between the user and each operated bus, and taking a unique alternative vehicle as the bus taken by the user if the distance between the unique alternative vehicle and the user is smaller than a second preset threshold value and the distances between other alternative vehicles and the user are larger than or equal to a third preset threshold value.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
Fig. 1 is a schematic overall flow chart of a method for determining a public transport vehicle taken by a user according to an embodiment of the present invention;
fig. 2 is a schematic overall structure diagram of an apparatus for determining a public transportation vehicle taken by a user according to an embodiment of the present invention;
fig. 3 is a schematic view of an overall structure of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
In an embodiment of the present invention, a method for determining a bus taken by a user is provided, and fig. 1 is an overall flowchart of the method for determining a bus taken by a user according to the embodiment of the present invention, where the method includes: s101, acquiring a route of a public transport vehicle taken by a user, and acquiring all operated public transport vehicles on the route;
the route of the public transportation vehicle taken by the user can be acquired in various ways. One method may be selected by user input, as the user generally knows the route of the bus he/she is taking; and the other method can also calculate the route of the bus taken by the user through the GPS data of the client uploaded by the client of the user. The present embodiment is not limited to these two ways. The client of the user can be a smart phone, the smart phone is very popular, and the smart phone is provided with a GPS data positioning function. When a user takes a bus, GPS data of the user client side is collected through a GPS data positioning function. Then according to the line L of the public transport vehicles taken by the user1Screening out the line L1And all the operated buses are started.
S102, calculating the distance between each operated public transport vehicle and the user, taking the operated public transport vehicles corresponding to the distance smaller than a first preset threshold value as alternative vehicles, and taking the set of all the alternative vehicles as a vehicle alternative set;
the distance between each operating public transport vehicle and the user is calculated. For any one operated bus, the distance between the operated bus and the user can be calculated according to the latest GPS (Global Positioning System) data of each operated bus and the latest GPS data of the client of the user. The client of the user and the operated public transport vehicles upload GPS data in real time, namely the GPS data of the client and the operated public transport vehicles can be collected in real time. And acquiring an operation public transport vehicle which is less than a first preset threshold value d from the user, wherein if d is 1000 meters. And taking the set of the operation public transport vehicles which are less than a first preset threshold value from the user as a vehicle alternative set. Namely the alternative vehicle set U = { < license plate number 1, gps1, time1>, < license plate number 2, gps2, time2>, … }. The license plate number 1 represents the license plate number of a first operation bus, the GPS1 represents the GPS data of the first operation bus, the time1 represents the GPS data acquisition time of the first operation bus, the license plate number 2 represents the license plate number of a second operation bus, the GPS2 represents the GPS data of the second operation bus, and the time2 represents the GPS data acquisition time of the second operation bus.
S103, judging whether the distance between the user and a unique candidate vehicle exists in the vehicle candidate set or not, wherein the distance between the user and other candidate vehicles except the unique candidate vehicle in the vehicle candidate set is smaller than a second preset threshold value, and the distance between the user and other candidate vehicles except the unique candidate vehicle in the vehicle candidate set is larger than or equal to a third preset threshold value, and if yes, taking the unique candidate vehicle as a bus vehicle taken by the user; wherein the third preset threshold is greater than the second preset threshold.
And judging whether the distance between the unique candidate vehicle and the user is smaller than a second preset threshold value minDis according to the distance between each candidate vehicle in the vehicle candidate set and the user, wherein if the distance between the unique candidate vehicle and the user is smaller than the second preset threshold value minDis, the distance between other candidate vehicles and the user is larger than or equal to a third preset threshold value. Preferably, the third preset threshold is 2 minDis. And if so, taking the only alternative vehicle with the distance to the user being less than minDis as the bus vehicle taken by the user, and quitting the execution. And determining the bus vehicle taken by the user according to the license plate number of the unique candidate vehicle in the vehicle candidate set.
In the embodiment, GPS data of a user client is acquired through a GPS positioning function, and then the GPS data of the public transport vehicle is combined, so that the relative relation and displacement condition of the user position and the vehicle position are judged by the two types of data of the user, whether the user is on a certain public transport vehicle or not is determined, and the public transport vehicle taken by the user is determined. The user client-side GPS data, the bus GPS data and the corresponding bus license plate number can be given when the user takes the bus, and the bus taking the user can be judged.
According to the method and the device, when the user takes the bus, the route of the bus taken by the user is obtained, all operated buses on the route are obtained, the alternative vehicles are screened out according to the distance between the user and each operated bus, if the distance between the unique alternative vehicle and the user is smaller than a second preset threshold value, and the distances between other alternative vehicles and the user are larger than or equal to a third preset threshold value, the unique alternative vehicle is used as the bus taken by the user.
On the basis of the foregoing embodiment, in this embodiment, after the step of taking the operated bus corresponding to the distance smaller than the first preset threshold as the candidate vehicle, the method further includes: calculating a difference between the GPS data update time of the client of the user and the GPS data update time of each alternative vehicle; corresponding to any one of the alternative vehicles, dividing the distance between the alternative vehicle and the user by the difference value to obtain the running speed of the alternative vehicle; and if the running speed of the candidate vehicle is not within the preset speed range, deleting the candidate vehicle from the vehicle candidate set.
The updating frequency of the GPS data of the user client is generally less than 30 seconds, and the updating frequency of the public transport vehicle is generally less than 15 seconds/time. For any candidate vehicle in the vehicle candidate set U, the distance between the candidate vehicle and the user is obtained S1, the time difference t1 of the GPS data update of the user client and the candidate vehicle is calculated, namely the time of the GPS data update of the user client-the time of the GPS data update of the candidate vehicle, and the running speed v = S1/t1 of the candidate vehicle is estimated. If v is not within the preset speed range, the vehicle is deleted from the vehicle candidate set. The preset speed range is set according to the reasonable speed range of the bus.
On the basis of the foregoing embodiment, in this embodiment, the step of determining whether the distance between the user and the only candidate vehicle in the vehicle candidate set is smaller than a second preset threshold, and the distances between the user and the other candidate vehicles in the vehicle candidate set except the only candidate vehicle are greater than or equal to a third preset threshold further includes: if the distance between a plurality of or no alternative vehicles in the vehicle alternative set and the user is smaller than a second preset threshold value, continuously acquiring the GPS data of the client of the user and the GPS data of each alternative vehicle;
if a plurality of candidate vehicles or no candidate vehicle is within the range from the user minDis, the riding vehicle of the user cannot be determined temporarily, the GPS data updated after the user client and the GPS data updated after each candidate vehicle are continuously acquired, and the riding vehicle of the user is judged by using more GPS data.
For any alternative vehicle, if the difference value between the current GPS data acquisition time of the client and the latest GPS data acquisition time of the alternative vehicle is smaller than a fourth preset threshold value, constructing a GPS pair according to the current GPS data of the client, the latest GPS data of the alternative vehicle, the current GPS data acquisition time of the client and the latest GPS data acquisition time of the alternative vehicle, and adding the GPS pair into a GPS pair list corresponding to the alternative vehicle;
for any alternative vehicle, if the difference between the current GPS data acquisition time of the client and the latest GPS data acquisition time of the alternative vehicle is less than a fourth preset threshold t2, a GPS pair < the current GPS data of the client, the latest GPS data of the alternative vehicle, the current GPS data acquisition time of the client, the latest GPS data acquisition time of the alternative vehicle > is constructed, and the GPS pair is added to the GPS pair list corresponding to the alternative vehicle. For each candidate vehicle in the vehicle candidate set U, a LIST of GPS pairs is maintained, and the GPS pair of each candidate vehicle is added to the corresponding LIST of GPS pairs LIST.
If a plurality of GPS pairs exist in the GPS pair list, selecting a preset number of recently added GPS pairs from the GPS pair list; calculating the distance between the user and the alternative vehicle according to the selected GPS pairs, and calculating the moving distance of the user according to the GPS data of the client side of the GPS pair which is added in the selected GPS pair at the earliest and the GPS data of the client side of the GPS pair which is added in the selected GPS pair at the latest; and judging whether the distance between the user and the alternative vehicle is smaller than the second preset threshold value and whether the moving distance of the user is larger than a fifth preset threshold value, and if so, determining that the user takes the alternative vehicle.
For any alternative vehicle, if a plurality of GPS pairs, such as three or more, exist in the candidate vehicle's GPS pair list, a preset number of GPS pairs, such as three, that have recently been added are selected from the candidate vehicle's GPS pair list. And calculating the distance between the user and each alternative vehicle in the selected GPS pair according to the GPS data of the client in the selected GPS pair and the GPS data of the alternative vehicles. And calculating the moving distance of the user according to the GPS data of the client terminal of the GPS pair which is added in the earliest time in the selected GPS pair and the GPS data of the client terminal of the GPS pair which is added in the latest time in the selected GPS pair. If the preset number is 3, calculating the moving distance of the user according to the GPS data of the client of the first joined GPS pair and the GPS data of the client of the third joined GPS pair in the 3 GPS pairs. And if the distance between the user and each candidate vehicle in each selected GPS pair is smaller than the second preset threshold value minDis, and the moving distance of the user is larger than a fifth preset threshold value d2, determining that the user takes the candidate vehicle. d2 may take 200 to 500 meters. Execution then exits.
And constructing a GPS pair and adding the GPS pair into a GPS pair list every time the user client updates GPS data, and then judging until the bus taken by the user is judged.
In another embodiment of the present invention, an apparatus for determining a public transportation vehicle taken by a user is provided, and the apparatus is used for implementing the method in the foregoing embodiments. Therefore, the description and definition in the embodiments of the method for determining the public transportation vehicle taken by the user can be used for understanding the execution modules in the embodiments of the present invention. Fig. 2 is a schematic overall structure diagram of an apparatus for determining a public transportation vehicle taken by a user according to an embodiment of the present invention, where the apparatus includes an obtaining module 201, a calculating module 202, and a determining module 203, where:
the acquisition module 201 is configured to acquire a route of a bus taken by a user, and acquire all operated buses on the route;
the acquisition module 201 may acquire the route of the public transportation vehicle taken by the user in various ways. One method may be selected by user input, as the user generally knows the route of the bus he/she is taking; and the other method can also calculate the route of the bus taken by the user through the GPS data of the client uploaded by the client of the user. The present embodiment is not limited to these two ways. The client of the user can be a smart phone, the smart phone is very popular, and the smart phone is provided with a GPS data positioning function. When a user takes a bus, GPS data of the user client side is collected through a GPS data positioning function. Then, the obtaining module 201 screens out all the operated buses on the route according to the route of the buses taken by the user.
The calculating module 202 is configured to calculate a distance between each operated bus and the user, use the operated bus corresponding to the distance smaller than a first preset threshold as an alternative vehicle, and use a set of all the alternative vehicles as a vehicle alternative set;
the calculation module 202 calculates the distance between each operating public transport vehicle and the user. For any one bus in operation, the distance between the bus in operation and the user can be calculated according to the latest GPS data of each bus in operation and the latest GPS data of the client of the user. The client of the user and the operated public transport vehicles upload GPS data in real time, namely the GPS data of the client and the operated public transport vehicles can be collected in real time. And acquiring the operation public transport vehicles which are less than a first preset threshold value from the user. And taking the set of the operation public transport vehicles which are less than a first preset threshold value from the user as a vehicle alternative set.
The determining module 203 is configured to determine whether a distance between a unique candidate vehicle and the user in the vehicle candidate set is smaller than a second preset threshold, and distances between other candidate vehicles in the vehicle candidate set except the unique candidate vehicle and the user are both greater than or equal to a third preset threshold, and if yes, use the unique candidate vehicle as a bus vehicle taken by the user; wherein the third preset threshold is greater than the second preset threshold.
The determining module 203 determines whether the distance between the unique vehicle candidate and the user is smaller than a second preset threshold and the distances between the other vehicle candidates and the user are greater than or equal to a third preset threshold according to the distance between each vehicle candidate in the vehicle candidate set and the user. And if the alternative vehicles exist, taking the only alternative vehicles with the distance to the user smaller than a second preset threshold value as the buses taken by the user, and quitting the execution. And determining the bus vehicle taken by the user according to the license plate number of the unique candidate vehicle in the vehicle candidate set.
According to the method and the device, when the user takes the bus, the route of the bus taken by the user is obtained, all operated buses on the route are obtained, the alternative vehicles are screened out according to the distance between the user and each operated bus, if the distance between the unique alternative vehicle and the user is smaller than a second preset threshold value, and the distances between other alternative vehicles and the user are larger than or equal to a third preset threshold value, the unique alternative vehicle is used as the bus taken by the user.
On the basis of the foregoing embodiment, the obtaining module of this embodiment is specifically configured to: and determining the route of the bus taken by the user according to the GPS data of the client uploaded by the client of the user.
On the basis of the foregoing embodiment, the calculating module in this embodiment is specifically configured to: and calculating the distance between each operated bus and the user according to the latest GPS data of each operated bus and the latest GPS data of the client of the user.
On the basis of the above embodiment, the present embodiment further includes a deletion module, configured to calculate a difference between the GPS data update time of the client of the user and the GPS data update time of each candidate vehicle; corresponding to any one of the alternative vehicles, dividing the distance between the alternative vehicle and the user by the difference value to obtain the running speed of the alternative vehicle; and if the running speed of the candidate vehicle is not within the preset speed range, deleting the candidate vehicle from the vehicle candidate set.
On the basis of the foregoing embodiments, in this embodiment, the determining module is further configured to: if the distance between a plurality of or no alternative vehicles in the vehicle alternative set and the user is smaller than a second preset threshold value, continuously acquiring the GPS data of the client of the user and the GPS data of each alternative vehicle; for any alternative vehicle, if the difference value between the current GPS data acquisition time of the client and the latest GPS data acquisition time of the alternative vehicle is smaller than a fourth preset threshold value, constructing a GPS pair according to the current GPS data of the client, the latest GPS data of the alternative vehicle, the current GPS data acquisition time of the client and the latest GPS data acquisition time of the alternative vehicle, and adding the GPS pair into a GPS pair list corresponding to the alternative vehicle; if a plurality of GPS pairs exist in the GPS pair list, selecting a preset number of recently added GPS pairs from the GPS pair list; calculating the distance between the user and the alternative vehicle according to the selected GPS pairs, and calculating the moving distance of the user according to the GPS data of the client side of the GPS pair which is added in the selected GPS pair at the earliest and the GPS data of the client side of the GPS pair which is added in the selected GPS pair at the latest; and judging whether the distance between the user and the alternative vehicle is smaller than the second preset threshold value and whether the moving distance of the user is larger than a fifth preset threshold value, and if so, determining that the user takes the alternative vehicle.
On the basis of the above embodiment, in this embodiment, the third preset threshold is twice the second preset threshold.
The embodiment provides an electronic device, and fig. 3 is a schematic view of an overall structure of the electronic device according to the embodiment of the present invention, where the electronic device includes: at least one processor 301, at least one memory 302, and a bus 303; wherein,
the processor 301 and the memory 302 are communicated with each other through a bus 303;
the memory 302 stores program instructions executable by the processor 301, and the processor calls the program instructions to perform the methods provided by the above method embodiments, for example, the method includes: acquiring a route of a public transport vehicle taken by a user, and acquiring all operated public transport vehicles on the route; calculating the distance between each operated public transport vehicle and a user, taking the operated public transport vehicle corresponding to the distance smaller than a first preset threshold value as an alternative vehicle, and taking the set of all the alternative vehicles as a vehicle alternative set; judging whether the distance between the unique candidate vehicle and the user is smaller than a second preset threshold value or not in the vehicle candidate set, and judging whether the distances between other candidate vehicles except the unique candidate vehicle in the vehicle candidate set and the user are larger than or equal to a third preset threshold value or not, if so, taking the unique candidate vehicle as a public transport vehicle taken by the user; and the third preset threshold is greater than the second preset threshold.
The present embodiments provide a non-transitory computer-readable storage medium storing computer instructions that cause a computer to perform the methods provided by the above method embodiments, for example, including: acquiring a route of a public transport vehicle taken by a user, and acquiring all operated public transport vehicles on the route; calculating the distance between each operated public transport vehicle and a user, taking the operated public transport vehicle corresponding to the distance smaller than a first preset threshold value as an alternative vehicle, and taking the set of all the alternative vehicles as a vehicle alternative set; judging whether the distance between the unique candidate vehicle and the user is smaller than a second preset threshold value or not in the vehicle candidate set, and judging whether the distances between other candidate vehicles except the unique candidate vehicle in the vehicle candidate set and the user are larger than or equal to a third preset threshold value or not, if so, taking the unique candidate vehicle as a public transport vehicle taken by the user; and the third preset threshold is greater than the second preset threshold.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.