[postgis-tickets] r17559 - Improve output of lwgeom_summary

Sandro Santilli strk at kbt.io
Wed Jun 26 01:04:14 PDT 2019


Author: strk
Date: 2019-06-26 01:04:14 -0700 (Wed, 26 Jun 2019)
New Revision: 17559

Modified:
   trunk/liblwgeom/lwgeom_debug.c
   trunk/regress/core/lwgeom_regress_expected
   trunk/regress/core/summary_expected
   trunk/regress/core/tickets_expected
Log:
Improve output of lwgeom_summary

- Do not print a useless newline
- Use plural/singular correctly
- Prepend a colon to elements listing

Modified: trunk/liblwgeom/lwgeom_debug.c
===================================================================
--- trunk/liblwgeom/lwgeom_debug.c	2019-06-25 21:51:46 UTC (rev 17558)
+++ trunk/liblwgeom/lwgeom_debug.c	2019-06-26 08:04:14 UTC (rev 17559)
@@ -98,10 +98,13 @@
 
 	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; i<col->ngeoms; i++)
 	{
@@ -136,10 +139,13 @@
 
 	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; i<poly->nrings; i++)
 	{

Modified: trunk/regress/core/lwgeom_regress_expected
===================================================================
--- trunk/regress/core/lwgeom_regress_expected	2019-06-25 21:51:46 UTC (rev 17558)
+++ trunk/regress/core/lwgeom_regress_expected	2019-06-26 08:04:14 UTC (rev 17559)
@@ -7,15 +7,15 @@
 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)

Modified: trunk/regress/core/summary_expected
===================================================================
--- trunk/regress/core/summary_expected	2019-06-25 21:51:46 UTC (rev 17558)
+++ trunk/regress/core/summary_expected	2019-06-26 08:04:14 UTC (rev 17559)
@@ -6,19 +6,19 @@
 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]

Modified: trunk/regress/core/tickets_expected
===================================================================
--- trunk/regress/core/tickets_expected	2019-06-25 21:51:46 UTC (rev 17558)
+++ trunk/regress/core/tickets_expected	2019-06-26 08:04:14 UTC (rev 17559)
@@ -237,15 +237,15 @@
 #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)))



More information about the postgis-tickets mailing list