distance_se_geo_pl_ar.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2017-2018, Oracle and/or its affiliates.
  4. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  5. // Licensed under the Boost Software License version 1.0.
  6. // http://www.boost.org/users/license.html
  7. #include <iostream>
  8. #ifndef BOOST_TEST_MODULE
  9. #define BOOST_TEST_MODULE test_distance_geographic_pointlike_areal
  10. #endif
  11. #include <boost/range.hpp>
  12. #include <boost/type_traits/is_same.hpp>
  13. #include <boost/test/included/unit_test.hpp>
  14. #include <boost/geometry/util/condition.hpp>
  15. #include <boost/geometry/strategies/strategies.hpp>
  16. #include "test_distance_geo_common.hpp"
  17. #include "test_empty_geometry.hpp"
  18. template
  19. <
  20. typename Point,
  21. typename Strategy_pp,
  22. typename Strategy_ps
  23. >
  24. void test_distance_point_ring(Strategy_pp const& strategy_pp,
  25. Strategy_ps const& strategy_ps)
  26. {
  27. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  28. std::cout << std::endl;
  29. std::cout << "point/ring distance tests" << std::endl;
  30. #endif
  31. typedef bg::model::ring<Point> ring_type;
  32. typedef test_distance_of_geometries<Point, ring_type> tester;
  33. std::string const ring = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
  34. tester::apply("pr1", "POINT(0 10)", ring,
  35. ps_distance<Point>("POINT(0 10)",
  36. "SEGMENT(0 20, 10 10)", strategy_ps),
  37. strategy_ps, true, true, false);
  38. tester::apply("pr2", "POINT(10 0)", ring,
  39. pp_distance<Point>("POINT(10 10)", "POINT(10 0)", strategy_pp),
  40. strategy_ps, true, true, false);
  41. tester::apply("pr3", "POINT(0 20)", ring,
  42. 0, strategy_ps, true, true, false);
  43. tester::apply("pr4", "POINT(10 10)", ring,
  44. 0, strategy_ps, true, true, false);
  45. tester::apply("pr4", "POINT(10 11)", ring,
  46. 0, strategy_ps, true, true, false);
  47. }
  48. //===========================================================================
  49. template
  50. <
  51. typename Point,
  52. typename Strategy_ps
  53. >
  54. void test_distance_multipoint_ring(Strategy_ps const& strategy_ps)
  55. {
  56. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  57. std::cout << std::endl;
  58. std::cout << "multipoint/ring distance tests" << std::endl;
  59. #endif
  60. typedef bg::model::ring<Point> ring_type;
  61. typedef bg::model::multi_point<Point> multi_point_type;
  62. typedef test_distance_of_geometries<multi_point_type, ring_type> tester;
  63. std::string const ring = "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
  64. tester::apply("pr1", "MULTIPOINT(0 10,10 0,0 0)", ring,
  65. ps_distance<Point>("POINT(0 10)",
  66. "SEGMENT(0 20, 10 10)", strategy_ps),
  67. strategy_ps, true, true, false);
  68. }
  69. //===========================================================================
  70. template
  71. <
  72. typename Point,
  73. typename Strategy_pp,
  74. typename Strategy_ps
  75. >
  76. void test_distance_point_polygon(Strategy_pp const& strategy_pp,
  77. Strategy_ps const& strategy_ps)
  78. {
  79. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  80. std::cout << std::endl;
  81. std::cout << "point/polygon distance tests" << std::endl;
  82. #endif
  83. typedef bg::model::polygon<Point> polygon_type;
  84. typedef test_distance_of_geometries<Point, polygon_type> tester;
  85. std::string const polygon =
  86. "POLYGON((10 10,0 20, 15 30, 20 15, 15 10, 10 10))";
  87. tester::apply("pr1", "POINT(0 10)", polygon,
  88. ps_distance<Point>("POINT(0 10)",
  89. "SEGMENT(0 20, 10 10)", strategy_ps),
  90. strategy_ps, true, true, false);
  91. tester::apply("pr2", "POINT(10 0)", polygon,
  92. pp_distance<Point>("POINT(10 10)", "POINT(10 0)", strategy_pp),
  93. strategy_ps, true, true, false);
  94. tester::apply("pr3", "POINT(0 20)", polygon,
  95. 0, strategy_ps, true, true, false);
  96. tester::apply("pr4", "POINT(10 10)", polygon,
  97. 0, strategy_ps, true, true, false);
  98. tester::apply("pr5", "POINT(10 10.1)", polygon,
  99. 0, strategy_ps, false, false, false);
  100. }
  101. //===========================================================================
  102. template
  103. <
  104. typename Point,
  105. typename Strategy_pp,
  106. typename Strategy_ps
  107. >
  108. void test_distance_multipoint_polygon(Strategy_pp const& strategy_pp,
  109. Strategy_ps const& strategy_ps)
  110. {
  111. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  112. std::cout << std::endl;
  113. std::cout << "multipoint/polygon distance tests" << std::endl;
  114. #endif
  115. typedef bg::model::polygon<Point> polygon_type;
  116. typedef bg::model::multi_point<Point> multi_point_type;
  117. typedef test_distance_of_geometries<multi_point_type, polygon_type> tester;
  118. std::string const polygon = "POLYGON((10 10,0 20,15 30,20 15,15 10,10 10))";
  119. tester::apply("mpp1", "MULTIPOINT(0 10,10 0,0 0)", polygon,
  120. ps_distance<Point>("POINT(0 10)",
  121. "SEGMENT(0 20, 10 10)", strategy_ps),
  122. strategy_ps, true, true, false);
  123. tester::apply("mpp2", "MULTIPOINT(0 10,10 0,0 0,20.1 15)", polygon,
  124. pp_distance<Point>("POINT(20 15)",
  125. "POINT(20.1 15)", strategy_pp),
  126. strategy_ps, true, true, false);
  127. tester::apply("mpp3", "MULTIPOINT(0 10,10 0,0 0,20.1 15,10 10)", polygon,
  128. 0, strategy_ps, true, true, false);
  129. tester::apply("mpp4", "MULTIPOINT(0 10,10 0,0 0,20.1 15,10 11)", polygon,
  130. 0, strategy_ps, true, true, false);
  131. }
  132. //===========================================================================
  133. template
  134. <
  135. typename Point,
  136. typename Strategy_pp,
  137. typename Strategy_ps
  138. >
  139. void test_distance_point_multipolygon(Strategy_pp const& strategy_pp,
  140. Strategy_ps const& strategy_ps)
  141. {
  142. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  143. std::cout << std::endl;
  144. std::cout << "point/multipolygon distance tests" << std::endl;
  145. #endif
  146. typedef bg::model::polygon<Point> polygon_type;
  147. typedef bg::model::multi_polygon<polygon_type> multipolygon_type;
  148. typedef test_distance_of_geometries<Point, multipolygon_type> tester;
  149. std::string const mpoly = "MULTIPOLYGON(((20 20, 20 30, 30 40, 20 20)),\
  150. ((10 10,0 20, 15 30, 20 15, 15 10, 10 10)))";
  151. tester::apply("pmp1", "POINT(0 10)", mpoly,
  152. ps_distance<Point>("POINT(0 10)",
  153. "SEGMENT(0 20, 10 10)", strategy_ps),
  154. strategy_ps, true, true, false);
  155. tester::apply("pmp2", "POINT(10 9.9)", mpoly,
  156. pp_distance<Point>("POINT(10 9.9)",
  157. "POINT(10 10)", strategy_pp),
  158. strategy_ps, true, true, false);
  159. tester::apply("pmp3", "POINT(10 11)", mpoly,
  160. 0, strategy_ps, true, true, false);
  161. }
  162. //===========================================================================
  163. template
  164. <
  165. typename Point,
  166. typename Strategy_pp,
  167. typename Strategy_ps
  168. >
  169. void test_distance_multipoint_multipolygon(Strategy_pp const& strategy_pp,
  170. Strategy_ps const& strategy_ps)
  171. {
  172. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  173. std::cout << std::endl;
  174. std::cout << "multipoint/multipolygon distance tests" << std::endl;
  175. #endif
  176. typedef bg::model::polygon<Point> polygon_type;
  177. typedef bg::model::multi_polygon<polygon_type> multipolygon_type;
  178. typedef bg::model::multi_point<Point> multi_point_type;
  179. typedef test_distance_of_geometries<multi_point_type, multipolygon_type> tester;
  180. std::string const mpoly = "MULTIPOLYGON(((20 20, 20 30, 30 40, 20 20)),\
  181. ((10 10,0 20, 15 30, 20 15, 15 10, 10 10)))";
  182. tester::apply("pr1", "MULTIPOINT(0 10,10 0,0 0)", mpoly,
  183. ps_distance<Point>("POINT(0 10)",
  184. "SEGMENT(0 20, 10 10)", strategy_ps),
  185. strategy_ps, true, true, false);
  186. tester::apply("pmp2", "MULTIPOINT(0 10,10 0,0 0,10 9.9)", mpoly,
  187. pp_distance<Point>("POINT(10 9.9)",
  188. "POINT(10 10)", strategy_pp),
  189. strategy_ps, true, true, false);
  190. tester::apply("pmp3", "MULTIPOINT(0 10,10 0,0 0,10 9.9,10 11)", mpoly,
  191. 0, strategy_ps, true, true, false);
  192. }
  193. //===========================================================================
  194. // Cases for relative location of a point wrt to a box
  195. //
  196. // | |
  197. // | 3 |
  198. // | |
  199. // +---------+
  200. // | |
  201. // 1 | 5 | 2
  202. // | |
  203. // +---------+
  204. // | |
  205. // | 4 |
  206. // | |
  207. //
  208. // and also the following cases
  209. //
  210. // | |
  211. // A B
  212. // | |
  213. // +----C----+
  214. // | |
  215. // D E
  216. // | |
  217. // +----F----+
  218. // | |
  219. // G H
  220. // | |
  221. //
  222. // and finally we have the corners
  223. //
  224. // | |
  225. // | |
  226. // | |
  227. // a---------b
  228. // | |
  229. // | |
  230. // | |
  231. // c---------d
  232. // | |
  233. // | |
  234. // | |
  235. //
  236. // for each relative position we also have to test the shifted point
  237. // (this is due to the fact that boxes have longitudes in the
  238. // range [-180, 540)
  239. //===========================================================================
  240. template
  241. <
  242. typename Point,
  243. typename Strategy_pp,
  244. typename Strategy_ps,
  245. typename Strategy_pb
  246. >
  247. void test_distance_point_box(Strategy_pp const& strategy_pp,
  248. Strategy_ps const& strategy_ps,
  249. Strategy_pb const& strategy_pb)
  250. {
  251. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  252. std::cout << std::endl;
  253. std::cout << "point/box distance tests" << std::endl;
  254. #endif
  255. typedef bg::model::box<Point> box_type;
  256. typedef test_distance_of_geometries<Point, box_type> tester;
  257. std::string const box1 = "BOX(10 10,20 20)";
  258. // case 1
  259. tester::apply("pb1-1a", "POINT(5 25)", box1,
  260. pp_distance<Point>("POINT(5 25)", "POINT(10 20)", strategy_pp),
  261. strategy_pb);
  262. // case 1
  263. tester::apply("pb1-1b", "POINT(3 12)", box1,
  264. ps_distance<Point>("POINT(3 12)",
  265. "SEGMENT(10 10,10 20)", strategy_ps),
  266. strategy_pb);
  267. // case 1
  268. tester::apply("pb1-1c", "POINT(3 17)", box1,
  269. ps_distance<Point>("POINT(3 17)",
  270. "SEGMENT(10 10,10 20)", strategy_ps),
  271. strategy_pb);
  272. // case 1
  273. tester::apply("pb1-1d", "POINT(5 4)", box1,
  274. pp_distance<Point>("POINT(5 4)", "POINT(10 10)", strategy_pp),
  275. strategy_pb);
  276. // case 1
  277. tester::apply("pb1-1e", "POINT(-100 20)", box1,
  278. pp_distance<Point>("POINT(-100 20)",
  279. "POINT(10 20)", strategy_pp),
  280. strategy_pb);
  281. // case 1
  282. tester::apply("pb1-1g", "POINT(-100 10)", box1,
  283. ps_distance<Point>("POINT(-100 10)",
  284. "SEGMENT(10 10,10 20)", strategy_ps),
  285. strategy_pb);
  286. // case 2
  287. tester::apply("pb1-2a", "POINT(31 25)", box1,
  288. pp_distance<Point>("POINT(31 25)",
  289. "POINT(20 20)", strategy_pp),
  290. strategy_pb);
  291. // case 2
  292. tester::apply("pb1-2b", "POINT(23 17)", box1,
  293. ps_distance<Point>("POINT(23 17)",
  294. "SEGMENT(20 10,20 20)", strategy_ps),
  295. strategy_pb);
  296. // case 2
  297. tester::apply("pb1-2c", "POINT(29 3)", box1,
  298. pp_distance<Point>("POINT(29 3)",
  299. "POINT(20 10)", strategy_pp),
  300. strategy_pb);
  301. // case 2
  302. tester::apply("pb1-2d", "POINT(131 65)", box1,
  303. pp_distance<Point>("POINT(131 65)",
  304. "POINT(20 20)", strategy_pp),
  305. strategy_pb);
  306. // case 2
  307. tester::apply("pb1-2e", "POINT(110 10)", box1,
  308. ps_distance<Point>("POINT(110 10)",
  309. "SEGMENT(20 10,20 20)", strategy_ps),
  310. strategy_pb);
  311. // case 2
  312. tester::apply("pb1-2f", "POINT(150 20)", box1,
  313. pp_distance<Point>("POINT(150 20)",
  314. "POINT(20 20)", strategy_pp),
  315. strategy_pb);
  316. // case 3
  317. tester::apply("pb1-3a", "POINT(11 25)", box1,
  318. pp_distance<Point>("POINT(11 25)",
  319. "POINT(11 20)", strategy_pp),
  320. strategy_pb);
  321. // case 3
  322. tester::apply("pb1-3b", "POINT(15 25)", box1,
  323. pp_distance<Point>("POINT(15 25)",
  324. "POINT(15 20)", strategy_pp),
  325. strategy_pb);
  326. // case 3
  327. tester::apply("pb1-3c", "POINT(18 25)", box1,
  328. pp_distance<Point>("POINT(18 25)",
  329. "POINT(18 20)", strategy_pp),
  330. strategy_pb);
  331. // case 4
  332. tester::apply("pb1-4a", "POINT(13 4)", box1,
  333. pp_distance<Point>("POINT(13 4)",
  334. "POINT(13 10)", strategy_pp),
  335. strategy_pb);
  336. // case 4
  337. tester::apply("pb1-4b", "POINT(19 4)", box1,
  338. pp_distance<Point>("POINT(19 4)",
  339. "POINT(19 10)", strategy_pp),
  340. strategy_pb);
  341. // case 5
  342. tester::apply("pb1-5", "POINT(15 14)", box1, 0, strategy_pb);
  343. // case A
  344. tester::apply("pb1-A", "POINT(10 28)", box1,
  345. pp_distance<Point>("POINT(10 28)",
  346. "POINT(10 20)", strategy_pp),
  347. strategy_pb);
  348. // case B
  349. tester::apply("pb1-B", "POINT(20 28)", box1,
  350. pp_distance<Point>("POINT(20 28)",
  351. "POINT(20 20)", strategy_pp),
  352. strategy_pb);
  353. // case C
  354. tester::apply("pb1-C", "POINT(14 20)", box1, 0, strategy_pb);
  355. // case D
  356. tester::apply("pb1-D", "POINT(10 17)", box1, 0, strategy_pb);
  357. // case E
  358. tester::apply("pb1-E", "POINT(20 11)", box1, 0, strategy_pb);
  359. // case F
  360. tester::apply("pb1-F", "POINT(19 10)", box1, 0, strategy_pb);
  361. // case G
  362. tester::apply("pb1-G", "POINT(10 -40)", box1,
  363. pp_distance<Point>("POINT(10 -40)",
  364. "POINT(10 10)", strategy_pp),
  365. strategy_pb);
  366. // case H
  367. tester::apply("pb1-H", "POINT(20 -50)", box1,
  368. pp_distance<Point>("POINT(20 -50)",
  369. "POINT(20 10)", strategy_pp),
  370. strategy_pb);
  371. // case a
  372. tester::apply("pb1-a", "POINT(10 20)", box1, 0, strategy_pb);
  373. // case b
  374. tester::apply("pb1-b", "POINT(20 20)", box1, 0, strategy_pb);
  375. // case c
  376. tester::apply("pb1-c", "POINT(10 10)", box1, 0, strategy_pb);
  377. // case d
  378. tester::apply("pb1-d", "POINT(20 10)", box1, 0, strategy_pb);
  379. std::string const box2 = "BOX(170 -60,400 80)";
  380. // case 1 - point is closer to western meridian
  381. tester::apply("pb2-1a", "POINT(160 0)", box2,
  382. ps_distance<Point>("POINT(160 0)",
  383. "SEGMENT(170 -60,170 80)", strategy_ps),
  384. strategy_pb);
  385. // case 1 - point is closer to eastern meridian
  386. tester::apply("pb2-1b", "POINT(50 0)", box2,
  387. ps_distance<Point>("POINT(50 0)",
  388. "SEGMENT(40 -60,40 80)", strategy_ps),
  389. strategy_pb);
  390. // case 3 - equivalent point POINT(390 85) is above the box
  391. tester::apply("pb2-3", "POINT(30 85)", box2,
  392. pp_distance<Point>("POINT(30 85)",
  393. "POINT(30 80)", strategy_pp),
  394. strategy_pb);
  395. // case 4 - equivalent point POINT(390 -75) is below the box
  396. tester::apply("pb2-4", "POINT(30 -75)", box2,
  397. pp_distance<Point>("POINT(30 -75)",
  398. "POINT(30 -60)", strategy_pp),
  399. strategy_pb);
  400. // case 5 - equivalent point POINT(390 0) is inside box
  401. tester::apply("pb2-5", "POINT(30 0)", box2, 0, strategy_pb);
  402. std::string const box3 = "BOX(-150 -50,-40 70)";
  403. // case 1 - point is closer to western meridian
  404. tester::apply("pb3-1a", "POINT(-170 10)", box3,
  405. ps_distance<Point>("POINT(-170 10)",
  406. "SEGMENT(-150 -50,-150 70)", strategy_ps),
  407. strategy_pb);
  408. // case 2 - point is closer to eastern meridian
  409. tester::apply("pb3-2a", "POINT(5 10)", box3,
  410. ps_distance<Point>("POINT(5 10)",
  411. "SEGMENT(-40 -50,-40 70)", strategy_ps),
  412. strategy_pb);
  413. // case 2 - point is closer to western meridian
  414. tester::apply("pb3-2a", "POINT(160 10)", box3,
  415. ps_distance<Point>("POINT(160 10)",
  416. "SEGMENT(-150 -50,-150 70)", strategy_ps),
  417. strategy_pb);
  418. // case 2 - point is at equal distance from eastern and western meridian
  419. tester::apply("pb3-2c1", "POINT(85 20)", box3,
  420. ps_distance<Point>("POINT(85 20)",
  421. "SEGMENT(-150 -50,-150 70)", strategy_ps),
  422. strategy_pb);
  423. // case 2 - point is at equal distance from eastern and western meridian
  424. tester::apply("pb3-2c2", "POINT(85 20)", box3,
  425. ps_distance<Point>("POINT(85 20)",
  426. "SEGMENT(-40 -50,-40 70)", strategy_ps),
  427. strategy_pb);
  428. // box that is symmetric wrt the prime meridian
  429. std::string const box4 = "BOX(-75 -45,75 65)";
  430. // case 1 - point is closer to western meridian
  431. tester::apply("pb4-1a", "POINT(-100 10)", box4,
  432. ps_distance<Point>("POINT(-100 10)",
  433. "SEGMENT(-75 -45,-75 65)", strategy_ps),
  434. strategy_pb);
  435. // case 2 - point is closer to eastern meridian
  436. tester::apply("pb4-2a", "POINT(90 15)", box4,
  437. ps_distance<Point>("POINT(90 15)",
  438. "SEGMENT(75 -45,75 65)", strategy_ps),
  439. strategy_pb);
  440. // case 2 - point is at equal distance from eastern and western meridian
  441. tester::apply("pb4-2c1", "POINT(-180 20)", box4,
  442. ps_distance<Point>("POINT(-180 20)",
  443. "SEGMENT(-75 -45,-75 65)", strategy_ps),
  444. strategy_pb);
  445. // case 2 - point is at equal distance from eastern and western meridian
  446. tester::apply("pb4-2c2", "POINT(-180 20)", box4,
  447. ps_distance<Point>("POINT(-180 20)",
  448. "SEGMENT(75 -45,75 65)", strategy_ps),
  449. strategy_pb);
  450. //box degenerates to a meridian segment
  451. std::string const boxdeg1 = "BOX(0 10,0 20)";
  452. tester::apply("pbd1", "POINT(1 10)", boxdeg1,
  453. ps_distance<Point>("POINT(1 10)",
  454. "SEGMENT(0 10, 0 20)", strategy_ps),
  455. strategy_pb);
  456. tester::apply("pbd2", "POINT(1 5)", boxdeg1,
  457. ps_distance<Point>("POINT(1 5)",
  458. "SEGMENT(0 10, 0 20)", strategy_ps),
  459. strategy_pb);
  460. tester::apply("pbd3", "POINT(1 15)", boxdeg1,
  461. ps_distance<Point>("POINT(1 15)",
  462. "SEGMENT(0 10, 0 20)", strategy_ps),
  463. strategy_pb);
  464. tester::apply("pbd4", "POINT(1 25)", boxdeg1,
  465. ps_distance<Point>("POINT(1 25)",
  466. "SEGMENT(0 10, 0 20)", strategy_ps),
  467. strategy_pb);
  468. //box degenerates to a horizontal line; that is not a geodesic segment
  469. std::string const boxdeg2 = "BOX(10 10,20 10)";
  470. tester::apply("pbd5", "POINT(15 15)", boxdeg2,
  471. pp_distance<Point>("POINT(15 15)",
  472. "POINT(15 10)", strategy_pp),
  473. strategy_pb);
  474. tester::apply("pbd6", "POINT(5 15)", boxdeg2,
  475. pp_distance<Point>("POINT(5 15)",
  476. "POINT(10 10)", strategy_pp),
  477. strategy_pb);
  478. tester::apply("pbd7", "POINT(25 15)", boxdeg2,
  479. pp_distance<Point>("POINT(25 15)",
  480. "POINT(20 10)", strategy_pp),
  481. strategy_pb);
  482. //box degenerates to a point
  483. std::string const boxdeg3 = "BOX(0 10,0 10)";
  484. tester::apply("pbd8", "POINT(1 11)", boxdeg3,
  485. pp_distance<Point>("POINT(1 11)",
  486. "POINT(0 10)", strategy_pp),
  487. strategy_pb);
  488. }
  489. template
  490. <
  491. typename Point,
  492. typename Strategy_pp,
  493. typename Strategy_ps,
  494. typename Strategy_pb
  495. >
  496. void test_distance_multipoint_box(Strategy_pp const& strategy_pp,
  497. Strategy_ps const& strategy_ps,
  498. Strategy_pb const& strategy_pb)
  499. {
  500. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  501. std::cout << std::endl;
  502. std::cout << "multipoint/box distance tests" << std::endl;
  503. #endif
  504. typedef bg::model::box<Point> box_type;
  505. typedef bg::model::multi_point<Point> multi_point_type;
  506. typedef test_distance_of_geometries<multi_point_type, box_type> tester;
  507. std::string const box1 = "BOX(10 10,20 20)";
  508. tester::apply("mpb1", "MULTIPOINT(5 25,25 26)", box1,
  509. pp_distance<Point>("POINT(5 25)", "POINT(10 20)", strategy_pp),
  510. strategy_pb, true, false, false);
  511. tester::apply("mpb2", "MULTIPOINT(110 10,110 9,110 0)", box1,
  512. ps_distance<Point>("POINT(110 10)",
  513. "SEGMENT(20 10,20 20)", strategy_ps),
  514. strategy_pb, true, false, false);
  515. tester::apply("mpb3", "MULTIPOINT(110 10,110 9,110 0,10 20)", box1,
  516. 0, strategy_pb, true, false, false);
  517. tester::apply("mpb3", "MULTIPOINT(110 10,110 9,110 0,15 15)", box1,
  518. 0, strategy_pb, true, false, false);
  519. }
  520. //===========================================================================
  521. //===========================================================================
  522. //===========================================================================
  523. template
  524. <
  525. typename Point,
  526. typename Strategy_pp,
  527. typename Strategy_ps,
  528. typename Strategy_pb
  529. >
  530. void test_all_pl_ar(Strategy_pp pp_strategy,
  531. Strategy_ps ps_strategy,
  532. Strategy_pb pb_strategy)
  533. {
  534. test_distance_point_ring<Point>(pp_strategy, ps_strategy);
  535. test_distance_multipoint_ring<Point>(ps_strategy);
  536. test_distance_point_polygon<Point>(pp_strategy, ps_strategy);
  537. test_distance_multipoint_polygon<Point>(pp_strategy, ps_strategy);
  538. test_distance_point_multipolygon<Point>(pp_strategy, ps_strategy);
  539. test_distance_multipoint_multipolygon<Point>(pp_strategy, ps_strategy);
  540. test_distance_point_box<Point>(pp_strategy, ps_strategy, pb_strategy);
  541. test_distance_multipoint_box<Point>(pp_strategy, ps_strategy, pb_strategy);
  542. test_more_empty_input_pointlike_areal<Point>(ps_strategy);
  543. }
  544. BOOST_AUTO_TEST_CASE( test_all_pointlike_areal )
  545. {
  546. typedef bg::model::point
  547. <
  548. double, 2,
  549. bg::cs::spherical_equatorial<bg::degree>
  550. > sph_point;
  551. test_all_pl_ar<sph_point>(spherical_pp(), spherical_ps(), spherical_pb());
  552. typedef bg::model::point
  553. <
  554. double, 2,
  555. bg::cs::geographic<bg::degree>
  556. > geo_point;
  557. test_all_pl_ar<geo_point>(vincenty_pp(), vincenty_ps(), vincenty_pb());
  558. test_all_pl_ar<geo_point>(thomas_pp(), thomas_ps(), thomas_pb());
  559. test_all_pl_ar<geo_point>(andoyer_pp(), andoyer_ps(), andoyer_pb());
  560. // test with different spheroid
  561. stype spheroid(6372000, 6370000);
  562. test_all_pl_ar<geo_point>(andoyer_pp(spheroid), andoyer_ps(spheroid), andoyer_pb(spheroid));
  563. }