| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
#ifndef UNITTEST_GUNIT_GIS_TEST_GEOM_H_INCLUDED |
| 25 |
#define UNITTEST_GUNIT_GIS_TEST_GEOM_H_INCLUDED |
| 26 |
|
| 27 |
#include <cmath> |
| 28 |
|
| 29 |
#include "sql/gis/geometries_cs.h" |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
namespace { |
| 36 |
namespace test_geom { |
| 37 |
|
| 38 |
using Cpt = gis::Cartesian_point; |
| 39 |
using Cls = gis::Cartesian_linestring; |
| 40 |
using Cgc = gis::Cartesian_geometrycollection; |
| 41 |
using Gpt = gis::Geographic_point; |
| 42 |
using Gls = gis::Geographic_linestring; |
| 43 |
using Ggc = gis::Geographic_geometrycollection; |
| 44 |
|
| 45 |
inline Cpt point_origin() { return {0.0, 0.0}; } |
| 46 |
|
| 47 |
inline Cls linestring_line() { |
| 48 |
|
| 49 |
Cls ls; |
| 50 |
ls.push_back(Cpt{-1, -1}); |
| 51 |
ls.push_back(Cpt{+1, +1}); |
| 52 |
return ls; |
| 53 |
} |
| 54 |
|
| 55 |
inline Cls linestring_right_angle() { |
| 56 |
|
| 57 |
Cls ls; |
| 58 |
ls.push_back(Cpt{-1, -1}); |
| 59 |
ls.push_back(Cpt{+1, -1}); |
| 60 |
ls.push_back(Cpt{+1, +1}); |
| 61 |
return ls; |
| 62 |
} |
| 63 |
|
| 64 |
inline Cls linestring_triangle() { |
| 65 |
|
| 66 |
Cls ls; |
| 67 |
ls.push_back(Cpt{-1, -1}); |
| 68 |
ls.push_back(Cpt{+1, -1}); |
| 69 |
ls.push_back(Cpt{+1, +1}); |
| 70 |
ls.push_back(Cpt{-1, -1}); |
| 71 |
return ls; |
| 72 |
} |
| 73 |
|
| 74 |
inline Cls linestring_selfintersecting() { |
| 75 |
|
| 76 |
Cls ls; |
| 77 |
ls.push_back(Cpt{-1, +1}); |
| 78 |
ls.push_back(Cpt{+1, -1}); |
| 79 |
ls.push_back(Cpt{+1, +1}); |
| 80 |
ls.push_back(Cpt{-1, -1}); |
| 81 |
return ls; |
| 82 |
} |
| 83 |
|
| 84 |
inline Cls linestring_selfintersecting_closed() { |
| 85 |
|
| 86 |
Cls ls; |
| 87 |
ls.push_back(Cpt{-1, +1}); |
| 88 |
ls.push_back(Cpt{+1, -1}); |
| 89 |
ls.push_back(Cpt{+1, +1}); |
| 90 |
ls.push_back(Cpt{-1, -1}); |
| 91 |
ls.push_back(Cpt{-1, +1}); |
| 92 |
return ls; |
| 93 |
} |
| 94 |
|
| 95 |
inline Cls linestring_selftangential() { |
| 96 |
Cls ls; |
| 97 |
ls.push_back(Cpt{-1.0, -0.75}); |
| 98 |
ls.push_back(Cpt{+1.0, -0.75}); |
| 99 |
ls.push_back(Cpt{+0.0, +0.00}); |
| 100 |
ls.push_back(Cpt{+0.5, -0.50}); |
| 101 |
ls.push_back(Cpt{-0.5, -0.50}); |
| 102 |
ls.push_back(Cpt{+0.5, +0.50}); |
| 103 |
ls.push_back(Cpt{-1.0, -0.75}); |
| 104 |
return ls; |
| 105 |
} |
| 106 |
|
| 107 |
inline Gls linestring_pole_alias() { |
| 108 |
|
| 109 |
Gls ls; |
| 110 |
ls.push_back(Gpt{0, M_PI_2}); |
| 111 |
ls.push_back(Gpt{1, M_PI_2}); |
| 112 |
return ls; |
| 113 |
} |
| 114 |
|
| 115 |
inline Cgc geometrycollection_empty() { return {}; } |
| 116 |
|
| 117 |
inline Cgc geometrycollection_crossintersecting() { |
| 118 |
Cgc gc; |
| 119 |
{ |
| 120 |
Cls ls; |
| 121 |
ls.push_back(Cpt{-1, -1}); |
| 122 |
ls.push_back(Cpt{+1, +1}); |
| 123 |
gc.push_back(ls); |
| 124 |
} |
| 125 |
{ |
| 126 |
Cls ls; |
| 127 |
ls.push_back(Cpt{-1, +1}); |
| 128 |
ls.push_back(Cpt{+1, -1}); |
| 129 |
gc.push_back(ls); |
| 130 |
} |
| 131 |
return gc; |
| 132 |
} |
| 133 |
|
| 134 |
inline Cgc geometrycollection_subintersecting() { |
| 135 |
Cgc gc; |
| 136 |
gc.push_back(linestring_selfintersecting()); |
| 137 |
return gc; |
| 138 |
} |
| 139 |
|
| 140 |
inline Ggc bug26495068() { |
| 141 |
|
| 142 |
|
| 143 |
auto deg = [](double x) { return x * M_PI / 180; }; |
| 144 |
Ggc gc; |
| 145 |
{ |
| 146 |
Gls ls; |
| 147 |
ls.push_back(Gpt{deg(135), deg(0)}); |
| 148 |
ls.push_back(Gpt{deg(-150), deg(36)}); |
| 149 |
gc.push_back(ls); |
| 150 |
} |
| 151 |
{ |
| 152 |
Gls ls; |
| 153 |
ls.push_back(Gpt{deg(-101), deg(0)}); |
| 154 |
ls.push_back(Gpt{deg(-178), deg(30)}); |
| 155 |
gc.push_back(ls); |
| 156 |
} |
| 157 |
return gc; |
| 158 |
} |
| 159 |
|
| 160 |
} |
| 161 |
} |
| 162 |
|
| 163 |
#endif |