1 // Boost.Geometry 2 // Unit Test 3 4 // Copyright (c) 2019 Oracle and/or its affiliates. 5 6 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle 7 8 // Use, modification and distribution is subject to the Boost Software License, 9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 10 // http://www.boost.org/LICENSE_1_0.txt) 11 12 #ifndef BOOST_GEOMETRY_TEST_DISTANCE_CROSS_TRACK_CASES_HPP 13 #define BOOST_GEOMETRY_TEST_DISTANCE_CROSS_TRACK_CASES_HPP 14 15 struct coordinates 16 { 17 double lon; 18 double lat; 19 }; 20 21 struct expected_results 22 { 23 coordinates p1; //1st point of segment 24 coordinates p2; //2nd point of segment 25 coordinates p3; //point to compute distance from segment 26 double reference; // karney or vincenty 27 double vincenty_bisection; 28 double vincenty; 29 double thomas_bisection; 30 double thomas; 31 double andoyer_bisection; 32 double andoyer; 33 double spherical; 34 }; 35 36 expected_results expected[] = 37 { 38 { 39 { 0, 0 },{ 1, 1 },{ 0, 1 }, 40 78442.119873761606868, 41 78442.119873761606868, 42 78442.119873761592316, 43 78442.118218914125464, 44 78442.118218840550981, 45 78440.792929481409374, 46 78440.792934224984492, 47 78618.810427426869865 48 } , { 49 { 0, 0 },{ 1, 1 },{ 1, 0 }, 50 78453.98942845336569, 51 78453.98942845336569, 52 78453.98942845336569, 53 78453.990728736869642, 54 78453.990728682110785, 55 78453.54172924211889, 56 78453.541733992169611, 57 78630.786885094828904 58 } , { 59 { 10, 15 },{ 30, 15 },{ 15, 80 }, 60 7204174.4886689241976, 61 7204174.4886689241976, 62 7204174.4886689241976, 63 7204174.4785777237266, 64 7204174.4785777227953, 65 7204194.9162934627384, 66 7204194.9162937803194, 67 7205729.8545973757282 68 } , { 69 { 10, 15 },{ 30, 15 },{ 15, 10 }, 70 571412.78107940487098, 71 571412.78107940487098, 72 571412.78107940475456, 73 571412.77996722259559, 74 571412.77996722620446, 75 571408.51759251800831, 76 571408.51759251928888, 77 574226.66911869682372 78 } , { 79 { 10, 15 },{ 30, 15 },{ 5, 10 }, 80 775316.40275838342495, 81 775316.40275838342495, 82 775316.40275838342495, 83 775316.40098149504047, 84 775316.40098149504047, 85 775309.55307898123283, 86 775309.55307898123283, 87 776861.2271022957284 88 } , { 89 { 10, 15 },{ 30, 15 },{ 35, 10 }, 90 775316.40275838342495, 91 775316.40275838342495, 92 775316.40275838342495, 93 775316.40098149504047, 94 775316.40098149504047, 95 775309.55307898123283, 96 775309.55307898123283, 97 776861.22710229584482 98 } , { 99 { 2, 2 },{ 3, 2 },{ 3.5, 3 }, 100 123770.82713049851009, 101 123770.82713049851009, 102 123770.82713049851009, 103 123770.82682863833907, 104 123770.82682863833907, 105 123769.27773668900772, 106 123769.27773668900772, 107 124295.90554402528505 108 } , { 109 { 2, 2 },{ 3, 2 },{ 1.5, 3 }, 110 123770.82713049851009, 111 123770.82713049851009, 112 123770.82713049851009, 113 123770.82682863833907, 114 123770.82682863833907, 115 123769.27773668900772, 116 123769.27773668900772, 117 124295.90554402528505 118 } , { 119 { 2, 2 },{ 3, 2 },{ 2, 3 }, 120 110576.41139532231318, 121 110576.41139532231318, 122 110576.41139532238594, 123 110576.41139116862905, 124 110576.41139118297724, 125 110575.1780244907568, 126 110575.17802451056195, 127 111195.07457694716868 128 } , { 129 { 2, 2 },{ 3, 2 },{ 3, 3 }, 130 110576.41139532234229, 131 110576.41139532234229, 132 110576.41139532234229, 133 110576.41139242639474, 134 110576.41139243228827, 135 110575.17802478378871, 136 110575.17802474705968, 137 111195.07457694721234 138 } , { 139 { 2, 2 },{ 3, 2 },{ 3.5, 1 }, 140 123784.75399867084343, 141 123784.75399867084343, 142 123784.75399867084343, 143 123784.75369734384003, 144 123784.75369734384003, 145 123783.19294134904339, 146 123783.19294134904339, 147 124311.043335600305 148 } , { 149 { 2, 2 },{ 3, 2 },{ 1.5, 1 }, 150 123784.75399867084343, 151 123784.75399867084343, 152 123784.75399867084343, 153 123784.75369734384003, 154 123784.75369734384003, 155 123783.19294134904339, 156 123783.19294134904339, 157 124311.043335600305 158 } , { 159 { 2, 2 },{ 3, 2 },{ 2, 1 }, 160 110575.06481432798319, 161 110575.06481432798319, 162 110575.06481432798319, 163 110575.06688667042181, 164 110575.06688667042181, 165 110573.82008001199574, 166 110573.82008001199574, 167 111195.07973463158123 168 } , { 169 { 2, 2 },{ 3, 2 },{ 3, 1 }, 170 110575.06481432798319, 171 110575.06481432798319, 172 110575.06481432798319, 173 110575.06688667042181, 174 110575.06688667042181, 175 110573.82008001199574, 176 110573.82008001199574, 177 111195.07973463158123 178 } , { 179 { 2, -2 },{ 3, -2 },{ 3, -1 }, 180 110575.06481432798319, 181 110575.06481432798319, 182 110575.06481432798319, 183 110575.06688667042181, 184 110575.06688667042181, 185 110573.82008001199574, 186 110573.82008001199574, 187 111195.07973463158123 188 } , { 189 { 220, 2 },{ 3, 2 },{ 3, 1 }, 190 110575.06481432798319, 191 110575.06481432798319, 192 110575.06481432798319, 193 110575.06688667042181, 194 110575.06688667042181, 195 110573.82008001199574, 196 110573.82008001199574, 197 111195.07973463158123 198 } , //antimeridian 199 { 200 { 220, 2 },{ 3, 2 },{ 220, 1 }, 201 110575.06481432798319, 202 110575.06481432798319, 203 110575.06481432798319, 204 110575.06688667042181, 205 110575.06688667042181, 206 110573.82008001199574, 207 110573.82008001199574, 208 111195.07973463158123 209 } , //meridian 210 { 211 { 2, 2 },{ 2, 4 },{ 2.5, 2 }, 212 55626.064900081859, 213 55626.064900081859, 214 55626.064900081867, 215 55626.06490013907, 216 55626.064900107223, 217 55626.065279513903, 218 55626.065279463517, 219 55563.670489238102 220 } , { 221 { 2, 2 },{ 2, 4 },{ 2.5, 5 }, 222 123722.15822285149, 223 123722.15822285149, 224 123722.15822285149, 225 123722.15791917888, 226 123722.15791917888, 227 123720.64936755209, 228 123720.64936755209, 229 124243.00560435352 230 } , { 231 { 2, 2 },{ 2, 4 },{ 2.5, 3 }, 232 55583.973320908837, 233 55583.973320908837, 234 55583.97332090883, 235 55583.973320941128, 236 55583.973320900877, 237 55583.97416950998, 238 55583.974169663285, 239 55521.343440931159 240 } , { 241 { 0, 40 },{ 180, 80 },{ 0, 20 }, 242 2217162.7761786841, 243 2217162.7761786841, 244 2217162.7761786841, 245 2217162.7361901053, 246 2217162.7361901053, 247 2217171.9891410829, 248 2217171.9891410829, 249 2223901.5946926316 250 } , { 251 { 0, 40 },{ 0, 80 },{ 0, 20 }, 252 2217162.7761786841, 253 2217162.7761786841, 254 2217162.7761786841, 255 2217162.7361901053, 256 2217162.7361901053, 257 2217171.9891410829, 258 2217171.9891410829, 259 2223901.5946926316 260 } , { 261 { 0, 0 },{ 0, 90 },{ 0, 80 }, 262 0, 263 0, 264 0, 265 0, 266 0, 267 0, 268 0, 269 0 270 } , { 271 { 0, 0 },{ 0, 90 },{ 1, 80 }, 272 19392.530629092114, 273 19392.530629092114, 274 19392.530629092107, 275 19392.53062953979, 276 19392.530629094777, 277 19392.328788289116, 278 19392.328788113067, 279 19307.872231041671 280 } , { 281 { 1, -1 }, { 1, 0 },{ 2, 0 }, 282 111319.4907932264, 283 111319.4907932264, 284 111319.4907932264, 285 111319.49079334327, 286 111319.49079326246, 287 111319.49079326226, 288 111319.49079326246, 289 111195.07973463158 290 } , //equator 291 { 292 { 2, 0 },{ 3, 0 },{ 0, 0 }, 293 222638.98158645280637, 294 222638.98158645280637, 295 222638.98158645280637, 296 222638.98158654122381, 297 222638.98158654122381, 298 222638.98158654125291, 299 222638.98158654125291, 300 222390.15946926316246 301 } , { 302 { 2, 0 },{ 3, 0 },{ 2.5, 3 }, 303 331725.86989626317518, 304 331725.86989626317518, 305 331725.86989626317518, 306 331725.87608870770782, 307 331725.87608870770782, 308 331722.14136137196328, 309 331722.14136137196328, 310 333585.2392038948019 311 } , { 312 { 2, 0 },{ 3, 0 },{ 2, 0 }, 313 0, 314 0, 315 0, 316 0, 317 0, 318 0, 319 0, 320 0 321 } , { 322 { 2, 0 },{ 3, 0 },{ 3, 0 }, 323 0, 324 0, 325 0, 326 0, 327 0, 328 0, 329 0, 330 0 331 } , { 332 { 2, 0 },{ 3, 0 },{ 2.5, 0 }, 333 0, 334 0, 335 0, 336 0, 337 0, 338 0, 339 0, 340 0 341 } , { 342 { 2, 0 },{ 3, 0 },{ 3.5, 3 }, 343 336358.80734967370518, 344 336358.80734967370518, 345 336358.80734967370518, 346 336358.80718013871228, 347 336358.80718013871228, 348 336354.9292840428534, 349 336354.9292840428534, 350 338182.45508443051949 351 } , //segment pass by pole 352 /* those cases have expected very large reference errors for spherical 353 * { 354 { 0, 0 },{ 180, 0 },{ 0, 90 }, 355 0, 356 0, 357 0, 358 0, 359 0, 360 0, 361 0, 362 10007557.176116843 363 } , { 364 { 0, 0 },{ 180, 0 },{ 80, 89 }, 365 109996.81571864839, 366 109996.81571864839, 367 109996.81571864836, 368 109996.81571864968, 369 109996.81571858823, 370 109995.58014976831, 371 109995.58014972134, 372 9896362.096382184, 373 }*/ // short distance to segment 374 { 375 { 0.5, 0 },{ 175.5, 0 },{ 90, 1e-3 }, 376 110.57427582169922, 377 110.57427582169922, 378 110.57427582169922, 379 110.57427792305019, 380 110.57427792305019, 381 110.57302444153535, 382 110.57302444153535, 383 111.19507973475258 384 } , { 385 { 0.5, 0 },{ 175.5, 0 },{ 90, 1e-8 }, 386 0.0011057427582158647, 387 0.0011057427582158647, 388 0.0011057427582158647, 389 0.0011057427792293744, 390 0.0011057427792293744, 391 0.0011057302444142166, 392 0.0011057302444142166, 393 0.0011119503057618657 394 } , { 395 // mysql Bug #29545865 396 { -16.42203, -7.52882 },{ 4.89998, -6.15568 },{ 3.32696, -6.29345 }, 397 481.73908764883043, 398 481.73908764883043, 399 481.73908764873721, 400 481.74578258317035, 401 481.74576160418479, 402 480.34603374821353, 403 480.34602624448405, 404 508.0731159303939 405 } , { // same segment but the point is from the other side 406 { -16.42203, -7.52882 },{ 4.89998, -6.15568 },{ 3.3262, -6.28451}, 407 510.48273138899611, 408 510.48273138899611, 409 510.48273138908797, 410 510.47605556026537, 411 510.47605888246693, 412 511.86547773473234, 413 511.86548088955459, 414 489.55321195417821 415 } , { 416 { -16.42203, -7.52882 },{ 4.89998, -6.1556 },{ 3.32696, -6.2889 }, 417 11.511229576046485, 418 11.511229576046485, 419 11.51122957617916, 420 11.50474785537202, 421 11.504394870933424, 422 12.898977232559222, 423 12.898968261046516, 424 12.130727461169611 425 } , { 426 { -16.42203, -7.52882 },{ 4.89998, -6.1556 },{ 3.32696, -6.28895 }, 427 6.0009073659133909, 428 6.0009073659133909, 429 6.0009073659387502, 430 5.9949823734311893, 431 5.9941706378723278, 432 7.3883629173067344, 433 7.3889362323779535, 434 17.671122161310702 435 } , { 436 // mysql Bug #29545865 437 //{ 8.65279, -2.71668 }, 438 { -7.13372, 8.35583 },{ -9.09998, -1.22625 },{ -7.35561, 7.2137 }, 439 1671.2894143458557, 440 1671.2894143458557, 441 1671.2894143458786, 442 1671.2962894596874, 443 1671.296284713379, 444 1677.2323385335374, 445 1677.232338307874, 446 1668.697566121507 447 } 448 #ifdef GEOMETRY_TEST_INCLUDE_FAILING_TESTS 449 , { 450 { 0, 10 }, { 20, 10 }, { 18.00000000000003908, 10.054676080707787733 }, 451 0.0011398027228318023, 452 0.0011398027228318023, 453 0.0060057460922939617, 454 0, 455 0, 456 0, 457 0.30055333992381872, 458 39.88666722147299 459 } , { 460 { 0, 10 }, { 20, 10 }, { 18, 10.054678231628329854 }, 461 0.23669789852514209, 462 0.23669789852514209, 463 0.23669789883426567, 464 0.25069019912476698, 465 0.23204712322540744, 466 0.26712030782599411, 467 0.40206187237490559, 468 40.125767043637062 469 } , { 470 { 0, 10 }, { 20, 10 },{ 17.999999999999950262, 10.054676091041047314 }, 471 2.7930744094407741e-06, 472 2.7930744094407741e-06, 473 0.0058967770186943418, 474 0, 475 0, 476 0, 477 0.30055160527904862, 478 39.887815883329125 479 } 480 #endif 481 , // large distance to segment 482 { 483 { 0.5, 0 }, { 175.5, 0 }, { 90, 90 }, 484 10001965.729311479, 485 10001965.729311479, 486 10001965.729311479, 487 10001965.729311479, 488 10001965.729311479, 489 10001958.678477952, 490 10001958.678477952, 491 10007557.108987356 492 } , { 493 { 0.5, -89 }, { 175.5, -89 }, { 90, 90 }, 494 19892237.59370932, 495 19892237.59370932, 496 19892237.59370932, 497 19892237.570068691, 498 19892237.570068691, 499 19892224.746673118, 500 19892224.746673118, 501 19903919.272499084 502 } , //acos issue solved 503 { 504 { 90, 0 }, { 0, 1.000005 }, {0, 90}, 505 9891389.2448064201, 506 9891389.2448064201, 507 9891389.2448064163, 508 9891370.4775929395, 509 9891370.4775932431, 510 9891383.4444574378, 511 9891383.4444574378, 512 9896361.5404068138 513 } 514 }; 515 516 size_t const expected_size = sizeof(expected) / sizeof(expected_results); 517 518 #endif // BOOST_GEOMETRY_TEST_DISTANCE_CROSS_TRACK_CASES_HPP 519