Note that there are some explanatory texts on larger screens.

plurals
  1. POFind how many (googlemap) polygons near x distance of a point
    primarykey
    data
    text
    <p>I'm working on a MYSQL/PHP system where I have the following:</p> <p>-- a set of latitude, longitude in the form of (lat,lng) stored as text format : (lat1,lng1)#(lat2,lng2)#(lat3,lng3) etc. which is basically a polygon drawn over a googlemap instance stored in the database. </p> <p>-- a table which stores in a field - a point's coordinates P(plat,plng) which is basically a point where a device is stationed</p> <p>I need to figure out how many polygons from the first table are within a distance of X kilometers from the point P essentially using MYSQL.</p> <p>I have come across quite a few Google Map libraries regarding this already, but I intend to resolve this by the quickest method possible - which I assume is via a MYSQL query. </p> <p>Can anyone please please shed some light regarding this?</p> <hr> <p>I've so far consulted a few examples on geospatial querying - and come up with this :</p> <pre><code> SELECT user_id, latitude, longitude, GeomFromText( "POINT(CONCAT_WS(' ',latitude,longitude))" ) AS point, Contains( GeomFromText( 'POLYGON(-26.167918065075458 28.10680389404297, - 26.187020810321858 28.091354370117188, -26.199805575765794 28.125,-26.181937320958628 28.150405883789062, -26.160676690299308 28.13220977783203, -26.167918065075458 28.10680389404297)' ) , GEOMFromText( "POINT(CONCAT_WS(' ',latitude,longitude))" ) ) FROM user_location </code></pre> <p>But the problem is it shows a record with lat: -26.136230, long: 28.338850 as well which is way off the polygon's boundaries. Can anyone please guide?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload