PostGIS  2.5.7dev-r@@SVN_REVISION@@

## ◆ test_tree_circ_distance_threshold()

 static void test_tree_circ_distance_threshold ( void )
static

Definition at line 354 of file cu_tree.c.

355 {
356  SPHEROID s;
357  int i, j;
358  int step = 10;
359
360  const char *txt_poly1 = "0103000020E6100000010000000B0000000AA2F068F47651C0F7893DEB70B8454007ABD4C6D57651C000FB650799B84540C21AA2645A7651C011C24BA84AB8454089A9A325E87751C03314EB5453B74540AF9ED96BF57751C0BF9818F889B74540E936A498B47751C0690C87D1C5B74540F5386204DC7751C02FCA658F1AB8454077B65F7B657751C012C586EE37B845408C1862C5977751C00F17E41674B84540D4012F57357751C0AD3BC67E99B845400AA2F068F47651C0F7893DEB70B84540";
362  const char *polys[2];
363  static int npolys = 2;
364
365  polys[0] = txt_poly1;
366  polys[1] = txt_poly2;
367
370
371  for ( j = 0; j < npolys; j++ )
372  {
374  LWGEOM *lwg2 = lwgeom_from_wkt("POINT(-69.83262 43.43636)", LW_PARSER_CHECK_NONE);
375
378
379  for ( i = 50; i < 1500 / step; i++ )
380  {
381  double d1, d2;
382  double d = lwgeom_distance_spheroid(lwg1, lwg2, &s, 0);
383  double threshold = step * i;
384  d1 = circ_tree_distance_tree(c1, c2, &s, threshold);
385  d2 = lwgeom_distance_spheroid(lwg1, lwg2, &s, threshold);
386  if (threshold > d && (d1 > threshold || d2 > threshold))
387  {
388  printf("polygon #%d\n"
389  "threshold = %g\n"
390  "true distance = %g\n"
391  "circ_tree_distance = %g\n"
392  "lwgeom_distance_spheroid = %g\n", j, threshold, d, d1, d2);
393  CU_FAIL_FATAL();
394  }
395  }
396
397  circ_tree_free(c1);
398  circ_tree_free(c2);
399  lwgeom_free(lwg1);
400  lwgeom_free(lwg2);
401  }
402
403 }
char * s
Definition: cu_in_wkt.c:23
#define WGS84_MAJOR_AXIS
Definition: liblwgeom.h:128
LWGEOM * lwgeom_from_hexwkb(const char *hexwkb, const char check)
Definition: lwin_wkb.c:809
double lwgeom_distance_spheroid(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2, const SPHEROID *spheroid, double tolerance)
Calculate the geodetic distance from lwgeom1 to lwgeom2 on the spheroid.
Definition: lwgeodetic.c:2187
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2005
#define WGS84_MINOR_AXIS
Definition: liblwgeom.h:130
void spheroid_init(SPHEROID *s, double a, double b)
Initialize a spheroid object for use in geodetic functions.
Definition: lwspheroid.c:39
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
double circ_tree_distance_tree(const CIRC_NODE *n1, const CIRC_NODE *n2, const SPHEROID *spheroid, double threshold)
void circ_tree_free(CIRC_NODE *node)
Recurse from top of node tree and free all children.
CIRC_NODE * lwgeom_calculate_circ_tree(const LWGEOM *lwgeom)
Note that p1 and p2 are pointers into an independent POINTARRAY, do not free them.

Referenced by tree_suite_setup().

Here is the call graph for this function:
Here is the caller graph for this function: