PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ test_mindistance2d_tolerance()

static void test_mindistance2d_tolerance ( void  )
static

Definition at line 72 of file cu_measures.c.

References DIST2DTEST.

Referenced by measures_suite_setup().

73 {
74  /*
75  ** Simple case.
76  */
77  DIST2DTEST("POINT(0 0)", "MULTIPOINT(0 1.5,0 2,0 2.5)", 1.5);
78 
79  /*
80  ** Point vs Geometry Collection.
81  */
82  DIST2DTEST("POINT(0 0)", "GEOMETRYCOLLECTION(POINT(3 4))", 5.0);
83 
84  /*
85  ** Point vs Geometry Collection Collection.
86  */
87  DIST2DTEST("POINT(0 0)", "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4)))", 5.0);
88 
89  /*
90  ** Point vs Geometry Collection Collection Collection.
91  */
92  DIST2DTEST("POINT(0 0)", "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4))))", 5.0);
93 
94  /*
95  ** Point vs Geometry Collection Collection Collection Multipoint.
96  */
97  DIST2DTEST("POINT(0 0)", "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(3 4))))", 5.0);
98 
99  /*
100  ** Geometry Collection vs Geometry Collection
101  */
102  DIST2DTEST("GEOMETRYCOLLECTION(POINT(0 0))", "GEOMETRYCOLLECTION(POINT(3 4))", 5.0);
103 
104  /*
105  ** Geometry Collection Collection vs Geometry Collection Collection
106  */
107  DIST2DTEST("GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(0 0)))", "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(3 4)))", 5.0);
108 
109  /*
110  ** Geometry Collection Collection Multipoint vs Geometry Collection Collection Multipoint
111  */
112  DIST2DTEST("GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(0 0)))", "GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(MULTIPOINT(3 4)))", 5.0);
113 
114  /*
115  ** Linestring vs its start point
116  */
117  DIST2DTEST("LINESTRING(-2 0, -0.2 0)", "POINT(-2 0)", 0);
118 
119  /*
120  ** Linestring vs its end point
121  */
122  DIST2DTEST("LINESTRING(-0.2 0, -2 0)", "POINT(-2 0)", 0);
123 
124  /*
125  ** Linestring vs its start point (tricky number, see #1459)
126  */
127  DIST2DTEST("LINESTRING(-1e-8 0, -0.2 0)", "POINT(-1e-8 0)", 0);
128 
129  /*
130  ** Linestring vs its end point (tricky number, see #1459)
131  */
132  DIST2DTEST("LINESTRING(-0.2 0, -1e-8 0)", "POINT(-1e-8 0)", 0);
133 
134  /*
135  * Circular string and point
136  */
137  DIST2DTEST("CIRCULARSTRING(-1 0, 0 1, 1 0)", "POINT(0 0)", 1);
138  DIST2DTEST("CIRCULARSTRING(-3 0, -2 0, -1 0, 0 1, 1 0)", "POINT(0 0)", 1);
139 
140  /*
141  * Circular string and Circular string
142  */
143  DIST2DTEST("CIRCULARSTRING(-1 0, 0 1, 1 0)", "CIRCULARSTRING(0 0, 1 -1, 2 0)", 1);
144 
145  /*
146  * CurvePolygon and Point
147  */
148  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)))";
149  DIST2DTEST(cs1, "POINT(3 14)", 1);
150  DIST2DTEST(cs1, "POINT(3 8)", 0);
151  DIST2DTEST(cs1, "POINT(6 5)", 1);
152  DIST2DTEST(cs1, "POINT(6 4)", 0);
153 
154  /*
155  * CurvePolygon and Linestring
156  */
157  DIST2DTEST(cs1, "LINESTRING(0 0, 50 0)", 0.917484);
158  DIST2DTEST(cs1, "LINESTRING(6 0, 10 7)", 0);
159  DIST2DTEST(cs1, "LINESTRING(4 4, 4 8)", 0);
160  DIST2DTEST(cs1, "LINESTRING(4 7, 5 6, 6 7)", 0.585786);
161  DIST2DTEST(cs1, "LINESTRING(10 0, 10 2, 10 0)", 1.52913);
162 
163  /*
164  * CurvePolygon and Polygon
165  */
166  DIST2DTEST(cs1, "POLYGON((10 4, 10 8, 13 8, 13 4, 10 4))", 0.58415);
167  DIST2DTEST(cs1, "POLYGON((9 4, 9 8, 12 8, 12 4, 9 4))", 0);
168  DIST2DTEST(cs1, "POLYGON((1 4, 1 8, 4 8, 4 4, 1 4))", 0);
169 
170  /*
171  * CurvePolygon and CurvePolygon
172  */
173  DIST2DTEST(cs1, "CURVEPOLYGON(CIRCULARSTRING(-1 4, 0 5, 1 4, 0 3, -1 4))", 0.0475666);
174  DIST2DTEST(cs1, "CURVEPOLYGON(CIRCULARSTRING(1 4, 2 5, 3 4, 2 3, 1 4))", 0.0);
175 
176  /*
177  * MultiSurface and CurvePolygon
178  */
179  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)))";
180  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(5 2,6 3,7 2,6 1,5 2))", 1);
181  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(4 2,5 3,6 2,5 1,4 2))", 0);
182  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(5 3,6 2,5 1,4 2,5 3))", 0);
183  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(4.5 3,5.5 2,4.5 1,3.5 2,4.5 3))", 0);
184  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(5.5 3,6.5 2,5.5 1,4.5 2,5.5 3))", 0.5);
185  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(10 3,11 2,10 1,9 2,10 3))", 0);
186  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(2 3,3 2,2 1,1 2,2 3))", 0);
187  DIST2DTEST(cs2, "CURVEPOLYGON(CIRCULARSTRING(5 7,6 8,7 7,6 6,5 7))", 2.60555);
188 
189  /*
190  * MultiCurve and Linestring
191  */
192  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);
193 
194 }
#define DIST2DTEST(str1, str2, res)
Definition: cu_measures.c:32
Here is the caller graph for this function: