[postgis-tickets] r15757 - Trig length calculation for compound curve in 2.2 (references #3774)

Paul Ramsey pramsey at cleverelephant.ca
Mon Sep 18 06:28:25 PDT 2017


Author: pramsey
Date: 2017-09-18 06:28:25 -0700 (Mon, 18 Sep 2017)
New Revision: 15757

Modified:
   branches/2.2/liblwgeom/lwcompound.c
Log:
Trig length calculation for compound curve in 2.2 (references #3774)


Modified: branches/2.2/liblwgeom/lwcompound.c
===================================================================
--- branches/2.2/liblwgeom/lwcompound.c	2017-09-18 13:27:42 UTC (rev 15756)
+++ branches/2.2/liblwgeom/lwcompound.c	2017-09-18 13:28:25 UTC (rev 15757)
@@ -55,25 +55,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