Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/home2/people/www/blog/tmp) is not within the allowed path(s): (/home/people/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/people/public_html/blog/wp-content/plugins/wassup/lib/wassup.class.php on line 268

Warning: Cannot modify header information - headers already sent by (output started at /home/people/public_html/blog/wp-content/plugins/wassup/lib/wassup.class.php:268) in /home/people/public_html/blog/wp-content/plugins/wassup/wassup.php on line 1265

Warning: Cannot modify header information - headers already sent by (output started at /home/people/public_html/blog/wp-content/plugins/wassup/lib/wassup.class.php:268) in /home/people/public_html/blog/wp-includes/feed-rss2-comments.php on line 8
Comments on: mysql latitude/longitude radius http://blog.peoplesdns.com/archives/24 all the stuff that doesn't get posted elsewhere Fri, 21 Nov 2008 13:57:36 +0000 http://wordpress.org/?v=2.5 By: matt http://blog.peoplesdns.com/archives/24#comment-20240 matt Mon, 14 Apr 2008 19:07:51 +0000 http://blog.peoplesdns.com/?p=24#comment-20240 I have been doing radius searches for ages, but have always used php to order the results by distance, this is genius! I love it! thanks! I have been doing radius searches for ages, but have always used php to order the results by distance, this is genius! I love it! thanks!

]]>
By: joeldg http://blog.peoplesdns.com/archives/24#comment-19466 joeldg Wed, 19 Mar 2008 17:02:58 +0000 http://blog.peoplesdns.com/?p=24#comment-19466 [quote comment="17979"]Hi, thanks for that calculation. i am finding it extremely accurate. I am wondering what kind of index you are using on your tables? I have a table with over 2 million rows, so its taking longer than I would like to bring the results back. Has anyone optimised a table for this kind of thing before?[/quote] Kev How I originally set this is up to have a "points" table which is simply id, lat, long Then, from there we set up a data table that has the info for the position and then uses a point_id for the GeoPoint field.. You use a indexed Double type for the lat/long and run the query against that table and then right join in the data table with the point_id's matching. For MySql machines, my suggestion is ReiserFS for the file system (assuming dedicated mysql machine) and make sure your my.cnf file is fully optimized for the machine.. I should write up my config stuff for determining the proper my.cnf options.For this, you want to watch your join/sort server variables to make sure things are well speedy. MyISAM engine type is usually what I use, however for data that is queried a lot and not changed often you can use HEAP tables to increase performance a lot. HEAP tables can be flushed to disk via a cron as needed to make sure new data is saved. Just some ideas to speed things up.

Hi,
thanks for that calculation. i am finding it extremely accurate.

I am wondering what kind of index you are using on your tables?
I have a table with over 2 million rows, so its taking longer than I would like to bring the results back.
Has anyone optimised a table for this kind of thing before?

Kev

How I originally set this is up to have a “points” table which is simply id, lat, long
Then, from there we set up a data table that has the info for the position and then uses a point_id for the GeoPoint field..
You use a indexed Double type for the lat/long and run the query against that table and then right join in the data table with the point_id’s matching.
For MySql machines, my suggestion is ReiserFS for the file system (assuming dedicated mysql machine) and make sure your my.cnf file is fully optimized for the machine.. I should write up my config stuff for determining the proper my.cnf options.For this, you want to watch your join/sort server variables to make sure things are well speedy.
MyISAM engine type is usually what I use, however for data that is queried a lot and not changed often you can use HEAP tables to increase performance a lot. HEAP tables can be flushed to disk via a cron as needed to make sure new data is saved.
Just some ideas to speed things up.

]]>
By: J.G. http://blog.peoplesdns.com/archives/24#comment-19420 J.G. Tue, 18 Mar 2008 08:21:46 +0000 http://blog.peoplesdns.com/?p=24#comment-19420 Just wanted to remark that Claude's comment above is correct. I successfully found locations withing an 8 mile radius, and the distance in miles is accurate as verified by a similar search in another program. I also dropped the last calculation in the ORDER BY clause and just put: ORDER BY distance Thanks to joeldg for the original post (INCREDIBLE, man) and Claude for the clarification. :) Just wanted to remark that Claude’s comment above is correct. I successfully found locations withing an 8 mile radius, and the distance in miles is accurate as verified by a similar search in another program. I also dropped the last calculation in the ORDER BY clause and just put: ORDER BY distance

Thanks to joeldg for the original post (INCREDIBLE, man) and Claude for the clarification. :)

]]>
By: Tom http://blog.peoplesdns.com/archives/24#comment-18404 Tom Tue, 19 Feb 2008 11:52:21 +0000 http://blog.peoplesdns.com/?p=24#comment-18404 Thanks for that, saved me some think time. Just wanted to point out that multiplying by 3963.191 in the ORDER part is superfluous. Thanks for that, saved me some think time. Just wanted to point out that multiplying by 3963.191 in the ORDER part is superfluous.

]]>
By: Kev http://blog.peoplesdns.com/archives/24#comment-17979 Kev Sat, 09 Feb 2008 15:41:33 +0000 http://blog.peoplesdns.com/?p=24#comment-17979 Hi, thanks for that calculation. i am finding it extremely accurate. I am wondering what kind of index you are using on your tables? I have a table with over 2 million rows, so its taking longer than I would like to bring the results back. Has anyone optimised a table for this kind of thing before? Hi,
thanks for that calculation. i am finding it extremely accurate.

I am wondering what kind of index you are using on your tables?
I have a table with over 2 million rows, so its taking longer than I would like to bring the results back.
Has anyone optimised a table for this kind of thing before?

]]>
By: Dhruba Baishya http://blog.peoplesdns.com/archives/24#comment-17598 Dhruba Baishya Thu, 31 Jan 2008 07:26:20 +0000 http://blog.peoplesdns.com/?p=24#comment-17598 Good Tutorial. Thnx! Typo: In "ORDER BY 3963.191 ... PI()* -73.99319 /180)))". You have '*' and '-' together, it might end up with some errors when used w/ variables e.g. *-$longitude. Just put "()" around longitude value:) Good Tutorial. Thnx!

Typo: In “ORDER BY 3963.191 … PI()* -73.99319 /180)))”.

You have ‘*’ and ‘-’ together, it might end up with some errors when used w/ variables e.g. *-$longitude. Just put “()” around longitude value:)

]]>
By: mohamed http://blog.peoplesdns.com/archives/24#comment-17169 mohamed Thu, 17 Jan 2008 10:35:57 +0000 http://blog.peoplesdns.com/?p=24#comment-17169 Is this correct solution for for finding closest locations latitude and longitude with given miles? Is this correct solution for for finding closest locations latitude and longitude with given miles?

]]>
By: Howard http://blog.peoplesdns.com/archives/24#comment-14107 Howard Mon, 15 Oct 2007 21:11:54 +0000 http://blog.peoplesdns.com/?p=24#comment-14107 Joel, Could you give a brief concrete example of how to work a bounding-box subquery into your code? I've got a piece of mysql that looks very similar to your code above. It works but runs a bit slow, since it's joining against over 850,000 Canadian postal codes! I'd like to filter out everything but say a 10-kilometre box around the postal code I'm interested in, but I'm new enough to SQL that I can't figure out how to do the subquery or subselection. I've looked at the mysql docs but am still confused. TIA, Howard Joel,

Could you give a brief concrete example of how to work a bounding-box subquery into your code? I’ve got a piece of mysql that looks very similar to your code above. It works but runs a bit slow, since it’s joining against over 850,000 Canadian postal codes!

I’d like to filter out everything but say a 10-kilometre box around the postal code I’m interested in, but I’m new enough to SQL that I can’t figure out how to do the subquery or subselection. I’ve looked at the mysql docs but am still confused.

TIA,
Howard

]]>
By: mekdigital http://blog.peoplesdns.com/archives/24#comment-13105 mekdigital Thu, 20 Sep 2007 15:40:48 +0000 http://blog.peoplesdns.com/?p=24#comment-13105 SO GREAT! :) you can use this combined with this great google maps example: http://maps.forum.nu/gm_clickable_circle.html just change a function.. and post the query to the following action.. function drawFilledCircle(){ oStatusDiv = document.getElementById("statusDiv"); var zoom = map.getZoom(); var centerPt = normalProj.fromLatLngToPixel(centerMarker.getPoint(), zoom); var radiusPt = normalProj.fromLatLngToPixel(radiusMarker, zoom); var circlePoints = Array(); with (Math) { var radius = floor(sqrt(pow((centerPt.x-radiusPt.x),2) + pow((centerPt.y-radiusPt.y),2))); var thickness = min(255,radius); for (var n = 1 ; n \n'; oStatusDiv.innerHTML += 'Circumference on Earth: ' + (PI*radOnEarth*2).toFixed(3) + ' km\n'; oStatusDiv.innerHTML += 'Areal on Earth: ' + (PI*pow(radOnEarth,2)).toFixed(3) + ' km\n'; oStatusDiv.innerHTML += ''; oStatusDiv.innerHTML += 'select city,latitude,longitude, acos(SIN( PI()* '+ lat +' /180 )*SIN( PI()*latitude/180 ))+(cos(PI()* '+ lat +' /180)*COS( PI()*latitude/180) *COS(PI()*longitude/180-PI()* '+ lng +' /180))* 6378.137 AS distance FROM geodatas WHERE 1=1 AND 6378.137 * ACOS( (SIN(PI()* '+ lat +' /180)*SIN(PI() * latitude/180)) + (COS(PI()* '+ lat +' /180)*cos(PI()*latitude/180)*COS(PI() * longitude/180-PI()* '+ lng +' /180))) '; map.removeOverlay(circleLine2); circleLine2 = new GPolyline(circlePoints,'#96BDFE',thickness,0.5); map.addOverlay(circleLine2); } } } SO GREAT! :)

you can use this combined with this great google maps example:

http://maps.forum.nu/gm_clickable_circle.html

just change a function.. and post the query to the following action..

function drawFilledCircle(){
oStatusDiv = document.getElementById(”statusDiv”);
var zoom = map.getZoom();

var centerPt = normalProj.fromLatLngToPixel(centerMarker.getPoint(), zoom);
var radiusPt = normalProj.fromLatLngToPixel(radiusMarker, zoom);

var circlePoints = Array();

with (Math) {
var radius = floor(sqrt(pow((centerPt.x-radiusPt.x),2) + pow((centerPt.y-radiusPt.y),2)));
var thickness = min(255,radius);

for (var n = 1 ; n \n’;
oStatusDiv.innerHTML += ‘Circumference on Earth: ‘ + (PI*radOnEarth*2).toFixed(3) + ‘ km\n’;
oStatusDiv.innerHTML += ‘Areal on Earth: ‘ + (PI*pow(radOnEarth,2)).toFixed(3) + ‘ km\n’;
oStatusDiv.innerHTML += ”;
oStatusDiv.innerHTML += ’select city,latitude,longitude, acos(SIN( PI()* ‘+ lat +’ /180 )*SIN( PI()*latitude/180 ))+(cos(PI()* ‘+ lat +’ /180)*COS( PI()*latitude/180) *COS(PI()*longitude/180-PI()* ‘+ lng +’ /180))* 6378.137 AS distance FROM geodatas WHERE 1=1 AND 6378.137 * ACOS( (SIN(PI()* ‘+ lat +’ /180)*SIN(PI() * latitude/180)) + (COS(PI()* ‘+ lat +’ /180)*cos(PI()*latitude/180)*COS(PI() * longitude/180-PI()* ‘+ lng +’ /180))) ‘;

map.removeOverlay(circleLine2);
circleLine2 = new GPolyline(circlePoints,’#96BDFE’,thickness,0.5);
map.addOverlay(circleLine2);
}
}
}

]]>
By: robert http://blog.peoplesdns.com/archives/24#comment-12522 robert Fri, 31 Aug 2007 20:54:01 +0000 http://blog.peoplesdns.com/?p=24#comment-12522 even better might be to be able to select within a rang of coordinates .. say everything within a 50 mile radius? thanks a lot.. very appreciative. even better might be to be able to select within a rang of coordinates .. say everything within a 50 mile radius?

thanks a lot.. very appreciative.

]]>

Warning: is_writable() [function.is-writable]: open_basedir restriction in effect. File(error_log) is not within the allowed path(s): (/home/people/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/people/public_html/blog/wp-includes/wp-db.php on line 199