Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Speeding up point-in-polygon -- take two

by punkish (Priest)
on Aug 28, 2006 at 04:16 UTC ( [id://569929]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        CREATE TABLE polys (
          id   INTEGER PRIMARY KEY,
    ...
        CREATE INDEX ix_polys ON polys (xmin, ymin, xmax, ymax)
        
        CREATE INDEX ix_points ON points (x, y)
    
  2. or download this
        SELECT py.name, py.n, py.ar_x, py.ar_y, pt.id, pt.x, pt.y 
        FROM polys py JOIN points pt ON 
          (py.xmin < pt.x AND py.ymin < pt.y AND py.xmax > pt.x AND py.yma
    +x > pt.y) 
        WHERE py.id = ?
    
  3. or download this
        UPDATE points SET name = ? WHERE id IN (?)
    
  4. or download this
    sub _pointIsInPolygon {
      my ($a_point, $n, $a_x, $a_y) = @_;
    ...
      }
      return $side ? 1 : 0;
    }
    
  5. or download this
    >perl test_point_in_poly.pl
    5000.10000.15000.20000.25000.30000.35000.40000.45000.50000.55000.60000
    +.65000.70000.75000.80000.85000.90000.95000.100000.
    processed 100000 polys, updated 2948276 points 
    Total time: 8451 wallclock secs (6340.54 usr + 200.52 sys = 6541.06 CP
    +U)
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://569929]
Approved by imp
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-03-29 07:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found