PostGIS  2.2.8dev-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 117 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().

118 {
119  double x,y;
120  DISTPTS thedl;
121  double initdistance = FLT_MAX;
122  LWGEOM *result;
124  thedl.mode = mode;
125  thedl.distance= initdistance;
126  thedl.tolerance = 0;
128  LWDEBUG(2, "lw_dist2d_distancepoint is called");
130  if (!lw_dist2d_comp( lw1,lw2,&thedl))
131  {
132  /*should never get here. all cases ought to be error handled earlier*/
133  lwerror("Some unspecified error.");
134  result = (LWGEOM *)lwcollection_construct_empty(COLLECTIONTYPE, srid, 0, 0);
135  }
136  if (thedl.distance == initdistance)
137  {
138  LWDEBUG(3, "didn't find geometries to measure between, returning null");
139  result = (LWGEOM *)lwcollection_construct_empty(COLLECTIONTYPE, srid, 0, 0);
140  }
141  else
142  {
143  x=thedl.p1.x;
144  y=thedl.p1.y;
145  result = (LWGEOM *)lwpoint_make2d(srid, x, y);
146  }
147  return result;
148 }
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:231
LWPOINT * lwpoint_make2d(int srid, double x, double y)
Definition: lwpoint.c:132
int mode
Definition: measures.h:27
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
Definition: measures.h:25
double tolerance
Definition: measures.h:29
double x
Definition: liblwgeom.h:312
double y
Definition: liblwgeom.h:312
double distance
Definition: measures.h:24
Structure used in distance-calculations.
Definition: measures.h:22
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:81
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
Definition: liblwgeom.h:76
Here is the call graph for this function:
Here is the caller graph for this function: