PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_unstroke()

static void test_unstroke ( )
static

Definition at line 364 of file cu_lwstroke.c.

365 {
366  LWGEOM *in, *out;
367  char *str;
368 
369  /* It would be nice if this example returned two arcs (it's the intersection of two circles)
370  but it looks like the intersection itself is too sloppy in generating the derived point
371  to accurately reconstruct the circles.
372  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))");
373  out = lwgeom_unstroke(in);
374  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
375  printf("%s\n", str);
376  ASSERT_STRING_EQUAL(str, "CIRCULARSTRING(-1 0,0 1,0 -1)");
377  lwgeom_free(in);
378  lwgeom_free(out);
379  lwfree(str);
380  */
381 
382  in = lwgeom_from_text("CIRCULARSTRING(-1 0,0 1,0 -1)");
383  out = lwgeom_stroke(in,8);
384  lwgeom_free(in);
385  in = out;
386  out = lwgeom_unstroke(in);
387  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
388  // printf("%s\n", str);
389  ASSERT_STRING_EQUAL(str, "CIRCULARSTRING(-1 0,0.70710678 0.70710678,0 -1)");
390  lwgeom_free(in);
391  lwgeom_free(out);
392  lwfree(str);
393 
394  in = lwgeom_from_text("COMPOUNDCURVE(CIRCULARSTRING(-1 0,0 1,0 -1),(0 -1,-1 -1))");
395  out = lwgeom_stroke(in,8);
396  lwgeom_free(in);
397  in = out;
398  out = lwgeom_unstroke(in);
399  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
400  // printf("%s\n", str);
401  ASSERT_STRING_EQUAL(str, "COMPOUNDCURVE(CIRCULARSTRING(-1 0,0.70710678 0.70710678,0 -1),(0 -1,-1 -1))");
402  lwgeom_free(in);
403  lwgeom_free(out);
404  lwfree(str);
405 
406  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))");
407  out = lwgeom_stroke(in,8);
408  lwgeom_free(in);
409  in = out;
410  out = lwgeom_unstroke(in);
411  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
412  // printf("%s\n", str);
414  str,
415  "COMPOUNDCURVE((-3 -3,-1 0),CIRCULARSTRING(-1 0,0.70710678 "
416  "0.70710678,0 -1),(0 -1,0 -1.5,0 -2),CIRCULARSTRING(0 "
417  "-2,-0.70710678 -3.70710678,1 -3),(1 -3,5 5))");
418  lwgeom_free(in);
419  lwgeom_free(out);
420  lwfree(str);
421 
422  in = lwgeom_from_text("COMPOUNDCURVE(CIRCULARSTRING(-1 0,0 1,0 -1),CIRCULARSTRING(0 -1,-1 -2,1 -2))");
423  out = lwgeom_stroke(in,8);
424  lwgeom_free(in);
425  in = out;
426  out = lwgeom_unstroke(in);
427  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
428  // printf("%s\n", str);
430  str,
431  "COMPOUNDCURVE(CIRCULARSTRING(-1 0,0.70710678 0.70710678,0 "
432  "-1),CIRCULARSTRING(0 -1,-0.70710678 -2.70710678,1 -2))");
433  lwgeom_free(in);
434  lwgeom_free(out);
435  lwfree(str);
436 
437  in = lwgeom_from_text("COMPOUNDCURVE((0 0, 1 1), CIRCULARSTRING(1 1, 2 2, 3 1), (3 1, 4 4))");
438  out = lwgeom_stroke(in,8);
439  lwgeom_free(in);
440  in = out;
441  out = lwgeom_unstroke(in);
442  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
443  ASSERT_STRING_EQUAL(str, "COMPOUNDCURVE((0 0,1 1),CIRCULARSTRING(1 1,2 2,3 1),(3 1,4 4))");
444  lwgeom_free(in);
445  lwgeom_free(out);
446  // printf("%s\n", str);
447  lwfree(str);
448 
449  // See http://trac.osgeo.org/postgis/ticket/2425
450  // and http://trac.osgeo.org/postgis/ticket/2420
451  in = lwgeom_from_text("LINESTRING(0 0,10 0,10 10,0 10,0 0)");
452  out = lwgeom_unstroke(in);
453  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
454  ASSERT_STRING_EQUAL(str, "LINESTRING(0 0,10 0,10 10,0 10,0 0)");
455  lwgeom_free(in);
456  lwgeom_free(out);
457  lwfree(str);
458 
459  in = lwgeom_from_text("LINESTRING(10 10,0 10,0 0,10 0)");
460  out = lwgeom_unstroke(in);
461  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
462  ASSERT_STRING_EQUAL(str, "LINESTRING(10 10,0 10,0 0,10 0)");
463  // printf("%s\n", str);
464  lwgeom_free(in);
465  lwgeom_free(out);
466  lwfree(str);
467 
468  in = lwgeom_from_text("LINESTRING(0 0,10 0,10 10,0 10)");
469  out = lwgeom_unstroke(in);
470  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
471  ASSERT_STRING_EQUAL(str, "LINESTRING(0 0,10 0,10 10,0 10)");
472  // printf("%s\n", str);
473  lwgeom_free(in);
474  lwgeom_free(out);
475  lwfree(str);
476 
477  // See http://trac.osgeo.org/postgis/ticket/2412
478  in = lwgeom_from_text("LINESTRING(0 0, 1 1)");
479  out = lwgeom_unstroke(in);
480  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
481  // printf("%s\n", str);
482  ASSERT_STRING_EQUAL(str, "LINESTRING(0 0,1 1)");
483  lwgeom_free(in);
484  lwgeom_free(out);
485  lwfree(str);
486 
487  in = lwgeom_from_text("GEOMETRYCOLLECTION(LINESTRING(10 10,10 11),LINESTRING(10 11,11 11),LINESTRING(11 11,10 10))");
488  out = lwgeom_stroke(in,8);
489  lwgeom_free(in);
490  in = out;
491  out = lwgeom_unstroke(in);
492  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
493  ASSERT_STRING_EQUAL(str, "GEOMETRYCOLLECTION(LINESTRING(10 10,10 11),LINESTRING(10 11,11 11),LINESTRING(11 11,10 10))");
494  lwgeom_free(in);
495  lwgeom_free(out);
496  lwfree(str);
497 
498  in = lwgeom_from_text("GEOMETRYCOLLECTION(LINESTRING(4 4,4 8),CIRCULARSTRING(4 8,6 10,8 8),LINESTRING(8 8,8 4))");
499  out = lwgeom_stroke(in,8);
500  lwgeom_free(in);
501  in = out;
502  out = lwgeom_unstroke(in);
503  str = lwgeom_to_wkt(out, WKT_ISO, 8, NULL);
504  // printf("%s\n", str);
505  ASSERT_STRING_EQUAL(str, "GEOMETRYCOLLECTION(LINESTRING(4 4,4 8),CIRCULARSTRING(4 8,6 10,8 8),LINESTRING(8 8,8 4))");
506  lwgeom_free(in);
507  lwgeom_free(out);
508  lwfree(str);
509 }
static LWGEOM * lwgeom_from_text(const char *str)
Definition: cu_lwstroke.c:26
#define ASSERT_STRING_EQUAL(o, e)
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
LWGEOM * lwgeom_unstroke(const LWGEOM *geom)
Definition: lwstroke.c:1168
LWGEOM * lwgeom_stroke(const LWGEOM *geom, uint32_t perQuad)
Definition: lwstroke.c:768
void lwfree(void *mem)
Definition: lwutil.c:244
#define WKT_ISO
Definition: liblwgeom.h:2075
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
Definition: lwout_wkt.c:676

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

Referenced by lwstroke_suite_setup().

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