TestMap.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 2018/3/6
  6. * Time: 下午5:20
  7. */
  8. define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
  9. require_once(BASE_ROOT_PATH . '/fooder.php');
  10. require_once(BASE_ROOT_PATH . '/core/framework/function/http.php');
  11. require_once(BASE_ROOT_PATH . '/helper/geo_helper.php');
  12. class TestMap extends PHPUnit_Framework_TestCase
  13. {
  14. const amap_key = 'a284df4b8cef6aa5144f43ad5753b7d4';
  15. public static function setUpBeforeClass()
  16. {
  17. Base::run_util();
  18. }
  19. public function testLoc()
  20. {
  21. $loc_l = geo_helper::instance()->geocodes("上海","上海市第六人民医院");
  22. $loc_r = geo_helper::instance()->geocodes("上海","徐汇区番禺路900号");
  23. $dis = geo_helper::instance()->getdistance($loc_l[0],$loc_l[1],$loc_r[0],$loc_r[1]);
  24. }
  25. public function testUpdateStore()
  26. {
  27. $mod_member = Model('store');
  28. $i = 0;
  29. while (true) {
  30. $start = $i * 1000;
  31. $items = $mod_member->field('*')->order('store_id asc')->limit("{$start},1000")->select();
  32. if (empty($items)) {
  33. return;
  34. }
  35. $i++;
  36. foreach ($items as $item) {
  37. $store_id = intval($item['store_id']);
  38. $ret = geo_helper::instance()->update_store($store_id);
  39. }
  40. }
  41. }
  42. public function testUpdate()
  43. {
  44. geo_helper::instance()->update_store(38);
  45. }
  46. }