]> granicus.if.org Git - postgis/commitdiff
Allow signed distance for ST_Project (Darafei Praliaskouski)
authorRegina Obe <lr@pcorp.us>
Sun, 27 Aug 2017 15:17:39 +0000 (15:17 +0000)
committerRegina Obe <lr@pcorp.us>
Sun, 27 Aug 2017 15:17:39 +0000 (15:17 +0000)
Closes https://github.com/postgis/postgis/pull/138
Closes #3709

git-svn-id: http://svn.osgeo.org/postgis/trunk@15598 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
doc/reference_measure.xml
liblwgeom/lwgeodetic.c
regress/tickets.sql
regress/tickets_expected

diff --git a/NEWS b/NEWS
index 50d29b5c11ea1b8fecad8970563fbe2cf85fe7fe..5f36c701a23032f70981ca67aca8b132d1c77788 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ PostGIS 2.4.0
   - 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 *
 
index dbeb9566ac5aa40c55bfd5386e923ddca8d5fb6a..dcde1a9e08baeee5c29d3ad860fa7c892a0fd88a 100644 (file)
@@ -4344,6 +4344,7 @@ SELECT ST_AsEWKT(ST_PointOnSurface(ST_GeomFromEWKT('LINESTRING(0 5 1, 0 0 1, 0 1
                        <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>
 
index b48a90868ae851757ca2855bcd2f63896345ed98..e96b9584074ea5803c79c389e2da17c78e8ee558 100644 (file)
@@ -2009,18 +2009,20 @@ LWPOINT* lwgeom_project_spheroid(const LWPOINT *r, const SPHEROID *spheroid, dou
        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;
        }
                
index 61582dcfd748d764ee1e5453b1860f7efad41c76..fab5d78d8aed8b391313faedc1181e4f009dbd93 100644 (file)
@@ -1015,5 +1015,8 @@ SELECT '#3627b', ST_Equals(geom, ST_LineFromEncodedPolyline(ST_AsEncodedPolyline
 -- #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;
index cbe200c62acb30f9b79e34a87849ba97a00a597b..4525030603cde8449466af1256f542989507febd 100644 (file)
@@ -302,3 +302,4 @@ ERROR:  invalid KML representation
 #3627a|o}~~|AdshNoSsBgd@eGoBlm@wKhj@~@?
 #3627b|t
 #3704|t
+#3709|t