Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can find a usefull post here: </p> <p><a href="http://blog.jcole.us/2007/11/24/on-efficiently-geo-referencing-ips-with-maxmind-geoip-and-mysql-gis/" rel="nofollow">http://blog.jcole.us/2007/11/24/on-efficiently-geo-referencing-ips-with-maxmind-geoip-and-mysql-gis/</a></p> <p>I have used this post as a "starting point" for a project over 150milions of record -myisam- and it works fine</p> <p>BTW, in general the best way is to use the <code>GEOMETRY</code> and <code>SPATIAL INDEX</code> -only for myisam- like as follow:</p> <ul> <li><code>ALTER TABLE &lt;table&gt; ADD geom_point GEOMETRY NOT NULL ;</code></li> <li><code>ALTER TABLE &lt;table&gt; ADD SPATIAL INDEX geom_point (geom_point) ;</code></li> <li><code>UPDATE &lt;table&gt; SET geom_point = POINT(latitude, longitude);</code></li> </ul> <p>Now you can find all "names" into a "square" using a query like this:</p> <pre><code>SELECT * from &lt;table&gt; WHERE MBRContains(GeomFromText('LineString(&lt;lata&gt; &lt;lona&gt;, &lt;latb&gt; &lt;lonb&gt;)'), geom_point) </code></pre> <p>Or by distance like:</p> <pre><code>$longitude = 8.449997; $latitude = 45.550003; $distance = 50; # km $point1 = $latitude + $distance / ( 111.1 / cos($latitude)); $point2 = $longitude + $distance / 111.1; $point3 = $latitude - $distance / ( 111.1 / cos($latitude)); $point4 = $longitude - $distance / 111.1; SELECT * from &lt;table&gt; WHERE MBRContains(GeomFromText('LineString(&lt;$point1&gt; &lt;$point2&gt;, &lt;$point3&gt; &lt;$point4&gt;)'), geom_point) </code></pre> <p>Try on your test table ;)</p>
 

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