PostGIS  3.6.1dev-r@@SVN_REVISION@@

◆ test_mindistance2d_tolerance()

static void test_mindistance2d_tolerance ( void  )
static

Definition at line 86 of file cu_measures.c.

87 {
88  double default_accepted_error = 0.00001;
89  double zero_accepted_error = 0.0;
90 
91 
92  /*
93  * CurvePolygon and Point, #5989
94  */
95  DIST2DTEST(
96  "CURVEPOLYGON(COMPOUNDCURVE((129296 142584,94722 100435,91618 97138,57306 60686,26874 28357,13059 34228,14572 65506,14593 65948,14616 66389),CIRCULARSTRING(14616 66389,17955 101124,24417 135415,24655 136418,24895 137421),(24895 137421,25472 139809,19354 141285,0 0,148000 142000,129296 142584)))",
97  "POINT(19925 112376)",
98  199.655, 0.001);
99 
100  /*
101  ** Simple case.
102  */
103  DIST2DTEST("POINT(0 0)", "MULTIPOINT(0 1.5,0 2,0 2.5)", 1.5, default_accepted_error);
104 
105  /*
106  ** Point vs Geometry Collection.
107  */
108  DIST2DTEST("POINT(0 0)", "GEOMETRYCOLLECTION(POINT(3 4))", 5.0, default_accepted_error);
109 
110  /*
111  ** Point vs Geometry Collection Collection.
112  */
113  DIST2DTEST("POINT(0 0)", "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4)))", 5.0, default_accepted_error);
114 
115  /*
116  ** Point vs Geometry Collection Collection Collection.
117  */
118  DIST2DTEST("POINT(0 0)", "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4))))", 5.0, default_accepted_error);
119 
120  /*
121  ** Point vs Geometry Collection Collection Collection Multipoint.
122  */
123  DIST2DTEST("POINT(0 0)", "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(3 4))))", 5.0, default_accepted_error);
124 
125  /*
126  ** Geometry Collection vs Geometry Collection
127  */
128  DIST2DTEST("GEOMETRYCOLLECTION(POINT(0 0))", "GEOMETRYCOLLECTION(POINT(3 4))", 5.0, default_accepted_error);
129 
130  /*
131  ** Geometry Collection Collection vs Geometry Collection Collection
132  */
133  DIST2DTEST("GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(0 0)))", "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4)))", 5.0, default_accepted_error);
134 
135  /*
136  ** Geometry Collection Collection Multipoint vs Geometry Collection Collection Multipoint
137  */
138  DIST2DTEST("GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(0 0)))", "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(3 4)))", 5.0, default_accepted_error);
139 
140  /*
141  ** Linestring vs its start point
142  */
143  DIST2DTEST("LINESTRING(-2 0, -0.2 0)", "POINT(-2 0)", 0, zero_accepted_error);
144 
145  /*
146  ** Linestring vs its end point
147  */
148  DIST2DTEST("LINESTRING(-0.2 0, -2 0)", "POINT(-2 0)", 0, zero_accepted_error);
149 
150  /*
151  ** Linestring vs its start point (tricky number, see #1459)
152  */
153  DIST2DTEST("LINESTRING(-1e-8 0, -0.2 0)", "POINT(-1e-8 0)", 0, zero_accepted_error);
154 
155  /*
156  ** Linestring vs its end point (tricky number, see #1459)
157  */
158  DIST2DTEST("LINESTRING(-0.2 0, -1e-8 0)", "POINT(-1e-8 0)", 0, zero_accepted_error);
159 
160  /*
161  * Circular string and point
162  */
163  DIST2DTEST("CIRCULARSTRING(-1 0, 0 1, 1 0)", "POINT(0 0)", 1, default_accepted_error);
164  DIST2DTEST("CIRCULARSTRING(-3 0, -2 0, -1 0, 0 1, 1 0)", "POINT(0 0)", 1, default_accepted_error);
165 
166  /*
167  * Circular string and Circular string
168  */
169  DIST2DTEST("CIRCULARSTRING(-1 0, 0 1, 1 0)", "CIRCULARSTRING(0 0, 1 -1, 2 0)", 1, default_accepted_error);
170 
171  /*
172  * CurvePolygon and Point
173  */
174  static char *cs1 = "CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(1 6, 6 1, 9 7),(9 7, 3 13, 1 6)),COMPOUNDCURVE((3 6, 5 4, 7 4, 7 6),CIRCULARSTRING(7 6,5 8,3 6)))";
175  DIST2DTEST(cs1, "POINT(3 14)", 1, default_accepted_error);
176  DIST2DTEST(cs1, "POINT(3 8)", 0, default_accepted_error);
177  DIST2DTEST(cs1, "POINT(6 5)", 1, default_accepted_error);
178  DIST2DTEST(cs1, "POINT(6 4)", 0, default_accepted_error);
179 
180  /*
181  * CurvePolygon and Linestring
182  */
183  DIST2DTEST(cs1, "LINESTRING(0 0, 50 0)", 0.917484, default_accepted_error);
184  DIST2DTEST(cs1, "LINESTRING(6 0, 10 7)", 0, default_accepted_error);
185  DIST2DTEST(cs1, "LINESTRING(4 4, 4 8)", 0, default_accepted_error);
186  DIST2DTEST(cs1, "LINESTRING(4 7, 5 6, 6 7)", 0.585786, default_accepted_error);
187  DIST2DTEST(cs1, "LINESTRING(10 0, 10 2, 10 0)", 1.52913, default_accepted_error);
188 
189  /*
190  * CurvePolygon and Polygon
191  */
192  DIST2DTEST(cs1, "POLYGON((10 4, 10 8, 13 8, 13 4, 10 4))", 0.58415, default_accepted_error);
193  DIST2DTEST(cs1, "POLYGON((9 4, 9 8, 12 8, 12 4, 9 4))", 0, default_accepted_error);
194  DIST2DTEST(cs1, "POLYGON((1 4, 1 8, 4 8, 4 4, 1 4))", 0, default_accepted_error);
195 
196  /*
197  * CurvePolygon and CurvePolygon
198  */
199  DIST2DTEST(cs1, "CURVEPOLYGON(CIRCULARSTRING(-1 4, 0 5, 1 4, 0 3, -1 4))", 0.0475666, default_accepted_error);
200  DIST2DTEST(cs1, "CURVEPOLYGON(CIRCULARSTRING(1 4, 2 5, 3 4, 2 3, 1 4))", 0.0, default_accepted_error);
201 
202  /*
203  * MultiSurface and CurvePolygon
204  */
205  static char *cs2 = "MULTISURFACE(POLYGON((0 0,0 4,4 4,4 0,0 0)),CURVEPOLYGON(CIRCULARSTRING(8 2,10 4,12 2,10 0,8 2)))";
206  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(5 2,6 3,7 2,6 1,5 2))", 1, default_accepted_error);
207  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(4 2,5 3,6 2,5 1,4 2))", 0, default_accepted_error);
208  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(5 3,6 2,5 1,4 2,5 3))", 0, default_accepted_error);
209  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(4.5 3,5.5 2,4.5 1,3.5 2,4.5 3))", 0, default_accepted_error);
210  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(5.5 3,6.5 2,5.5 1,4.5 2,5.5 3))", 0.5, default_accepted_error);
211  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(10 3,11 2,10 1,9 2,10 3))", 0, default_accepted_error);
212  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(2 3,3 2,2 1,1 2,2 3))", 0, default_accepted_error);
213  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(5 7,6 8,7 7,6 6,5 7))", 2.60555, default_accepted_error);
214 
215  /*
216  * MultiCurve and Linestring
217  */
218  DIST2DTEST("LINESTRING(0.5 1,0.5 3)", "MULTICURVE(CIRCULARSTRING(2 3,3 2,2 1,1 2,2 3),(0 0, 0 5))", 0.5, default_accepted_error);
219 
220  /*
221  ** "Fast path" case
222  */
223  DIST2DTEST("LINESTRING(10 0,11 1,12 2,13 3,14 4,15 5,16 6)",
224  "LINESTRING(1 1.5,2 3,3 4.5,4 6,5 7.5,6 9)",
225  8.3205, default_accepted_error);
226 
227  /*
228  ** Ticket 4326
229  */
230  DIST2DTEST(
231  "CURVEPOLYGON(CIRCULARSTRING(7874821 8715927,8907663 8715927,8844683 7750316,7937800 7750316,7874821 8715927))",
232  "POINT(5433865 8243495)", 2271704.2698450615, default_accepted_error);
233 
234  /* Ticket 5989 */
235  DIST2DTEST(
236  "CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(0 0, -1 5, 0 10), (0 10, -10 10, -10 0, 0 0)))",
237  "POINT(-0.5 5)", 0.5, default_accepted_error);
238 }
#define DIST2DTEST(str1, str2, res, accepted_error)
Definition: cu_measures.c:33

References DIST2DTEST.

Referenced by measures_suite_setup().

Here is the caller graph for this function: