Summary of the invention
The purpose of the embodiment of the invention is to propose a kind of orientation for place method, Apparatus and system based on map.
The present invention provides a kind of orientation for place method based on map, and said method comprises:
Obtain coordinate, screen center's point coordinate of primary importance;
Whether the coordinate of judging said primary importance is in screen; If not, then according to the coordinate of said primary importance and screen center's point position, obtain first angle and second angle;
Through described primary importance coordinate and said first angle and second angle, confirm the position relation of primary importance and screen, and described position relation is shown.
Wherein, described " obtaining first angle and second angle " is specially:
α=arctan(((gapy)*10.0)/((gapx)*10.0))*180/3.14;
β=arctan((maxy*10.0)/(maxx*10.0))*180/3.14;
Wherein α is first angle, and β is second angle;
Wherein gapx=| (| px|-|dx|) |; Gapy=| (| py|-|dy|) |; Gapx is the absolute value of primary importance coordinate and screen center's point position coordinates X coordinate difference; Gapy is the absolute value of primary importance coordinate and screen center's point position coordinates Y coordinate difference;
Wherein px, py be the primary importance coordinate that obtains for (px, py); Dx, dy be screen center's point position coordinates of obtaining for (dx, dy); Screen width is x, highly for y, maxx=x/2, maxy=y/2.
Wherein, described " through described primary importance coordinate and said first angle and second angle, confirming the position relation of primary importance and screen " is specially:
Is common vertex with said screen with screen center's point, in advance said screen is divided into the individual subregion of n (n is a positive integer) equably;
Which through described primary importance coordinate and first angle and second angle, confirm in the zone of first coordinate in n zone; Thereby confirm the position relation of said primary importance and screen.
Wherein, described " is common vertex with said screen with screen center's point, in advance said screen is divided into the individual subregion of n (n is a positive integer) equably " is specially:
Reset-to-n=8;
Screen width is x, highly is to preset maxx=x/2 by y, presets maxy=y/2; Px, py be the primary importance coordinate that obtains for (px, py); Dx, dy be screen center's point position coordinates of obtaining for (dx, dy);
With maxx length is the boundary, is divided into a left side ((px-dx)<0) to screen, right ((px-dx)>=0) 2 zones;
With maxy length is the boundary, is divided into screen ((py-dy)<0), down ((py-dy)>=0) 2 zones; Screen is divided into four rectangular areas;
Carry out subregion with two diagonal line of screen again, be divided into eight zonules to four rectangular areas of screen again, and name area code to be respectively in a clockwise direction: 1,2,3,4,5,6,7,8.
Wherein, described " through described primary importance coordinate and first angle and second angle, confirming which zone of first coordinate in n zone " is specially:
Judge (px-dx)>=0, and (py-dy)>=0, primary importance is in the screen lower right area so; The angle of primary importance is 90+ α, further judges when α>β, and primary importance is in No. 4 zones; When α<=β, the indication point position is in No. 3 zones;
Judge (px-dx)>=0, and (py-dy)<0, primary importance is in the screen right regions so; The angle of primary importance is 90-α, further judges when α>β, and primary importance is in No. 1 zone, and when α<=β, primary importance is in No. 2 zones;
Judge (px-dx)<0, and (py-dy)>=0, primary importance is at the left lower area of screen so; Primary importance 270-α further judges when α>β, and primary importance is in No. 5 zones; When α<=β, primary importance is in No. 6 zones;
Judge (px-dx)<0, and (py-dy)<0, primary importance is in the screen top left region so; Primary importance 270+ α further judges when α>β, and the indication point position is in No. 8 zones; When α<=β, primary importance is in No. 7 zones.
The present invention also provides a kind of orientation for place device based on map, and said device comprises:
First acquiring unit is used to obtain coordinate, screen center's point coordinate of primary importance;
First processing unit, whether the coordinate that is used to judge said primary importance is in screen; If not, then according to the coordinate of said primary importance and screen center's point position, obtain first angle and second angle;
Second processing unit is used for through described primary importance coordinate and said first angle and second angle, confirms the position relation of primary importance and screen, and described position relation is shown.
Wherein, first processing unit comprises: judging unit, second acquisition unit;
Judging unit, whether the coordinate that is used to judge said primary importance is in screen;
Second acquisition unit is used for coordinate when described primary importance not in screen the time, according to the coordinate of said primary importance and screen center's point position, obtains first angle and second angle; Saidly obtain first angle and second angle is specially:
α=arctan(((gapy)*10.0)/((gapx)*10.0))*180/3.14;
β=arctan((maxy*10.0)/(maxx*10.0))*180/3.14;
Wherein α is first angle, and β is second angle;
Wherein gapx=| (| px|-|dx|) |; Gapy=| (| py|-|dy|) |; Gapx is the absolute value of primary importance coordinate and screen center's point position coordinates X coordinate difference; Gapy is the absolute value of primary importance coordinate and screen center's point position coordinates Y coordinate difference;
Wherein px, py be the primary importance coordinate that obtains for (px, py); Dx, dy be screen center's point position coordinates of obtaining for (dx, dy); Screen width is x, highly for y, maxx=x/2, maxy=y/2.
Wherein, described second processing unit comprises:
First division unit, being used for said screen is common vertex with screen center's point, in advance said screen is divided into the individual subregion of n (n is a positive integer) equably;
Primary importance is confirmed the unit, is used for through described primary importance coordinate and first angle and second angle, confirms in which zone of first coordinate in n zone; Thereby confirm the position relation of said primary importance and screen.
Wherein, described first division unit comprises:
Preset unit is used for reset-to-n=8; Screen width is x, highly is to preset maxx=x/2 by y, presets maxy=y/2; Px, py be the primary importance coordinate that obtains for (px, py); Dx, dy be screen center's point position coordinates of obtaining for (dx, dy);
Second division unit, being used for maxx length is the boundary, is divided into a left side ((px-dx)<0) to screen, right ((px-dx)>=0) 2 zones;
With maxy length is the boundary, is divided into screen ((py-dy)<0), down ((py-dy)>=0) 2 zones; Screen is divided into four rectangular areas;
Carry out subregion with two diagonal line of screen again, be divided into eight zonules to four rectangular areas of screen again, and name area code to be respectively in a clockwise direction: 1,2,3,4,5,6,7,8.
Wherein, described primary importance is confirmed the unit, comprising:
The second place is confirmed the unit, be used for judging (px-dx)>=0, and (py-dy)>=0, primary importance is in the screen lower right area so; The angle of primary importance is 90+ α, further judges when α>β, and primary importance is in No. 4 zones; When α<=β, the indication point position is in No. 3 zones;
The 3rd position determination unit be used for judging (px-dx)>=0, and (py-dy)<0, primary importance is in the screen right regions so; The angle of primary importance is 90-α, further judges when α>β, and primary importance is in No. 1 zone, and when α<=β, primary importance is in No. 2 zones;
The 4th position determination unit is used for judging (px-dx)<0, and (py-dy)>=0, primary importance is at the left lower area of screen so; Primary importance 270-α further judges when α>β, and primary importance is in No. 5 zones; When α<=β, primary importance is in No. 6 zones;
The 5th position determination unit be used for judging (px-dx)<0, and (py-dy)<0, primary importance is in the screen top left region so; Primary importance 270+ α further judges when α>β, and the indication point position is in No. 8 zones; When α<=β, primary importance is in No. 7 zones.
The present invention becomes n zone with screen divider, confirms the position relation of desired location and screen then in the inside, this n zone, thereby the direction that needs drag is prompted to the user.Through this method, the user need not reorientate, and only need drag map just can get back to desired location apace; Reduced operation steps of user, and, also can practice thrift network traffics for some users who uses wireless network.
Embodiment
In order to make the object of the invention, technical scheme and advantage clearer, below in conjunction with accompanying drawing and embodiment, the present invention is further elaborated, for the ease of explanation, only show the part relevant with the embodiment of the invention.Should be appreciated that the specific embodiment that this place is described, only be used to explain the present invention, not in order to restriction the present invention.
Before introducing the present invention, at first introduce the relation of physical coordinates system and mobile phone coordinate system:
Referring to Fig. 1, the hachure coordinate system is the physical world coordinates system among the figure, and broad-brush is the mobile phone screen coordinate system.Be expression more specifically, referring to Fig. 2, the placement location of the acquiescence of the graphing in the physical world is the central point of physical world; Referring to Fig. 3, the default location of graphing is the upper left corner of screen in screen; Fig. 4 is the contrast situation of graphing in physical world and the screen.
That is to say, just can find out very clearly that physical world coordinates system is different with the mobile phone screen coordinate system, the upper left corner of mobile phone screen (0,0) coordinate, the center point coordinate of physical world just from Fig. 1 to Fig. 4.During the mobile phone screen graphing, acquiescence is all with upper left corner point as a reference.
In mathematics, trigonometric function is the function at angle; In research triangle and modeling periodic phenomena and many other application is very important.Trigonometric function is normally defined the ratio on two limits of the right-angle triangle that comprises this angle, also can the length that be defined as the various line segments on the unit circle of equal value.More modern definition is expressed as separating of the infinite series or the specific differential equation to them, allows them to expand to positive count and negative value, or even complex values.
In rectangular coordinate system, the definition of its trigonometric function is following:
Referring to Fig. 5, establishing α is a quadrant angle among the plane right-angle coordinate xOy, P (x, y) be among the plane right-angle coordinate xOy a bit, r be P (x, y) to the distance of initial point O (0,0), then:
1. the sine of α is its opposite side (y) and the ratio of hypotenuse (r).In last figure, sin α=opposite side/hypotenuse=y/r
2. the cosine of α is its adjacent side (x) and the ratio of hypotenuse (r).In last figure, cos α=adjacent side/hypotenuse=x/r
3. the tangent of α is its opposite side (y) and the ratio of adjacent side (x).In last figure, tan α=opposite side/adjacent side=y/x
4. the cotangent of α is its adjacent side (x) and the ratio of opposite side (y).In last figure, ctan α=adjacent side/opposite side=x/y
Wherein, r=√ [(x-0) ^2+ (y-0) ^2]
In right-angle triangle, the definition of acute angle trigonometric function is following:
1. the sine of an acute angle is its opposite side and the ratio of hypotenuse.Sin α=opposite side/hypotenuse.
2. the cosine of an acute angle is its adjacent side and the ratio of hypotenuse.Cos α=adjacent side/hypotenuse.
3. the tangent of an acute angle is its opposite side and the ratio of adjacent side.Tan α=opposite side/adjacent side.
4. the cotangent of an acute angle is its adjacent side and the ratio of opposite side.Ctan α=adjacent side/opposite side.
Above-mentioned brief account mobile phone screen and physical world coordinates system different, content of the present invention is introduced in and the definition at some angles below in detail.
Embodiment one
Referring to Fig. 6, the invention provides a kind of orientation for place method based on map:
Step 101: the coordinate that obtains primary importance and screen center's point; The primary importance coordinate be (px, py), screen center's point position coordinates be (dx, dy).
Referring to Fig. 7, primary importance P according to the invention is meant that the user is provided with the position of explicit identification on map, for example can be the position at the current place of user, also can be the position that the user finds on map.P is ordered the primary importance that is identified and is the current position of user in Fig. 2.
The method of obtaining the coordinate of primary importance can adopt MPoint class members method getOsetX () and getOsetY () obtain the customer location coordinate (px, py), use getOriginDX () and getOriginDY () obtain screen center's point position coordinates (dx, dy).This method is the technological means that those skilled in the art use always, is not described in detail in this.
Step 102: in screen, if not, then execution in step 104 for the coordinate of judging said primary importance; If then execution in step 103:
Rule of judgment is: px ∈ [0,2dx] and py ∈ [0,2dy]
Step 103: show primary importance;
Step 104:, obtain first angle and second angle according to the coordinate of said primary importance and screen center's point position;
Referring to Fig. 7, described first angle is α; Second angle is β;
α=arctan(((gapy)*10.0)/((gapx)*10.0))*180/3.14;
β=arctan((maxy*10.0)/(maxx*10.0))*180/3.14;
Wherein α is first angle, and β is second angle;
Wherein gapx=| (| px|-|dx|) |;
gapy=|(|py|-|dy|)|;
Gapx is the absolute value of primary importance P coordinate and screen center's point position coordinates X coordinate difference; Gapy is the absolute value of primary importance P coordinate and screen center's point position coordinates Y coordinate difference;
Wherein px, py be the primary importance coordinate that obtains for (px, py); Dx, dy be screen center's point position coordinates of obtaining for (dx, dy); Screen width is x, highly for y, maxx=x/2, maxy=y/2.
That is to say, carry out subregion, be divided into eight zonules to screen, and name area code to be in a clockwise direction with two diagonal line of screen: 1,2,3,4,5,6,7,8, wherein, screen center's point is O, and P is the user position, and Q is the vertical intersection point of straight line PQ and OQ.
Step 105:, confirm the position relation of primary importance and screen through described primary importance coordinate and said first angle and second angle.
This method is specially:
Is common vertex with said screen with screen center's point, in advance said screen is divided into the individual subregion of n (n is a positive integer) equably;
Which through described primary importance coordinate and first angle and second angle, confirm in the zone of first coordinate in n zone; Thereby confirm the position relation of said primary importance and screen.
In the above-mentioned steps 105, the method for " is common vertex with said screen with screen center's point, in advance said screen is divided into the individual subregion of n (n is a positive integer) equably " can for:
N=8 is set in advance; Referring to Fig. 7
Owing to screen width is x, highly is to preset maxx=x/2 by y, preset maxy=y/2; Px, py be the primary importance coordinate that obtains for (px, py); Dx, dy be screen center's point position coordinates of obtaining for (dx, dy);
Be the boundary with maxx length so, be divided into a left side ((px-dx)<0) to screen, right ((px-dx)>=0) 2 zones;
With maxy length is the boundary, is divided into screen ((py-dy)<0), down ((py-dy)>=0) 2 zones; So far screen is divided into four rectangular areas;
Carry out subregion with two diagonal line of screen again, be divided into eight zonules to four rectangular areas of screen again, and name area code to be respectively in a clockwise direction: 1,2,3,4,5,6,7,8.
In the above-mentioned steps 105, ", confirming which zone of first coordinate in n zone " through the relation of described primary importance coordinate and first angle and second angle can for:
If (px-dx)>=0, (py-dy)>=0, primary importance is in the screen lower right area so; The angle of primary importance is 90+ α, and when α>β, primary importance is in No. 4 zones; When α<=β, the indication point position is in No. 3 zones;
If (px-dx)>=0, py-dy)<0, primary importance is in the screen right regions so; The angle of primary importance is 90-α, and when α>β, primary importance is in No. 1 zone, and when α<=β, primary importance is in No. 2 zones;
If (px-dx)<0, (py-dy)>=0, primary importance is at the left lower area of screen so; Primary importance 270-α, when α>β, primary importance is in No. 5 zones; When α<=β, primary importance is in No. 6 zones;
If (px-dx)<0, py-dy)<0, primary importance is in the screen top left region so; Primary importance 270+ α, when α>β, the indication point position is in No. 8 zones; When α<=β, primary importance is in No. 7 zones.
Step 106: described position relation is shown.
For example, when the position at user place is invisible on map, want that the user does not just know this toward which direction has moved, and effect is referring to Fig. 8 through dragging map when getting back to the position at current place apace.
When the position at user place is invisible on map,, then can send Location Request so to server if this moment, the user carried out reorientating operation; And waiting for server is returned relevant location information data; This equally also can get back to current position, can bring a lot of additional overhead to the user but do like this, as: traffic fee; The smoothness of operating experience, the time waiting of location and location failure (when network is bad) or the like.The locating effect that sends Location Request to server is referring to Fig. 9.
Use method provided by the invention; When the user locatees when successful at every turn; The capital is at the current particular location of user shown in screen center's place's demonstration, and this moment, the position at user place was visible on map, i.e. shinny blue arrow small icon among the figure; The top relevant positional information of bubble mark, effect such as Figure 10.
Can calculate the position and the direction at the current place of user and dynamically make correct prompting through this method to the user; The user need not to reorientate, as long as drag the map location that map just can be got back to current place apace according to prompting (small icon in the circle is pointed to).Figure 11 for example.
Embodiment 2, and the present invention provides a kind of orientation for place device based on map, and referring to Figure 12, said device comprises:
First acquiring unit is used to obtain coordinate, screen center's point coordinate of primary importance;
First processing unit, whether the coordinate that is used to judge said primary importance is in screen; If not, then according to the coordinate of said primary importance and screen center's point position, obtain first angle and second angle; If then show primary importance;
Second processing unit is used for through described primary importance coordinate and said first angle and second angle, confirms the position relation of primary importance and screen, and described position relation is shown.
Wherein, first processing unit comprises: judging unit, second acquisition unit;
Judging unit, whether the coordinate that is used to judge said primary importance is in screen;
Second acquisition unit is used for coordinate when described primary importance not in screen the time, according to the coordinate of said primary importance and screen center's point position, obtains first angle and second angle; Saidly obtain first angle and second angle is specially:
α=arctan(((gapy)*10.0)/((gapx)*10.0))*180/3.14;
β=arctan((maxy*10.0)/(maxx*10.0))*180/3.14;
Wherein α is first angle, and β is second angle;
Wherein gapx=| (| px|-|dx|) |; Gapy=| (| py|-|dy|) |; Gapx is the absolute value of primary importance coordinate and screen center's point position coordinates X coordinate difference; Gapy is the absolute value of primary importance coordinate and screen center's point position coordinates Y coordinate difference;
Wherein px, py be the primary importance coordinate that obtains for (px, py); Dx, dy be screen center's point position coordinates of obtaining for (dx, dy); Screen width is x, highly for y, maxx=x/2, maxy=y/2.
Wherein, described second processing unit comprises:
First division unit, being used for said screen is common vertex with screen center's point, in advance said screen is divided into the individual subregion of n (n is a positive integer) equably;
Primary importance is confirmed the unit, is used for through described primary importance coordinate and first angle and second angle, confirms in which zone of first coordinate in n zone; Thereby confirm the position relation of said primary importance and screen.
Wherein, described first division unit comprises:
Preset unit is used for reset-to-n=8; Screen width is x, highly is to preset maxx=x/2 by y, presets maxy=y/2; Px, py be the primary importance coordinate that obtains for (px, py); Dx, dy be screen center's point position coordinates of obtaining for (dx, dy);
Second division unit, being used for maxx length is the boundary, is divided into a left side ((px-dx)<0) to screen, right ((px-dx)>=0) 2 zones;
With maxy length is the boundary, is divided into screen ((py-dy)<0), down ((py-dy)>=0) 2 zones; Screen is divided into four rectangular areas;
Carry out subregion with two diagonal line of screen again, be divided into eight zonules to four rectangular areas of screen again, and name area code to be respectively in a clockwise direction: 1,2,3,4,5,6,7,8.
Wherein, described primary importance is confirmed the unit, comprising:
The second place is confirmed the unit, be used for judging (px-dx)>=0, and (py-dy)>=0, primary importance is in the screen lower right area so; The angle of primary importance is 90+ α, further judges when α>β, and primary importance is in No. 4 zones; When α<=β, the indication point position is in No. 3 zones;
The 3rd position determination unit be used for judging (px-dx)>=0, and (py-dy)<0, primary importance is in the screen right regions so; The angle of primary importance is 90-α, further judges when α>β, and primary importance is in No. 1 zone, and when α<=β, primary importance is in No. 2 zones;
The 4th position determination unit is used for judging (px-dx)<0, and (py-dy)>=0, primary importance is at the left lower area of screen so; Primary importance 270-α further judges when α>β, and primary importance is in No. 5 zones; When α<=β, primary importance is in No. 6 zones;
The 5th position determination unit be used for judging (px-dx)<0, and (py-dy)<0, primary importance is in the screen top left region so; Primary importance 270+ α further judges when α>β, and the indication point position is in No. 8 zones; When α<=β, primary importance is in No. 7 zones.
Those having ordinary skill in the art will appreciate that; All or part of step in realization the foregoing description method can be accomplished through the programmed instruction related hardware; Described program can be stored in the computer read/write memory medium, and described storage medium can be ROM, RAM, disk, CD etc.
The above is merely preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of within spirit of the present invention and principle, being done, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.