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

Function initializing closestpoint calculations.

Definition at line 91 of file measures.c.

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

Referenced by LWGEOM_closestpoint().

92 {
93  double x,y;
94  DISTPTS thedl;
95  double initdistance = MAXFLOAT;
96  LWGEOM *result;
97 
98  thedl.mode = mode;
99  thedl.distance= initdistance;
100  thedl.tolerance = 0;
101 
102  LWDEBUG(2, "lw_dist2d_distancepoint is called");
103 
104  if (!lw_dist2d_comp( lw1,lw2,&thedl))
105  {
106  /*should never get here. all cases ought to be error handled earlier*/
107  lwerror("Some unspecified error.");
108  result = (LWGEOM *)lwcollection_construct_empty(COLLECTIONTYPE, srid, 0, 0);
109  }
110  if (thedl.distance == initdistance)
111  {
112  LWDEBUG(3, "didn't find geometries to measure between, returning null");
113  result = (LWGEOM *)lwcollection_construct_empty(COLLECTIONTYPE, srid, 0, 0);
114  }
115  else
116  {
117  x=thedl.p1.x;
118  y=thedl.p1.y;
119  result = (LWGEOM *)lwpoint_make2d(srid, x, y);
120  }
121  return result;
122 }
int lw_dist2d_comp(LWGEOM *lw1, LWGEOM *lw2, DISTPTS *dl)
This function just deserializes geometries Bboxes is not checked here since it is the subgeometries b...
Definition: measures.c:205
LWPOINT * lwpoint_make2d(int srid, double x, double y)
Definition: lwpoint.c:130
int mode
Definition: measures.h:26
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
char ** result
Definition: liblwgeom.h:218
POINT2D p1
Definition: measures.h:24
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
double tolerance
Definition: measures.h:28
double x
Definition: liblwgeom.h:284
double y
Definition: liblwgeom.h:284
tuple x
Definition: pixval.py:53
double distance
Definition: measures.h:23
#define MAXFLOAT
Largest float value.
Structure used in distance-calculations.
Definition: measures.h:21
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:81
tuple y
Definition: pixval.py:54
#define COLLECTIONTYPE
Definition: liblwgeom.h:66

Here is the call graph for this function:

Here is the caller graph for this function: