Extend MySQL implementation of PiP Algorithm?

Posted by Mike on Stack Overflow See other posts from Stack Overflow or by Mike
Published on 2013-01-16T17:40:37Z Indexed on 2013/11/10 3:53 UTC
Read the original article Hit count: 193

Filed under:
|
|
|

I need to make a point in polygon MySQL query.

I already found these two great solutions:

http://forums.mysql.com/read.php?23,286574,286574

MySQL implementation of ray-casting Algorithm?

But these functions can only check if one point is inside a poly. I have a query where the PiP part should only be one part of the query and check for x points inside a polygon.

Something like this:

$points = list/array/whatever of points in language of favour

SELECT d.name
FROM data AS d
WHERE d.name LIKE %red%
// just bla bla

// how to do this ?
AND $points INSIDE d.polygon
AND myWithin( $points, d.polygo ) // or

UPDATE

I tried it with MBR functions like this:

SET @g1 = GeomFromText('Polygon((13.43971 52.55757,13.41293 52.49825,13.53378 52.49574, 13.43971 52.55757))');
SET @g2 = GeomFromText('Point(13.497834 52.540489)');
SELECT MBRContains(@g1,@g2);

G2 should NOT be inside G1 but MBR says it is.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql