PostGIS  3.6.1dev-r@@SVN_REVISION@@

◆ lw_dist2d_distancepoint()

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

Function initializing closestpoint calculations.

Definition at line 143 of file measures.c.

144 {
145  double x, y;
146  DISTPTS thedl;
147  double initdistance = FLT_MAX;
148  LWGEOM *result;
149 
150  thedl.mode = mode;
151  thedl.distance = initdistance;
152  thedl.tolerance = 0;
153 
154  LWDEBUG(2, "lw_dist2d_distancepoint is called");
155 
156  if (!lw_dist2d_comp(lw1, lw2, &thedl))
157  {
158  /*should never get here. all cases ought to be error handled earlier*/
159  lwerror("Some unspecified error.");
161  }
162  if (thedl.distance == initdistance)
163  {
164  LWDEBUG(3, "didn't find geometries to measure between, returning null");
166  }
167  else
168  {
169  x = thedl.p1.x;
170  y = thedl.p1.y;
171  result = (LWGEOM *)lwpoint_make2d(srid, x, y);
172  }
173  return result;
174 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:267
#define COLLECTIONTYPE
Definition: liblwgeom.h:108
LWPOINT * lwpoint_make2d(int32_t srid, double x, double y)
Definition: lwpoint.c:163
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
Definition: lwcollection.c:92
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:101
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
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:251
POINT2D p1
Definition: measures.h:52
double tolerance
Definition: measures.h:56
int mode
Definition: measures.h:54
double distance
Definition: measures.h:51
Structure used in distance-calculations.
Definition: measures.h:50
double y
Definition: liblwgeom.h:390
double x
Definition: liblwgeom.h:390

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

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

Here is the call graph for this function:
Here is the caller graph for this function: