public function matching_shortest_routes() { return $this->shortest_routes; } // the shortest possible distance to travel public function shortest_distance() { return $this->shortest_distance; } // returns an array of all the possible routes public function routes() { return $this->all_routes; } } $tsp = new TSP(); /*$db = new PDO('mysql:host=localhost;dbname=binapp','root',''); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); $lat = $_GET['lat']; // latitude of centre of bounding circle in degrees $lon = $_GET['lon']; // longitude of centre of bounding circle in degrees $rad = $_GET['rad']; // radius of bounding circle in kilometers $R = 6371; // earth's mean radius, km // first-cut bounding box (in degrees) $maxLat = $lat + rad2deg($rad/$R); $minLat = $lat - rad2deg($rad/$R); // compensate for degrees longitude getting smaller with increasing latitude $maxLon = $lon + rad2deg($rad/$R/cos(deg2rad($lat))); $minLon = $lon - rad2deg($rad/$R/cos(deg2rad($lat)));
public function matching_shortest_routes() { return $this->shortest_routes; } // the shortest possible distance to travel public function shortest_distance() { return $this->shortest_distance; } // returns an array of all the possible routes public function routes() { return $this->all_routes; } } $tsp = new TSP(); $db = new PDO('mysql:host=localhost;dbname=binapp', 'root', ''); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); $tsp->add('newquay', 50.413608, -5.083364); $tsp->add('london', 51.500152, -0.126236); $tsp->add('birmingham', 52.483003, -1.893561); $tsp->add('manchester', 53.480712, -2.234377); $tsp->compute(); echo 'Shortest Distance: ' . $tsp->shortest_distance(); echo '<br />Shortest Route: '; print_r($tsp->shortest_route()); echo '<br />Num Routes: ' . count($tsp->routes()); echo '<br />Matching shortest Routes: '; print_r($tsp->matching_shortest_routes()); echo '<br />All Routes: '; print_r($tsp->routes());
public function matching_shortest_routes() { return $this->shortest_routes; } // the shortest possible distance to travel public function shortest_distance() { return $this->shortest_distance; } // returns an array of all the possible routes public function routes() { return $this->all_routes; } } $tsp = new TSP(); $db = new PDO('mysql:host=localhost;dbname=binapp', 'root', ''); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); $lat = $_GET['lat']; // latitude of centre of bounding circle in degrees $lon = $_GET['lon']; // longitude of centre of bounding circle in degrees $rad = $_GET['rad']; // radius of bounding circle in kilometers $R = 6371; // earth's mean radius, km // first-cut bounding box (in degrees) $maxLat = $lat + rad2deg($rad / $R); $minLat = $lat - rad2deg($rad / $R); // compensate for degrees longitude getting smaller with increasing latitude $maxLon = $lon + rad2deg($rad / $R / cos(deg2rad($lat)));