location.dk.inc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. // Denmark
  3. function location_province_list_dk() {
  4. return array('CC' => "Copenhagen (municipality)",
  5. 'FC' => "Frederiksberg (municipality)",
  6. 'CO' => "Copenhagen",
  7. 'FR' => "Frederiksborg",
  8. 'RO' => "Roskilde",
  9. 'WZ' => "West Zealand",
  10. 'ST' => "Storstrom",
  11. 'FU' => "Funen",
  12. 'SJ' => "South Jutland",
  13. 'RB' => "Ribe",
  14. 'VK' => "Vejle",
  15. 'RK' => "Ringkjobing",
  16. 'VB' => "Viborg",
  17. 'NJ' => "North Jutland",
  18. 'AR' => "Arhus",
  19. 'BH' => "Bornholm",
  20. 'GL' => "Greenland",
  21. 'FO' => "Faroe Islands");
  22. }
  23. /**
  24. * Generate findvej.dk map link.
  25. *
  26. * @param array $location
  27. * The location array we're trying to generate a link for.
  28. * @return string or null
  29. * Map link if generation successful, otherwise null.
  30. */
  31. function location_map_link_dk_findvej($location = array()) {
  32. if (isset($location['street']) && !empty($location['street']) &&
  33. isset($location['postal_code']) && !empty($location['postal_code'])) {
  34. return url('http://findvej.dk/' . $location['street'] . ',' . $location['postal_code']);
  35. }
  36. elseif (isset($location['street']) && !empty($location['street']) &&
  37. isset($location['city']) && !empty($location['city'])) {
  38. return url('http://findvej.dk/' . $location['street'] . ',' . $location['city']);
  39. }
  40. elseif (location_has_coordinates($location)) {
  41. return url('http://findvej.dk/', array('query' => array(
  42. 'latitude' => $location['latitude'],
  43. 'longitude' => $location['longitude'],
  44. )));
  45. }
  46. else {
  47. return NULL;
  48. }
  49. }
  50. /**
  51. * Generate a link to Rejseplanen.
  52. *
  53. * Rejseplanen is a route planner for Danish public transportation.
  54. *
  55. * @param array $location
  56. * The location array we're trying to generate a link for.
  57. * @return string or null
  58. * Map link if generation successful, otherwise null.
  59. */
  60. function location_map_link_dk_rejseplanen($location = array()) {
  61. $keys = array();
  62. // Iterate over all the possible details, and if set, add them to an array.
  63. foreach (array('street', 'postal_code', 'city') as $name) {
  64. if (isset($location[$name]) && !empty($location[$name])) {
  65. $keys[$name] = $location[$name];
  66. }
  67. }
  68. // Merge postal code and city if both are available, since they
  69. // shouldn't be comma separated in Danish addresses.
  70. if (isset($keys['postal_code']) && isset($keys['city'])) {
  71. $keys['postal_code'] = $keys['postal_code'] . ' ' . $keys['city'];
  72. unset($keys['city']);
  73. }
  74. // If any of the key values were available, generate a URL.
  75. if (!empty($keys)) {
  76. return url('http://www.rejseplanen.dk/bin/query.exe/mn?Z=' . implode(', ', $keys) . '&ZADR=1');
  77. }
  78. else {
  79. return NULL;
  80. }
  81. }
  82. /**
  83. * @return
  84. * An array where
  85. * -> the key is the word that helps identify the name of function that builds the link. For example, a key of 'yahoo' means the name of the
  86. * the function that builds a link to a map on Yahoo! Maps would be 'location_map_link_us_yahoo'
  87. * -> the value is itself an array with 3 key/value pairs:
  88. * 'name' => points to the name of the mapping service. For 'yahoo', this would be 'Yahoo! Maps'
  89. * 'url' => the url of the main page of the mapping service. For 'yahoo', this would be 'http://maps.yahoo.com'
  90. * 'tos' => the url of the page that explains the map providers Terms of Service, or Terms of Use. For 'yahoo', this would be
  91. * 'http://help.yahoo.com/help/us/maps/maps-24.html'
  92. */
  93. function location_map_link_dk_providers() {
  94. return array(
  95. 'findvej' => array(
  96. 'name' => 'findvej.dk',
  97. 'url' => 'http://findvej.dk',
  98. 'tos' => 'http://www.google.com/intl/da_ALL/help/terms_maps.html',
  99. ),
  100. 'rejseplanen' => array(
  101. 'name' => 'Rejseplanen',
  102. 'url' => 'http://www.rejseplanen.dk/',
  103. 'tos' => 'http://info.rejseplanen.dk/om_rejseplanen', // As close as I could find.
  104. ),
  105. );
  106. }
  107. /**
  108. * @return
  109. * An array of values that work as keys to the array returned by location_map_link_us_providers. The idea is that if the
  110. * administrator of the site has not yet had a chance to visit the "Map Links" subtab on the location module's settings page,
  111. * that we can provide deep-linking to a relatively safe default. By 'relatively safe', we mean that the Terms Of Service of
  112. * the provider of the maps are flexible enough for most parties.
  113. *
  114. * For the case of the U.S., 'google' has relatively flexible Terms Of Service, whereas Yahoo! Maps and MapQuest have more
  115. * restrictive Terms Of Service.
  116. *
  117. */
  118. function location_map_link_dk_default_providers() {
  119. return array('findvej', 'rejseplanen');
  120. }
  121. /**
  122. * Returns minimum and maximum latitude and longitude needed to create a bounding box.
  123. */
  124. function location_bounds_dk() {
  125. return array(
  126. 'minlng' => 8.00875,
  127. 'minlat' => 54.590067,
  128. 'maxlng' => 15.15975,
  129. 'maxlat' => 57.805567,
  130. );
  131. }