Search method and the device of GPS periphery
Technical field
The invention belongs to network technology field, particularly relate to a kind of method and the device of searching GPS periphery.
Background technology
GPS (GlobalPositionSystem, global positioning system (GPS)) common apply to mobile terminal and configuration of automobiles, its topmost function is for user provides navigation Service, as long as user inputs point of destination in navigating instrument, system can automatically complete path of navigation and calculate, and advanced along the route preset by display screen and voice guiding in real time user in stroke way. In ecommerce, businessman needs to use GPS to be positioned client position in the process providing service, to determine whether this user provides service or provides service by the site in which region to client.
In prior art, businessman obtains the GPS location of client, by the distance of the position and client that calculate self, judges this distance whether in default scope, and when the data volume of user is many, greatly, speed of response is slow for the calculated amount causing data.
Summary of the invention
The object of the embodiment of the present invention is to provide a kind of method and device searching GPS periphery, it is intended to solve by searching the big problem of GPS perimeter data amount in prior art.
The embodiment of the present invention realizes like this, and a kind of method searching GPS periphery, described method comprises the steps:
Centered by the GPS location of a default server, draw a preset shape;
Judge in the scope whether GPS location of each client terminal falls into described shape, it is judge that described client terminal is in the peripheral extent of described server.
Further, described centered by the GPS location of a default server, draw a preset shape and specifically comprise:
Centered by the GPS location of described server, according to one or more default length value, calculate described shape at horizontal and vertical length value;
Described shape is described according to described horizontal and vertical length value.
Further, described judge it is judge that the peripheral extent that described client terminal is in described server specifically comprises in the scope whether GPS location of each client terminal falls into described shape:
Obtain the gps coordinate of multiple point on the frame of described shape;
The described gps coordinate of multiple point, the gps coordinate of described client terminal are converted into binary data or shape data;
Contrast binary data or the shape data of described multiple point and described client terminal, when difference is less than preset value, judge that described client terminal is in the peripheral extent of described server.
Further, described shape is square, circular or rectangle.
Further, when described shape is square, on the frame of described shape, the gps coordinate of multiple point is the coordinate figure on described four square summits.
The present invention also proposes a kind of device searching GPS periphery, and described device comprises:
Drafting module, for, centered by the GPS location of a default server, drawing a preset shape;
Judge module, whether fall into for judging the GPS location of each client terminal in the scope of described shape, be, judge that described client terminal is in the peripheral extent of described server.
Further, described drafting module comprises:
Calculate unit, for centered by the GPS location of described server, according to one or more default length value, calculate described shape at horizontal and vertical length value;
Describe unit, for describing described shape according to described horizontal and vertical length value.
Further, described judgement module comprises:
Acquiring unit, the gps coordinate of multiple point on the frame obtaining described shape;
Scaling unit, for being converted into binary data or shape data by the described gps coordinate of multiple point, the gps coordinate of described client terminal;
Contrast unit, for contrasting binary data or the shape data of described multiple point and described client terminal, when difference is less than preset value, judges that described client terminal is in the peripheral extent of described server.
Further, described shape is square, circular or rectangle.
Further, when described shape is square, on the frame of described shape, the gps coordinate of multiple point is the coordinate figure on described four square summits.
The embodiment of the present invention, by customer-centric, is drawn a shaped at user's periphery certain distance, is judged to be in user's GPS periphery for any point fallen in this form range, and the distance avoiding user and peripheral point calculates, and has saved the data volume calculated. And all data are all converted into scale-of-two or shaping calculates, and further save calculated amount, significantly reduce computing amount and the resource occupation of server, it is to increase accurate data degree.
Accompanying drawing explanation
Fig. 1 is the schema of the method searching GPS periphery that the embodiment of the present invention one provides;
Fig. 2 is the schema of plot step in the method searching GPS periphery that provides of the embodiment of the present invention one;
Fig. 3 is the schema of determining step in the method searching GPS periphery that provides of the embodiment of the present invention one;
Fig. 4 is the structure iron of the device searching GPS periphery that the embodiment of the present invention two provides;
Fig. 5 is the structure iron of drafting module in the device searching GPS periphery that provides of the embodiment of the present invention two;
Fig. 6 judges the structure iron of module in the device searching GPS periphery that provides of the embodiment of the present invention two.
Embodiment
In order to make the object of the present invention, technical scheme and advantage clearly understand, below in conjunction with drawings and Examples, the present invention is further elaborated. It is to be understood that specific embodiment described herein is only in order to explain the present invention, it is not intended to limit the present invention.
Embodiment one
As shown in Figure 1, the method for a kind of GPS of searching periphery that the embodiment of the present invention one proposes comprises step:
S1, centered by the GPS location of a default server, draw a preset shape; In actual applications, this server position is businessman position, and default shape can be arrange according to actual needs, such as square, circular, rectangle etc., it may be preferred that select the square shape as the embodiment of the present invention one. As shown in Figure 2, this step specifically comprises:
S11, centered by the GPS location of server, according to one or more default length value, calculate shape at horizontal and vertical length value;For square, owing to the length of side is identical, only a length value need to be set, according to this length value, can calculate centered by the GPS location of server, square at horizontal and vertical length value. Other shape in this way, such as rectangle, then needs to arrange two length values, and a length value is as rectangular length, and another length value is as rectangular width.
S12, describe described shape according to horizontal and vertical length value. The transverse direction of known form and the length value of drafting, then depict this shape centered by the GPS location of server, and further, the also direction of this shape of adjustable, with applicable customer need.
Whether S2, the GPS location judging each client terminal fall in the scope of this shape, are, judge that client terminal is in the peripheral extent of server. As shown in Figure 3, step S2 specifically comprises:
S21, the gps coordinate obtaining multiple point on the frame of shape; For rectangle or square, it is preferable that select the gps coordinate on four summits on frame, for circular or other shape, the gps coordinate of multiple point can be selected equidistantly.
S22, multiple gps coordinate of point, the gps coordinate of client terminal are converted into binary data or shape data; When server receives the request of client terminal, this request includes the gps coordinate of client terminal and the longitude of client terminal and latitude, the gps coordinate of multiple points selected in step S21 and the gps coordinate of client terminal are converted into binary data or shape data further, binary data or shape data after conversion compare GPS coordinate data, its data volume greatly reduces, and precision improves greatly.
S23, the binary data contrasting multiple point and client terminal or shape data, when difference is less than preset value, judge that client terminal is in the peripheral extent of described server. Above-mentioned preset value based on experience value or actual needs arrange, such as, when the difference of a certain client terminal and a square summit is less than predicated value, judge that this client terminal is in the peripheral extent of server, otherwise judge that this client does not belong to the peripheral extent of server.
The embodiment of the present invention one passes through customer-centric, a shaped is drawn at user's periphery certain distance, being judged to be in user's GPS periphery for any point fallen in this form range, the distance avoiding user and peripheral point calculates, and has saved the data volume calculated. And all data are all converted into scale-of-two or shaping calculates, and further save calculated amount, significantly reduce computing amount and the resource occupation of server, it is to increase accurate data degree.
Embodiment two
The embodiment of the present invention one proposes a kind of device searching GPS periphery, and this device can be mobile terminal or server itself, it is also possible to be the built-in or external device of server. As shown in Figure 4, the device that the embodiment of the present invention two proposes comprises:
Drafting module 10, for, centered by the GPS location of a default server, drawing a preset shape;
Judge module 20, whether fall into for judging the GPS location of each client terminal in the scope of described shape, be, judge that described client terminal is in the peripheral extent of described server.
As shown in Figure 5, drafting module 10 comprises:
Calculate unit 11, for centered by the GPS location of server, according to one or more default length value, calculate shape at horizontal and vertical length value;
Describe unit 12, for describing described shape according to horizontal and vertical length value.
As shown in Figure 6, judge that module 20 comprises:
Acquiring unit 21, for obtaining the gps coordinate of multiple point on the frame of shape;
Scaling unit 22, for being converted into binary data or shape data by multiple gps coordinate of point, the gps coordinate of client terminal;
Contrast unit 23, for contrasting binary data or the shape data of multiple point and described client terminal, when difference is less than preset value, judges that client terminal is in the peripheral extent of described server.
Specifically, the device principle of work of the embodiment of the present invention two is as follows:
Drafting module 10, centered by the GPS location of a default server, draws a preset shape; In actual applications, this server position is businessman position, and default shape can be arrange according to actual needs, such as square, circular, rectangle etc., it may be preferred that select the square shape as the embodiment of the present invention one. Specifically, calculate unit 11 centered by the GPS location of server, according to one or more default length value, calculate shape at horizontal and vertical length value; For square, owing to the length of side is identical, only a length value need to be set, according to this length value, can calculate centered by the GPS location of server, square at horizontal and vertical length value. Other shape in this way, such as rectangle, then needs to arrange two length values, and a length value is as rectangular length, and another length value is as rectangular width. Describe unit 12 and describe described shape according to horizontal and vertical length value. The transverse direction of known form and the length value of drafting, then depict this shape centered by the GPS location of server, and further, the also direction of this shape of adjustable, with applicable customer need.
Judge that module 20 judges in the scope whether GPS location of each client terminal falls into this shape to be, judge that client terminal is in the peripheral extent of server. Specifically,
Acquiring unit 21 obtains the gps coordinate of multiple point on the frame of shape; For rectangle or square, it is preferable that select the gps coordinate on four summits on frame, for circular or other shape, the gps coordinate of multiple point can be selected equidistantly.
Multiple gps coordinate of point, the gps coordinate of client terminal are converted into binary data or shape data by scaling unit 22; When server receives the request of client terminal, this request includes the gps coordinate of client terminal and the longitude of client terminal and latitude, the gps coordinate of multiple points selected and the gps coordinate of client terminal are converted into binary data or shape data further, binary data or shape data after conversion compare GPS coordinate data, its data volume greatly reduces, and precision improves greatly.
Contrast unit 23 contrasts binary data or the shape data of multiple point and client terminal, when difference is less than preset value, judges that client terminal is in the peripheral extent of described server. Above-mentioned preset value based on experience value or actual needs arrange, such as, when the difference of a certain client terminal and a square summit is less than predicated value, judge that this client terminal is in the peripheral extent of server, otherwise judge that this client does not belong to the peripheral extent of server.
The embodiment of the present invention two passes through customer-centric, a shaped is drawn at user's periphery certain distance, being judged to be in user's GPS periphery for any point fallen in this form range, the distance avoiding user and peripheral point calculates, and has saved the data volume calculated. And all data are all converted into scale-of-two or shaping calculates, and further save calculated amount, significantly reduce computing amount and the resource occupation of server, it is to increase accurate data degree.
The foregoing is only the better embodiment of the present invention, not in order to limit the present invention, all any amendment, equivalent replacement and improvement etc. done within the spirit and principles in the present invention, all should be included within protection scope of the present invention.