PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ test_mindistance2d_tolerance()

static void test_mindistance2d_tolerance ( void  )
static

Definition at line 87 of file cu_measures.c.

88 {
89  double default_accepted_error = 0.00001;
90  double zero_accepted_error = 0.0;
91  /*
92  ** Simple case.
93  */
94  DIST2DTEST("POINT(0 0)", "MULTIPOINT(0 1.5,0 2,0 2.5)", 1.5, default_accepted_error);
95 
96  /*
97  ** Point vs Geometry Collection.
98  */
99  DIST2DTEST("POINT(0 0)", "GEOMETRYCOLLECTION(POINT(3 4))", 5.0, default_accepted_error);
100 
101  /*
102  ** Point vs Geometry Collection Collection.
103  */
104  DIST2DTEST("POINT(0 0)", "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4)))", 5.0, default_accepted_error);
105 
106  /*
107  ** Point vs Geometry Collection Collection Collection.
108  */
109  DIST2DTEST("POINT(0 0)", "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4))))", 5.0, default_accepted_error);
110 
111  /*
112  ** Point vs Geometry Collection Collection Collection Multipoint.
113  */
114  DIST2DTEST("POINT(0 0)", "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(3 4))))", 5.0, default_accepted_error);
115 
116  /*
117  ** Geometry Collection vs Geometry Collection
118  */
119  DIST2DTEST("GEOMETRYCOLLECTION(POINT(0 0))", "GEOMETRYCOLLECTION(POINT(3 4))", 5.0, default_accepted_error);
120 
121  /*
122  ** Geometry Collection Collection vs Geometry Collection Collection
123  */
124  DIST2DTEST("GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(0 0)))", "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4)))", 5.0, default_accepted_error);
125 
126  /*
127  ** Geometry Collection Collection Multipoint vs Geometry Collection Collection Multipoint
128  */
129  DIST2DTEST("GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(0 0)))", "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(3 4)))", 5.0, default_accepted_error);
130 
131  /*
132  ** Linestring vs its start point
133  */
134  DIST2DTEST("LINESTRING(-2 0, -0.2 0)", "POINT(-2 0)", 0, zero_accepted_error);
135 
136  /*
137  ** Linestring vs its end point
138  */
139  DIST2DTEST("LINESTRING(-0.2 0, -2 0)", "POINT(-2 0)", 0, zero_accepted_error);
140 
141  /*
142  ** Linestring vs its start point (tricky number, see #1459)
143  */
144  DIST2DTEST("LINESTRING(-1e-8 0, -0.2 0)", "POINT(-1e-8 0)", 0, zero_accepted_error);
145 
146  /*
147  ** Linestring vs its end point (tricky number, see #1459)
148  */
149  DIST2DTEST("LINESTRING(-0.2 0, -1e-8 0)", "POINT(-1e-8 0)", 0, zero_accepted_error);
150 
151  /*
152  * Circular string and point
153  */
154  DIST2DTEST("CIRCULARSTRING(-1 0, 0 1, 1 0)", "POINT(0 0)", 1, default_accepted_error);
155  DIST2DTEST("CIRCULARSTRING(-3 0, -2 0, -1 0, 0 1, 1 0)", "POINT(0 0)", 1, default_accepted_error);
156 
157  /*
158  * Circular string and Circular string
159  */
160  DIST2DTEST("CIRCULARSTRING(-1 0, 0 1, 1 0)", "CIRCULARSTRING(0 0, 1 -1, 2 0)", 1, default_accepted_error);
161 
162  /*
163  * CurvePolygon and Point
164  */
165  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)))";
166  DIST2DTEST(cs1, "POINT(3 14)", 1, default_accepted_error);
167  DIST2DTEST(cs1, "POINT(3 8)", 0, default_accepted_error);
168  DIST2DTEST(cs1, "POINT(6 5)", 1, default_accepted_error);
169  DIST2DTEST(cs1, "POINT(6 4)", 0, default_accepted_error);
170 
171  /*
172  * CurvePolygon and Linestring
173  */
174  DIST2DTEST(cs1, "LINESTRING(0 0, 50 0)", 0.917484, default_accepted_error);
175  DIST2DTEST(cs1, "LINESTRING(6 0, 10 7)", 0, default_accepted_error);
176  DIST2DTEST(cs1, "LINESTRING(4 4, 4 8)", 0, default_accepted_error);
177  DIST2DTEST(cs1, "LINESTRING(4 7, 5 6, 6 7)", 0.585786, default_accepted_error);
178  DIST2DTEST(cs1, "LINESTRING(10 0, 10 2, 10 0)", 1.52913, default_accepted_error);
179 
180  /*
181  * CurvePolygon and Polygon
182  */
183  DIST2DTEST(cs1, "POLYGON((10 4, 10 8, 13 8, 13 4, 10 4))", 0.58415, default_accepted_error);
184  DIST2DTEST(cs1, "POLYGON((9 4, 9 8, 12 8, 12 4, 9 4))", 0, default_accepted_error);
185  DIST2DTEST(cs1, "POLYGON((1 4, 1 8, 4 8, 4 4, 1 4))", 0, default_accepted_error);
186 
187  /*
188  * CurvePolygon and CurvePolygon
189  */
190  DIST2DTEST(cs1, "CURVEPOLYGON(CIRCULARSTRING(-1 4, 0 5, 1 4, 0 3, -1 4))", 0.0475666, default_accepted_error);
191  DIST2DTEST(cs1, "CURVEPOLYGON(CIRCULARSTRING(1 4, 2 5, 3 4, 2 3, 1 4))", 0.0, default_accepted_error);
192 
193  /*
194  * MultiSurface and CurvePolygon
195  */
196  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)))";
197  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(5 2,6 3,7 2,6 1,5 2))", 1, default_accepted_error);
198  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(4 2,5 3,6 2,5 1,4 2))", 0, default_accepted_error);
199  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(5 3,6 2,5 1,4 2,5 3))", 0, default_accepted_error);
200  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(4.5 3,5.5 2,4.5 1,3.5 2,4.5 3))", 0, default_accepted_error);
201  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(5.5 3,6.5 2,5.5 1,4.5 2,5.5 3))", 0.5, default_accepted_error);
202  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(10 3,11 2,10 1,9 2,10 3))", 0, default_accepted_error);
203  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(2 3,3 2,2 1,1 2,2 3))", 0, default_accepted_error);
204  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(5 7,6 8,7 7,6 6,5 7))", 2.60555, default_accepted_error);
205 
206  /*
207  * MultiCurve and Linestring
208  */
209  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);
210 
211  /*
212  ** Ticket 4326
213  */
214  DIST2DTEST(
215  "CURVEPOLYGON(CIRCULARSTRING(7874821 8715927,8907663 8715927,8844683 7750316,7937800 7750316,7874821 8715927))",
216  "POINT(5433865 8243495)", 2271704.2698450615, default_accepted_error);
217 }
#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: