php - Bounding Box Search in MySQL -


this question has answer here:

i trying figure out how retrieve information mysql table below using "top-left latitude , longitude" , "bottom-right latitude , longitude" geographical bounding box.

create table `markers` (   `id` int not null auto_increment primary key ,   `name` varchar( 60 ) not null ,   `address` varchar( 80 ) not null ,   `lat` decimal(10,7) not null ,   `long` decimal(10,7) not null,   `geopoint` point not null,   primary key  (id),   spatial geopoint (geopoint) ) engine = myisam ; 

so far have sql query below , not sure if it's effective , efficient way of retrieving information?

$sql = "select * `markers` (long between '$west_long' , '$east_long') , (lat between '$north_lat' , '$south_lat')"; 

there quite impressive formulas convert 2 latitudes distance (meters, miles), same longitudes.

as long requests in range of earth, should assist mysql second simplified widened where-condition reduce right rectangle.

it's choice if take formulas in php or in sql - box in meters can converted box in lat/long.

a simple rectangle in lat-long-form never real rectangle, can see @ every orange.

marco


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -