From 85be728bf639f6974ad144e3708bad9e2b4e2245 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 24 Mar 2022 07:32:06 +0000 Subject: [PATCH 1/2] Create command to test getClosestOpenHubs. #652 --- src/Command/TestClosestOpenHubsCommand.php | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/Command/TestClosestOpenHubsCommand.php diff --git a/src/Command/TestClosestOpenHubsCommand.php b/src/Command/TestClosestOpenHubsCommand.php new file mode 100644 index 00000000..f82a1400 --- /dev/null +++ b/src/Command/TestClosestOpenHubsCommand.php @@ -0,0 +1,45 @@ +setName('test:closestopenhubs') + ->setDescription('Test the get closest open hubs service.') + ->setHelp('Test the get closese open hubs service.') + ->addArgument('long', InputArgument::REQUIRED, 'Longitude') + ->addArgument('lat', InputArgument::REQUIRED, 'Latitude'); + } + + public function __construct(MapTools $maptools) + { + $this->maptools = $maptools; + + parent::__construct(); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $long = $input->getArgument('long'); + $lat = $input->getArgument('lat'); + + $point = new Point($long, $lat); + $this->maptools->getClosestOpenHubs(); + + return 0; + } + +} From 3e238347be75a48015699fcb7d9f6da1bdce9be0 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 24 Mar 2022 08:19:44 +0000 Subject: [PATCH 2/2] Add hub output with distance. #652 --- src/Command/TestClosestOpenHubsCommand.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Command/TestClosestOpenHubsCommand.php b/src/Command/TestClosestOpenHubsCommand.php index f82a1400..f2cd25a2 100644 --- a/src/Command/TestClosestOpenHubsCommand.php +++ b/src/Command/TestClosestOpenHubsCommand.php @@ -13,7 +13,7 @@ use App\Service\MapTools; class TestClosestOpenHubsCommand extends Command { - $protected $maptools; + protected $maptools; protected function configure() { @@ -37,7 +37,16 @@ class TestClosestOpenHubsCommand extends Command $lat = $input->getArgument('lat'); $point = new Point($long, $lat); - $this->maptools->getClosestOpenHubs(); + + $hubs_with_distance = $this->maptools->getClosestOpenHubs($point, 10); + + foreach($hubs_with_distance as $hub_dist) + { + $hub = $hub_dist['hub']; + $distance = $hub_dist['distance']; + + error_log('Hub ID ' . $hub->getID() . ' - ' . $hub->getName() . ' = ' . $distance . ' kms away.'); + } return 0; }