PostGIS  2.1.10dev-r@@SVN_REVISION@@
LWGEOM* lw_dist3d_distanceline ( LWGEOM lw1,
LWGEOM lw2,
int  srid,
int  mode 
)

Function initializing 3dshortestline and 3dlongestline calculations.

Definition at line 30 of file measures3d.c.

References COLLECTIONTYPE, DIST_MIN, DISTPTS3D::distance, lw_dist3d_recursive(), lwcollection_construct_empty(), LWDEBUG, lwerror(), lwline_from_ptarray(), lwpoint_make3dz(), MAXFLOAT, DISTPTS3D::mode, DISTPTS3D::p1, DISTPTS3D::p2, result, DISTPTS3D::tolerance, POINT3DZ::x, POINT3DZ::y, and POINT3DZ::z.

Referenced by LWGEOM_longestline3d(), and LWGEOM_shortestline3d().

31 {
32  double x1,x2,y1,y2, z1, z2;
33  double initdistance = ( mode == DIST_MIN ? MAXFLOAT : -1.0);
34  DISTPTS3D thedl;
35  LWPOINT *lwpoints[2];
36  LWGEOM *result;
37 
38  thedl.mode = mode;
39  thedl.distance = initdistance;
40  thedl.tolerance = 0.0;
41 
42  LWDEBUG(2, "lw_dist3d_distanceline is called");
43  if (!lw_dist3d_recursive(lw1, lw2, &thedl))
44  {
45  /*should never get here. all cases ought to be error handled earlier*/
46  lwerror("Some unspecified error.");
47  result = (LWGEOM *)lwcollection_construct_empty(COLLECTIONTYPE, srid, 0, 0);
48  }
49 
50  /*if thedl.distance is unchanged there where only empty geometries input*/
51  if (thedl.distance == initdistance)
52  {
53  LWDEBUG(3, "didn't find geometries to measure between, returning null");
54  result = (LWGEOM *)lwcollection_construct_empty(COLLECTIONTYPE, srid, 0, 0);
55  }
56  else
57  {
58  x1=thedl.p1.x;
59  y1=thedl.p1.y;
60  z1=thedl.p1.z;
61  x2=thedl.p2.x;
62  y2=thedl.p2.y;
63  z2=thedl.p2.z;
64 
65 
66  lwpoints[0] = lwpoint_make3dz(srid, x1, y1, z1);
67  lwpoints[1] = lwpoint_make3dz(srid, x2, y2, z2);
68 
69  result = (LWGEOM *)lwline_from_ptarray(srid, 2, lwpoints);
70  }
71 
72  return result;
73 }
double z
Definition: liblwgeom.h:290
double y
Definition: liblwgeom.h:290
double distance
Definition: measures3d.h:26
double x
Definition: liblwgeom.h:290
POINT3DZ p2
Definition: measures3d.h:28
#define DIST_MIN
LWLINE * lwline_from_ptarray(int srid, uint32_t npoints, LWPOINT **points)
Definition: lwline.c:213
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
Structure used in distance-calculations.
Definition: measures3d.h:24
char ** result
Definition: liblwgeom.h:218
POINT3DZ p1
Definition: measures3d.h:27
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
LWPOINT * lwpoint_make3dz(int srid, double x, double y, double z)
Definition: lwpoint.c:140
int mode
Definition: measures3d.h:29
int lw_dist3d_recursive(const LWGEOM *lwg1, const LWGEOM *lwg2, DISTPTS3D *dl)
This is a recursive function delivering every possible combinatin of subgeometries.
Definition: measures3d.c:194
double tolerance
Definition: measures3d.h:31
#define MAXFLOAT
Largest float value.
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:81
#define COLLECTIONTYPE
Definition: liblwgeom.h:66

Here is the call graph for this function:

Here is the caller graph for this function: