PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_ptarray_unstroke()

static void test_ptarray_unstroke ( )
static

Definition at line 345 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().

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