ConvertCoordinateFormat.mjs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /**
  2. * Convert co-ordinate format tests
  3. *
  4. * @author j433866
  5. *
  6. * @copyright Crown Copyright 2019
  7. * @license Apache-2.0
  8. */
  9. /**
  10. * TEST CO-ORDINATES
  11. * DD: 51.504°,-0.126°,
  12. * DDM: 51° 30.24',-0° 7.56',
  13. * DMS: 51° 30' 14.4",-0° 7' 33.6",
  14. * Geohash: gcpvj0h0x,
  15. * MGRS: 30U XC 99455 09790,
  16. * OSNG: TQ 30163 80005,
  17. * UTM: 30N 699456 5709791,
  18. */
  19. import TestRegister from "../../TestRegister";
  20. TestRegister.addTests([
  21. {
  22. name: "Co-ordinates: From Decimal Degrees to Degrees Minutes Seconds",
  23. input: "51.504°,-0.126°,",
  24. expectedOutput: "51° 30' 14.4\",-0° 7' 33.6\",",
  25. recipeConfig: [
  26. {
  27. op: "Convert co-ordinate format",
  28. args: ["Decimal Degrees", "Comma", "Degrees Minutes Seconds", "Comma", "None", 1]
  29. },
  30. ],
  31. },
  32. {
  33. name: "Co-ordinates: From Degrees Minutes Seconds to Decimal Degrees",
  34. input: "51° 30' 14.4\",-0° 7' 33.6\",",
  35. expectedOutput: "51.504°,-0.126°,",
  36. recipeConfig: [
  37. {
  38. op: "Convert co-ordinate format",
  39. args: ["Degrees Minutes Seconds", "Comma", "Decimal Degrees", "Comma", "None", 3]
  40. },
  41. ],
  42. },
  43. {
  44. name: "Co-ordinates: From Decimal Degrees to Degrees Decimal Minutes",
  45. input: "51.504°,-0.126°,",
  46. expectedOutput: "51° 30.24',-0° 7.56',",
  47. recipeConfig: [
  48. {
  49. op: "Convert co-ordinate format",
  50. args: ["Decimal Degrees", "Comma", "Degrees Decimal Minutes", "Comma", "None", 2]
  51. }
  52. ]
  53. },
  54. {
  55. name: "Co-ordinates: From Degrees Decimal Minutes to Decimal Degrees",
  56. input: "51° 30.24',-0° 7.56',",
  57. expectedOutput: "51.504°,-0.126°,",
  58. recipeConfig: [
  59. {
  60. op: "Convert co-ordinate format",
  61. args: ["Degrees Decimal Minutes", "Comma", "Decimal Degrees", "Comma", "None", 3]
  62. }
  63. ]
  64. },
  65. {
  66. name: "Co-ordinates: From Decimal Degrees to Decimal Degrees",
  67. input: "51.504°,-0.126°,",
  68. expectedOutput: "51.504°,-0.126°,",
  69. recipeConfig: [
  70. {
  71. op: "Convert co-ordinate format",
  72. args: ["Decimal Degrees", "Comma", "Decimal Degrees", "Comma", "None", 3]
  73. }
  74. ]
  75. },
  76. {
  77. name: "Co-ordinates: From Decimal Degrees to Geohash",
  78. input: "51.504°,-0.126°,",
  79. expectedOutput: "gcpvj0h0x,",
  80. recipeConfig: [
  81. {
  82. op: "Convert co-ordinate format",
  83. args: ["Decimal Degrees", "Comma", "Geohash", "Comma", "None", 9]
  84. },
  85. ],
  86. },
  87. {
  88. name: "Co-ordinates: From Geohash to Decimal Degrees",
  89. input: "gcpvj0h0x,",
  90. expectedOutput: "51.504°,-0.126°,",
  91. recipeConfig: [
  92. {
  93. op: "Convert co-ordinate format",
  94. args: ["Geohash", "Comma", "Decimal Degrees", "Comma", "None", 3]
  95. },
  96. ],
  97. },
  98. {
  99. name: "Co-ordinates: From Decimal Degrees to MGRS",
  100. input: "51.504°,-0.126°,",
  101. expectedOutput: "30U XC 99455 09790,",
  102. recipeConfig: [
  103. {
  104. op: "Convert co-ordinate format",
  105. args: ["Decimal Degrees", "Comma", "Military Grid Reference System", "Comma", "None", 10]
  106. },
  107. ],
  108. },
  109. {
  110. name: "Co-ordinates: From MGRS to Decimal Degrees",
  111. input: "30U XC 99455 09790,",
  112. expectedOutput: "51.504°,-0.126°,",
  113. recipeConfig: [
  114. {
  115. op: "Convert co-ordinate format",
  116. args: ["Military Grid Reference System", "Comma", "Decimal Degrees", "Comma", "None", 3]
  117. }
  118. ]
  119. },
  120. {
  121. name: "Co-ordinates: From Decimal Degrees to OSNG",
  122. input: "51.504°,-0.126°,",
  123. expectedOutput: "TQ 30163 80005,",
  124. recipeConfig: [
  125. {
  126. op: "Convert co-ordinate format",
  127. args: ["Decimal Degrees", "Comma", "Ordnance Survey National Grid", "Comma", "None", 10]
  128. },
  129. ],
  130. },
  131. {
  132. name: "Co-ordinates: From OSNG to Decimal Degrees",
  133. input: "TQ 30163 80005,",
  134. expectedOutput: "51.504°,-0.126°,",
  135. recipeConfig: [
  136. {
  137. op: "Convert co-ordinate format",
  138. args: ["Ordnance Survey National Grid", "Comma", "Decimal Degrees", "Comma", "None", 3]
  139. },
  140. ],
  141. },
  142. {
  143. name: "Co-ordinates: From Decimal Degrees to UTM",
  144. input: "51.504°,-0.126°,",
  145. expectedOutput: "30 N 699456 5709791,",
  146. recipeConfig: [
  147. {
  148. op: "Convert co-ordinate format",
  149. args: ["Decimal Degrees", "Comma", "Universal Transverse Mercator", "Comma", "None", 0]
  150. },
  151. ],
  152. },
  153. {
  154. name: "Co-ordinates: From UTM to Decimal Degrees",
  155. input: "30 N 699456 5709791,",
  156. expectedOutput: "51.504°,-0.126°,",
  157. recipeConfig: [
  158. {
  159. op: "Convert co-ordinate format",
  160. args: ["Universal Transverse Mercator", "Comma", "Decimal Degrees", "Comma", "None", 3]
  161. },
  162. ],
  163. },
  164. {
  165. name: "Co-ordinates: Directions in input, not output",
  166. input: "N51.504°,W0.126°,",
  167. expectedOutput: "51.504°,-0.126°,",
  168. recipeConfig: [
  169. {
  170. op: "Convert co-ordinate format",
  171. args: ["Decimal Degrees", "Comma", "Decimal Degrees", "Comma", "None", 3]
  172. },
  173. ],
  174. },
  175. {
  176. name: "Co-ordinates: Directions in input and output",
  177. input: "N51.504°,W0.126°,",
  178. expectedOutput: "N 51.504°,W 0.126°,",
  179. recipeConfig: [
  180. {
  181. op: "Convert co-ordinate format",
  182. args: ["Decimal Degrees", "Comma", "Decimal Degrees", "Comma", "Before", 3]
  183. },
  184. ],
  185. },
  186. {
  187. name: "Co-ordinates: Directions not in input, in output",
  188. input: "51.504°,-0.126°,",
  189. expectedOutput: "N 51.504°,W 0.126°,",
  190. recipeConfig: [
  191. {
  192. op: "Convert co-ordinate format",
  193. args: ["Decimal Degrees", "Comma", "Decimal Degrees", "Comma", "Before", 3]
  194. },
  195. ],
  196. },
  197. {
  198. name: "Co-ordinates: Directions not in input, in converted output",
  199. input: "51.504°,-0.126°,",
  200. expectedOutput: "N 51° 30' 14.4\",W 0° 7' 33.6\",",
  201. recipeConfig: [
  202. {
  203. op: "Convert co-ordinate format",
  204. args: ["Decimal Degrees", "Comma", "Degrees Minutes Seconds", "Comma", "Before", 3]
  205. },
  206. ],
  207. }
  208. ]);