I need help with clustering algorithm. I have a mysql database with lat, lng, geohash(12 chars).
I am usign this query to select all records for zoom level 2 (2 chars)
SELECT COUNT( id ) , LEFT( `geohash` , 2 )
FROM server_cluster
GROUP BY LEFT( `geohash` , 2 )
But how to select all records for bounding box?
mymap.getBounds()._northEast
M {lat: 42.51665075361143, lng: -87.95448303222658} (dp93yect2n0n)
mymap.getBounds()._southWest
M {lat: 42.313877566161864, lng: -88.36647033691406} (dp90tpj80n86)
UPD: here is how I use it now:
$bounds = explode(",", $bounds);
$NE = substr(GeoHash3::encode($bounds[0],$bounds[1]),0,$zoom);
$SW = substr(GeoHash3::encode($bounds[2],$bounds[3]),0,$zoom);
$sql = ' SELECT count(id) as count, LEFT(`geohash`, '.$zoom.') AS geo
FROM server_cluster
WHERE
LEFT( `geohash` , '.$zoom.' ) <= "'.$NE.'"
AND
LEFT( `geohash` , '.$zoom.' ) >= "'.$SW.'"
group by geo
ORDER BY `geohash`
';
But it is not ok.
Or is there any simple server side clustering algorithm with php and mysql that can handle 60k markers on the 0 zoom level?