PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void test_ptarray_desegmentize ( )
static

Definition at line 346 of file cu_ptarray.c.

References lwfree(), lwgeom_desegmentize(), lwgeom_free(), lwgeom_from_text(), lwgeom_segmentize(), lwgeom_to_wkt(), and WKT_ISO.

Referenced by ptarray_suite_setup().

347 {
348  LWGEOM *in, *out;
349  char *str;
350 
351  /* It would be nice if this example returned two arcs (it's the intersection of two circles)
352  but it looks like the intersection itself is too sloppy in generating the derived point
353  to accurately reconstruct the circles.
354  in = lwgeom_from_text("POLYGON((0.5 0,0.471177920604846 -0.292635483024192,0.38581929876693 -0.574025148547634,0.247204418453818 -0.833355349529403,0.0606601717798223 -1.06066017177982,-5.44089437167602e-17 -1.11044268820754,-0.0606601717798188 -1.06066017177982,-0.247204418453816 -0.833355349529406,-0.385819298766929 -0.574025148547639,-0.471177920604845 -0.292635483024197,-0.5 -4.84663372329776e-15,-0.471177920604847 0.292635483024187,-0.385819298766932 0.57402514854763,-0.247204418453821 0.833355349529398,-0.0606601717798256 1.06066017177982,3.45538806345173e-16 1.11044268820754,0.0606601717798183 1.06066017177982,0.247204418453816 0.833355349529407,0.385819298766929 0.574025148547638,0.471177920604845 0.292635483024196,0.5 0))");
355  out = lwgeom_desegmentize(in);
356  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
357  printf("%s\n", str);
358  CU_ASSERT_STRING_EQUAL(str, "CIRCULARSTRING(-1 0,0 1,0 -1)");
359  lwgeom_free(in);
360  lwgeom_free(out);
361  lwfree(str);
362  */
363 
364  in = lwgeom_from_text("CIRCULARSTRING(-1 0,0 1,0 -1)");
365  out = lwgeom_segmentize(in,8);
366  lwgeom_free(in);
367  in = out;
368  out = lwgeom_desegmentize(in);
369  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
370  //printf("%s\n", str);
371  CU_ASSERT_STRING_EQUAL(str, "CIRCULARSTRING(-1 0,0.70710678 0.70710678,0 -1)");
372  lwgeom_free(in);
373  lwgeom_free(out);
374  lwfree(str);
375 
376  in = lwgeom_from_text("COMPOUNDCURVE(CIRCULARSTRING(-1 0,0 1,0 -1),(0 -1,-1 -1))");
377  out = lwgeom_segmentize(in,8);
378  lwgeom_free(in);
379  in = out;
380  out = lwgeom_desegmentize(in);
381  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
382  //printf("%s\n", str);
383  CU_ASSERT_STRING_EQUAL(str, "COMPOUNDCURVE(CIRCULARSTRING(-1 0,0.70710678 0.70710678,0 -1),(0 -1,-1 -1))");
384  lwgeom_free(in);
385  lwgeom_free(out);
386  lwfree(str);
387 
388  in = lwgeom_from_text("COMPOUNDCURVE((-3 -3,-1 0),CIRCULARSTRING(-1 0,0 1,0 -1),(0 -1,0 -1.5,0 -2),CIRCULARSTRING(0 -2,-1 -3,1 -3),(1 -3,5 5))");
389  out = lwgeom_segmentize(in,8);
390  lwgeom_free(in);
391  in = out;
392  out = lwgeom_desegmentize(in);
393  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
394  //printf("%s\n", str);
395  CU_ASSERT_STRING_EQUAL(str, "COMPOUNDCURVE((-3 -3,-1 0),CIRCULARSTRING(-1 0,0.70710678 0.70710678,0 -1),(0 -1,0 -1.5,0 -2),CIRCULARSTRING(0 -2,-0.70710678 -3.7071068,1 -3),(1 -3,5 5))");
396  lwgeom_free(in);
397  lwgeom_free(out);
398  lwfree(str);
399 
400  in = lwgeom_from_text("COMPOUNDCURVE(CIRCULARSTRING(-1 0,0 1,0 -1),CIRCULARSTRING(0 -1,-1 -2,1 -2))");
401  out = lwgeom_segmentize(in,8);
402  lwgeom_free(in);
403  in = out;
404  out = lwgeom_desegmentize(in);
405  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
406  //printf("%s\n", str);
407  CU_ASSERT_STRING_EQUAL(str, "COMPOUNDCURVE(CIRCULARSTRING(-1 0,0.70710678 0.70710678,0 -1),CIRCULARSTRING(0 -1,-0.70710678 -2.7071068,1 -2))");
408  lwgeom_free(in);
409  lwgeom_free(out);
410  lwfree(str);
411 
412  in = lwgeom_from_text("COMPOUNDCURVE((0 0, 1 1), CIRCULARSTRING(1 1, 2 2, 3 1), (3 1, 4 4))");
413  out = lwgeom_segmentize(in,8);
414  lwgeom_free(in);
415  in = out;
416  out = lwgeom_desegmentize(in);
417  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
418  CU_ASSERT_STRING_EQUAL(str, "COMPOUNDCURVE((0 0,1 1),CIRCULARSTRING(1 1,2 2,3 1),(3 1,4 4))");
419  lwgeom_free(in);
420  lwgeom_free(out);
421 // printf("%s\n", str);
422  lwfree(str);
423 
424  // See http://trac.osgeo.org/postgis/ticket/2425
425  // and http://trac.osgeo.org/postgis/ticket/2420
426  in = lwgeom_from_text("LINESTRING(0 0,10 0,10 10,0 10,0 0)");
427  out = lwgeom_desegmentize(in);
428  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
429  CU_ASSERT_STRING_EQUAL(str, "LINESTRING(0 0,10 0,10 10,0 10,0 0)");
430  lwgeom_free(in);
431  lwgeom_free(out);
432  lwfree(str);
433 
434  in = lwgeom_from_text("LINESTRING(10 10,0 10,0 0,10 0)");
435  out = lwgeom_desegmentize(in);
436  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
437  CU_ASSERT_STRING_EQUAL(str, "LINESTRING(10 10,0 10,0 0,10 0)");
438  // printf("%s\n", str);
439  lwgeom_free(in);
440  lwgeom_free(out);
441  lwfree(str);
442 
443  in = lwgeom_from_text("LINESTRING(0 0,10 0,10 10,0 10)");
444  out = lwgeom_desegmentize(in);
445  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
446  CU_ASSERT_STRING_EQUAL(str, "LINESTRING(0 0,10 0,10 10,0 10)");
447  // printf("%s\n", str);
448  lwgeom_free(in);
449  lwgeom_free(out);
450  lwfree(str);
451 
452  // See http://trac.osgeo.org/postgis/ticket/2412
453  in = lwgeom_from_text("LINESTRING(0 0, 1 1)");
454  out = lwgeom_desegmentize(in);
455  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
456 //printf("%s\n", str);
457  CU_ASSERT_STRING_EQUAL(str, "LINESTRING(0 0,1 1)");
458  lwgeom_free(in);
459  lwgeom_free(out);
460  lwfree(str);
461 }
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:655
LWGEOM * lwgeom_desegmentize(LWGEOM *geom)
Definition: lwsegmentize.c:841
void lwfree(void *mem)
Definition: lwutil.c:190
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
LWGEOM * lwgeom_segmentize(LWGEOM *geom, uint32_t perQuad)
Definition: lwsegmentize.c:446
static LWGEOM * lwgeom_from_text(const char *str)
Definition: cu_ptarray.c:25
#define WKT_ISO
Definition: liblwgeom.h:1776

Here is the call graph for this function:

Here is the caller graph for this function: