PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lw_dist2d_distancepoint()

LWGEOM* lw_dist2d_distancepoint ( const LWGEOM lw1,
const LWGEOM lw2,
int  srid,
int  mode 

Function initializing closestpoint calculations.

Definition at line 131 of file measures.c.

References COLLECTIONTYPE, DISTPTS::distance, lw_dist2d_comp(), lwcollection_construct_empty(), LWDEBUG, lwerror(), lwpoint_make2d(), DISTPTS::mode, DISTPTS::p1, DISTPTS::tolerance, pixval::x, POINT2D::x, pixval::y, and POINT2D::y.

Referenced by lw_dist3d_distancepoint(), lwgeom_closest_point(), and lwgeom_furthest_point().

132 {
133  double x,y;
134  DISTPTS thedl;
135  double initdistance = FLT_MAX;
136  LWGEOM *result;
138  thedl.mode = mode;
139  thedl.distance= initdistance;
140  thedl.tolerance = 0;
142  LWDEBUG(2, "lw_dist2d_distancepoint is called");
144  if (!lw_dist2d_comp( lw1,lw2,&thedl))
145  {
146  /*should never get here. all cases ought to be error handled earlier*/
147  lwerror("Some unspecified error.");
148  result = (LWGEOM *)lwcollection_construct_empty(COLLECTIONTYPE, srid, 0, 0);
149  }
150  if (thedl.distance == initdistance)
151  {
152  LWDEBUG(3, "didn't find geometries to measure between, returning null");
153  result = (LWGEOM *)lwcollection_construct_empty(COLLECTIONTYPE, srid, 0, 0);
154  }
155  else
156  {
157  x=thedl.p1.x;
158  y=thedl.p1.y;
159  result = (LWGEOM *)lwpoint_make2d(srid, x, y);
160  }
161  return result;
162 }
int lw_dist2d_comp(const LWGEOM *lw1, const LWGEOM *lw2, DISTPTS *dl)
This function just deserializes geometries Bboxes is not checked here since it is the subgeometries b...
Definition: measures.c:245
LWPOINT * lwpoint_make2d(int srid, double x, double y)
Definition: lwpoint.c:163
int mode
Definition: measures.h:54
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
Definition: measures.h:52
double tolerance
Definition: measures.h:56
double x
Definition: liblwgeom.h:328
double y
Definition: liblwgeom.h:328
double distance
Definition: measures.h:51
Structure used in distance-calculations.
Definition: measures.h:49
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:94
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
Definition: liblwgeom.h:91
Here is the call graph for this function:
Here is the caller graph for this function: