CN110569445A - A Location-Based Neighbor Detection Method in Social Networks - Google Patents
A Location-Based Neighbor Detection Method in Social Networks Download PDFInfo
- Publication number
- CN110569445A CN110569445A CN201910808171.XA CN201910808171A CN110569445A CN 110569445 A CN110569445 A CN 110569445A CN 201910808171 A CN201910808171 A CN 201910808171A CN 110569445 A CN110569445 A CN 110569445A
- Authority
- CN
- China
- Prior art keywords
- vertex
- convex polygon
- point
- user
- given
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000001514 detection method Methods 0.000 title claims abstract description 15
- 238000000034 method Methods 0.000 claims description 48
- 238000005192 partition Methods 0.000 abstract description 13
- 238000010586 diagram Methods 0.000 description 10
- 239000000284 extract Substances 0.000 description 2
- 230000006855 networking Effects 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/953—Querying, e.g. by the use of web search engines
- G06F16/9536—Search customisation based on social or collaborative filtering
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/953—Querying, e.g. by the use of web search engines
- G06F16/9537—Spatial or temporal dependent retrieval, e.g. spatiotemporal queries
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q50/00—Information and communication technology [ICT] specially adapted for implementation of business processes of specific business sectors, e.g. utilities or tourism
- G06Q50/01—Social networking
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D30/00—Reducing energy consumption in communication networks
- Y02D30/70—Reducing energy consumption in communication networks in wireless communication networks
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Business, Economics & Management (AREA)
- Data Mining & Analysis (AREA)
- General Engineering & Computer Science (AREA)
- Economics (AREA)
- Health & Medical Sciences (AREA)
- Computing Systems (AREA)
- General Health & Medical Sciences (AREA)
- Human Resources & Organizations (AREA)
- Marketing (AREA)
- Primary Health Care (AREA)
- Strategic Management (AREA)
- Tourism & Hospitality (AREA)
- General Business, Economics & Management (AREA)
- Image Analysis (AREA)
- Image Generation (AREA)
Abstract
Description
技术领域technical field
本发明属于社交网络技术领域,涉及一种社交网络中近邻检测方法,具体涉及一种基于位置的社交网络服务中利用点与凸多边形位置关系进行近邻检测的方法。The invention belongs to the technical field of social networks, and relates to a method for detecting neighbors in a social network, in particular to a method for detecting neighbors by utilizing the positional relationship between points and convex polygons in a location-based social network service.
背景技术Background technique
随着位置感知移动终端的普及和社交应用的普及,基于位置的社交网络服务(LBSNS)给人们的生活带来了极大的便利。其中,近邻检测服务是LBS的典型应用。近邻检测允许用户在地图上选择一个特定的几何范围,然后询问他的朋友是否在这个范围内。通常将用户选定的几何范围抽象为凸多边形,将用户朋友的位置抽象为一个点,通过判断点与凸多边形的位置关系来解决近邻检测问题。With the popularization of location-aware mobile terminals and social applications, location-based social networking services (LBSNS) have brought great convenience to people's lives. Among them, the neighbor detection service is a typical application of LBS. Neighbor detection allows the user to select a specific geometric range on the map and then ask his friends if they are within this range. Usually, the geometric range selected by the user is abstracted as a convex polygon, and the position of the user's friend is abstracted as a point, and the neighbor detection problem is solved by judging the positional relationship between the point and the convex polygon.
目前判断点与凸多边形的方法有:计算点的方位(文献1)、射线法(文献2)、夹角法(文献3)、面积法(文献4)等。在计算点的方位方法中,需要判断点与凸多边形每条边的方位;在夹角法中,需要计算点与凸多边形每条边的夹角;在面积法中,需要将点与凸多边形的位置问题转化为三角形面积问题,然后再求解三角形面积问题,因此,这些方法普遍存在计算效率不高的问题。在射线法中,通过给定点引出一条射线,计算该射线与凸多边形的交点数,若交点的数为奇数,则坐标点在凸多边形内部,否则坐标点在凸多边形外。但当给定点位于凸多边形边上时,该方法存在误判的可能性。因此,如何高效实现社交网络中的近邻检测仍然是一个值得研究的问题。At present, methods for judging points and convex polygons include: calculating point orientation (document 1), ray method (document 2), angle method (document 3), area method (document 4), etc. In the method of calculating the orientation of a point, it is necessary to judge the orientation of the point and each side of the convex polygon; in the angle method, it is necessary to calculate the angle between the point and each side of the convex polygon; Therefore, these methods generally have the problem of low computational efficiency. In the ray method, a ray is drawn from a given point, and the number of intersections between the ray and the convex polygon is calculated. If the number of intersections is odd, the coordinate point is inside the convex polygon, otherwise the coordinate point is outside the convex polygon. However, when the given point is located on the edge of a convex polygon, this method has the possibility of misjudgment. Therefore, how to efficiently implement neighbor detection in social networks is still a problem worthy of research.
[1]F.Feito,J.C.Torres,and A.Orientation,simplicity,andinclusion test for planar polygons[J].Comput.Graph.,1995,19(4):595–600.[1] F. Feito, JC Torres, and A. Orientation, simplicity, and inclusion test for planar polygons [J]. Comput. Graph., 1995, 19(4): 595–600.
[2]GALETZKA M,GLAUNER P O.A simple and correct even-odd algorithm forthe point-in-polygon problem for complex polygons[OL].In:Proceedings ofthe12th International Joint Conference on Computer Vision,Imaging andComputer Graphics Theory and Applications(VISIGRAPP 2017).Porto,Portugal,2017:175-178.[2] GALETZKA M, GLAUNER P O.A simple and correct even-odd algorithm for the point-in-polygon problem for complex polygons [OL]. In: Proceedings of the 12th International Joint Conference on Computer Vision, Imaging and Computer Graphics Theory and Applications (VISIGRAPP 2017 ). Porto, Portugal, 2017:175-178.
[3]HORMANN K,AGATHOS A.The point in polygon problem for arbitrarypolygons[J].Computational Geometry,2001,20(3):131-144.[3] HORMANN K, AGATHOS A. The point in polygon problem for arbitrary polygons [J]. Computational Geometry, 2001, 20(3): 131-144.
[4]陈振华,李顺东,黄琼,董立红,陈娓.两个保密位置判断问题的新解法[J].计算机学报,2018,41(2):336-348.[4] Chen Zhenhua, Li Shundong, Huang Qiong, Dong Lihong, Chen Wei. A new solution to the problem of judging two confidential locations [J]. Journal of Computer Science, 2018, 41(2): 336-348.
发明内容Contents of the invention
为了解决上述问题,本发明提供了一种基于位置的社交网络服务中利用点与凸多边形位置关系进行近邻检测的方法。In order to solve the above problems, the present invention provides a method for performing neighbor detection by using the position relationship between points and convex polygons in a location-based social networking service.
本发明所采用的技术方案是:一种基于位置的社交网络中近邻检测方法,假设用户指定的几何范围是一个具有n个顶点的凸多边形L,从纵坐标最大的顶点开始依次进行逆时针编号,假设为{P1,P2,…,Pn},其坐标分别为(xi,yi),i=1,2,…,n,并将用户朋友的位置表示为一个点P(xp,yp),判断点P与凸多边形L之间的位置关系,即判断点P是位于凸多边形L的外部还是内部;点P位于凸多边形L的内部包括点P在凸多边形L边上的情况;如果点P位于凸多边形L的外部,则说明用户的朋友不在用户指定的几何范围内;如果点P位于凸多边形L的内部,则说明用户的朋友位于用户指定的几何范围内;The technical solution adopted in the present invention is: a method for detecting neighbors in a location-based social network, assuming that the geometric range specified by the user is a convex polygon L with n vertices, and starting from the vertex with the largest ordinate, the numbers are sequentially counterclockwise , assuming {P 1 ,P 2 ,…,P n }, its coordinates are ( xi ,y i ), i=1,2,…,n, and the position of the user’s friend is expressed as a point P( x p , y p ), judge the positional relationship between the point P and the convex polygon L, that is, judge whether the point P is located outside or inside the convex polygon L; the point P is located inside the convex polygon L, including the point P on the side of the convex polygon L If the point P is located outside the convex polygon L, it means that the user's friend is not within the geometric range specified by the user; if the point P is located inside the convex polygon L, it means that the user's friend is within the geometric range specified by the user;
其特征在于,所述方法包括以下步骤:It is characterized in that the method comprises the following steps:
步骤1:找出凸多边形L的四个特征顶点:最上顶点、最左顶点、最下顶点和最右顶点;最上顶点记为P1,假设最左顶点记为Pl,最下顶点记为Pd,最右顶点记为Pr,则有1≤l≤d≤r≤n;Step 1 : find out the four characteristic vertices of the convex polygon L : the uppermost vertex, the leftmost vertex, the lowermost vertex and the rightmost vertex; P d , the rightmost vertex is recorded as P r , then 1≤l≤d≤r≤n;
步骤2:判定给定点P与凸多边形L的位置关系;Step 2: Determine the positional relationship between the given point P and the convex polygon L;
步骤3:如果点P在凸多边形L的内部,则返回用户的朋友位于用户指定的几何范围内;如果点P在凸多边形L的外部,则返回用户的朋友不在用户指定的几何范围内。Step 3: If the point P is inside the convex polygon L, return the user's friend is within the user-specified geometric range; if the point P is outside the convex polygon L, return the user's friend is not within the user-specified geometric range.
作为优选,步骤2的具体实现包括以下子步骤:Preferably, the specific realization of step 2 includes the following sub-steps:
步骤2.1:如果yp<yd或者yp>y1或者xp<xl或者xp>xr,则给定点P(xp,yp)位于凸多边形L的外部,本流程结束;Step 2.1: If y p <y d or y p >y 1 or x p <x l or x p >x r , then the given point P(x p , y p ) is located outside the convex polygon L, and the procedure ends;
否则进入步骤2.2;Otherwise go to step 2.2;
步骤2.2:如果xp≤x1且yp≥yl,即此时给定点P(xp,yp)位于最上顶点P1的左侧和最左顶点Pl的上侧,此时,执行判断过程I,本流程结束;Step 2.2: If x p ≤ x 1 and y p ≥ y l , that is, the given point P(x p , y p ) is located on the left side of the uppermost vertex P 1 and on the upper side of the leftmost vertex P l , at this time, Execute the judgment process I, and this process ends;
否则进入步骤2.3;Otherwise go to step 2.3;
所述判断过程I的具体实现包括以下子步骤:The concrete realization of described judging process I comprises the following substeps:
步骤2.2.1:在顶点{P1,P2,…,Pl}中找到相邻的两个顶点Pi和Pi+1,使得xi≤x≤xi+1,其中1≤i≤l-1;Step 2.2.1: Find two adjacent vertices P i and P i+1 in the vertices {P 1 ,P 2 ,…,P l } such that x i ≤x≤x i+1 , where 1≤i ≤ l-1;
步骤2.2.2:计算过顶点Pi和Pi+1的直线,用符号f1(x)表示该直线;Step 2.2.2: Calculate the straight line between vertices P i and P i+1 , and use the symbol f 1 (x) to represent the straight line;
步骤2.2.3:如果yp≤f1(xp),则给定点P(xp,yp)位于凸多边形L的内部,否则给定点P(xp,yp)位于凸多边形L的外部;Step 2.2.3: If y p ≤ f 1 (x p ), then the given point P(x p ,y p ) is inside the convex polygon L, otherwise the given point P(x p ,y p ) is inside the convex polygon L external;
步骤2.3:如果xp≤xd且yp<yl,即此时给定点P(xp,yp)位于最下顶点Pd的左侧和最左顶点Pl的下侧,此时,执行判断过程II,本流程结束;Step 2.3: If x p ≤ x d and y p <y l , that is, the given point P(x p , y p ) is located on the left side of the lowest vertex P d and the lower side of the leftmost vertex P l at this time. , execute the judgment process II, and this process ends;
否则进入步骤2.4;Otherwise go to step 2.4;
所述判断过程II的具体实现包括以下子步骤:The concrete realization of described judging process II comprises the following sub-steps:
步骤2.3.1:在顶点{Pl,Pl+1,Pl+2,…,Pd}中找到相邻的两个顶点Pi和Pi+1,使得xi+1≤x≤xi,其中l-1≤i≤d;Step 2.3.1: Find two adjacent vertices P i and P i+1 in the vertices {P l ,P l+1 ,P l+2 ,…,P d } such that x i+1 ≤x≤ x i , where l-1≤i≤d;
步骤2.3.2:计算过顶点Pi和Pi+1的直线,用符号f2(x)表示该直线;Step 2.3.2: Calculate the straight line through the vertices P i and P i+1 , and use the symbol f 2 (x) to represent the straight line;
步骤2.3.3:如果yp≥f2(xp),则给定点P(xp,yp)位于凸多边形L的内部,否则给定点P(xp,yp)位于凸多边形L的外部;Step 2.3.3: If y p ≥ f 2 (x p ), then the given point P(x p ,y p ) is inside the convex polygon L, otherwise the given point P(x p ,y p ) is inside the convex polygon L external;
步骤2.4:如果xp>xd且yp<yr,即此时给定点P(xp,yp)位于最下顶点Pd的右侧和最右顶点Pr的下侧,此时,执行判断过程III,本流程结束;Step 2.4: If x p >x d and y p <y r , that is, the given point P(x p , y p ) is located on the right side of the lowest vertex P d and the lower side of the rightmost vertex P r at this time, then , execute the judgment process III, and this process ends;
否则进入步骤2.5;Otherwise go to step 2.5;
所述判断过程III的具体实现包括以下子步骤:The concrete realization of described judging process III comprises the following substeps:
步骤2.4.1:在顶点{Pd,Pd+1,Pd+2,…,Pr}中找到相邻的两个顶点Pi和Pi+1,使得xi≤x≤xi+1,其中d≤i≤r-1;Step 2.4.1: Find two adjacent vertices P i and P i+1 in the vertices {P d , P d+1 , P d+2 ,…,P r }, so that x i ≤ x ≤ x i +1 , where d≤i≤r-1;
步骤2.4.2:计算过顶点Pi和Pi+1的直线,用符号f3(x)表示该直线;Step 2.4.2: Calculate the straight line between vertices P i and P i+1 , and use the symbol f 3 (x) to represent the straight line;
步骤2.4.3:如果yp≥f3(xp),则给定点P(xp,yp)位于凸多边形L的内部,否则给定点P(xp,yp)位于凸多边形L的外部;Step 2.4.3: If y p ≥ f 3 (x p ), then the given point P(x p ,y p ) is inside the convex polygon L, otherwise the given point P(x p ,y p ) is inside the convex polygon L external;
步骤2.5:如果xp>x1且yp≥yr,即此时给定点P(xp,yp)位于最上顶点P1的右侧和最右顶点Pr的上侧,此时,执行判断过程IV,本流程结束;Step 2.5: If x p >x 1 and y p ≥ y r , that is, the given point P(x p , y p ) is located on the right side of the uppermost vertex P 1 and on the upper side of the rightmost vertex P r , at this time, Execute the judgment process IV, and this process ends;
所述判断过程IV的具体实现包括以下子步骤:The concrete realization of described judging process IV comprises the following sub-steps:
步骤2.5.1:若x1≤x≤xn,则选中顶点Pn和P1,否则在顶点{Pr,Pr+1,Pr+2,…,Pn}中找到相邻的两个顶点Pi和Pi+1,使得xi+1≤x≤xi,其中r-1≤i≤n;Step 2.5.1: If x 1 ≤x≤x n , select vertices P n and P 1 , otherwise find adjacent vertices {P r ,P r+1 ,P r+2 ,…,P n } Two vertices P i and P i+1 such that x i+1 ≤ x ≤ x i , where r-1≤i≤n;
步骤2.5.2:若选中的顶点为Pn和P1,则计算过顶点Pn和P1的直线,否则计算过顶点Pi和Pi+1的直线,用符号f4(x)表示计算得到的直线;Step 2.5.2: If the selected vertices are P n and P 1 , calculate the straight line between vertices P n and P 1 , otherwise calculate the straight line between vertices P i and P i+1 , denoted by symbol f 4 (x) The calculated straight line;
步骤2.5.3:如果yp≤f4(xp),则给定点P(xp,yp)位于凸多边形L的内部,否则给定点P(xp,yp)位于凸多边形L的外部。Step 2.5.3: If y p ≤ f 4 (x p ), then the given point P(x p ,y p ) is inside the convex polygon L, otherwise the given point P(x p ,y p ) is inside the convex polygon L external.
针对现有方法存在计算代价、效率不高的问题,本发明公开了一种基于位置的社交网络中近邻检测方法;本发明首先将用户选择的几何范围抽象为一个凸多边形,将用户朋友的位置抽象为一个点,然后提取凸多边形的四个特征顶点,根据四个特征顶点对凸多边形进行划分,并给出每个分区内点与凸多边形的位置判定过程;最后根据给定点的坐标判断该点落在哪个分区,然后执行相应的位置判定过程,最终得到问题的解。在本发明提出的方法中,给定点并不需要和凸多边形的所有边进行位置判定,也不需要进行问题转换,因此,本发明大大减少了计算开销。Aiming at the problems of computational cost and low efficiency in existing methods, the present invention discloses a location-based neighbor detection method in social networks; the present invention first abstracts the geometric range selected by the user into a convex polygon, and the location of the user's friends Abstract as a point, then extract the four characteristic vertices of the convex polygon, divide the convex polygon according to the four characteristic vertices, and give the position determination process of the point and the convex polygon in each partition; finally judge the position according to the coordinates of the given point Which partition the point falls in, and then perform the corresponding position determination process, and finally get the solution of the problem. In the method proposed by the present invention, the given point does not need to determine the position with all the sides of the convex polygon, nor does it need to perform problem conversion. Therefore, the present invention greatly reduces the calculation cost.
附图说明Description of drawings
图1:本发明实施例的给定凸多边形;Figure 1: A given convex polygon of an embodiment of the present invention;
图2:本发明实施例的给定凸多边形划分示意图;Figure 2: Schematic diagram of given convex polygon division in the embodiment of the present invention;
图3:本发明实施例的方法流程图;Fig. 3: method flowchart of the embodiment of the present invention;
图4:本发明实施例的第一种点与给定凸多边形位置关系的示意图;Figure 4: A schematic diagram of the positional relationship between the first point and a given convex polygon in the embodiment of the present invention;
图5:本发明实施例的第二种点与给定凸多边形位置关系的示意图;Figure 5: A schematic diagram of the positional relationship between the second point and a given convex polygon in the embodiment of the present invention;
图6:本发明实施例的第三种点与给定凸多边形位置关系的示意图;Figure 6: A schematic diagram of the positional relationship between the third point and a given convex polygon in the embodiment of the present invention;
图7:本发明实施例的第四种点与给定凸多边形位置关系的示意图;Figure 7: A schematic diagram of the positional relationship between the fourth point and a given convex polygon in the embodiment of the present invention;
图8:本发明实施例的第五种点与给定凸多边形位置关系的示意图;Figure 8: A schematic diagram of the positional relationship between the fifth point and a given convex polygon in the embodiment of the present invention;
图9:本发明实施例的第六种点与给定凸多边形位置关系的示意图;Figure 9: A schematic diagram of the positional relationship between the sixth point and a given convex polygon in the embodiment of the present invention;
图10:本发明实施例的第七种点与给定凸多边形位置关系的示意图;Figure 10: A schematic diagram of the positional relationship between the seventh point and a given convex polygon in the embodiment of the present invention;
图11:本发明实施例的第八种点与给定凸多边形位置关系的示意图;Figure 11: A schematic diagram of the positional relationship between the eighth point and a given convex polygon in the embodiment of the present invention;
图12:本发明实施例的第九种点与给定凸多边形位置关系的示意图。Fig. 12: A schematic diagram of the positional relationship between the ninth point and a given convex polygon in the embodiment of the present invention.
具体实施specific implementation
为了便于本领域普通技术人员理解和实施本发明,下面结合附图及实施例对本发明作进一步的详细描述,应当理解,此处所描述的实施示例仅用于说明和解释本发明,并不用于限定本发明。In order to facilitate those of ordinary skill in the art to understand and implement the present invention, the present invention will be described in further detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the implementation examples described here are only used to illustrate and explain the present invention, and are not intended to limit this invention.
请见图1,假设用户指定的几何范围是一个具有n个顶点的凸多边形L,从纵坐标最大的顶点开始依次进行逆时针编号,假设为{P1,P2,…,Pn},其坐标分别为(xi,yi),i=1,2,…,n。其中四个特征顶点为P1(最上顶点),Pl(最左顶点),Pd(最下顶点),Pr(最右顶点)。Please refer to Figure 1, assuming that the geometric range specified by the user is a convex polygon L with n vertices, and the numbers are counterclockwise from the vertex with the largest ordinate, assuming {P 1 ,P 2 ,…,P n }, The coordinates are respectively ( xi , y i ), i=1, 2,..., n. The four feature vertices are P 1 (the uppermost vertex), P l (the leftmost vertex), P d (the lowermost vertex), and P r (the rightmost vertex).
请见图2,将用户朋友的位置表示为一个点P,根据四个特征顶点实现了对凸多边形的一种划分,得到5个分区:第一个分区对应于图2中的空白区域,如果点P落入这个区域,则说明点P在凸多边形的外部(请见图4);第二个分区对应于图2中标注为I的阴影区域,如果点P落入这个区域,需要进一步判断它与凸多边形的位置关系(请见图5和图6);第三个分区对应于图2中标注为II的阴影区域,如果点P落入这个区域,需要进一步判断它与凸多边形的位置关系(请见图7和图8);第四个分区对应于图2中标注为III的阴影区域,如果点P落入这个区域,需要进一步判断它与凸多边形的位置关系(请见图9和图10);第五个分区对应于图2中标注为IV的阴影区域,如果点P落入这个区域,需要进一步判断它与凸多边形的位置关系(请见图11和图12)。Please refer to Figure 2. The position of the user's friend is expressed as a point P, and a division of the convex polygon is realized according to the four characteristic vertices, and 5 partitions are obtained: the first partition corresponds to the blank area in Figure 2, if Point P falls into this area, indicating that point P is outside the convex polygon (see Figure 4); the second partition corresponds to the shaded area marked I in Figure 2, if point P falls into this area, further judgment is required Its position relationship with the convex polygon (see Figure 5 and Figure 6); the third partition corresponds to the shaded area marked II in Figure 2, if point P falls into this area, it is necessary to further judge its position with the convex polygon relationship (see Figure 7 and Figure 8); the fourth partition corresponds to the shaded area marked III in Figure 2, if point P falls into this area, it is necessary to further judge its positional relationship with the convex polygon (see Figure 9 and Fig. 10); the fifth partition corresponds to the shaded area marked as IV in Fig. 2, if point P falls into this area, it is necessary to further judge its positional relationship with the convex polygon (see Fig. 11 and Fig. 12).
请见图3,本发明提供的一种基于位置的社交网络中近邻检测方法,包括以下步骤:Please see Fig. 3, a kind of neighbor detection method in the location-based social network that the present invention provides, comprises the following steps:
步骤1:找出凸多边形L的四个特征顶点:最上顶点、最左顶点、最下顶点和最右顶点。根据上面的编号规则可知,最上顶点是P1,假设最左顶点为Pl,最下顶点为Pd,最右顶点为Pr,则有1≤l≤d≤r≤n。基于四个特征顶点实际上实现了对凸多边形的一种划分,请见图2,给定凸多边形被分成了5个分区。Step 1: Find four characteristic vertices of the convex polygon L: the uppermost vertex, the leftmost vertex, the lowermost vertex and the rightmost vertex. According to the numbering rules above, the uppermost vertex is P 1 , assuming the leftmost vertex is P l , the lowermost vertex is P d , and the rightmost vertex is P r , then 1≤l≤d≤r≤n. Based on the four characteristic vertices, a division of the convex polygon is actually realized. Please refer to Figure 2. The given convex polygon is divided into 5 partitions.
步骤2:判定给定点P与凸多边形L的位置关系。Step 2: Determine the positional relationship between the given point P and the convex polygon L.
请见图3中的步骤2.1至步骤2.5和图4至图12,步骤2的具体实现包括以下子步骤:Please see steps 2.1 to 2.5 in Figure 3 and Figure 4 to Figure 12, the specific implementation of step 2 includes the following sub-steps:
步骤2.1:如果yp<yd或者yp>y1或者xp<xl或者xp>xr,即点P(xp,yp)落入空白区域(对应图4所示情况),则给定点P(xp,yp)位于凸多边形L的外部,否则进入步骤2.2;Step 2.1: If y p <y d or y p >y 1 or x p <x l or x p >x r , the point P(x p ,y p ) falls into the blank area (corresponding to the situation shown in Figure 4) , then the given point P(x p ,y p ) is located outside the convex polygon L, otherwise go to step 2.2;
步骤2.2:如果xp≤x1且yp≥yl,即点P(xp,yp)落入区域I,此时执行下面的步骤2.2.1至步骤2.2.3,否则进入步骤2.3。Step 2.2: If x p ≤ x 1 and y p ≥ y l , that is, the point P(x p , y p ) falls into area I, then execute the following steps 2.2.1 to 2.2.3, otherwise go to step 2.3 .
步骤2.2.1:在顶点{P1,P2,…,Pl}中找到相邻的两个顶点Pi和Pi+1,使得xi≤x≤xi+1,其中1≤i≤l-1;Step 2.2.1: Find two adjacent vertices P i and P i+1 in the vertices {P 1 ,P 2 ,…,P l } such that x i ≤x≤x i+1 , where 1≤i ≤ l-1;
步骤2.2.2:计算过顶点Pi和Pi+1的直线,用符号f1(x)表示该直线;Step 2.2.2: Calculate the straight line between vertices P i and P i+1 , and use the symbol f 1 (x) to represent the straight line;
步骤2.2.3:如果yp≤f1(xp)(对应图5所示情况),则给定点P(xp,yp)位于凸多边形L的内部,否则(对应图6所示情况)给定点P(xp,yp)位于凸多边形L的外部。Step 2.2.3: If y p ≤ f 1 (x p ) (corresponding to the situation shown in Figure 5), then the given point P(x p ,y p ) is located inside the convex polygon L, otherwise (corresponding to the situation shown in Figure 6 ) A given point P(x p , y p ) lies outside the convex polygon L.
步骤2.3:如果xp≤xd且yp<yl,即点P(xp,yp)落入区域II,此时执行下面的步骤2.3.1至步骤2.3.3,否则进入步骤2.4。Step 2.3: If x p ≤ x d and y p <y l , that is, the point P(x p , y p ) falls into area II, then execute the following steps 2.3.1 to 2.3.3, otherwise go to step 2.4 .
步骤2.3.1:在顶点{Pl,Pl+1,Pl+2,…,Pd}中找到相邻的两个顶点Pi和Pi+1,使得xi+1≤x≤xi,其中l-1≤i≤d;Step 2.3.1: Find two adjacent vertices P i and P i+1 in the vertices {P l ,P l+1 ,P l+2 ,…,P d } such that x i+1 ≤x≤ x i , where l-1≤i≤d;
步骤2.3.2:计算过顶点Pi和Pi+1的直线,用符号f2(x)表示该直线;Step 2.3.2: Calculate the straight line through the vertices P i and P i+1 , and use the symbol f 2 (x) to represent the straight line;
步骤2.3.3:如果yp≥f2(xp)(对应图7所示情况),则给定点P(xp,yp)位于凸多边形L的内部,否则(对应图8所示情况)给定点P(xp,yp)位于凸多边形L的外部。Step 2.3.3: If y p ≥ f 2 (x p ) (corresponding to the situation shown in Figure 7), then the given point P(x p ,y p ) is located inside the convex polygon L, otherwise (corresponding to the situation shown in Figure 8 ) A given point P(x p , y p ) lies outside the convex polygon L.
步骤2.4:如果xp>xd且yp<yr,即点P(xp,yp)落入区域III,此时执行下面的步骤2.4.1至步骤2.4.3,否则进入步骤2.5。Step 2.4: If x p >x d and y p <y r , that is, the point P(x p ,y p ) falls into region III, then execute the following steps 2.4.1 to 2.4.3, otherwise go to step 2.5 .
步骤2.4.1:在顶点{Pd,Pd+1,Pd+2,…,Pr}中找到相邻的两个顶点Pi和Pi+1,使得xi≤x≤xi+1,其中d≤i≤r-1;Step 2.4.1: Find two adjacent vertices P i and P i+1 in the vertices {P d , P d+1 , P d+2 ,…,P r }, so that x i ≤ x ≤ x i +1 , where d≤i≤r-1;
步骤2.4.2:计算过顶点Pi和Pi+1的直线,用符号f3(x)表示该直线;Step 2.4.2: Calculate the straight line between vertices P i and P i+1 , and use the symbol f 3 (x) to represent the straight line;
步骤2.4.3:如果yp≥f3(xp)(对应图9所示情况),则给定点P(xp,yp)位于凸多边形L的内部,否则(对应图10所示情况)给定点P(xp,yp)位于凸多边形L的外部。Step 2.4.3: If y p ≥ f 3 (x p ) (corresponding to the situation shown in Figure 9), then the given point P(x p ,y p ) is located inside the convex polygon L, otherwise (corresponding to the situation shown in Figure 10 ) A given point P(x p , y p ) lies outside the convex polygon L.
步骤2.5:此时xp>x1且yp≥yr,即点P(xp,yp)落入区域IV,执行下面的步骤2.5.1至步骤2.5.3。Step 2.5: At this point x p >x 1 and y p ≥y r , that is, the point P(x p ,y p ) falls into region IV, and the following steps 2.5.1 to 2.5.3 are performed.
步骤2.5.1:若x1≤x≤xn,则选中顶点Pn和P1,否则在顶点{Pr,Pr+1,Pr+2,…,Pn}中找到相邻的两个顶点Pi和Pi+1,使得xi+1≤x≤xi,其中r-1≤i≤n;Step 2.5.1: If x 1 ≤x≤x n , select vertices P n and P 1 , otherwise find adjacent vertices {P r ,P r+1 ,P r+2 ,…,P n } Two vertices P i and P i+1 such that x i+1 ≤ x ≤ x i , where r-1≤i≤n;
步骤2.5.2:若选中的顶点为Pn和P1,则计算过顶点Pn和P1的直线,否则计算过顶点Pi和Pi+1的直线,用符号f4(x)表示计算得到的直线;Step 2.5.2: If the selected vertices are P n and P 1 , calculate the straight line between vertices P n and P 1 , otherwise calculate the straight line between vertices P i and P i+1 , denoted by symbol f 4 (x) The calculated straight line;
步骤2.5.3:如果yp≤f4(xp)(对应图11所示情况),则给定点P(xp,yp)位于凸多边形L的内部,否则(对应图12所示情况)给定点P(xp,yp)位于凸多边形L的外部。Step 2.5.3: If y p ≤ f 4 (x p ) (corresponding to the situation shown in Figure 11), then the given point P(x p ,y p ) is located inside the convex polygon L, otherwise (corresponding to the situation shown in Figure 12 ) A given point P(x p , y p ) lies outside the convex polygon L.
步骤3:如果点P在凸多边形L的内部,则返回用户的朋友位于用户指定的几何范围内;如果点P在凸多边形L的外部,则返回用户的朋友不在用户指定的几何范围内。Step 3: If the point P is inside the convex polygon L, return the user's friend is within the user-specified geometric range; if the point P is outside the convex polygon L, return the user's friend is not within the user-specified geometric range.
本发明针对社交网络中近邻检测问题,首先将用户选择的几何范围抽象为一个凸多边形,将用户朋友的位置抽象为一个点,然后提取凸多边形的四个特征顶点,根据四个特征顶点对凸多边形进行划分,并给出每个分区内点与凸多边形的位置判定过程;最后根据给定点的坐标判断该点落在哪个分区,然后执行相应的位置判定过程,最终得到问题的解。本发明只需要进行一次点与边的判断即可得到点与凸多边形的位置关系,因此高效地解决了社交网络中近邻检测问题。Aiming at the problem of neighbor detection in social networks, the present invention firstly abstracts the geometric range selected by the user into a convex polygon, and abstracts the position of the user's friend into a point, then extracts four characteristic vertices of the convex polygon, and performs a convex alignment according to the four characteristic vertices. The polygon is divided, and the position judgment process of the point and the convex polygon in each partition is given; finally, according to the coordinates of the given point, it is judged which partition the point falls in, and then the corresponding position judgment process is performed, and finally the solution of the problem is obtained. The invention only needs to judge the point and the edge once to obtain the positional relationship between the point and the convex polygon, thus efficiently solving the problem of neighbor detection in the social network.
应当理解的是,本说明书未详细阐述的部分均属于现有技术。It should be understood that the parts not described in detail in this specification belong to the prior art.
应当理解的是,上述针对较佳实施例的描述较为详细,并不能因此而认为是对本发明专利保护范围的限制,本领域的普通技术人员在本发明的启示下,在不脱离本发明权利要求所保护的范围情况下,还可以做出替换或变形,均落入本发明的保护范围之内,本发明的请求保护范围应以所附权利要求为准。It should be understood that the above-mentioned descriptions for the preferred embodiments are relatively detailed, and should not therefore be considered as limiting the scope of the patent protection of the present invention. Within the scope of protection, replacements or modifications can also be made, all of which fall within the protection scope of the present invention, and the scope of protection of the present invention should be based on the appended claims.
Claims (2)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910808171.XA CN110569445B (en) | 2019-08-29 | 2019-08-29 | Neighbor detection method in social network based on position |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910808171.XA CN110569445B (en) | 2019-08-29 | 2019-08-29 | Neighbor detection method in social network based on position |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110569445A true CN110569445A (en) | 2019-12-13 |
CN110569445B CN110569445B (en) | 2023-06-02 |
Family
ID=68776700
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910808171.XA Active CN110569445B (en) | 2019-08-29 | 2019-08-29 | Neighbor detection method in social network based on position |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110569445B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112509031A (en) * | 2020-12-02 | 2021-03-16 | 湖北工业大学 | Position judging method |
Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101114379A (en) * | 2007-09-07 | 2008-01-30 | 中国科学院软件研究所 | A method to determine whether a point is inside a polygon |
US20100017126A1 (en) * | 2008-07-16 | 2010-01-21 | Qualcomm Incorporated | Method for dynamic creation of a geofence in a wireless system |
CN102063493A (en) * | 2010-12-30 | 2011-05-18 | 北京大学 | Content extraction method based on regular expression group and control logic |
US20110320319A1 (en) * | 2010-06-23 | 2011-12-29 | Justin Streich | Methods, Systems and Machines for Identifying Geospatial Compatibility Between Consumers and Providers of Goods or Services |
CN102982562A (en) * | 2012-10-19 | 2013-03-20 | 浙江中正智能科技有限公司 | Method for judging whether target point is positioned inside polygon area |
CN104123737A (en) * | 2014-07-15 | 2014-10-29 | 沈颖 | Testing method for judging inclusivity of points on inner portion, outer portion or boundary of polygonal area |
CN105869188A (en) * | 2016-04-22 | 2016-08-17 | 广州日滨科技发展有限公司 | Detection method and system for point to polygon position relation |
CN106878941A (en) * | 2016-12-29 | 2017-06-20 | 贵州财富之舟科技有限公司 | position reminding method and device |
CN108269283A (en) * | 2017-12-26 | 2018-07-10 | 武汉长江通信智联技术有限公司 | A kind of implementation method for judging transfer point disengaging polygonal region |
CN108777839A (en) * | 2018-05-25 | 2018-11-09 | 湖北工业大学 | The positioning of secret protection is registered system and method in a kind of mobile Internet |
CN109934890A (en) * | 2019-03-08 | 2019-06-25 | 南京泛在地理信息产业研究院有限公司 | An automatic extraction method of meander envelope |
-
2019
- 2019-08-29 CN CN201910808171.XA patent/CN110569445B/en active Active
Patent Citations (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101114379A (en) * | 2007-09-07 | 2008-01-30 | 中国科学院软件研究所 | A method to determine whether a point is inside a polygon |
US20100017126A1 (en) * | 2008-07-16 | 2010-01-21 | Qualcomm Incorporated | Method for dynamic creation of a geofence in a wireless system |
US20110320319A1 (en) * | 2010-06-23 | 2011-12-29 | Justin Streich | Methods, Systems and Machines for Identifying Geospatial Compatibility Between Consumers and Providers of Goods or Services |
CN102063493A (en) * | 2010-12-30 | 2011-05-18 | 北京大学 | Content extraction method based on regular expression group and control logic |
CN102982562A (en) * | 2012-10-19 | 2013-03-20 | 浙江中正智能科技有限公司 | Method for judging whether target point is positioned inside polygon area |
CN104123737A (en) * | 2014-07-15 | 2014-10-29 | 沈颖 | Testing method for judging inclusivity of points on inner portion, outer portion or boundary of polygonal area |
CN105869188A (en) * | 2016-04-22 | 2016-08-17 | 广州日滨科技发展有限公司 | Detection method and system for point to polygon position relation |
CN106878941A (en) * | 2016-12-29 | 2017-06-20 | 贵州财富之舟科技有限公司 | position reminding method and device |
CN108269283A (en) * | 2017-12-26 | 2018-07-10 | 武汉长江通信智联技术有限公司 | A kind of implementation method for judging transfer point disengaging polygonal region |
CN108777839A (en) * | 2018-05-25 | 2018-11-09 | 湖北工业大学 | The positioning of secret protection is registered system and method in a kind of mobile Internet |
CN109934890A (en) * | 2019-03-08 | 2019-06-25 | 南京泛在地理信息产业研究院有限公司 | An automatic extraction method of meander envelope |
Non-Patent Citations (2)
Title |
---|
沈华;张明武;: "一种隐私保护的智能电网多级用户电量聚合控制方案", 密码学报 * |
郝建强;宫云战;叶红;: "点对多边形位置检测的稳定串行最优与并行的算法", 计算机应用研究 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112509031A (en) * | 2020-12-02 | 2021-03-16 | 湖北工业大学 | Position judging method |
CN112509031B (en) * | 2020-12-02 | 2022-08-16 | 湖北工业大学 | Position judging method |
Also Published As
Publication number | Publication date |
---|---|
CN110569445B (en) | 2023-06-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103365599B (en) | Mobile terminal operation optimization method and device based on screen sliding track | |
CN111275820B (en) | Method, device, terminal and storage medium for drawing three-dimensional wall based on two-dimensional plane | |
CN102890703B (en) | A kind of heterogeneous multidimensional scaling method of network | |
CN112652036B (en) | Road data processing method, device, equipment and storage medium | |
WO2019057192A1 (en) | Method and apparatus for displaying knowledge graph, mobile terminal, and readable storage medium | |
CN110569445B (en) | Neighbor detection method in social network based on position | |
CN103559209B (en) | A kind of efficient spatial K-NN search method that Voronoi Diagram is combined with virtual grid | |
CN112861293A (en) | Power transmission network wiring diagram generation method and device and electronic equipment | |
CN113379871B (en) | Map processing method and device | |
CN101533525A (en) | Method for analyzing the overlay of point and face | |
CN103268611B (en) | Accurate real-time curve detection method in a kind of complex scene | |
US20230196674A1 (en) | Method and apparatus for processing three dimentional graphic data, device, storage medium and product | |
CN117591615A (en) | Area determination method, device and storage medium | |
CN115081122B (en) | Method, equipment and medium for automatically extracting geometric middle plane of plate-shell structure | |
CN112948517B (en) | Regional position calibration method and device and electronic equipment | |
CN110704896A (en) | Method and product for placing connecting node between keel column model and wall keel model | |
CN116823996A (en) | Automatic layout method for graph model | |
JP2004139485A (en) | Abstract map generation device, road map conversion device, program, and abstract map service system | |
CN115294237A (en) | Power simulation modeling connection line optimization method, device and equipment and readable storage medium | |
CN106874916A (en) | A kind of complicated outside plate point cloud scene comparison extracting method and device | |
CN112509031B (en) | Position judging method | |
CN116303260B (en) | Buffer fusion parallel method and device based on R tree continuous index | |
Zhou et al. | A systematic scheme to maintain multiple characteristics for effective polygon rasterization | |
CN113870332B (en) | A registration method for optical images and SAR images based on straight line features | |
CN109688561B (en) | Indoor positioning method and structure for three-dimensional fingerprint distribution |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |