earth.test 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * @file
  4. * Tests for earth.inc functionality.
  5. */
  6. require_once drupal_get_path('module', 'location') .'/earth.inc';
  7. require_once drupal_get_path('module', 'location') .'/tests/location_testcase.php';
  8. class LocationEarthTest extends LocationTestCase {
  9. function getInfo() {
  10. return array(
  11. 'name' => t('Location earth.inc tests'),
  12. 'description' => t('Test earth.inc calculations.'),
  13. 'group' => t('Location'),
  14. );
  15. }
  16. function setUp() {
  17. parent::setUp('location');
  18. }
  19. function testXYZ() {
  20. $expected = array(5076436.1926031, 3086400.2318368, 2312685.5571307);
  21. $result = earth_xyz(31.299, 21.4);
  22. $this->assertArrayEpsilon($result, $expected, 0.01);
  23. // Taj Mahal
  24. $expected = array(1179389.7524227, 605469.92806515, 6217918.5984722);
  25. $result = earth_xyz(27.174858, 78.042383);
  26. $this->assertArrayEpsilon($result, $expected, 0.01, 'Taj Mahal');
  27. // Four Corners
  28. $expected = array(-1667195.89356, -1256280.4293852, -6006637.16009);
  29. $result = earth_xyz(36.999084, -109.045223);
  30. $this->assertArrayEpsilon($result, $expected, 0.01, 'Four Corners');
  31. // North Magnetic Pole
  32. $expected = array(-335727.75631839, -2620765.1318567, -5785664.2896111);
  33. $result = earth_xyz(82.7, -114.4);
  34. $this->assertArrayEpsilon($result, $expected, 0.01, 'North Magnetic Pole');
  35. // Wall Drug
  36. $expected = array(-976074.77491191, -942362.77881868, -6211268.2459008);
  37. $result = earth_xyz(43.993266, -102.241794);
  38. $this->assertArrayEpsilon($result, $expected, 0.01, 'Wall Drug');
  39. }
  40. }