PostGIS  2.5.0dev-r@@SVN_REVISION@@
static void test_ptarray_unstroke ( )
static

Definition at line 343 of file cu_ptarray.c.

References ASSERT_STRING_EQUAL, lwfree(), lwgeom_free(), lwgeom_from_text(), lwgeom_stroke(), lwgeom_to_wkt(), lwgeom_unstroke(), and WKT_ISO.

Referenced by ptarray_suite_setup().

344 {
345  LWGEOM *in, *out;
346  char *str;
347 
348  /* It would be nice if this example returned two arcs (it's the intersection of two circles)
349  but it looks like the intersection itself is too sloppy in generating the derived point
350  to accurately reconstruct the circles.
351  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))");
352  out = lwgeom_unstroke(in);
353  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
354  printf("%s\n", str);
355  ASSERT_STRING_EQUAL(str, "CIRCULARSTRING(-1 0,0 1,0 -1)");
356  lwgeom_free(in);
357  lwgeom_free(out);
358  lwfree(str);
359  */
360 
361  in = lwgeom_from_text("CIRCULARSTRING(-1 0,0 1,0 -1)");
362  out = lwgeom_stroke(in,8);
363  lwgeom_free(in);
364  in = out;
365  out = lwgeom_unstroke(in);
366  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
367  // printf("%s\n", str);
368  ASSERT_STRING_EQUAL(str, "CIRCULARSTRING(-1 0,0.70710678 0.70710678,0 -1)");
369  lwgeom_free(in);
370  lwgeom_free(out);
371  lwfree(str);
372 
373  in = lwgeom_from_text("COMPOUNDCURVE(CIRCULARSTRING(-1 0,0 1,0 -1),(0 -1,-1 -1))");
374  out = lwgeom_stroke(in,8);
375  lwgeom_free(in);
376  in = out;
377  out = lwgeom_unstroke(in);
378  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
379  // printf("%s\n", str);
380  ASSERT_STRING_EQUAL(str, "COMPOUNDCURVE(CIRCULARSTRING(-1 0,0.70710678 0.70710678,0 -1),(0 -1,-1 -1))");
381  lwgeom_free(in);
382  lwgeom_free(out);
383  lwfree(str);
384 
385  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))");
386  out = lwgeom_stroke(in,8);
387  lwgeom_free(in);
388  in = out;
389  out = lwgeom_unstroke(in);
390  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
391  // printf("%s\n", str);
393  str,
394  "COMPOUNDCURVE((-3 -3,-1 0),CIRCULARSTRING(-1 0,0.70710678 "
395  "0.70710678,0 -1),(0 -1,0 -1.5,0 -2),CIRCULARSTRING(0 "
396  "-2,-0.70710678 -3.70710678,1 -3),(1 -3,5 5))");
397  lwgeom_free(in);
398  lwgeom_free(out);
399  lwfree(str);
400 
401  in = lwgeom_from_text("COMPOUNDCURVE(CIRCULARSTRING(-1 0,0 1,0 -1),CIRCULARSTRING(0 -1,-1 -2,1 -2))");
402  out = lwgeom_stroke(in,8);
403  lwgeom_free(in);
404  in = out;
405  out = lwgeom_unstroke(in);
406  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
407  // printf("%s\n", str);
409  str,
410  "COMPOUNDCURVE(CIRCULARSTRING(-1 0,0.70710678 0.70710678,0 "
411  "-1),CIRCULARSTRING(0 -1,-0.70710678 -2.70710678,1 -2))");
412  lwgeom_free(in);
413  lwgeom_free(out);
414  lwfree(str);
415 
416  in = lwgeom_from_text("COMPOUNDCURVE((0 0, 1 1), CIRCULARSTRING(1 1, 2 2, 3 1), (3 1, 4 4))");
417  out = lwgeom_stroke(in,8);
418  lwgeom_free(in);
419  in = out;
420  out = lwgeom_unstroke(in);
421  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
422  ASSERT_STRING_EQUAL(str, "COMPOUNDCURVE((0 0,1 1),CIRCULARSTRING(1 1,2 2,3 1),(3 1,4 4))");
423  lwgeom_free(in);
424  lwgeom_free(out);
425  // printf("%s\n", str);
426  lwfree(str);
427 
428  // See http://trac.osgeo.org/postgis/ticket/2425
429  // and http://trac.osgeo.org/postgis/ticket/2420
430  in = lwgeom_from_text("LINESTRING(0 0,10 0,10 10,0 10,0 0)");
431  out = lwgeom_unstroke(in);
432  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
433  ASSERT_STRING_EQUAL(str, "LINESTRING(0 0,10 0,10 10,0 10,0 0)");
434  lwgeom_free(in);
435  lwgeom_free(out);
436  lwfree(str);
437 
438  in = lwgeom_from_text("LINESTRING(10 10,0 10,0 0,10 0)");
439  out = lwgeom_unstroke(in);
440  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
441  ASSERT_STRING_EQUAL(str, "LINESTRING(10 10,0 10,0 0,10 0)");
442  // printf("%s\n", str);
443  lwgeom_free(in);
444  lwgeom_free(out);
445  lwfree(str);
446 
447  in = lwgeom_from_text("LINESTRING(0 0,10 0,10 10,0 10)");
448  out = lwgeom_unstroke(in);
449  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
450  ASSERT_STRING_EQUAL(str, "LINESTRING(0 0,10 0,10 10,0 10)");
451  // printf("%s\n", str);
452  lwgeom_free(in);
453  lwgeom_free(out);
454  lwfree(str);
455 
456  // See http://trac.osgeo.org/postgis/ticket/2412
457  in = lwgeom_from_text("LINESTRING(0 0, 1 1)");
458  out = lwgeom_unstroke(in);
459  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
460  // printf("%s\n", str);
461  ASSERT_STRING_EQUAL(str, "LINESTRING(0 0,1 1)");
462  lwgeom_free(in);
463  lwgeom_free(out);
464  lwfree(str);
465 
466 }
LWGEOM * lwgeom_stroke(const LWGEOM *geom, uint32_t perQuad)
Definition: lwstroke.c:714
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:675
void lwfree(void *mem)
Definition: lwutil.c:244
#define ASSERT_STRING_EQUAL(o, e)
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1137
static LWGEOM * lwgeom_from_text(const char *str)
Definition: cu_ptarray.c:24
#define WKT_ISO
Definition: liblwgeom.h:2068
LWGEOM * lwgeom_unstroke(const LWGEOM *geom)
Definition: lwstroke.c:1086

Here is the call graph for this function:

Here is the caller graph for this function: