PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ test_unstroke()

static void test_unstroke ( )
static

Definition at line 374 of file cu_lwstroke.c.

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

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

Referenced by lwstroke_suite_setup().

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