PostGIS  2.1.10dev-r@@SVN_REVISION@@
Go to the documentation of this file.
2 /**********************************************************************
3  * $Id: measures.h 4715 2009-11-01 17:58:42Z nicklas $
4  *
5  * PostGIS - Spatial Types for PostgreSQL
6  *
7  * Copyright 2011 Nicklas Avén
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU General Public Licence. See the COPYING file.
11  *
12  **********************************************************************/
14 #include "liblwgeom_internal.h"
16 #define DOT(u,v) (u.x * v.x + u.y * v.y + u.z * v.z)
17 #define VECTORLENGTH(v) sqrt((v.x * v.x) + (v.y * v.y) + (v.z * v.z))
24 typedef struct
25 {
26  double distance; /*the distance between p1 and p2*/
29  int mode; /*the direction of looking, if thedir = -1 then we look for 3dmaxdistance and if it is 1 then we look for 3dmindistance*/
30  int twisted; /*To preserve the order of incoming points to match the first and second point in 3dshortest and 3dlongest line*/
31  double tolerance; /*the tolerance for 3ddwithin and 3ddfullywithin*/
34 typedef struct
35 {
36  double x,y,z;
37 }
40 typedef struct
41 {
42  POINT3DZ pop; /*Point On Plane*/
43  VECTOR3D pv; /*Perpendicular normal vector*/
44 }
48 /*
49 Preprocessing functions
50 */
52 int lw_dist3d_recursive(const LWGEOM *lwg1,const LWGEOM *lwg2, DISTPTS3D *dl);
53 int lw_dist3d_distribute_fast(LWGEOM *lwg1, LWGEOM *lwg2, DISTPTS3D *dl);
55 /*
56 Brute force functions
57 */
59 int lw_dist3d_point_point(LWPOINT *point1, LWPOINT *point2, DISTPTS3D *dl);
60 int lw_dist3d_point_line(LWPOINT *point, LWLINE *line, DISTPTS3D *dl);
61 int lw_dist3d_line_line(LWLINE *line1,LWLINE *line2 , DISTPTS3D *dl);
62 int lw_dist3d_point_poly(LWPOINT *point, LWPOLY *poly, DISTPTS3D *dl);
63 int lw_dist3d_line_poly(LWLINE *line, LWPOLY *poly, DISTPTS3D *dl);
64 int lw_dist3d_poly_poly(LWPOLY *poly1, LWPOLY *poly2, DISTPTS3D *dl);
69 int lw_dist3d_pt_poly(POINT3DZ *p, LWPOLY *poly, PLANE3D *plane,POINT3DZ *projp, DISTPTS3D *dl);
70 int lw_dist3d_ptarray_poly(POINTARRAY *pa, LWPOLY *poly, PLANE3D *plane, DISTPTS3D *dl);
74 double project_point_on_plane(POINT3DZ *p, PLANE3D *pl, POINT3DZ *p0);
75 int define_plane(POINTARRAY *pa, PLANE3D *pl);
76 int pt_in_ring_3d(const POINT3DZ *p, const POINTARRAY *ring,PLANE3D *plane);
77 /*
78 Helper functions
79 */
84 int
86 {
87  v->x=p2->x-p1->x;
88  v->y=p2->y-p1->y;
89  v->z=p2->z-p1->z;
91  return LW_TRUE;
92 }
94 int
96 {
97  v->x=(v1->y*v2->z)-(v1->z*v2->y);
98  v->y=(v1->z*v2->x)-(v1->x*v2->z);
99  v->z=(v1->x*v2->y)-(v1->y*v2->x);
101  return LW_TRUE;
102 }
double z
Definition: liblwgeom.h:290
double y
Definition: liblwgeom.h:290
double distance
Definition: measures3d.h:26
double x
Definition: liblwgeom.h:290
int lw_dist3d_line_poly(LWLINE *line, LWPOLY *poly, DISTPTS3D *dl)
line to polygon calculation
Definition: measures3d.c:460
double z
Definition: measures3d.h:36
Definition: measures3d.h:28
int lw_dist3d_pt_pt(POINT3DZ *p1, POINT3DZ *p2, DISTPTS3D *dl)
Compares incomming points and stores the points closest to each other or most far away from each othe...
Definition: measures3d.c:598
int lw_dist3d_poly_poly(LWPOLY *poly1, LWPOLY *poly2, DISTPTS3D *dl)
polygon to polygon calculation
Definition: measures3d.c:480
POINT2D * p1
Definition: lwtree.h:12
Definition: measures3d.h:43
Structure used in distance-calculations.
Definition: measures3d.h:24
double project_point_on_plane(POINT3DZ *p, PLANE3D *pl, POINT3DZ *p0)
Finds a point on a plane from where the original point is perpendicular to the plane.
Definition: measures3d.c:989
Definition: measures3d.h:27
double y
Definition: measures3d.h:36
int lw_dist3d_seg_seg(POINT3DZ *A, POINT3DZ *B, POINT3DZ *C, POINT3DZ *D, DISTPTS3D *dl)
Finds the two closest points on two linesegments.
Definition: measures3d.c:684
POINT2D * p2
Definition: lwtree.h:13
int lw_dist3d_distribute_fast(LWGEOM *lwg1, LWGEOM *lwg2, DISTPTS3D *dl)
int lw_dist3d_pt_poly(POINT3DZ *p, LWPOLY *poly, PLANE3D *plane, POINT3DZ *projp, DISTPTS3D *dl)
Checking if the point projected on the plane of the polygon actually is inside that polygon...
Definition: measures3d.c:806
int lw_dist3d_point_poly(LWPOINT *point, LWPOLY *poly, DISTPTS3D *dl)
Computes point to polygon distance For mindistance that means: 1)find the plane of the polygon 2)proj...
Definition: measures3d.c:417
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:51
int lw_dist3d_distribute_bruteforce(LWGEOM *lwg1, LWGEOM *lwg2, DISTPTS3D *dl)
This function distributes the brut-force for 3D so far the only type, tasks depending on type...
Definition: measures3d.c:275
int twisted
Definition: measures3d.h:30
int mode
Definition: measures3d.h:29
tuple x
Definition: measures3d.h:42
int lw_dist3d_recursive(const LWGEOM *lwg1, const LWGEOM *lwg2, DISTPTS3D *dl)
This is a recursive function delivering every possible combinatin of subgeometries.
Definition: measures3d.c:194
int lw_dist3d_point_line(LWPOINT *point, LWLINE *line, DISTPTS3D *dl)
point to line calculation
Definition: measures3d.c:395
int define_plane(POINTARRAY *pa, PLANE3D *pl)
Here we define the plane of a polygon (boundary pointarray of a polygon) the plane is stored as a pon...
Definition: measures3d.c:923
double tolerance
Definition: measures3d.h:31
int pt_in_ring_3d(const POINT3DZ *p, const POINTARRAY *ring, PLANE3D *plane)
pt_in_ring_3d(): crossing number test for a point in a polygon input: p = a point, pa = vertex points of a ring V[n+1] with V[n]=V[0] plane=the plane that the vertex points are lying on returns: 0 = outside, 1 = inside
Definition: measures3d.c:1027
int lw_dist3d_point_point(LWPOINT *point1, LWPOINT *point2, DISTPTS3D *dl)
point to point calculation
Definition: measures3d.c:379
int get_3dvector_from_points(POINT3DZ *p1, POINT3DZ *p2, VECTOR3D *v)
Definition: measures3d.h:85
int lw_dist3d_pt_seg(POINT3DZ *p, POINT3DZ *A, POINT3DZ *B, DISTPTS3D *dl)
If searching for min distance, this one finds the closest point on segment A-B from p...
Definition: measures3d.c:542
double x
Definition: measures3d.h:36
int lw_dist3d_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2, DISTPTS3D *dl)
Finds all combinationes of segments between two pointarrays.
Definition: measures3d.c:630
int lw_dist3d_line_line(LWLINE *line1, LWLINE *line2, DISTPTS3D *dl)
line to line calculation
Definition: measures3d.c:447
int get_3dcross_product(VECTOR3D *v1, VECTOR3D *v2, VECTOR3D *v)
Definition: measures3d.h:95
int lw_dist3d_pt_ptarray(POINT3DZ *p, POINTARRAY *pa, DISTPTS3D *dl)
search all the segments of pointarray to see which one is closest to p Returns distance between point...
Definition: measures3d.c:512
tuple y
int lw_dist3d_ptarray_poly(POINTARRAY *pa, LWPOLY *poly, PLANE3D *plane, DISTPTS3D *dl)
Computes pointarray to polygon distance.
Definition: measures3d.c:840