Oracle stored procedure description that determines whether a point falls on a polygon

Source: Internet
Author: User

1. Background

In the Leting project, engineering colleagues put forward the need for docking vehicle GPS reporting points, can be real-time to determine whether the point falls in the Leting administrative region. If not, alarm it.

Processing ideas are divided into two, one is the front-end real-time pull from the database to save the GPS point, and then determine whether the point falls in the regional plane. Second, in real-time docking GPS data with GPS manufacturers, the GPS data into our database corresponding table, the point is whether to fall in the area of the judgment, if not, in the corresponding table in the judgment point surface relationship field will be labeled.

Taking into account the efficiency and the preservation of records, finally choose the second option, that is, to operate at the database level, and to save the decision record mode.

2. Algorithm 2.1 algorithm selection for judging point-surface relation

The algorithms for judging point-surface relationships are generally as follows:

A difference multiplication discriminant method (only for convex polygons)

B. Area discrimination method (only for convex polygons)

C. Angle and discriminant method (any polygon can be)

For the generality of later storage procedures, the choice of use angle and discriminant method more meet the requirements.

2.2 Principle of angle and discriminant method

principle: make P={P1,P2,..., pn,p1} is a closed polygon with a vertex of Pi (xi,yi), i=1,2,..., N, and PT is a test point. PTPI is a vector that joins PT and Pi, and like represents the angle of the vector ptpi to ptpi+1.

If Σαi = 0 pt is outside of P;

If Σαi =±2πpt in P.

3. Using the stored procedure to achieve the algorithm 3.1 single angle acquisition (angle like algorithm)

3.2 Angle Sum discrimination

3. Algorithm optimization

The above angle and algorithm is relatively time-consuming, if we judge the point surface relationship before the simplest way to do a filter judgment, so that only the points to meet the requirements into the angle and algorithm judgment, will be more helpful to the efficiency hints.

Here, you can filter the point directly using the four-corner coordinates of the range when you get to it.

4. Algorithm Testing

Due to the existence of a certain error range of GPs, the Leting boundary has been extended to some extent. The extended range is then transformed into the ring-formatted JSON point string. Then select multiple points to test.

Repeated testing of multiple samples, all meet the requirements.

--Welcome reprint, but retain the copyright, please indicate the source in obvious place: http://www.cnblogs.com/naaoveGIS/

Oracle stored procedure description that determines whether a point falls on a polygon

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.