PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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 128 of file measures.c.

129{
130 double x, y;
131 DISTPTS thedl;
132 double initdistance = FLT_MAX;
133 LWGEOM *result;
134
135 thedl.mode = mode;
136 thedl.distance = initdistance;
137 thedl.tolerance = 0;
138
139 LWDEBUG(2, "lw_dist2d_distancepoint is called");
140
141 if (!lw_dist2d_comp(lw1, lw2, &thedl))
142 {
143 /*should never get here. all cases ought to be error handled earlier*/
144 lwerror("Some unspecified error.");
145 result = (LWGEOM *)lwcollection_construct_empty(COLLECTIONTYPE, srid, 0, 0);
146 }
147 if (thedl.distance == initdistance)
148 {
149 LWDEBUG(3, "didn't find geometries to measure between, returning null");
150 result = (LWGEOM *)lwcollection_construct_empty(COLLECTIONTYPE, srid, 0, 0);
151 }
152 else
153 {
154 x = thedl.p1.x;
155 y = thedl.p1.y;
156 result = (LWGEOM *)lwpoint_make2d(srid, x, y);
157 }
158 return result;
159}
#define COLLECTIONTYPE
Definition liblwgeom.h:122
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)
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:83
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition lwutil.c:190
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:236
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:376
double x
Definition liblwgeom.h:376

References COLLECTIONTYPE, DISTPTS::distance, lw_dist2d_comp(), lwcollection_construct_empty(), LWDEBUG, lwerror(), lwpoint_make2d(), DISTPTS::mode, DISTPTS::p1, DISTPTS::tolerance, POINT2D::x, and POINT2D::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: