*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.24 1997/09/18 20:22:13 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.25 1997/09/20 16:22:31 thomas Exp $
*
*-------------------------------------------------------------------------
*/
#define PI 3.1415926536
#endif
+/*
+ * Internal routines
+ */
+
static int point_inside(Point *p, int npts, Point plist[]);
static int lseg_crossing(double x, double y, double px, double py);
static BOX *box_construct(double x1, double x2, double y1, double y2);
* "(f8, f8), (f8, f8)"
* also supports the older style "(f8, f8, f8, f8)"
*/
-BOX *
+BOX *
box_in(char *str)
{
BOX *box = PALLOCTYPE(BOX);
/* box_out - convert a box to external form.
*/
-char *
+char *
box_out(BOX *box)
{
if (!PointerIsValid(box))
/* box_area - returns the area of the box.
*/
-double *
+double *
box_area(BOX *box)
{
double *result = PALLOCTYPE(double);
/* box_width - returns the width of the box
* (horizontal magnitude).
*/
-double *
+double *
box_width(BOX *box)
{
double *result = PALLOCTYPE(double);
/* box_height - returns the height of the box
* (vertical magnitude).
*/
-double *
+double *
box_height(BOX *box)
{
double *result = PALLOCTYPE(double);
/* box_distance - returns the distance between the
* center points of two boxes.
*/
-double *
+double *
box_distance(BOX *box1, BOX *box2)
{
double *result = PALLOCTYPE(double);
/* box_center - returns the center point of the box.
*/
-Point *
+Point *
box_center(BOX *box)
{
Point *result = PALLOCTYPE(Point);
* returns the overlapping portion of two boxes,
* or NULL if they do not intersect.
*/
-BOX *
+BOX *
box_intersect(BOX *box1, BOX *box2)
{
BOX *result;
* positive-slope diagonal of "box".
* provided, of course, we have LSEGs.
*/
-LSEG *
+LSEG *
box_diagonal(BOX *box)
{
Point p1,
* "(closed, npts, xcoord, ycoord,... )"
*---------------------------------------------------------*/
-PATH *
+PATH *
path_in(char *str)
{
PATH *path;
} /* path_in() */
-char *
+char *
path_out(PATH *path)
{
if (!PointerIsValid(path))
return (path->npts);
} /* path_npoints() */
-PATH *
+PATH *
path_close(PATH *path)
{
PATH *result;
} /* path_close() */
-PATH *
+PATH *
path_open(PATH *path)
{
PATH *result;
} /* path_open() */
-PATH *
+PATH *
path_copy(PATH *path)
{
PATH *result;
/* this essentially does a cartesian product of the lsegs in the
two paths, and finds the min distance between any two lsegs */
-double *
+double *
path_distance(PATH *p1, PATH *p2)
{
double *min = NULL,
* "Arithmetic" operations.
*---------------------------------------------------------*/
-double *
+double *
path_length(PATH *path)
{
double *result;
* "x,y"
*---------------------------------------------------------*/
-Point *
+Point *
point_in(char *str)
{
Point *point;
return (point);
} /* point_in() */
-char *
+char *
point_out(Point *pt)
{
if (!PointerIsValid(pt))
return (point_horiz(pt1, pt2) && point_vert(pt1, pt2));
}
+bool
+point_ne(Point *pt1, Point *pt2)
+{
+ return (! point_eq(pt1, pt2));
+}
+
/*----------------------------------------------------------
* "Arithmetic" operators on points.
*---------------------------------------------------------*/
return (result);
}
-double *
+double *
point_distance(Point *pt1, Point *pt2)
{
double *result = PALLOCTYPE(double);
return (HYPOT(pt1->x - pt2->x, pt1->y - pt2->y));
}
-double *
+double *
point_slope(Point *pt1, Point *pt2)
{
double *result = PALLOCTYPE(double);
* (old form) "(x1, y1, x2, y2)"
*---------------------------------------------------------*/
-LSEG *
+LSEG *
lseg_in(char *str)
{
LSEG *lseg;
} /* lseg_in() */
-char *
+char *
lseg_out(LSEG *ls)
{
if (!PointerIsValid(ls))
/* lseg_construct -
* form a LSEG from two Points.
*/
-LSEG *
+LSEG *
lseg_construct(Point *pt1, Point *pt2)
{
LSEG *result = PALLOCTYPE(LSEG);
* point will be from one of the endpoints to the other
* segment.
*/
-double *
+double *
lseg_distance(LSEG *l1, LSEG *l2)
{
double *result = PALLOCTYPE(double);
} /* lseg_dt() */
-Point *
+Point *
lseg_center(LSEG *lseg)
{
Point *result;
* endpoints since there may be rounding effects with annoying
* lsb residue. - tgl 1997-07-09
*/
-Point *
+Point *
lseg_interpt(LSEG *l1, LSEG *l2)
{
Point *result;
* Minimum distance from one object to another.
*-------------------------------------------------------------------*/
-double *
+double *
dist_pl(Point *pt, LINE *line)
{
double *result = PALLOCTYPE(double);
return (result);
}
-double *
+double *
dist_ps(Point *pt, LSEG *lseg)
{
double m; /* slope of perp. */
/*
** Distance from a point to a path
*/
-double *
+double *
dist_ppath(Point *pt, PATH *path)
{
double *result;
return (result);
}
-double *
+double *
dist_pb(Point *pt, BOX *box)
{
Point *tmp;
}
-double *
+double *
dist_sl(LSEG *lseg, LINE *line)
{
double *result,
}
-double *
+double *
dist_sb(LSEG *lseg, BOX *box)
{
Point *tmp;
}
-double *
+double *
dist_lb(LINE *line, BOX *box)
{
Point *tmp;
}
-double *
+double *
dist_cpoly(CIRCLE *circle, POLYGON *poly)
{
double *result;
* The intersection point of a perpendicular of the line
* through the point.
*/
-Point *
+Point *
close_pl(Point *pt, LINE *line)
{
Point *result;
* above, or below the segment, otherwise find the intersection
* point of the segment and its perpendicular through the point.
*/
-Point *
+Point *
close_ps(Point *pt, LSEG *lseg)
{
Point *result;
return (result);
} /* close_ps() */
-Point *
+Point *
close_pb(Point *pt, BOX *box)
{
/* think about this one for a while */
return (NULL);
}
-Point *
+Point *
close_sl(LSEG *lseg, LINE *line)
{
Point *result;
return (result);
}
-Point *
+Point *
close_sb(LSEG *lseg, BOX *box)
{
/* think about this one for a while */
return (NULL);
}
-Point *
+Point *
close_lb(LINE *line, BOX *box)
{
/* think about this one for a while */
* "x0,y0,...,xn,yn"
* also supports the older style "(x1,...,xn,y1,...yn)"
*------------------------------------------------------------------*/
-POLYGON *
+POLYGON *
poly_in(char *str)
{
POLYGON *poly;
* character string format "((f8,f8),...,(f8,f8))"
* also support old format "(f8,f8,...,f8,f8)"
*---------------------------------------------------------------*/
-char *
+char *
poly_out(POLYGON *poly)
{
if (!PointerIsValid(poly))
}
return TRUE;
#endif
-} /* poly_same() */
+} /* poly_same() */
/*-----------------------------------------------------------------
* Determine if polygon A overlaps polygon B by determining if
} /* pt_contained_poly() */
-double *
+double *
poly_distance(POLYGON *polya, POLYGON *polyb)
{
double *result;
**
***********************************************************************/
-Point *
+Point *
point(float8 *x, float8 *y)
{
if (!(PointerIsValid(x) && PointerIsValid(y)))
} /* point() */
-Point *
+Point *
point_add(Point *p1, Point *p2)
{
Point *result;
return (result);
} /* point_add() */
-Point *
+Point *
point_sub(Point *p1, Point *p2)
{
Point *result;
return (result);
} /* point_sub() */
-Point *
+Point *
point_mul(Point *p1, Point *p2)
{
Point *result;
return (result);
} /* point_mul() */
-Point *
+Point *
point_div(Point *p1, Point *p2)
{
Point *result;
**
***********************************************************************/
-BOX *
+BOX *
box(Point *p1, Point *p2)
{
BOX *result;
return (result);
} /* box() */
-BOX *
+BOX *
box_add(BOX *box, Point *p)
{
BOX *result;
return (result);
} /* box_add() */
-BOX *
+BOX *
box_sub(BOX *box, Point *p)
{
BOX *result;
return (result);
} /* box_sub() */
-BOX *
+BOX *
box_mul(BOX *box, Point *p)
{
BOX *result;
return (result);
} /* box_mul() */
-BOX *
+BOX *
box_div(BOX *box, Point *p)
{
BOX *result;
/* path_add()
* Concatenate two paths (only if they are both open).
*/
-PATH *
+PATH *
path_add(PATH *p1, PATH *p2)
{
PATH *result;
/* path_add_pt()
* Translation operator.
*/
-PATH *
+PATH *
path_add_pt(PATH *path, Point *point)
{
PATH *result;
return (result);
} /* path_add_pt() */
-PATH *
+PATH *
path_sub_pt(PATH *path, Point *point)
{
PATH *result;
/* path_mul_pt()
* Rotation and scaling operators.
*/
-PATH *
+PATH *
path_mul_pt(PATH *path, Point *point)
{
PATH *result;
return (result);
} /* path_mul_pt() */
-PATH *
+PATH *
path_div_pt(PATH *path, Point *point)
{
PATH *result;
} /* pt_contained_path() */
-Point *
+Point *
path_center(PATH *path)
{
Point *result;
return (result);
} /* path_center() */
-POLYGON *
+POLYGON *
path_poly(PATH *path)
{
POLYGON *poly;
* New-style: '((x1,y1),...)' for closed path
* '[(x1,y1),...]' for open path
*/
-PATH
- *
+PATH *
upgradepath(PATH *path)
{
PATH *result;
} /* poly_npoints() */
-Point *
+Point *
poly_center(POLYGON *poly)
{
Point *result;
} /* poly_center() */
-BOX *
+BOX *
poly_box(POLYGON *poly)
{
BOX *box;
/* box_poly()
* Convert a box to a polygon.
*/
-POLYGON *
+POLYGON *
box_poly(BOX *box)
{
POLYGON *poly;
} /* box_poly() */
-PATH *
+PATH *
poly_path(POLYGON *poly)
{
PATH *path;
* Old-style: '(x1,x2,...,y1,y2,...)'
* New-style: '(x1,y1,x2,y2,...)'
*/
-POLYGON
- *
+POLYGON *
upgradepoly(POLYGON *poly)
{
POLYGON *result;
/* revertpoly()
* Reverse effect of upgradepoly().
*/
-POLYGON
- *
+POLYGON *
revertpoly(POLYGON *poly)
{
POLYGON *result;
* "((f8,f8)<f8>)"
* also supports quick entry style "(f8,f8,f8)"
*/
-CIRCLE *
+CIRCLE *
circle_in(char *str)
{
CIRCLE *circle;
/* circle_out - convert a circle to external form.
*/
-char *
+char *
circle_out(CIRCLE *circle)
{
char *result;
return (FPeq(circle1->radius, circle2->radius)
&& FPeq(circle1->center.x, circle2->center.x)
&& FPeq(circle1->center.y, circle2->center.y));
-}
+} /* circle_same() */
/* circle_overlap - does circle1 overlap circle2?
*/
/* circle_add_pt()
* Translation operator.
*/
-CIRCLE *
+CIRCLE *
circle_add_pt(CIRCLE *circle, Point *point)
{
CIRCLE *result;
return (result);
} /* circle_add_pt() */
-CIRCLE *
+CIRCLE *
circle_sub_pt(CIRCLE *circle, Point *point)
{
CIRCLE *result;
/* circle_mul_pt()
* Rotation and scaling operators.
*/
-CIRCLE *
+CIRCLE *
circle_mul_pt(CIRCLE *circle, Point *point)
{
CIRCLE *result;
return (result);
} /* circle_mul_pt() */
-CIRCLE *
+CIRCLE *
circle_div_pt(CIRCLE *circle, Point *point)
{
CIRCLE *result;
/* circle_area - returns the area of the circle.
*/
-double *
+double *
circle_area(CIRCLE *circle)
{
double *result;
/* circle_diameter - returns the diameter of the circle.
*/
-double *
+double *
circle_diameter(CIRCLE *circle)
{
double *result;
/* circle_radius - returns the radius of the circle.
*/
-double *
+double *
circle_radius(CIRCLE *circle)
{
double *result;
/* circle_distance - returns the distance between
* two circles.
*/
-double *
+double *
circle_distance(CIRCLE *circle1, CIRCLE *circle2)
{
double *result;
/* dist_pc - returns the distance between
* a point and a circle.
*/
-double *
+double *
dist_pc(Point *point, CIRCLE *circle)
{
double *result;
/* circle_center - returns the center point of the circle.
*/
-Point *
+Point *
circle_center(CIRCLE *circle)
{
Point *result;
* Conversion operators.
*---------------------------------------------------------*/
-CIRCLE *
+CIRCLE *
circle(Point *center, float8 *radius)
{
CIRCLE *result;
}
-BOX *
+BOX *
circle_box(CIRCLE *circle)
{
BOX *box;
/* box_circle()
* Convert a box to a circle.
*/
-CIRCLE *
+CIRCLE *
box_circle(BOX *box)
{
CIRCLE *circle;
} /* box_circle() */
-POLYGON *
+POLYGON *
circle_poly(int npts, CIRCLE *circle)
{
POLYGON *poly;
* XXX This algorithm should use weighted means of line segments
* rather than straight average values of points - tgl 97/01/21.
*/
-CIRCLE *
+CIRCLE *
poly_circle(POLYGON *poly)
{
CIRCLE *circle;
}
return (FALSE);
-} /* plist_same() */
+} /* plist_same() */