From 60b2efd7033b0c27f2b2f95b85204b9ff7c54f5d Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 26 Jun 2019 08:04:14 +0000 Subject: [PATCH] Improve output of lwgeom_summary - Do not print a useless newline - Use plural/singular correctly - Prepend a colon to elements listing git-svn-id: http://svn.osgeo.org/postgis/trunk@17559 b70326c6-7e19-0410-871a-916f4a2858ee --- liblwgeom/lwgeom_debug.c | 14 ++++++++++---- regress/core/lwgeom_regress_expected | 8 ++++---- regress/core/summary_expected | 16 ++++++++-------- regress/core/tickets_expected | 12 ++++++------ 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/liblwgeom/lwgeom_debug.c b/liblwgeom/lwgeom_debug.c index 0fb9bf718..e3d7b3a6e 100644 --- a/liblwgeom/lwgeom_debug.c +++ b/liblwgeom/lwgeom_debug.c @@ -98,10 +98,13 @@ lwcollection_summary(LWCOLLECTION *col, int offset) result = (char *)lwalloc(size); - sprintf(result, "%*.s%s[%s] with %d elements\n", + sprintf(result, "%*.s%s[%s] with %d element%s", offset, pad, lwtype_name(col->type), zmflags, - col->ngeoms); + col->ngeoms, + col->ngeoms ? + ( col->ngeoms > 1 ? "s:\n" : ":\n") + : "s"); for (i=0; ingeoms; i++) { @@ -136,10 +139,13 @@ lwpoly_summary(LWPOLY *poly, int offset) result = (char *)lwalloc(size); - sprintf(result, "%*.s%s[%s] with %i rings\n", + sprintf(result, "%*.s%s[%s] with %i ring%s", offset, pad, lwtype_name(poly->type), zmflags, - poly->nrings); + poly->nrings, + poly->nrings ? + ( poly->nrings > 1 ? "s:\n" : ":\n") + : "s"); for (i=0; inrings; i++) { diff --git a/regress/core/lwgeom_regress_expected b/regress/core/lwgeom_regress_expected index 17d0348ca..696bbb0da 100644 --- a/regress/core/lwgeom_regress_expected +++ b/regress/core/lwgeom_regress_expected @@ -7,15 +7,15 @@ BOX3D(0 0.1 -55,11 12 12) 11184 #3069|Point[S] #3069|LineString[S] with 2 points -#3069|MultiPoint[S] with 1 elements Point[S] -#3069|MultiLineString[S] with 1 elements LineString[S] with 2 points -#3069|Polygon[BS] with 1 rings ring 0 has 5 points +#3069|MultiPoint[S] with 1 element: Point[S] +#3069|MultiLineString[S] with 1 element: LineString[S] with 2 points +#3069|Polygon[BS] with 1 ring: ring 0 has 5 points #3069|BOX(1 1,1 1) #3069|BOX(0 0,1 1) #3069|BOX(0 0,1 1) #3069|BOX(1 1,1 1) #3069|BOX(0 0,1 1) -#2902|GeometryCollection[ZBS] with 3 elements Polygon[ZS] with 1 rings ring 0 has 5 points Point[ZS] MultiLineString[ZS] with 1 elements LineString[ZS] with 2 points +#2902|GeometryCollection[ZBS] with 3 elements: Polygon[ZS] with 1 ring: ring 0 has 5 points Point[ZS] MultiLineString[ZS] with 1 element: LineString[ZS] with 2 points BoundingDiagonal1|SRID=4326;LINESTRING(999999986991104 999999986991104,1e+15 1e+15) BoundingDiagonal2|SRID=4326;LINESTRING(1e+15 1e+15,1e+15 1e+15) BoundingDiagonal3|SRID=4326;LINESTRING(999999986991104 999999986991104,1e+15 1e+15) diff --git a/regress/core/summary_expected b/regress/core/summary_expected index 005f29f4d..595fbd56f 100644 --- a/regress/core/summary_expected +++ b/regress/core/summary_expected @@ -6,19 +6,19 @@ T1Z|Point[Z] T1ZM|Point[ZM] T1ZMB|Point[ZMB] T1ZMBS|Point[ZMBS] -T3|MultiPoint[] with 1 elements +T3|MultiPoint[] with 1 element: Point[] -T4|MultiPoint[S] with 1 elements +T4|MultiPoint[S] with 1 element: Point[S] -T5|GeometryCollection[B] with 2 elements - MultiLineString[] with 2 elements +T5|GeometryCollection[B] with 2 elements: + MultiLineString[] with 2 elements: LineString[] with 2 points LineString[] with 2 points - MultiPoint[] with 1 elements + MultiPoint[] with 1 element: Point[] -T6|GeometryCollection[BS] with 2 elements - MultiLineString[S] with 2 elements +T6|GeometryCollection[BS] with 2 elements: + MultiLineString[S] with 2 elements: LineString[S] with 2 points LineString[S] with 2 points - MultiPoint[S] with 1 elements + MultiPoint[S] with 1 element: Point[S] diff --git a/regress/core/tickets_expected b/regress/core/tickets_expected index 4b723b90c..0c94a308c 100644 --- a/regress/core/tickets_expected +++ b/regress/core/tickets_expected @@ -237,15 +237,15 @@ ERROR: invalid GML representation #2145|6792004 #2232|M 0 0 l 0 0 1 0 0 0 1 0 0 0 #2307|MULTIPOLYGON(((-41.1932 -7.3257,-41.1616 -7.3257,-41.1569 -7.3257,-41.1569 -7.3483,-41.1932 -7.3483,-41.1932 -7.3257),(-41.1616 -7.3257,-41.1879 -7.3257,-41.1879 -7.3425,-41.1616 -7.3425,-41.1616 -7.3257))) -#2409|GeometryCollection[B] with 2 elements - MultiSurface[] with 2 elements - Polygon[] with 1 rings +#2409|GeometryCollection[B] with 2 elements: + MultiSurface[] with 2 elements: + Polygon[] with 1 ring: ring 0 has 5 points - CurvePolygon[] with 1 elements - CompoundCurve[] with 2 elements + CurvePolygon[] with 1 element: + CompoundCurve[] with 2 elements: LineString[] with 5 points CircularString[] with 5 points - Tin[] with 1 elements + Tin[] with 1 element: Triangle[] with 4 points #2415.1|MULTICURVE(COMPOUNDCURVE((0 0,10 0),CIRCULARSTRING(10 0,15 1,20 10))) #2415.2|MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(10 0,15 1,20 0,18 5,20 10,10 10,10 0))) -- 2.40.0