location.georss.inc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * @file
  4. * GeoRSS support for Location.
  5. */
  6. /**
  7. * @function
  8. * Return an array of RSS items for a location.
  9. */
  10. function _location_rss_item($location, $mode = 'simple') {
  11. $ret = FALSE;
  12. if (location_has_coordinates($location, TRUE)) {
  13. switch ($mode) {
  14. // W3C Basic Geo Vocabulary
  15. case 'w3c':
  16. $ret = array(
  17. 'key' => 'geo:Point',
  18. 'namespace' => array('xmlns:geo' => 'http://www.w3.org/2003/01/geo/wgs84_pos#'),
  19. 'value' => array(
  20. array('key' => 'geo:lat', 'value' => $location['latitude']),
  21. array('key' => 'geo:long', 'value' => $location['longitude']),
  22. ),
  23. );
  24. break;
  25. // Location 1.x-2.x bug compatible.
  26. // W3C Basic Geo Vocabulary with a misspelled longitude tag.
  27. case 'w3c_bugcompat':
  28. $ret = array(
  29. 'key' => 'geo:Point',
  30. 'namespace' => array('xmlns:geo' => 'http://www.w3.org/2003/01/geo/wgs84_pos#'),
  31. 'value' => array(
  32. array('key' => 'geo:lat', 'value' => $location['latitude']),
  33. array('key' => 'geo:lon', 'value' => $location['longitude']),
  34. ),
  35. );
  36. break;
  37. // GeoRSS-Simple
  38. case 'simple':
  39. $ret = array(
  40. 'key' => 'georss:point',
  41. 'namespace' => array('xmlns:georss' => 'http://www.georss.org/georss'),
  42. 'value' => "$location[latitude] $location[longitude]",
  43. );
  44. break;
  45. //
  46. case 'gml':
  47. $ret = array(
  48. 'key' => 'georss:where',
  49. 'namespace' => array(
  50. 'xmlns:georss' => 'http://www.georss.org/georss',
  51. 'xmlns:gml' => 'http://www.opengis.net/gml',
  52. ),
  53. 'value' => array(
  54. 'gml:Point' => array(
  55. 'gml:pos' => "$location[latitude] $location[longitude]",
  56. ),
  57. ),
  58. );
  59. break;
  60. }
  61. }
  62. return $ret;
  63. }