[postgis-tickets] r15598 - Allow signed distance for ST_Project (Darafei Praliaskouski)

Regina Obe lr at pcorp.us
Sun Aug 27 08:17:40 PDT 2017


Author: robe
Date: 2017-08-27 08:17:39 -0700 (Sun, 27 Aug 2017)
New Revision: 15598

Modified:
   trunk/NEWS
   trunk/doc/reference_measure.xml
   trunk/liblwgeom/lwgeodetic.c
   trunk/regress/tickets.sql
   trunk/regress/tickets_expected
Log:
Allow signed distance for ST_Project (Darafei Praliaskouski)
Closes https://github.com/postgis/postgis/pull/138
Closes #3709

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2017-08-27 07:02:10 UTC (rev 15597)
+++ trunk/NEWS	2017-08-27 15:17:39 UTC (rev 15598)
@@ -18,6 +18,7 @@
   - Most aggregates (raster and geometry),
     and all stable / immutable (raster and geometry) marked as parallel safe
   - #2249, ST_MakeEmptyCoverage for raster (David Zwarg, ainomieli)
+  - #3709, Allow signed distance for ST_Project (Darafei Praliaskouski)
 
 * Enhancements *
 

Modified: trunk/doc/reference_measure.xml
===================================================================
--- trunk/doc/reference_measure.xml	2017-08-27 07:02:10 UTC (rev 15597)
+++ trunk/doc/reference_measure.xml	2017-08-27 15:17:39 UTC (rev 15598)
@@ -4344,6 +4344,7 @@
 			<para>The distance is given in meters.</para>
 
 			<para>Availability: 2.0.0</para>
+			<para>Enhanced: 2.4.0 Allow negative distance and non-normalized azimuth.</para>
 
 		  </refsection>
 

Modified: trunk/liblwgeom/lwgeodetic.c
===================================================================
--- trunk/liblwgeom/lwgeodetic.c	2017-08-27 07:02:10 UTC (rev 15597)
+++ trunk/liblwgeom/lwgeodetic.c	2017-08-27 15:17:39 UTC (rev 15598)
@@ -2009,18 +2009,20 @@
 	double x, y;
 	POINTARRAY *pa;
 	LWPOINT *lwp;
-
-	/* Check the azimuth validity, convert to radians */
-	if ( azimuth < -2.0 * M_PI || azimuth > 2.0 * M_PI )
-	{
-		lwerror("Azimuth must be between -2PI and 2PI");
-		return NULL;
+	
+	/* Normalize distance to be positive*/
+	if ( distance < 0.0 ) {
+		distance = -distance;
+		azimuth += M_PI;
 	}
+	
+	/* Normalize azimuth */
+	azimuth -= 2.0 * M_PI * floor(azimuth / (2.0 * M_PI));
 
 	/* Check the distance validity */
-	if ( distance < 0.0 || distance > (M_PI * spheroid->radius) )
+	if ( distance > (M_PI * spheroid->radius) )
 	{
-		lwerror("Distance must be between 0 and %g", M_PI * spheroid->radius);
+		lwerror("Distance must not be greater than %g", M_PI * spheroid->radius);
 		return NULL;
 	}
 		

Modified: trunk/regress/tickets.sql
===================================================================
--- trunk/regress/tickets.sql	2017-08-27 07:02:10 UTC (rev 15597)
+++ trunk/regress/tickets.sql	2017-08-27 15:17:39 UTC (rev 15598)
@@ -1015,5 +1015,8 @@
 -- #3704
 SELECT '#3704', ST_AsX3D('LINESTRING EMPTY') = '';
 
+-- #3709
+select '#3709', ST_SnapToGrid(ST_Project('SRID=4326;POINT(1 1)'::geography, 100000, 20)::geometry, 0.0001) = ST_SnapToGrid(ST_Project('SRID=4326;POINT(1 1)'::geography, -100000, 20+pi())::geometry, 0.0001);
+
 -- Clean up
 DELETE FROM spatial_ref_sys;

Modified: trunk/regress/tickets_expected
===================================================================
--- trunk/regress/tickets_expected	2017-08-27 07:02:10 UTC (rev 15597)
+++ trunk/regress/tickets_expected	2017-08-27 15:17:39 UTC (rev 15598)
@@ -302,3 +302,4 @@
 #3627a|o}~~|AdshNoSsBgd at eGoBlm@wKhj@~@?
 #3627b|t
 #3704|t
+#3709|t



More information about the postgis-tickets mailing list