today's mobile Internet is mainly | databaserのブログ

databaserのブログ

ブログの説明を入力します。

Geofencing (Geo-fencing) Women Lebron Hyperdunk 2013 is a LBS application is to use a virtual fence around a virtual geographical boundaries, when the phone enter, leave a Air Max 2012 Black Red White particular geographic area, or in the time domain activity area, the phone can receive automatic notifications and warnings. As shown below, assuming that there are three shopping malls on the map, when the user enters a mall when the phone automatically receive coupons corresponding push messages sent by the mall. Geo-fencing is widely used, today's mobile Internet is mainly app as the US group, the public comment, hand wash, etc. can be applied to see their shadow. Figure 1 a schematic view of the core Air Max 2012 Black Red White issues geofenced geofenced is to determine whether the user falls inside a polygon fence. This article will introduce the practical application of common solutions. 1 How to determine the point in the interior of the polygon is a polygonal geofence general, how to determine the point in polygon inside it? By ray Reebok CL Chi Kaze method to determine whether the point inside the polygon. As shown below, from the point of departure along the X axis draw a ray, in order to determine the intersection of the ray of each edge, and the intersection of the number of statistics, if the number of intersections 2015 Nike Free 5.0 is odd, then the interior of the polygon (Figure 3 intersection ), the number is even if the focus is on the outside, ray method for convex and non-convex polygons are applicable, complexity is O (N), the other N is the number of edges. Source code can reference (http://alienryderflex.com/polygon/) Figure 2 ray method to judge the point at Polygon Geographical small fence Air Max 2012 Green Orange Black when the number of polygons, we can turn through each polygon (violence traversal method), followed by radiation method judge, so that efficiency is also high. When a larger number of polygons, such as a 100,000 polygons, this time you need to perform 100,000 times ray method, response time of 3.9 seconds, which is almost unbearable in Internet applications. The following table is my simple test polygon edges are 7. Table 1 ray method performance test 2 653642-400 Blue Orange Lebron James Mens Basketball Shoes Nike Zoom Soldier VIII 8 R-tree indexes to accelerate the judge violent traversal method inefficient because with each polygon have carried out a ray method to judge, if we can reduce the number of calls will be able to enhance the performance of ray method. So our thinking is very direct optimization, first through a coarse sieve method to quickly find qualified small number of polygons, and polygons using the ray method to judge the coarse New Nike Free Run 3 Shoes Women Grey Purple Womens sieve, the number of executions so-ray method is greatly reduced, efficiency Air Max 2011 Womens Yellow Grey White can be greatly improved. How coarse sieve it? For the one-dimensional data, we often use the index method, such as through the B-tree index to find a particular range range segment, then Nike Air Jordan Flight 45 this range segment traverse range to find, often used for two-dimensional spatial data spatial index methods, such as by R Tree Found polygon range interval, then the polygon within this range for accurate judgment, here are the most commonly used spatial index R-tree solution ideas. 1) represents bounding polygon polygon shapes Because we need in a unified manner to polygon approximation, the easiest way is to use the smallest bounding box to represent a polygon. Figure 3 Minimum bounding box (MBR) expression polygon 2) establish minimum bounding 4 R-tree indexes outsourcing minimum rectangle R-tree Air Max 2012 Blue Silver White indexes 3) Discover a) Firstly, R tree quickly determine the user's location (thick red point) outsourced rectangle covers (Figure 5, the red dots represent the user's location; R tree average query complexity is O (Log (N)), N is the number of polygons); b) if it is not covered with any bounding return not Geography inner fence polygon; c) if the bounding box cover is also required in addition to further determine whether Authentic Mens Basketball Shoes All Red Nike KD 7 Factory Outlet the package inside the rectangular New Nike Tr Fit Shoes Black Purple polygon using ray method to judge mentioned above (Figure 2). Figure 5 R tree query example 3 polygon edges how to do a few more for most applications geofencing polygons are relatively simple, but sometimes encounter some particularly complex polygon, such as a single polygon edges more than ten million pieces, At this time the implementation of this complex polygons once ray method is also very time-consuming (because the ray Nike Air Max method time complexity is O (N), N is the number of edges of polygons). How to improve the efficiency of complex polygon Air Jordan Outlet ray method to perform it? Also use the R-tree index! The author in the practical application of the large number of edges (eg more than 10,000) of polygon edges and then separate R-tree index, specifically shown in Figure 6, the first side of each polygon to build the smallest bounding box, and then these minimum Construction R-tree index (outsourcing rectangle R-tree index on not shown), so-ray method for the intersection when the first judgment by the R-tree ray intersects with the bounding box, the last tree on the edge R coarse sieve rectangle on the basis of outsourcing precise intersection judgment, the time complexity from O (N) dropped to O (Log (N)), greatly improving the computational efficiency. Six pairs of sides of the polygon R-tree indexes diagram of a 4-line application services practice has 300,000 geofencing polygons, by building R-tree indexes in memory, so that the online real-time geo-fencing query average response time of less than 1ms, and violence query response time is about 9 seconds. 5 R Tree Related Items https://pypi.python.org/pypi/Rtree/ (Python) http://jsi.sourceforge.net/ (Java) https://github.com/leaflet-extras/RTree (Javascript ) http://sourceforge.net/p/cspatialindexrt/code/HEAD/tree/ (C #)geofencing parsing algorithm