Pogledajte određenu poruku
Staro 16. 06. 2011.   #18
webarto
expert
Grand Master
 
Avatar webarto
 
Datum učlanjenja: 11.04.2010
Poruke: 998
Hvala: 141
893 "Hvala" u 153 poruka
webarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished road
Default

PHP kd:
class Radius{
   
    public 
$table "routes";
    public 
$column_lat "lat";
    public 
$column_lon "lon";
    public 
$order "distance";
    public 
$order_direction "ASC";
    public 
$kilometers true;
    
    public function 
build_query($lat$lon$distance){
        
        if(
$kilometers){
            
$multiplier 112.12;
        }else{
            
$multiplier 69.0467669;
        }
        
        
$query 
        
"SELECT *, (SQRT(POW(($this->column_lat - $lat), 2) + POW(($this->column_lon - $lon), 2)) * $multiplier) AS distance
        FROM 
$this->table 
        WHERE POW((
$this->column_lat - $lat), 2) + POW(($this->column_lon - $lon), 2) < POW(($distance / $multiplier), 2) 
        ORDER BY 
$this->order $this->order_direction";
        
        return 
$query;
    
    }
    

PHP kd:
$lat 44.818611;
$lon 20.468056;

$radius = new Radius;
$query $radius->build_query($lat$lon10);
/** 
SELECT *, (SQRT(POW((lat - 44.818611), 2) + POW((lon - 20.468056), 2)) * 112.12) AS distance 
FROM routes 
WHERE POW((lat - 44.818611), 2) + POW((lon - 20.468056), 2) < POW((10 / 112.12), 2) 
ORDER BY distance ASC */

$result mysql_query($query);
while(
$row mysql_fetch_assoc($result)){
    


(Picture unrelated)

I tako to
webarto je offline   Odgovorite uz citat
"Hvala" webarto za poruku: