[postgis-tickets] r15756 - Trig length calculation for compoundcurve in 2.3 branch (references #3774)

Paul Ramsey pramsey at cleverelephant.ca
Mon Sep 18 06:27:42 PDT 2017


Author: pramsey
Date: 2017-09-18 06:27:42 -0700 (Mon, 18 Sep 2017)
New Revision: 15756

Modified:
   branches/2.3/liblwgeom/lwcompound.c
Log:
Trig length calculation for compoundcurve in 2.3 branch (references #3774)


Modified: branches/2.3/liblwgeom/lwcompound.c
===================================================================
--- branches/2.3/liblwgeom/lwcompound.c	2017-09-18 13:21:53 UTC (rev 15755)
+++ branches/2.3/liblwgeom/lwcompound.c	2017-09-18 13:27:42 UTC (rev 15756)
@@ -68,25 +68,20 @@
 
 double lwcompound_length(const LWCOMPOUND *comp)
 {
-	double length = 0.0;
-	LWLINE *line;
-	if ( lwgeom_is_empty((LWGEOM*)comp) )
-		return 0.0;
-	line = lwcompound_stroke(comp, 32);
-	length = lwline_length(line);
-	lwline_free(line);
-	return length;
+	return lwcompound_length_2d(comp);
 }
 
 double lwcompound_length_2d(const LWCOMPOUND *comp)
 {
+	int i;
 	double length = 0.0;
-	LWLINE *line;
 	if ( lwgeom_is_empty((LWGEOM*)comp) )
 		return 0.0;
-	line = lwcompound_stroke(comp, 32);
-	length = lwline_length_2d(line);
-	lwline_free(line);
+
+	for (i = 0; i < comp->ngeoms; i++)
+	{
+		length += lwgeom_length_2d(comp->geoms[i]);
+	}
 	return length;
 }
 



More information about the postgis-tickets mailing list