]> granicus.if.org Git - postgis/commitdiff
Fix wrong behavior for closest point with unknown z-value in geometry 1 from last...
authorNicklas Avén <nicklas.aven@jordogskog.no>
Tue, 14 Jul 2015 16:14:49 +0000 (16:14 +0000)
committerNicklas Avén <nicklas.aven@jordogskog.no>
Tue, 14 Jul 2015 16:14:49 +0000 (16:14 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13803 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/measures3d.c
regress/measures_expected

index 6878e7475e71c85f75d1d5ee3cbc8334ab1f5ef4..c4d04fa20e5b543cc800a71ea44f610915421c7f 100644 (file)
@@ -188,7 +188,7 @@ lw_dist3d_distancepoint(const LWGEOM *lw1, const LWGEOM *lw2, int srid, int mode
                lwnotice("One or both of the geometries is missing z-value. The unknown z-value will be regarded as 'any value'");
                
                
-               if(!lwgeom_has_z(lw2))
+               if(!lwgeom_has_z(lw1) && !lwgeom_has_z(lw2))
                        return lw_dist2d_distancepoint(lw1, lw2, srid, mode);
                        
                
@@ -221,6 +221,25 @@ lw_dist3d_distancepoint(const LWGEOM *lw1, const LWGEOM *lw2, int srid, int mode
                                result = (LWGEOM *)lwcollection_construct_empty(COLLECTIONTYPE, srid, 0, 0);
                        }                       
                }       
+                               
+               if(!lwgeom_has_z(lw2))
+               {
+                       LWPOINT *lwpoints[2];
+                       LWGEOM *new_lw2;
+                       x=thedl2d.p2.x;
+                       y=thedl2d.p2.y;
+
+                       lwpoints[0] = lwpoint_make3dz(srid, x, y, FLT_MIN);
+                       lwpoints[1] = lwpoint_make3dz(srid, x, y, FLT_MAX);
+                       
+                       new_lw2 = (LWGEOM *)lwline_from_ptarray(srid, 2, lwpoints);             
+                       if (!lw_dist3d_recursive(lw1, new_lw2, &thedl))
+                       {
+                               /*should never get here. all cases ought to be error handled earlier*/
+                               lwerror("Some unspecified error.");
+                               result = (LWGEOM *)lwcollection_construct_empty(COLLECTIONTYPE, srid, 0, 0);
+                       }                       
+               }       
                
        }
        else
index 352a8f7d2180139660fa1c287d4c560204b9a1c0..c43f4ab027c69ac52a8efe48dd2f9e5700540f9c 100644 (file)
@@ -38,7 +38,7 @@ distancepoly6|0|32.5269119345812|LINESTRING(2 2,2 2)|LINESTRING(2 2,2 2)|LINESTR
 NOTICE:  One or both of the geometries is missing z-value. The unknown z-value will be regarded as 'any value'
 POINT Z (1 1 3)
 NOTICE:  One or both of the geometries is missing z-value. The unknown z-value will be regarded as 'any value'
-POINT(1 1)
+POINT Z (1 1 2)
 NOTICE:  One or both of the geometries is missing z-value. The unknown z-value will be regarded as 'any value'
 LINESTRING Z (1 1 3,1 2 3)
 NOTICE:  One or both of the geometries is missing z-value. The unknown z-value will be regarded as 'any value'