]> granicus.if.org Git - postgis/commitdiff
Stop curves at the door when entering 3D distance calc. #3253
authorNicklas Avén <nicklas.aven@jordogskog.no>
Fri, 21 Aug 2015 19:17:47 +0000 (19:17 +0000)
committerNicklas Avén <nicklas.aven@jordogskog.no>
Fri, 21 Aug 2015 19:17:47 +0000 (19:17 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@13970 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/measures3d.c

index a8e1897a6f3264348df8ac9299e29ed4d8efc942..873e07875cb58848b172ad230c8031d03ebf4529 100644 (file)
@@ -37,6 +37,19 @@ get_3dcross_product(VECTOR3D *v1,VECTOR3D *v2, VECTOR3D *v)
        return LW_TRUE;
 }
 
+/**
+Used for check compability before sending control to 2D calculations
+in case of mixed dimmentionality*/
+static inline int
+supported_type(const LWGEOM *lwg)
+{
+       int     t = lwg->type;
+       if(t==POINTTYPE || t==LINETYPE || t==POLYGONTYPE)
+               return LW_TRUE;
+       else
+               return LW_FALSE;
+}
+
 /**
 This function is used to create a vertical line used for cases where one if the 
 geometries lacks z-values. The vertical line crosses the 2d point that is closest 
@@ -100,6 +113,11 @@ lw_dist3d_distanceline(const LWGEOM *lw1, const LWGEOM *lw2, int srid, int mode)
        /*as an infinite z-value at one or two of the geometries*/
        if(!lwgeom_has_z(lw1) || !lwgeom_has_z(lw2))
        {
+               if(!supported_type(lw1))
+                       lwerror("Unsupported geometry type: %s", lwtype_name(lw1->type));
+               if(!supported_type(lw2))
+                       lwerror("Unsupported geometry type: %s", lwtype_name(lw2->type));
+               
                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(lw1) && !lwgeom_has_z(lw2))
@@ -204,6 +222,11 @@ lw_dist3d_distancepoint(const LWGEOM *lw1, const LWGEOM *lw2, int srid, int mode
        /*as an infinite z-value at one or two of the geometries*/
        if(!lwgeom_has_z(lw1) || !lwgeom_has_z(lw2))
        {
+               if(!supported_type(lw1))
+                       lwerror("Unsupported geometry type: %s", lwtype_name(lw1->type));
+               if(!supported_type(lw2))
+                       lwerror("Unsupported geometry type: %s", lwtype_name(lw2->type));
+               
                lwnotice("One or both of the geometries is missing z-value. The unknown z-value will be regarded as \"any value\"");
                
                
@@ -302,6 +325,11 @@ lwgeom_maxdistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tole
 {
        if(!lwgeom_has_z(lw1) || !lwgeom_has_z(lw2))
        {
+               if(!supported_type(lw1))
+                       lwerror("Unsupported geometry type: %s", lwtype_name(lw1->type));
+               if(!supported_type(lw2))
+                       lwerror("Unsupported geometry type: %s", lwtype_name(lw2->type));
+               
                lwnotice("One or both of the geometries is missing z-value. The unknown z-value will be regarded as \"any value\"");
                return lwgeom_maxdistance2d_tolerance(lw1, lw2, tolerance);     
        }
@@ -339,6 +367,11 @@ lwgeom_mindistance3d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tole
 {
        if(!lwgeom_has_z(lw1) || !lwgeom_has_z(lw2))
        {
+               if(!supported_type(lw1))
+                       lwerror("Unsupported geometry type: %s", lwtype_name(lw1->type));
+               if(!supported_type(lw2))
+                       lwerror("Unsupported geometry type: %s", lwtype_name(lw2->type));
+
                lwnotice("One or both of the geometries is missing z-value. The unknown z-value will be regarded as \"any value\"");
                return lwgeom_mindistance2d_tolerance(lw1, lw2, tolerance);     
        }