diff --git a/pgindent-excludes.list b/pgindent-excludes.list index c3add5c..629df90 100644 --- a/pgindent-excludes.list +++ b/pgindent-excludes.list @@ -1 +1,3 @@ pgs_process_moc.h +pgs_healpix.h +pgs_moc.h diff --git a/src/box.h b/src/box.h index 7314ac0..6444a52 100644 --- a/src/box.h +++ b/src/box.h @@ -11,8 +11,8 @@ */ typedef struct { - SPoint sw; /* South-west value of a box */ - SPoint ne; /* North-east value of a box */ + SPoint sw; /* South-west value of a box */ + SPoint ne; /* North-east value of a box */ } SBOX; @@ -56,373 +56,373 @@ typedef struct /* * Checks whether two boxes are equal. */ -bool sbox_eq(SBOX *b1, SBOX *b2); +extern bool sbox_eq(SBOX *b1, SBOX *b2); /* * Checks whether a point is contained by a box. */ -bool sbox_cont_point(const SBOX *b, const SPoint *p); +extern bool sbox_cont_point(const SBOX *b, const SPoint *p); /* * Input function of a box. */ -Datum spherebox_in(PG_FUNCTION_ARGS); +extern Datum spherebox_in(PG_FUNCTION_ARGS); /* * Input function of a box from two points. The first point * is the south-west position, the second the north-east position. */ -Datum spherebox_in_from_points(PG_FUNCTION_ARGS); +extern Datum spherebox_in_from_points(PG_FUNCTION_ARGS); /* * Returns the south-west edge of a box. */ -Datum spherebox_sw(PG_FUNCTION_ARGS); +extern Datum spherebox_sw(PG_FUNCTION_ARGS); /* * Returns the north-east edge of a box. */ -Datum spherebox_ne(PG_FUNCTION_ARGS); +extern Datum spherebox_ne(PG_FUNCTION_ARGS); /* * Returns the south-east edge of a box. */ -Datum spherebox_se(PG_FUNCTION_ARGS); +extern Datum spherebox_se(PG_FUNCTION_ARGS); /* * Returns the north-west edge of a box. */ -Datum spherebox_nw(PG_FUNCTION_ARGS); +extern Datum spherebox_nw(PG_FUNCTION_ARGS); /* * Returns the area of a box. */ -Datum spherebox_area(PG_FUNCTION_ARGS); +extern Datum spherebox_area(PG_FUNCTION_ARGS); /* * Returns the circumference of a box. */ -Datum spherebox_circ(PG_FUNCTION_ARGS); +extern Datum spherebox_circ(PG_FUNCTION_ARGS); /* * Checks whether two boxes are equal. */ -Datum spherebox_equal(PG_FUNCTION_ARGS); +extern Datum spherebox_equal(PG_FUNCTION_ARGS); /* * Checks whether two boxes are not equal. */ -Datum spherebox_equal_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_equal_neg(PG_FUNCTION_ARGS); /* * Checks whether a point is contained by a box. */ -Datum spherebox_cont_point(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_point(PG_FUNCTION_ARGS); /* * Checks whether a point isn't contained by a box. */ -Datum spherebox_cont_point_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_point_neg(PG_FUNCTION_ARGS); /* * Checks whether a point is contained by a box. */ -Datum spherebox_cont_point_com(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_point_com(PG_FUNCTION_ARGS); /* * Checks whether a point isn't contained by a box. */ -Datum spherebox_cont_point_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_point_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a circle. */ -Datum spherebox_cont_circle(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_circle(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a circle. */ -Datum spherebox_cont_circle_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a circle. */ -Datum spherebox_cont_circle_com(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_circle_com(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a circle. */ -Datum spherebox_cont_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a box. */ -Datum spherecircle_cont_box(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_box(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a box. */ -Datum spherecircle_cont_box_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_box_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a box. */ -Datum spherecircle_cont_box_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_box_com(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a box. */ -Datum spherecircle_cont_box_com_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_box_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and a box overlap. */ -Datum spherebox_overlap_circle(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_circle(PG_FUNCTION_ARGS); /* * Checks whether a circle and a box don't overlap. */ -Datum spherebox_overlap_circle_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and a box overlap. */ -Datum spherebox_overlap_circle_com(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_circle_com(PG_FUNCTION_ARGS); /* * Checks whether a circle and a box don't overlap. */ -Datum spherebox_overlap_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a line. */ -Datum spherebox_cont_line(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_line(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a line. */ -Datum spherebox_cont_line_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_line_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a line. */ -Datum spherebox_cont_line_com(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_line_com(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a line. */ -Datum spherebox_cont_line_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box and a line overlap. */ -Datum spherebox_overlap_line(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_line(PG_FUNCTION_ARGS); /* * Checks whether a box and a line don't overlap. */ -Datum spherebox_overlap_line_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_line_neg(PG_FUNCTION_ARGS); /* * Checks whether a box and a line overlap. */ -Datum spherebox_overlap_line_com(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_line_com(PG_FUNCTION_ARGS); /* * Checks whether a box and a line don't overlap. */ -Datum spherebox_overlap_line_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a path. */ -Datum spherebox_cont_path(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_path(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a path. */ -Datum spherebox_cont_path_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_path_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a path. */ -Datum spherebox_cont_path_com(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_path_com(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a path. */ -Datum spherebox_cont_path_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_path_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box and a path overlap. */ -Datum spherebox_overlap_path(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_path(PG_FUNCTION_ARGS); /* * Checks whether a box and a path don't overlap. */ -Datum spherebox_overlap_path_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_path_neg(PG_FUNCTION_ARGS); /* * Checks whether a box and a path overlap. */ -Datum spherebox_overlap_path_com(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_path_com(PG_FUNCTION_ARGS); /* * Checks whether a box and a path don't overlap. */ -Datum spherebox_overlap_path_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_path_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a polygon. */ -Datum spherebox_cont_poly(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_poly(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a polygon. */ -Datum spherebox_cont_poly_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_poly_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains a polygon. */ -Datum spherebox_cont_poly_com(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_poly_com(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain a polygon. */ -Datum spherebox_cont_poly_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_poly_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a box. */ -Datum spherepoly_cont_box(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_box(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a box. */ -Datum spherepoly_cont_box_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_box_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a box. */ -Datum spherepoly_cont_box_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_box_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a box. */ -Datum spherepoly_cont_box_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_box_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a box overlap. */ -Datum spherebox_overlap_poly(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_poly(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a box don't overlap. */ -Datum spherebox_overlap_poly_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_poly_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a box overlap. */ -Datum spherebox_overlap_poly_com(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_poly_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a box don't overlap. */ -Datum spherebox_overlap_poly_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_poly_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains an ellipse. */ -Datum spherebox_cont_ellipse(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_ellipse(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain an ellipse. */ -Datum spherebox_cont_ellipse_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_ellipse_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains an ellipse. */ -Datum spherebox_cont_ellipse_com(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_ellipse_com(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain an ellipse. */ -Datum spherebox_cont_ellipse_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_ellipse_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a box. */ -Datum sphereellipse_cont_box(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_box(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a box. */ -Datum sphereellipse_cont_box_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_box_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a box. */ -Datum sphereellipse_cont_box_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_box_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a box. */ -Datum sphereellipse_cont_box_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_box_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a box overlap. */ -Datum spherebox_overlap_ellipse(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_ellipse(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a box don't overlap. */ -Datum spherebox_overlap_ellipse_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_ellipse_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a box overlap. */ -Datum spherebox_overlap_ellipse_com(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_ellipse_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a box don't overlap. */ -Datum spherebox_overlap_ellipse_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_ellipse_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains another box. */ -Datum spherebox_cont_box(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_box(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain another box. */ -Datum spherebox_cont_box_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_box_neg(PG_FUNCTION_ARGS); /* * Checks whether a box contains another box. */ -Datum spherebox_cont_box_com(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_box_com(PG_FUNCTION_ARGS); /* * Checks whether a box doesn't contain another box. */ -Datum spherebox_cont_box_com_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_cont_box_com_neg(PG_FUNCTION_ARGS); /* * Checks whether two boxes overlap. */ -Datum spherebox_overlap_box(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_box(PG_FUNCTION_ARGS); /* * Checks whether two boxes don't overlap. */ -Datum spherebox_overlap_box_neg(PG_FUNCTION_ARGS); +extern Datum spherebox_overlap_box_neg(PG_FUNCTION_ARGS); #endif diff --git a/src/circle.h b/src/circle.h index b8aa520..614b0e8 100644 --- a/src/circle.h +++ b/src/circle.h @@ -10,151 +10,151 @@ */ typedef struct { - SPoint center; /* the center of circle */ - float8 radius; /* the circle radius in radians */ + SPoint center; /* the center of circle */ + float8 radius; /* the circle radius in radians */ } SCIRCLE; /* * Checks whether two circles are equal. */ -bool scircle_eq(const SCIRCLE *c1, const SCIRCLE *c2); +extern bool scircle_eq(const SCIRCLE *c1, const SCIRCLE *c2); /* * Checks whether a circle contains a point. */ -bool spoint_in_circle(const SPoint *p, const SCIRCLE *c); +extern bool spoint_in_circle(const SPoint *p, const SCIRCLE *c); /* * Transforms a circle using an Euler transformation. */ -void euler_scircle_trans(SCIRCLE *out, const SCIRCLE *in, const SEuler *se); +extern void euler_scircle_trans(SCIRCLE *out, const SCIRCLE *in, const SEuler *se); /* * Takes the input and stores it as a spherical circle. */ -Datum spherecircle_in(PG_FUNCTION_ARGS); +extern Datum spherecircle_in(PG_FUNCTION_ARGS); /* * Checks whether two circles are equal. */ -Datum spherecircle_equal(PG_FUNCTION_ARGS); +extern Datum spherecircle_equal(PG_FUNCTION_ARGS); /* * Checks whether two circles are not equal. */ -Datum spherecircle_equal_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_equal_neg(PG_FUNCTION_ARGS); /* * Calculate the distance of two circles. If they overlap, this function * returns 0.0. */ -Datum spherecircle_distance(PG_FUNCTION_ARGS); +extern Datum spherecircle_distance(PG_FUNCTION_ARGS); /* * Calculate the distance of a circle and a point. If a circle contains a point, * this function returns 0.0. */ -Datum spherecircle_point_distance(PG_FUNCTION_ARGS); +extern Datum spherecircle_point_distance(PG_FUNCTION_ARGS); /* * Calculate the distance of a point and a circle. If a circle contains a point, * this function returns 0.0. */ -Datum spherecircle_point_distance_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_point_distance_com(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a point. */ -Datum spherepoint_in_circle(PG_FUNCTION_ARGS); +extern Datum spherepoint_in_circle(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a point. */ -Datum spherepoint_in_circle_neg(PG_FUNCTION_ARGS); +extern Datum spherepoint_in_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a point. */ -Datum spherepoint_in_circle_com(PG_FUNCTION_ARGS); +extern Datum spherepoint_in_circle_com(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a point. */ -Datum spherepoint_in_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoint_in_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle is contained by other circle. */ -Datum spherecircle_in_circle(PG_FUNCTION_ARGS); +extern Datum spherecircle_in_circle(PG_FUNCTION_ARGS); /* * Checks whether a circle is not contained by other circle. */ -Datum spherecircle_in_circle_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_in_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains other circle. */ -Datum spherecircle_in_circle_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_in_circle_com(PG_FUNCTION_ARGS); /* * Checks whether circle does not contain other circle. */ -Datum spherecircle_in_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_in_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether two circles overlap. */ -Datum spherecircle_overlap(PG_FUNCTION_ARGS); +extern Datum spherecircle_overlap(PG_FUNCTION_ARGS); /* * Checks whether two circles overlap. */ -Datum spherecircle_overlap_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_overlap_neg(PG_FUNCTION_ARGS); /* * Returns the center of a circle. */ -Datum spherecircle_center(PG_FUNCTION_ARGS); +extern Datum spherecircle_center(PG_FUNCTION_ARGS); /* * Returns the radius of a circle. */ -Datum spherecircle_radius(PG_FUNCTION_ARGS); +extern Datum spherecircle_radius(PG_FUNCTION_ARGS); /* * Converts a point to a circle. */ -Datum spherepoint_to_circle(PG_FUNCTION_ARGS); +extern Datum spherepoint_to_circle(PG_FUNCTION_ARGS); /* * Creates a circle from center and radius. */ -Datum spherecircle_by_center(PG_FUNCTION_ARGS); +extern Datum spherecircle_by_center(PG_FUNCTION_ARGS); /* * Creates a circle from center and radius(in degrees). */ -Datum spherecircle_by_center_deg(PG_FUNCTION_ARGS); +extern Datum spherecircle_by_center_deg(PG_FUNCTION_ARGS); /* * Calculates the area of a circle in square radians. */ -Datum spherecircle_area(PG_FUNCTION_ARGS); +extern Datum spherecircle_area(PG_FUNCTION_ARGS); /* * Calculates the circumference of a circle in radians. */ -Datum spherecircle_circ(PG_FUNCTION_ARGS); +extern Datum spherecircle_circ(PG_FUNCTION_ARGS); /* * Transforms a circle using an Euler transformation. */ -Datum spheretrans_circle(PG_FUNCTION_ARGS); +extern Datum spheretrans_circle(PG_FUNCTION_ARGS); /* * Inverse transformation of a circle using an Euler transformation. */ -Datum spheretrans_circle_inverse(PG_FUNCTION_ARGS); +extern Datum spheretrans_circle_inverse(PG_FUNCTION_ARGS); #endif diff --git a/src/ellipse.h b/src/ellipse.h index b27bc3b..f600936 100644 --- a/src/ellipse.h +++ b/src/ellipse.h @@ -18,9 +18,9 @@ typedef struct */ float8 rad[2]; - float8 phi, /* the first rotation angle around z axis */ - theta, /* the second rotation angle around x axis */ - psi; /* the last rotation angle around z axis */ + float8 phi, /* the first rotation angle around z axis */ + theta, /* the second rotation angle around x axis */ + psi; /* the last rotation angle around z axis */ } SELLIPSE; /* @@ -47,258 +47,258 @@ typedef struct /* * Checks whether two ellipses are equal . */ -bool sellipse_eq(const SELLIPSE *e1, const SELLIPSE *e2); +extern bool sellipse_eq(const SELLIPSE *e1, const SELLIPSE *e2); /* * Returns the center of an ellipse. */ -void sellipse_center(SPoint *sp, const SELLIPSE *e); +extern void sellipse_center(SPoint *sp, const SELLIPSE *e); /* * Checks whether a ellipse contains point. */ -bool sellipse_cont_point(const SELLIPSE *se, const SPoint *sp); +extern bool sellipse_cont_point(const SELLIPSE *se, const SPoint *sp); /* * Returns the large axis of an ellipse as line. */ -bool sellipse_line(SLine *sl, const SELLIPSE *e); +extern bool sellipse_line(SLine *sl, const SELLIPSE *e); /* * Relationship between a line and an ellipse as PGS_ELLIPSE_LINE_REL int8 value. */ -int8 sellipse_line_pos(const SELLIPSE *se, const SLine *sl); +extern int8 sellipse_line_pos(const SELLIPSE *se, const SLine *sl); /* * Relationship between a circle and an ellipse as PGS_ELLIPSE_CIRCLE_REL int8 value. */ -int8 sellipse_circle_pos(const SELLIPSE *se, const SCIRCLE *sc); +extern int8 sellipse_circle_pos(const SELLIPSE *se, const SCIRCLE *sc); /* * Returns the Euler transformation of an ellipse. */ -void sellipse_trans(SEuler *se, const SELLIPSE *e); +extern void sellipse_trans(SEuler *se, const SELLIPSE *e); /* * Input of the spherical ellipse. */ -Datum sphereellipse_in(PG_FUNCTION_ARGS); +extern Datum sphereellipse_in(PG_FUNCTION_ARGS); /* * Input of the spherical ellipse from center, axes and inclination. */ -Datum sphereellipse_infunc(PG_FUNCTION_ARGS); +extern Datum sphereellipse_infunc(PG_FUNCTION_ARGS); /* * Returns the inclination of an ellipse. */ -Datum sphereellipse_incl(PG_FUNCTION_ARGS); +extern Datum sphereellipse_incl(PG_FUNCTION_ARGS); /* * Returns the length of the major axis of an ellipse. */ -Datum sphereellipse_rad1(PG_FUNCTION_ARGS); +extern Datum sphereellipse_rad1(PG_FUNCTION_ARGS); /* * Returns the length of the minor axis of an ellipse. */ -Datum sphereellipse_rad2(PG_FUNCTION_ARGS); +extern Datum sphereellipse_rad2(PG_FUNCTION_ARGS); /* * Returns the center of an ellipse. */ -Datum sphereellipse_center(PG_FUNCTION_ARGS); +extern Datum sphereellipse_center(PG_FUNCTION_ARGS); /* * Returns the Euler transformation of an ellipse. */ -Datum sphereellipse_trans(PG_FUNCTION_ARGS); +extern Datum sphereellipse_trans(PG_FUNCTION_ARGS); /* * Casts a spherical ellipse as circle. The created circle is the boundary * circle of ellipse. The diameter of returned circle is equal to length of * major axis of ellipse. */ -Datum sphereellipse_circle(PG_FUNCTION_ARGS); +extern Datum sphereellipse_circle(PG_FUNCTION_ARGS); /* * Casts a spherical point to an ellipse. */ -Datum spherepoint_ellipse(PG_FUNCTION_ARGS); +extern Datum spherepoint_ellipse(PG_FUNCTION_ARGS); /* * Casts a spherical circle to an ellipse. */ -Datum spherecircle_ellipse(PG_FUNCTION_ARGS); +extern Datum spherecircle_ellipse(PG_FUNCTION_ARGS); /* * Checks whether two ellipses are equal. */ -Datum sphereellipse_equal(PG_FUNCTION_ARGS); +extern Datum sphereellipse_equal(PG_FUNCTION_ARGS); /* * Checks whether two ellipses are not equal. */ -Datum sphereellipse_equal_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_equal_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a point. */ -Datum sphereellipse_cont_point(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_point(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a point. */ -Datum sphereellipse_cont_point_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_point_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a point. */ -Datum sphereellipse_cont_point_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_point_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a point. */ -Datum sphereellipse_cont_point_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_point_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a line. */ -Datum sphereellipse_cont_line(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_line(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a line. */ -Datum sphereellipse_cont_line_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_line_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a line. */ -Datum sphereellipse_cont_line_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_line_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a line. */ -Datum sphereellipse_cont_line_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a line overlap. */ -Datum sphereellipse_overlap_line(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_line(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a line don't overlap. */ -Datum sphereellipse_overlap_line_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_line_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a line overlap. */ -Datum sphereellipse_overlap_line_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_line_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a line don't overlap. */ -Datum sphereellipse_overlap_line_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a circle. */ -Datum sphereellipse_cont_circle(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_circle(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a circle. */ -Datum sphereellipse_cont_circle_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a circle. */ -Datum sphereellipse_cont_circle_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_circle_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a circle. */ -Datum sphereellipse_cont_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains an ellipse. */ -Datum spherecircle_cont_ellipse(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_ellipse(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain an ellipse. */ -Datum spherecircle_cont_ellipse_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_ellipse_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains an ellipse. */ -Datum spherecircle_cont_ellipse_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_ellipse_com(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain an ellipse. */ -Datum spherecircle_cont_ellipse_com_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_ellipse_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and an ellipse overlap. */ -Datum sphereellipse_overlap_circle(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_circle(PG_FUNCTION_ARGS); /* * Checks whether a circle and an ellipse don't overlap. */ -Datum sphereellipse_overlap_circle_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and an ellipse overlap. */ -Datum sphereellipse_overlap_circle_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_circle_com(PG_FUNCTION_ARGS); /* * Checks whether a circle and an ellipse don't overlap. */ -Datum sphereellipse_overlap_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains other ellipse. */ -Datum sphereellipse_cont_ellipse(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_ellipse(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain other ellipse. */ -Datum sphereellipse_cont_ellipse_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_ellipse_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse is contained by other ellipse. */ -Datum sphereellipse_cont_ellipse_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_ellipse_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse isn't contained by other ellipse. */ -Datum sphereellipse_cont_ellipse_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_ellipse_com_neg(PG_FUNCTION_ARGS); /* * Checks whether two ellipses overlap. */ -Datum sphereellipse_overlap_ellipse(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_ellipse(PG_FUNCTION_ARGS); /* * Checks whether two ellipses don't overlap. */ -Datum sphereellipse_overlap_ellipse_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_ellipse_neg(PG_FUNCTION_ARGS); /* * Transforms an ellipse using an Euler transformation. */ -Datum spheretrans_ellipse(PG_FUNCTION_ARGS); +extern Datum spheretrans_ellipse(PG_FUNCTION_ARGS); /* * Transforms an ellipse using an Euler transformation. */ -Datum spheretrans_ellipse_inv(PG_FUNCTION_ARGS); +extern Datum spheretrans_ellipse_inv(PG_FUNCTION_ARGS); #endif diff --git a/src/epochprop.h b/src/epochprop.h index 9e1b87e..a93e4c3 100644 --- a/src/epochprop.h +++ b/src/epochprop.h @@ -3,24 +3,24 @@ #include -Datum epoch_prop(PG_FUNCTION_ARGS); +extern Datum epoch_prop(PG_FUNCTION_ARGS); /* a cartesian point; this is like geo_decl's point, but you can't have both geo_decls and pg_sphere right now (both define a type Point, not to mention they have different ideas on EPSILON */ -typedef struct s_cpoint { - double x, y; +typedef struct s_cpoint +{ + double x, + y; } CPoint; -typedef struct s_phasevec { - SPoint pos; /* Position as an SPoint */ - double pm[2]; /* Proper motion long/lat in rad/year, - PM in longitude has cos(lat) applied */ - double parallax; /* in rad */ - double rv; /* radial velocity in km/s */ - int parallax_valid; /* 1 if the parallax really is a NULL */ +typedef struct s_phasevec +{ + SPoint pos; /* Position as an SPoint */ + double pm[2]; /* Proper motion long/lat in rad/year, PM in + * longitude has cos(lat) applied */ + double parallax; /* in rad */ + double rv; /* radial velocity in km/s */ + int parallax_valid; /* 1 if the parallax really is a NULL */ } phasevec; - - - diff --git a/src/euler.c b/src/euler.c index a45f7b3..f9d4190 100644 --- a/src/euler.c +++ b/src/euler.c @@ -109,8 +109,8 @@ spheretrans_from_float8_and_type(PG_FUNCTION_ARGS) d[1] = PG_GETARG_DATUM(1); d[2] = PG_GETARG_DATUM(2); se = (SEuler *) DatumGetPointer( - DirectFunctionCall3(spheretrans_from_float8, - d[0], d[1], d[2])); + DirectFunctionCall3(spheretrans_from_float8, + d[0], d[1], d[2])); for (i = 0; i < 3; i++) { @@ -165,7 +165,8 @@ seuler_set_zxz(SEuler *se) bool strans_eq(const SEuler *e1, const SEuler *e2) { - SPoint in[2], p[4]; + SPoint in[2], + p[4]; in[0].lng = 0.0; in[0].lat = 0.0; @@ -210,6 +211,7 @@ Datum spheretrans_theta(PG_FUNCTION_ARGS) { SEuler *se = (SEuler *) PG_GETARG_POINTER(0); + PG_RETURN_FLOAT8(se->theta); } @@ -267,8 +269,8 @@ spheretrans_type(PG_FUNCTION_ARGS) void spheretrans_inv(SEuler *se) { - float8 lng[3]; - const unsigned char c = se->phi_a; + float8 lng[3]; + const unsigned char c = se->phi_a; lng[2] = -se->phi; lng[1] = -se->theta; @@ -298,7 +300,7 @@ strans_zxz(SEuler *ret, const SEuler *se) } else { - SEuler tmp; + SEuler tmp; tmp.psi = 0.0; tmp.theta = 0.0; @@ -339,7 +341,7 @@ spheretrans_invert(PG_FUNCTION_ARGS) void seuler_trans_zxz(SEuler *out, const SEuler *in, const SEuler *se) { - SPoint sp[4]; + SPoint sp[4]; sp[0].lng = 0.0; sp[0].lat = 0.0; @@ -380,7 +382,8 @@ spheretrans_trans_inv(PG_FUNCTION_ARGS) void euler_spoint_trans(SPoint *out, const SPoint *in, const SEuler *se) { - Vector3D v, o; + Vector3D v, + o; spoint_vector3d(&v, in); euler_vector_trans(&o, &v, se); @@ -425,7 +428,9 @@ spherevector_to_euler_inv(SEuler *se, const SPoint *spb, const SPoint *spe) } else { - Vector3D vbeg, vend, vtmp; + Vector3D vbeg, + vend, + vtmp; SPoint spt[2]; SEuler set; @@ -448,7 +453,7 @@ spherevector_to_euler_inv(SEuler *se, const SPoint *spb, const SPoint *spe) bool spherevector_to_euler(SEuler *se, const SPoint *spb, const SPoint *spe) { - bool ret; + bool ret; ret = spherevector_to_euler_inv(se, spb, spe); if (ret) @@ -461,10 +466,13 @@ spherevector_to_euler(SEuler *se, const SPoint *spb, const SPoint *spe) void euler_vector_trans(Vector3D *out, const Vector3D *in, const SEuler *se) { - int i; - unsigned char t; - const double *a; - double u[3], vr[3], sa, ca; + int i; + unsigned char t; + const double *a; + double u[3], + vr[3], + sa, + ca; t = 0; a = NULL; diff --git a/src/euler.h b/src/euler.h index 35e3a2c..6baca28 100644 --- a/src/euler.h +++ b/src/euler.h @@ -12,12 +12,12 @@ */ typedef struct { - unsigned char phi_a:2, /* first axis */ - theta_a:2, /* second axis */ - psi_a:2; /* third axis */ - float8 phi, /* first rotation angle */ - theta, /* second rotation angle */ - psi; /* third rotation angle */ + unsigned char phi_a:2, /* first axis */ + theta_a:2, /* second axis */ + psi_a:2; /* third axis */ + float8 phi, /* first rotation angle */ + theta, /* second rotation angle */ + psi; /* third rotation angle */ } SEuler; @@ -25,137 +25,137 @@ typedef struct * Transforms a spherical point and returns the pointer to a transformed spherical * point. */ -void euler_spoint_trans(SPoint *out, const SPoint *in, const SEuler *se); +extern void euler_spoint_trans(SPoint *out, const SPoint *in, const SEuler *se); /* * Transforms a spherical vector from 'spb' to 'spe' into an Euler transformation. * Returns true if the transformation was successful. */ -bool spherevector_to_euler(SEuler *se, const SPoint *spb, const SPoint *spe); +extern bool spherevector_to_euler(SEuler *se, const SPoint *spb, const SPoint *spe); /* * Sets the axes of transformation to ZXZ. */ -void seuler_set_zxz(SEuler *se); +extern void seuler_set_zxz(SEuler *se); /* * Checks equality of two transformations. */ -bool strans_eq(const SEuler *e1, const SEuler *e2); +extern bool strans_eq(const SEuler *e1, const SEuler *e2); /* * Transforms a vector using an Euler transformation. Returns the pointer to * the result vector. */ -void euler_vector_trans(Vector3D *out, const Vector3D *in, const SEuler *se); +extern void euler_vector_trans(Vector3D *out, const Vector3D *in, const SEuler *se); /* * Inverts an Euler transformation. Returns the pointer to the * inverted transformation. */ -void spheretrans_inverse(SEuler *se_out, const SEuler *se_in); +extern void spheretrans_inverse(SEuler *se_out, const SEuler *se_in); /* * Inverts an Euler transformation replacing the original Euler transformation. * Returns the pointer to the inverted transformation. */ -void spheretrans_inv(SEuler *se); +extern void spheretrans_inv(SEuler *se); /* * Converts an Euler transformation to a ZXZ-axis transformation. Returns * the pointer to the converted transformation. */ -void strans_zxz(SEuler *ret, const SEuler *se); +extern void strans_zxz(SEuler *ret, const SEuler *se); /* * Transforms an Euler transformation 'in' into 'out' using 'se'. The result * is always a ZXZ-axis transformation. Returns the pointer to the transformed * transformation. */ -void seuler_trans_zxz(SEuler *out, const SEuler *in, const SEuler *se); +extern void seuler_trans_zxz(SEuler *out, const SEuler *in, const SEuler *se); /* * Input of an Euler transformation. */ -Datum spheretrans_in(PG_FUNCTION_ARGS); +extern Datum spheretrans_in(PG_FUNCTION_ARGS); /* * Input of an Euler transformation with axis Z,X,Z from three angles * (phi, theta, psi) in radians. */ -Datum spheretrans_from_float8(PG_FUNCTION_ARGS); +extern Datum spheretrans_from_float8(PG_FUNCTION_ARGS); /* * Returns the first angle of an Euler transformation in radians. */ -Datum spheretrans_phi(PG_FUNCTION_ARGS); +extern Datum spheretrans_phi(PG_FUNCTION_ARGS); /* * Returns the second angle of an Euler transformation in radians. */ -Datum spheretrans_theta(PG_FUNCTION_ARGS); +extern Datum spheretrans_theta(PG_FUNCTION_ARGS); /* * Returns the third angle of an Euler transformation in radians. */ -Datum spheretrans_psi(PG_FUNCTION_ARGS); +extern Datum spheretrans_psi(PG_FUNCTION_ARGS); /* * Returns the axis of an Euler transformation as three letter code. */ -Datum spheretrans_type(PG_FUNCTION_ARGS); +extern Datum spheretrans_type(PG_FUNCTION_ARGS); /* * Returns the Euler transformation (does nothing). This function is needed * for +strans operator. */ -Datum spheretrans(PG_FUNCTION_ARGS); +extern Datum spheretrans(PG_FUNCTION_ARGS); /* * Returns the inverse Euler transformation. */ -Datum spheretrans_invert(PG_FUNCTION_ARGS); +extern Datum spheretrans_invert(PG_FUNCTION_ARGS); /* * Convert an Euler transformation to a ZXZ-axis transformation. */ -Datum spheretrans_zxz(PG_FUNCTION_ARGS); +extern Datum spheretrans_zxz(PG_FUNCTION_ARGS); /* * This function creates an Euler transformation from 3 angle values in * radians and three letter code used for axes. A letter can be X, Y or Z * (case-insensitive). */ -Datum spheretrans_from_float8_and_type(PG_FUNCTION_ARGS); +extern Datum spheretrans_from_float8_and_type(PG_FUNCTION_ARGS); /* * Checks equality of two Euler transformations. */ -Datum spheretrans_equal(PG_FUNCTION_ARGS); +extern Datum spheretrans_equal(PG_FUNCTION_ARGS); /* * Checks inequality of two Euler transformations. */ -Datum spheretrans_not_equal(PG_FUNCTION_ARGS); +extern Datum spheretrans_not_equal(PG_FUNCTION_ARGS); /* * Transforms an Euler transformation. */ -Datum spheretrans_trans(PG_FUNCTION_ARGS); +extern Datum spheretrans_trans(PG_FUNCTION_ARGS); /* * Transforms inverse an Euler transformations. */ -Datum spheretrans_trans_inv(PG_FUNCTION_ARGS); +extern Datum spheretrans_trans_inv(PG_FUNCTION_ARGS); /* * Transforms a spherical point. */ -Datum spheretrans_point(PG_FUNCTION_ARGS); +extern Datum spheretrans_point(PG_FUNCTION_ARGS); /* * Perform inverse transformation of a spherical point. */ -Datum spheretrans_point_inverse(PG_FUNCTION_ARGS); +extern Datum spheretrans_point_inverse(PG_FUNCTION_ARGS); #endif diff --git a/src/gist.h b/src/gist.h index 6dac2a4..58e32f1 100644 --- a/src/gist.h +++ b/src/gist.h @@ -11,150 +11,150 @@ typedef unsigned char uchar; /* PGS_KEY_REL Key relationships */ -#define SCKEY_DISJ 0 /* two keys are disjunct */ -#define SCKEY_OVERLAP 1 /* two keys are overlapping */ -#define SCKEY_IN 2 /* first key contains second key */ -#define SCKEY_SAME 3 /* keys are equal */ +#define SCKEY_DISJ 0 /* two keys are disjunct */ +#define SCKEY_OVERLAP 1 /* two keys are overlapping */ +#define SCKEY_IN 2 /* first key contains second key */ +#define SCKEY_SAME 3 /* keys are equal */ -uchar spherekey_interleave(const int32 *k1, const int32 *k2); +extern uchar spherekey_interleave(const int32 *k1, const int32 *k2); /* * For given "query" of "pgstype" of PGS_DATA_TYPES type, puts key of cached * query into "key" pointer. Returns true when given query is equal to * current query. */ -bool gq_cache_get_value(unsigned pgstype, const void *query, int32 **key); +extern bool gq_cache_get_value(unsigned pgstype, const void *query, int32 **key); /* * Copy current query, type and its key value to cache. */ -void gq_cache_set_value(unsigned pgstype, const void *query, const int32 *key); +extern void gq_cache_set_value(unsigned pgstype, const void *query, const int32 *key); /* * Input function of key value. Just a dummy. But PostgreSQL need this * function to create a data type. */ -Datum spherekey_in(PG_FUNCTION_ARGS); +extern Datum spherekey_in(PG_FUNCTION_ARGS); /* * Output function of key value. Just a dummy. But PostgreSQL need this * function to create a data type. */ -Datum spherekey_out(PG_FUNCTION_ARGS); +extern Datum spherekey_out(PG_FUNCTION_ARGS); /* * GIST's decompress method. This function does nothing. */ -Datum g_spherekey_decompress(PG_FUNCTION_ARGS); +extern Datum g_spherekey_decompress(PG_FUNCTION_ARGS); /* * GIST's compress method for circle. Creates the key value from a spherical * circle. */ -Datum g_scircle_compress(PG_FUNCTION_ARGS); +extern Datum g_scircle_compress(PG_FUNCTION_ARGS); /* * GIST's compress method for point. Creates the key value from a spherical point. */ -Datum g_spoint_compress(PG_FUNCTION_ARGS); +extern Datum g_spoint_compress(PG_FUNCTION_ARGS); /* * GIST's compress method for line. Creates the key value from a spherical line. */ -Datum g_sline_compress(PG_FUNCTION_ARGS); +extern Datum g_sline_compress(PG_FUNCTION_ARGS); /* * GIST's compress method for path. Creates the key value from a spherical path. */ -Datum g_spath_compress(PG_FUNCTION_ARGS); +extern Datum g_spath_compress(PG_FUNCTION_ARGS); /* * GIST's compress method for polygon. Creates the key value from a spherical * polygon. */ -Datum g_spoly_compress(PG_FUNCTION_ARGS); +extern Datum g_spoly_compress(PG_FUNCTION_ARGS); /* * GIST's compress method for ellipse. Creates the key value from a spherical * ellipse. */ -Datum g_sellipse_compress(PG_FUNCTION_ARGS); +extern Datum g_sellipse_compress(PG_FUNCTION_ARGS); /* * GIST's compress method for box. Creates the key value from a spherical box. */ -Datum g_sbox_compress(PG_FUNCTION_ARGS); +extern Datum g_sbox_compress(PG_FUNCTION_ARGS); /* * The GiST Union method for boxes. Returns the minimal bounding box that * encloses all the entries in entryvec. */ -Datum g_spherekey_union(PG_FUNCTION_ARGS); +extern Datum g_spherekey_union(PG_FUNCTION_ARGS); /* * GIST's equality method. */ -Datum g_spherekey_same(PG_FUNCTION_ARGS); +extern Datum g_spherekey_same(PG_FUNCTION_ARGS); /* * GIST's consistent method for a point. */ -Datum g_spoint_consistent(PG_FUNCTION_ARGS); +extern Datum g_spoint_consistent(PG_FUNCTION_ARGS); /* * GIST's consistent method for a circle. */ -Datum g_scircle_consistent(PG_FUNCTION_ARGS); +extern Datum g_scircle_consistent(PG_FUNCTION_ARGS); /* * GIST's consistent method for a line. */ -Datum g_sline_consistent(PG_FUNCTION_ARGS); +extern Datum g_sline_consistent(PG_FUNCTION_ARGS); /* * GIST's consistent method for a path. */ -Datum g_spath_consistent(PG_FUNCTION_ARGS); +extern Datum g_spath_consistent(PG_FUNCTION_ARGS); /* * GIST's consistent method for a polygon. */ -Datum g_spoly_consistent(PG_FUNCTION_ARGS); +extern Datum g_spoly_consistent(PG_FUNCTION_ARGS); /* * GIST's consistent method for an ellipse. */ -Datum g_sellipse_consistent(PG_FUNCTION_ARGS); +extern Datum g_sellipse_consistent(PG_FUNCTION_ARGS); /* * GIST's consistent method for a box. */ -Datum g_sbox_consistent(PG_FUNCTION_ARGS); +extern Datum g_sbox_consistent(PG_FUNCTION_ARGS); /* * GIST's penalty method. */ -Datum g_spherekey_penalty(PG_FUNCTION_ARGS); +extern Datum g_spherekey_penalty(PG_FUNCTION_ARGS); /* * GIST's picksplit method. This method is using the double sorting node * splitting algorithm for R-Trees. See "A new double sorting-based node * splitting algorithm for R-tree", A. Korotkov. */ -Datum g_spherekey_picksplit(PG_FUNCTION_ARGS); - -Datum pointkey_in(PG_FUNCTION_ARGS); -Datum pointkey_out(PG_FUNCTION_ARGS); -Datum pointkey_volume(PG_FUNCTION_ARGS); -Datum pointkey_area(PG_FUNCTION_ARGS); -Datum pointkey_perimeter(PG_FUNCTION_ARGS); -Datum g_spoint3_compress(PG_FUNCTION_ARGS); -Datum g_spoint3_union(PG_FUNCTION_ARGS); -Datum g_spoint3_same(PG_FUNCTION_ARGS); -Datum g_spoint3_consistent(PG_FUNCTION_ARGS); -Datum g_spoint3_penalty(PG_FUNCTION_ARGS); -Datum g_spoint3_picksplit(PG_FUNCTION_ARGS); -Datum g_spoint3_distance(PG_FUNCTION_ARGS); -Datum g_spoint3_fetch(PG_FUNCTION_ARGS); +extern Datum g_spherekey_picksplit(PG_FUNCTION_ARGS); + +extern Datum pointkey_in(PG_FUNCTION_ARGS); +extern Datum pointkey_out(PG_FUNCTION_ARGS); +extern Datum pointkey_volume(PG_FUNCTION_ARGS); +extern Datum pointkey_area(PG_FUNCTION_ARGS); +extern Datum pointkey_perimeter(PG_FUNCTION_ARGS); +extern Datum g_spoint3_compress(PG_FUNCTION_ARGS); +extern Datum g_spoint3_union(PG_FUNCTION_ARGS); +extern Datum g_spoint3_same(PG_FUNCTION_ARGS); +extern Datum g_spoint3_consistent(PG_FUNCTION_ARGS); +extern Datum g_spoint3_penalty(PG_FUNCTION_ARGS); +extern Datum g_spoint3_picksplit(PG_FUNCTION_ARGS); +extern Datum g_spoint3_distance(PG_FUNCTION_ARGS); +extern Datum g_spoint3_fetch(PG_FUNCTION_ARGS); #endif diff --git a/src/gnomo.h b/src/gnomo.h index bae1d11..c7a2777 100644 --- a/src/gnomo.h +++ b/src/gnomo.h @@ -3,7 +3,7 @@ /* function prototypes for the direct and inverse gnomonic projections */ -Datum gnomonic_proj(PG_FUNCTION_ARGS); -Datum gnomonic_inv(PG_FUNCTION_ARGS); +extern Datum gnomonic_proj(PG_FUNCTION_ARGS); +extern Datum gnomonic_inv(PG_FUNCTION_ARGS); #endif diff --git a/src/key.h b/src/key.h index aa77ca9..e4c39dc 100644 --- a/src/key.h +++ b/src/key.h @@ -20,30 +20,32 @@ typedef struct { - char vl_len_[4]; + char vl_len_[4]; union { - struct /* the compiler will probably insert 4 bytes of padding here */ + struct /* the compiler will probably insert 4 bytes + * of padding here */ { - float8 lat, - lng; + float8 lat, + lng; }; }; -} GiSTSPointKey_Leaf; +} GiSTSPointKey_Leaf; typedef struct { - char vl_len_[4]; + char vl_len_[4]; union { - struct /* the compiler will probably insert 4 bytes of padding here */ + struct /* the compiler will probably insert 4 bytes + * of padding here */ { - float8 lat, - lng; + float8 lat, + lng; }; struct { - int32 k[6]; + int32 k[6]; }; }; } GiSTSPointKey; @@ -51,10 +53,12 @@ typedef struct #define INTERNAL_KEY_SIZE sizeof(GiSTSPointKey) #define LEAF_KEY_SIZE sizeof(GiSTSPointKey_Leaf) #define IS_LEAF(key) (VARSIZE(key) == LEAF_KEY_SIZE) + #define ALLOC_LEAF_KEY(key) do { \ key = (GiSTSPointKey *)palloc0(LEAF_KEY_SIZE); \ SET_VARSIZE(key, LEAF_KEY_SIZE); \ } while (0) ; + #define ALLOC_INTERNAL_KEY(key) do { \ key = (GiSTSPointKey *)palloc0(INTERNAL_KEY_SIZE); \ SET_VARSIZE(key, INTERNAL_KEY_SIZE); \ @@ -63,128 +67,128 @@ typedef struct /* * Returns the union of two keys. Result is placed into 'kunion'. */ -void spherekey_union_two(int32 *kunion, const int32 *key); +extern void spherekey_union_two(int32 *kunion, const int32 *key); /* * Returns the intersection of two keys. Returns NULL if there is * no intersection. Result is placed into 'kinter'. */ -bool spherekey_inter_two(int32 *kinter, const int32 *key); +extern bool spherekey_inter_two(int32 *kinter, const int32 *key); /* * Generates the key of a spherical point and returns it. Result is placed * into 'k'. */ -void spherepoint_gen_key(int32 *k, const SPoint *sp); +extern void spherepoint_gen_key(int32 *k, const SPoint *sp); /* * Generates the circle's key and returns it. Result is placed into 'k'. */ -void spherecircle_gen_key(int32 *k, const SCIRCLE *c); +extern void spherecircle_gen_key(int32 *k, const SCIRCLE *c); /* * Generates the key of a spherical ellipse and returns it. Result is placed * into 'k'. */ -void sphereellipse_gen_key(int32 *k, const SELLIPSE *e); +extern void sphereellipse_gen_key(int32 *k, const SELLIPSE *e); /* * Generates the key of a spherical line and returns it. Result is placed * into 'k'. */ -void sphereline_gen_key(int32 *k, const SLine *sl); +extern void sphereline_gen_key(int32 *k, const SLine *sl); /* * Generates the key of a polygon and returns it. Result is placed into 'k'. */ -void spherepoly_gen_key(int32 *k, const SPOLY *sp); +extern void spherepoly_gen_key(int32 *k, const SPOLY *sp); /* * Generates the key of a path and returns it. Result is placed into 'k'. */ -void spherepath_gen_key(int32 *k, const SPATH *sp); +extern void spherepath_gen_key(int32 *k, const SPATH *sp); /* * Generates the key of a box and returns it. Result is placed into 'k'. */ -void spherebox_gen_key(int32 *key, const SBOX *box); +extern void spherebox_gen_key(int32 *key, const SBOX *box); /* * Returns true if the first key is less than the second key. */ -Datum spherekey_lt(PG_FUNCTION_ARGS); +extern Datum spherekey_lt(PG_FUNCTION_ARGS); /* * Returns true if the first key is less or equal than the second key. */ -Datum spherekey_le(PG_FUNCTION_ARGS); +extern Datum spherekey_le(PG_FUNCTION_ARGS); /* * Returns true if two keys are equal. */ -Datum spherekey_eq(PG_FUNCTION_ARGS); +extern Datum spherekey_eq(PG_FUNCTION_ARGS); /* * Returns true if two keys are not equal. */ -Datum spherekey_eq_neg(PG_FUNCTION_ARGS); +extern Datum spherekey_eq_neg(PG_FUNCTION_ARGS); /* * Returns true if the first key is greater or equal than the second key. */ -Datum spherekey_ge(PG_FUNCTION_ARGS); +extern Datum spherekey_ge(PG_FUNCTION_ARGS); /* * Returns true if the first key is greater than the second key. */ -Datum spherekey_gt(PG_FUNCTION_ARGS); +extern Datum spherekey_gt(PG_FUNCTION_ARGS); /* * Returns relationship between the two keys. * Calls skey_cmp(const int32 *, const int32 *) for two keys. */ -Datum spherekey_cmp(PG_FUNCTION_ARGS); +extern Datum spherekey_cmp(PG_FUNCTION_ARGS); /* * Returns relationship between the keys of two spherical points. * Calls skey_cmp(const int32 *, const int32 *) for two points. */ -Datum spherepoint_cmp(PG_FUNCTION_ARGS); +extern Datum spherepoint_cmp(PG_FUNCTION_ARGS); /* * Returns relationship between the keys of two spherical circles. * Calls skey_cmp(const int32 *, const int32 *) for two circles. */ -Datum spherecircle_cmp(PG_FUNCTION_ARGS); +extern Datum spherecircle_cmp(PG_FUNCTION_ARGS); /* * Returns relationship between the keys of two spherical ellipses. * Calls skey_cmp(const int32 *, const int32 *) for two ellipses. */ -Datum sphereellipse_cmp(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cmp(PG_FUNCTION_ARGS); /* * Returns relationship between the keys of two spherical lines. * Calls skey_cmp(const int32 *, const int32 *) for two lines. */ -Datum sphereline_cmp(PG_FUNCTION_ARGS); +extern Datum sphereline_cmp(PG_FUNCTION_ARGS); /* * Returns relationship between the keys of two spherical paths. * Calls skey_cmp(const int32 *, const int32 *) for two paths. */ -Datum spherepath_cmp(PG_FUNCTION_ARGS); +extern Datum spherepath_cmp(PG_FUNCTION_ARGS); /* * Returns relationship between the keys of two spherical polygons. * Calls skey_cmp(const int32 *, const int32 *) for two polygons. */ -Datum spherepoly_cmp(PG_FUNCTION_ARGS); +extern Datum spherepoly_cmp(PG_FUNCTION_ARGS); /* * Returns relationship between the keys of two spherical boxes. * Calls skey_cmp(const int32 *, const int32 *) for two boxes. */ -Datum spherebox_cmp(PG_FUNCTION_ARGS); +extern Datum spherebox_cmp(PG_FUNCTION_ARGS); #endif diff --git a/src/line.h b/src/line.h index 002f371..deaa028 100644 --- a/src/line.h +++ b/src/line.h @@ -10,10 +10,10 @@ */ typedef struct { - float8 phi, /* the first rotation angle around z axis */ - theta, /* the second rotation angle around x axis */ - psi; /* the last rotation angle around z axis */ - float8 length; /* the length of the line */ + float8 phi, /* the first rotation angle around z axis */ + theta, /* the second rotation angle around x axis */ + psi; /* the last rotation angle around z axis */ + float8 length; /* the length of the line */ } SLine; /* PGS_RELATIONSHIPS Object relationships */ @@ -37,47 +37,47 @@ typedef struct * * Returns false if the distance between the 'pbeg' and the 'pend' is 180deg. */ -bool sline_from_points(SLine *sl, const SPoint *pbeg, const SPoint *pend); +extern bool sline_from_points(SLine *sl, const SPoint *pbeg, const SPoint *pend); /* * Returns a meridian line of a given longitude in radians. The result is placed * into 'sl'. */ -void sline_meridian(SLine *sl, float8 lng); +extern void sline_meridian(SLine *sl, float8 lng); /* * Returns the starting point of a line 'l'. Result is placed into 'p'. */ -void sline_begin(SPoint *p, const SLine *l); +extern void sline_begin(SPoint *p, const SLine *l); /* * Returns the ending point of a line 'l'. Result is placed into 'p'. */ -void sline_end(SPoint *p, const SLine *l); +extern void sline_end(SPoint *p, const SLine *l); /* * Puts the minimum and the maximum latitudes of a spherical line 's1' into 'minlat' * and 'maxlat'. */ -void sline_min_max_lat(const SLine *sl, float8 *minlat, float8 *maxlat); +extern void sline_min_max_lat(const SLine *sl, float8 *minlat, float8 *maxlat); /* * Calculates spherical points with a latitude 'lat' on a spherical line. * * Returns the number of found points or <0 if undefined. */ -int32 sphereline_latitude_points(const SLine *sl, float8 lat, SPoint *p1, SPoint *p2); +extern int32 sphereline_latitude_points(const SLine *sl, float8 lat, SPoint *p1, SPoint *p2); /* * Returns true if two lines are equal. */ -bool sline_eq(const SLine *l1, const SLine *l2); +extern bool sline_eq(const SLine *l1, const SLine *l2); /* * Returns the relationship between a line and a circle as PGS_CIRCLE_LINE_REL * int8 value. */ -int8 sphereline_circle_pos(const SLine *sl, const SCIRCLE *sc); +extern int8 sphereline_circle_pos(const SLine *sl, const SCIRCLE *sc); /* * Assuming that a line and a circle overlap, this function returns true @@ -87,31 +87,31 @@ int8 sphereline_circle_pos(const SLine *sl, const SCIRCLE *sc); * * See sphereline_circle_pos (const SLine *, const SCIRCLE *) */ -bool sline_circle_touch(const SLine *sl, const SCIRCLE *sc); +extern bool sline_circle_touch(const SLine *sl, const SCIRCLE *sc); /* * Returns the relationship between two lines as PGS_LINE_LINE_REL int8 value. */ -int8 sline_sline_pos(const SLine *l1, const SLine *l2); +extern int8 sline_sline_pos(const SLine *l1, const SLine *l2); /* * Checks whether a point is on a line. */ -bool spoint_at_sline(const SPoint *p, const SLine *sl); +extern bool spoint_at_sline(const SPoint *p, const SLine *sl); /* * Returns the Euler transformation of a line. * * See spheretrans_from_line(PG_FUNCTION_ARGS) */ -void sphereline_to_euler(SEuler *se, const SLine *sl); +extern void sphereline_to_euler(SEuler *se, const SLine *sl); /* * Returns the inverse Euler transformation of a line. * * See spheretrans_from_line(PG_FUNCTION_ARGS) */ -void sphereline_to_euler_inv(SEuler *se, const SLine *sl); +extern void sphereline_to_euler_inv(SEuler *se, const SLine *sl); /* * Transforms a line using an Euler transformation. @@ -122,187 +122,187 @@ void sphereline_to_euler_inv(SEuler *se, const SLine *sl); * * See spheretrans_line (PG_FUNCTION_ARGS) */ -void euler_sline_trans(SLine *out, const SLine *in, const SEuler *se); +extern void euler_sline_trans(SLine *out, const SLine *in, const SEuler *se); /* * Puts the center of a line 'sl' into point 'c'. */ -void sline_center(SPoint *c, const SLine *sl); +extern void sline_center(SPoint *c, const SLine *sl); /* * Calculates the distance between a line 'sl' and a point 'p' */ -float8 sline_point_dist(const SLine *sl, const SPoint *p); +float8 sline_point_dist(const SLine *sl, const SPoint *p); /* * The input function for spherical line. */ -Datum sphereline_in(PG_FUNCTION_ARGS); +extern Datum sphereline_in(PG_FUNCTION_ARGS); /* * Create a line from a spherical point. */ -Datum sphereline_from_point(PG_FUNCTION_ARGS); +extern Datum sphereline_from_point(PG_FUNCTION_ARGS); /* * This function creates a spherical line using a starting point * and an ending point. The distance between the points must not be * equal to 180deg. */ -Datum sphereline_from_points(PG_FUNCTION_ARGS); +extern Datum sphereline_from_points(PG_FUNCTION_ARGS); /* * This function creates a spherical line using a given Euler transformation * and the length of a line. If the length is less than zero, an error occurs. * If the length is larger than 360deg, it is set to 360deg. */ -Datum sphereline_from_trans(PG_FUNCTION_ARGS); +extern Datum sphereline_from_trans(PG_FUNCTION_ARGS); /* * This function creates a meridian running from south to north. * The float8 param provides the longitude in radians. */ -Datum sphereline_meridian(PG_FUNCTION_ARGS); +extern Datum sphereline_meridian(PG_FUNCTION_ARGS); /* * Swaps the starting point and the ending point of a line. */ -Datum sphereline_swap_beg_end(PG_FUNCTION_ARGS); +extern Datum sphereline_swap_beg_end(PG_FUNCTION_ARGS); /* * Turns the line while preserving the starting & ending points. */ -Datum sphereline_turn(PG_FUNCTION_ARGS); +extern Datum sphereline_turn(PG_FUNCTION_ARGS); /* * Returns the beginning of a line. */ -Datum sphereline_begin(PG_FUNCTION_ARGS); +extern Datum sphereline_begin(PG_FUNCTION_ARGS); /* * Returns the ending of a line. */ -Datum sphereline_end(PG_FUNCTION_ARGS); +extern Datum sphereline_end(PG_FUNCTION_ARGS); /* * Returns the length of a line in radians. */ -Datum sphereline_length(PG_FUNCTION_ARGS); +extern Datum sphereline_length(PG_FUNCTION_ARGS); /* * Checks whether a line contains a point. */ -Datum sphereline_cont_point(PG_FUNCTION_ARGS); +extern Datum sphereline_cont_point(PG_FUNCTION_ARGS); /* * Checks whether a line doesn't contain a point. */ -Datum sphereline_cont_point_neg(PG_FUNCTION_ARGS); +extern Datum sphereline_cont_point_neg(PG_FUNCTION_ARGS); /* * Checks whether a line contains a point. */ -Datum sphereline_cont_point_com(PG_FUNCTION_ARGS); +extern Datum sphereline_cont_point_com(PG_FUNCTION_ARGS); /* * Checks whether a line doesn't contain a point. */ -Datum sphereline_cont_point_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereline_cont_point_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a line. */ -Datum spherecircle_cont_line(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_line(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a line. */ -Datum spherecircle_cont_line_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_line_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a line. */ -Datum spherecircle_cont_line_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_line_com(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a line. */ -Datum spherecircle_cont_line_com_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and a line overlap. */ -Datum sphereline_overlap_circle(PG_FUNCTION_ARGS); +extern Datum sphereline_overlap_circle(PG_FUNCTION_ARGS); /* * Checks whether circle and a line don't overlap. */ -Datum sphereline_overlap_circle_neg(PG_FUNCTION_ARGS); +extern Datum sphereline_overlap_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and a line overlap. */ -Datum sphereline_overlap_circle_com(PG_FUNCTION_ARGS); +extern Datum sphereline_overlap_circle_com(PG_FUNCTION_ARGS); /* * Checks whether circle and a line don't overlap. */ -Datum sphereline_overlap_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereline_overlap_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether two lines are equal. */ -Datum sphereline_equal(PG_FUNCTION_ARGS); +extern Datum sphereline_equal(PG_FUNCTION_ARGS); /* * Checks whether two lines are not equal. */ -Datum sphereline_equal_neg(PG_FUNCTION_ARGS); +extern Datum sphereline_equal_neg(PG_FUNCTION_ARGS); /* * Checks whether two lines cross each other. */ -Datum sphereline_crosses(PG_FUNCTION_ARGS); +extern Datum sphereline_crosses(PG_FUNCTION_ARGS); /* * Checks whether two lines don't cross each other. */ -Datum sphereline_crosses_neg(PG_FUNCTION_ARGS); +extern Datum sphereline_crosses_neg(PG_FUNCTION_ARGS); /* * Checks whether two lines overlap. */ -Datum sphereline_overlap(PG_FUNCTION_ARGS); +extern Datum sphereline_overlap(PG_FUNCTION_ARGS); /* * Checks whether two lines are overlap. */ -Datum sphereline_overlap_neg(PG_FUNCTION_ARGS); +extern Datum sphereline_overlap_neg(PG_FUNCTION_ARGS); /* * Returns an Euler transformation. An inverse transformation with it puts * the line into equator beginning at (0,0) and ending at (0,length). */ -Datum spheretrans_from_line(PG_FUNCTION_ARGS); +extern Datum spheretrans_from_line(PG_FUNCTION_ARGS); /* * Transforms a line with an Euler transformation. */ -Datum spheretrans_line(PG_FUNCTION_ARGS); +extern Datum spheretrans_line(PG_FUNCTION_ARGS); /* * Transforms a line with an inverse Euler transformation. */ -Datum spheretrans_line_inverse(PG_FUNCTION_ARGS); +extern Datum spheretrans_line_inverse(PG_FUNCTION_ARGS); /* * Returns the distance between a line and a point. */ -Datum sphereline_point_distance(PG_FUNCTION_ARGS); +extern Datum sphereline_point_distance(PG_FUNCTION_ARGS); /* * Returns the distance between a point and a line. */ -Datum sphereline_point_distance_com(PG_FUNCTION_ARGS); +extern Datum sphereline_point_distance_com(PG_FUNCTION_ARGS); #endif diff --git a/src/path.h b/src/path.h index 91e1662..8f98cee 100644 --- a/src/path.h +++ b/src/path.h @@ -12,22 +12,22 @@ */ typedef struct { - char vl_len_[4]; /* total size in bytes */ - int32 npts; /* count of points */ - SPoint p[1]; /* variable length array of SPoints */ + char vl_len_[4]; /* total size in bytes */ + int32 npts; /* count of points */ + SPoint p[1]; /* variable length array of SPoints */ } SPATH; /* Path and circle */ -#define PGS_CIRCLE_PATH_AVOID 0 /* circle avoids path */ -#define PGS_CIRCLE_CONT_PATH 1 /* circle contains path */ -#define PGS_CIRCLE_PATH_OVER 2 /* circle overlaps path */ +#define PGS_CIRCLE_PATH_AVOID 0 /* circle avoids path */ +#define PGS_CIRCLE_CONT_PATH 1 /* circle contains path */ +#define PGS_CIRCLE_PATH_OVER 2 /* circle overlaps path */ /* Path and polygon */ -#define PGS_POLY_PATH_AVOID 0 /* polygon avoids path */ -#define PGS_POLY_CONT_PATH 1 /* polygon contains path */ -#define PGS_POLY_PATH_OVER 2 /* polygon and path overlap */ +#define PGS_POLY_PATH_AVOID 0 /* polygon avoids path */ +#define PGS_POLY_CONT_PATH 1 /* polygon contains path */ +#define PGS_POLY_PATH_OVER 2 /* polygon and path overlap */ /* Path and ellipse */ #define PGS_ELLIPSE_PATH_AVOID 0 /* ellipse avoids path */ @@ -41,12 +41,12 @@ typedef struct /* * Checks whether two paths are equal. */ -bool spath_eq(const SPATH *p1, const SPATH *p2); +extern bool spath_eq(const SPATH *p1, const SPATH *p2); /* * Checks whether a path contains a point. */ -bool spath_cont_point(const SPATH *path, const SPoint *sp); +extern bool spath_cont_point(const SPATH *path, const SPoint *sp); /* * Returns the i-th line segment of a path. @@ -57,24 +57,24 @@ bool spath_cont_point(const SPATH *path, const SPoint *sp); * * Returns the pointer to the line segment or NULL if fails. */ -bool spath_segment(SLine *sl, const SPATH *path, int32 i); +extern bool spath_segment(SLine *sl, const SPATH *path, int32 i); /* * Input function of path. */ -Datum spherepath_in(PG_FUNCTION_ARGS); +extern Datum spherepath_in(PG_FUNCTION_ARGS); /* * Returns the n-th point of a path. * * See spherepath_get_point(PG_FUNCTION_ARGS) */ -Datum spherepath_get_point(PG_FUNCTION_ARGS); +extern Datum spherepath_get_point(PG_FUNCTION_ARGS); /* * Returns spath as array of points */ -Datum spherepath_get_array(PG_FUNCTION_ARGS); +extern Datum spherepath_get_array(PG_FUNCTION_ARGS); /* * This function interpolates between points of path. Returns the @@ -82,212 +82,212 @@ Datum spherepath_get_array(PG_FUNCTION_ARGS); * * See spherepath_point(PG_FUNCTION_ARGS) */ -Datum spherepath_point(PG_FUNCTION_ARGS); +extern Datum spherepath_point(PG_FUNCTION_ARGS); /* * Checks whether two paths are equal. */ -Datum spherepath_equal(PG_FUNCTION_ARGS); +extern Datum spherepath_equal(PG_FUNCTION_ARGS); /* * Checks whether two paths aren't equal. */ -Datum spherepath_equal_neg(PG_FUNCTION_ARGS); +extern Datum spherepath_equal_neg(PG_FUNCTION_ARGS); /* * Returns the length of a path. */ -Datum spherepath_length(PG_FUNCTION_ARGS); +extern Datum spherepath_length(PG_FUNCTION_ARGS); /* * Returns the number of points in a path. */ -Datum spherepath_npts(PG_FUNCTION_ARGS); +extern Datum spherepath_npts(PG_FUNCTION_ARGS); /* * Changes the direction of a path. */ -Datum spherepath_swap(PG_FUNCTION_ARGS); +extern Datum spherepath_swap(PG_FUNCTION_ARGS); /* * Checks whether a path contains a point. */ -Datum spherepath_cont_point(PG_FUNCTION_ARGS); +extern Datum spherepath_cont_point(PG_FUNCTION_ARGS); /* * Checks whether a path doesn't contain a point. */ -Datum spherepath_cont_point_neg(PG_FUNCTION_ARGS); +extern Datum spherepath_cont_point_neg(PG_FUNCTION_ARGS); /* * Checks whether a path contains a point. */ -Datum spherepath_cont_point_com(PG_FUNCTION_ARGS); +extern Datum spherepath_cont_point_com(PG_FUNCTION_ARGS); /* * Checks whether a path doesn't contain a point. */ -Datum spherepath_cont_point_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepath_cont_point_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a path and a line overlap. */ -Datum spherepath_overlap_line(PG_FUNCTION_ARGS); +extern Datum spherepath_overlap_line(PG_FUNCTION_ARGS); /* * Checks whether a path and a line don't overlap. */ -Datum spherepath_overlap_line_neg(PG_FUNCTION_ARGS); +extern Datum spherepath_overlap_line_neg(PG_FUNCTION_ARGS); /* * Checks whether path and line overlap. */ -Datum spherepath_overlap_line_com(PG_FUNCTION_ARGS); +extern Datum spherepath_overlap_line_com(PG_FUNCTION_ARGS); /* * Checks whether a path and a line don't overlap. */ -Datum spherepath_overlap_line_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepath_overlap_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a path. */ -Datum spherecircle_cont_path(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_path(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a path. */ -Datum spherecircle_cont_path_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_path_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a path. */ -Datum spherecircle_cont_path_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_path_com(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a path. */ -Datum spherecircle_cont_path_com_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_path_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and a path overlap. */ -Datum spherecircle_overlap_path(PG_FUNCTION_ARGS); +extern Datum spherecircle_overlap_path(PG_FUNCTION_ARGS); /* * Checks whether a circle and a path don't overlap. */ -Datum spherecircle_overlap_path_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_overlap_path_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle and a path overlap. */ -Datum spherecircle_overlap_path_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_overlap_path_com(PG_FUNCTION_ARGS); /* * Checks whether a circle and a path don't overlap. */ -Datum spherecircle_overlap_path_com_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_overlap_path_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a path. */ -Datum spherepoly_cont_path(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_path(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a path. */ -Datum spherepoly_cont_path_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_path_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains path. */ -Datum spherepoly_cont_path_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_path_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a path. */ -Datum spherepoly_cont_path_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_path_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a path overlap. */ -Datum spherepoly_overlap_path(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_path(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a path don't overlap. */ -Datum spherepoly_overlap_path_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_path_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a path overlap. */ -Datum spherepoly_overlap_path_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_path_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a path don't overlap. */ -Datum spherepoly_overlap_path_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_path_com_neg(PG_FUNCTION_ARGS); /* * Checks whether two paths overlap. */ -Datum spherepath_overlap_path(PG_FUNCTION_ARGS); +extern Datum spherepath_overlap_path(PG_FUNCTION_ARGS); /* * Checks whether two paths don't overlap. */ -Datum spherepath_overlap_path_neg(PG_FUNCTION_ARGS); +extern Datum spherepath_overlap_path_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains path. */ -Datum sphereellipse_cont_path(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_path(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a path. */ -Datum sphereellipse_cont_path_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_path_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a path. */ -Datum sphereellipse_cont_path_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_path_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a path. */ -Datum sphereellipse_cont_path_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_path_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a path overlap. */ -Datum sphereellipse_overlap_path(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_path(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a path don't overlap. */ -Datum sphereellipse_overlap_path_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_path_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a path overlap. */ -Datum sphereellipse_overlap_path_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_path_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse and a path don't overlap. */ -Datum sphereellipse_overlap_path_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_overlap_path_com_neg(PG_FUNCTION_ARGS); /* * Performs an Euler transformation on a path. */ -Datum spheretrans_path(PG_FUNCTION_ARGS); +extern Datum spheretrans_path(PG_FUNCTION_ARGS); /* * Performs an inverse Euler transformation on a path. */ -Datum spheretrans_path_inverse(PG_FUNCTION_ARGS); +extern Datum spheretrans_path_inverse(PG_FUNCTION_ARGS); /* * State transition function for aggregate function spath(spoint). Never @@ -295,11 +295,11 @@ Datum spheretrans_path_inverse(PG_FUNCTION_ARGS); * * Adds a point to a path. */ -Datum spherepath_add_point(PG_FUNCTION_ARGS); +extern Datum spherepath_add_point(PG_FUNCTION_ARGS); /* * Finalize function for adding spoints to a path. */ -Datum spherepath_add_points_finalize(PG_FUNCTION_ARGS); +extern Datum spherepath_add_points_finalize(PG_FUNCTION_ARGS); #endif diff --git a/src/pg_sphere.h b/src/pg_sphere.h index 24d950a..9cfc5f2 100644 --- a/src/pg_sphere.h +++ b/src/pg_sphere.h @@ -72,7 +72,7 @@ #else #define PGSPHERE_FLOAT_STORE 0 #endif -#endif // PGSPHERE_FLOAT_STORE +#endif /* PGSPHERE_FLOAT_STORE */ #define EPSILON 1.0E-09 @@ -84,6 +84,7 @@ static inline bool FPeq(double A, double B) { const volatile double AB = A - B; + return A == B || fabs(AB) <= EPSILON; } @@ -91,6 +92,7 @@ static inline bool FPne(double A, double B) { const volatile double AB = A - B; + return A != B && fabs(AB) > EPSILON; } @@ -98,6 +100,7 @@ static inline bool FPlt(double A, double B) { const volatile double AE = A + EPSILON; + return AE < B; } @@ -105,6 +108,7 @@ static inline bool FPle(double A, double B) { const volatile double BE = B + EPSILON; + return A <= BE; } @@ -112,6 +116,7 @@ static inline bool FPgt(double A, double B) { const volatile double BE = B + EPSILON; + return A > BE; } @@ -119,6 +124,7 @@ static inline bool FPge(double A, double B) { const volatile double AE = A + EPSILON; + return AE >= B; } @@ -160,7 +166,7 @@ FPge(double A, double B) return A + EPSILON >= B; } -#endif // PGSPHERE_FLOAT_STORE +#endif /* PGSPHERE_FLOAT_STORE */ /*--------------------------------------------------------------------- * Point - (x,y) @@ -171,7 +177,6 @@ typedef struct y; } Point; -void sphere_yyparse(void); +extern void sphere_yyparse(void); #endif - diff --git a/src/pgs_chealpix.h b/src/pgs_chealpix.h index c3233d1..f15b4fe 100644 --- a/src/pgs_chealpix.h +++ b/src/pgs_chealpix.h @@ -2,7 +2,7 @@ #define __PGS_CHEALPIX_H__ #include -#include /* PostgreSQL type definitions */ +#include /* PostgreSQL type definitions */ /* * Actually, chealpix changed its API: thus, this file must be included first, * directly or indirectly. diff --git a/src/pgs_util.h b/src/pgs_util.h index 1b3ad76..f04d5be 100644 --- a/src/pgs_util.h +++ b/src/pgs_util.h @@ -1,18 +1,18 @@ #ifndef __PGS_UTIL_H__ #define __PGS_UTIL_H__ -#define PI 3.14159265358979323846 /* pi */ -#define PIH 1.57079632679489661923 /* pi/2 */ -#define PID 6.2831853071795864769 /* 2*pi */ -#define RADIANS 57.295779513082320877 /* 180/pi */ +#define PI 3.14159265358979323846 /* pi */ +#define PIH 1.57079632679489661923 /* pi/2 */ +#define PID 6.2831853071795864769 /* 2*pi */ +#define RADIANS 57.295779513082320877 /* 180/pi */ #define PI_EPS 4.4408920985006261617e-16 /* 2 ** -51 */ -#define Sqr(a) ( (a) * (a) ) /* square function as macro */ +#define Sqr(a) ( (a) * (a) ) /* square function as macro */ #ifdef EPSILON #undef EPSILON #endif -#define EPSILON 1.0E-09 /* precision of floating point values */ +#define EPSILON 1.0E-09 /* precision of floating point values */ /* spherical circle constants */ #define SPHERE_SURFACE (4 * PI) @@ -22,7 +22,8 @@ static inline double conv_theta(double x) { - double y = PIH - x; + double y = PIH - x; + if (fabs(x) < PI_EPS / 2) return PIH; if (fabs(y) < PI_EPS / 2) @@ -30,7 +31,8 @@ conv_theta(double x) return y; } -static inline double deg_to_rad(double in) +static inline double +deg_to_rad(double in) { return in * PI / 180; } diff --git a/src/point.h b/src/point.h index d7af228..b9d85d1 100644 --- a/src/point.h +++ b/src/point.h @@ -11,100 +11,109 @@ */ typedef struct { - float8 lng; /* longitude value in radians */ - float8 lat; /* latitude value in radians */ + float8 lng; /* longitude value in radians */ + float8 lat; /* latitude value in radians */ } SPoint; -Oid get_spoint_type_oid(void); +extern Oid get_spoint_type_oid(void); /* * Calculate the distance between two spherical points in radians. */ -float8 spoint_dist(const SPoint *p1, const SPoint *p2); + +extern float8 spoint_dist(const SPoint *p1, const SPoint *p2); /* * Check whether two points are equal. */ -bool spoint_eq(const SPoint *p1, const SPoint *p2); + +extern bool spoint_eq(const SPoint *p1, const SPoint *p2); /* * Check the longitude and latitude values of a spherical point. */ -void spoint_check(SPoint *spoint); + +extern void spoint_check(SPoint *spoint); /* * Transforms a 3d vector into a spherical point. */ -void vector3d_spoint(SPoint *p, const Vector3D *v); + +extern void vector3d_spoint(SPoint *p, const Vector3D *v); /* * Transforms a spherical point into a 3d vector. */ -void spoint_vector3d(Vector3D *v, const SPoint *p); + +extern void spoint_vector3d(Vector3D *v, const SPoint *p); /* * Take the input and store it as a spherical point. */ -Datum spherepoint_in(PG_FUNCTION_ARGS); + +extern Datum spherepoint_in(PG_FUNCTION_ARGS); /* * Create spherical point from lat, lng and store to first argument(pointer) */ -void create_spherepoint_from_long_lat(SPoint *p, float8 lng, float8 lat); + +extern void create_spherepoint_from_long_lat(SPoint *p, float8 lng, float8 lat); /* * Create a spherical point from longitude and latitude both in radians. */ -Datum spherepoint_from_long_lat(PG_FUNCTION_ARGS); + +extern Datum spherepoint_from_long_lat(PG_FUNCTION_ARGS); /* * Create a spherical point from longitude and latitude both in degrees. */ -Datum spherepoint_from_long_lat_deg(PG_FUNCTION_ARGS); + +extern Datum spherepoint_from_long_lat_deg(PG_FUNCTION_ARGS); /* * Calculate the distance between two spherical points. */ -Datum spherepoint_distance(PG_FUNCTION_ARGS); +extern Datum spherepoint_distance(PG_FUNCTION_ARGS); /* * Longitude of a spherical point. */ -Datum spherepoint_long(PG_FUNCTION_ARGS); +extern Datum spherepoint_long(PG_FUNCTION_ARGS); /* * Latitude of a spherical point. */ -Datum spherepoint_lat(PG_FUNCTION_ARGS); +extern Datum spherepoint_lat(PG_FUNCTION_ARGS); /* * Cartesian x-value of a spherical point. */ -Datum spherepoint_x(PG_FUNCTION_ARGS); +extern Datum spherepoint_x(PG_FUNCTION_ARGS); /* * Cartesian y-value of a spherical point. */ -Datum spherepoint_y(PG_FUNCTION_ARGS); +extern Datum spherepoint_y(PG_FUNCTION_ARGS); /* * Cartesian z-value of a spherical point. */ -Datum spherepoint_z(PG_FUNCTION_ARGS); +extern Datum spherepoint_z(PG_FUNCTION_ARGS); /* * Cartesian values of a spherical point as an array. */ -Datum spherepoint_xyz(PG_FUNCTION_ARGS); +extern Datum spherepoint_xyz(PG_FUNCTION_ARGS); /* * Check whether two points are equal. */ -Datum spherepoint_equal(PG_FUNCTION_ARGS); +extern Datum spherepoint_equal(PG_FUNCTION_ARGS); /* * Compute a 32-bit hash value of a point. */ -Datum spherepoint_hash32(PG_FUNCTION_ARGS); +extern Datum spherepoint_hash32(PG_FUNCTION_ARGS); #endif diff --git a/src/polygon.h b/src/polygon.h index b8c754d..0233c41 100644 --- a/src/polygon.h +++ b/src/polygon.h @@ -12,9 +12,9 @@ */ typedef struct { - char vl_len_[4]; /* total size in bytes */ - int32 npts; /* count of points */ - SPoint p[1]; /* variable length array of SPoints */ + char vl_len_[4]; /* total size in bytes */ + int32 npts; /* count of points */ + SPoint p[1]; /* variable length array of SPoints */ } SPOLY; #define MAX_POINTS 1024 @@ -26,20 +26,20 @@ typedef struct #define PGS_ELLIPSE_POLY_OVER 3 /* ellipse overlaps polygon */ /* Polygon and circle */ -#define PGS_CIRCLE_POLY_AVOID 0 /* circle avoids polygon */ -#define PGS_POLY_CONT_CIRCLE 1 /* polygon contains circle */ -#define PGS_CIRCLE_CONT_POLY 2 /* circle contains polygon */ -#define PGS_CIRCLE_POLY_OVER 3 /* circle overlap polygon */ +#define PGS_CIRCLE_POLY_AVOID 0 /* circle avoids polygon */ +#define PGS_POLY_CONT_CIRCLE 1 /* polygon contains circle */ +#define PGS_CIRCLE_CONT_POLY 2 /* circle contains polygon */ +#define PGS_CIRCLE_POLY_OVER 3 /* circle overlap polygon */ /* Polygon and line */ -#define PGS_LINE_POLY_AVOID 0 /* line avoids polygon */ -#define PGS_POLY_CONT_LINE 1 /* polygon contains line */ -#define PGS_LINE_POLY_OVER 2 /* line overlap polygon */ +#define PGS_LINE_POLY_AVOID 0 /* line avoids polygon */ +#define PGS_POLY_CONT_LINE 1 /* polygon contains line */ +#define PGS_LINE_POLY_OVER 2 /* line overlap polygon */ /* Polygon and polygon */ -#define PGS_POLY_AVOID 0 /* polygon avoids other polygon */ -#define PGS_POLY_CONT 1 /* polygon contains other polygon */ -#define PGS_POLY_OVER 2 /* polygons overlap */ +#define PGS_POLY_AVOID 0 /* polygon avoids other polygon */ +#define PGS_POLY_CONT 1 /* polygon contains other polygon */ +#define PGS_POLY_OVER 2 /* polygons overlap */ #define PG_GETARG_SPOLY( arg ) \ @@ -53,7 +53,7 @@ typedef struct * * If 'dir' is true, check with reverse polygon of 'p2'. */ -bool spoly_eq(const SPOLY *p1, const SPOLY *p2, bool dir); +extern bool spoly_eq(const SPOLY *p1, const SPOLY *p2, bool dir); /* * Returns the i-th line segment of a polygon. @@ -62,7 +62,7 @@ bool spoly_eq(const SPOLY *p1, const SPOLY *p2, bool dir); * poly - pointer to the polygon * i - number of the segment */ -bool spoly_segment(SLine *sl, const SPOLY *poly, int32 i); +extern bool spoly_segment(SLine *sl, const SPOLY *poly, int32 i); /* * Checks whether a polygon contains a point. @@ -70,12 +70,12 @@ bool spoly_segment(SLine *sl, const SPOLY *poly, int32 i); * pg - pointer to the polygon * sp - pointer to the point */ -bool spoly_contains_point(const SPOLY *pg, const SPoint *sp); +extern bool spoly_contains_point(const SPOLY *pg, const SPoint *sp); /* * Returns the n-th point of a spoly. */ -Datum spherepoly_get_point(PG_FUNCTION_ARGS); +extern Datum spherepoly_get_point(PG_FUNCTION_ARGS); /* * Returns the relationship between a polygon and a line as @@ -84,295 +84,295 @@ Datum spherepoly_get_point(PG_FUNCTION_ARGS); * poly - pointer to the polygon * line - pointer to the line */ -int8 poly_line_pos(const SPOLY *poly, const SLine *line); +extern int8 poly_line_pos(const SPOLY *poly, const SLine *line); /* * Creates a spherical polygon (spoly) from an array of pair-consecutive * numbers (lng, lat), in radians. */ -Datum spherepoly_rad(PG_FUNCTION_ARGS); +extern Datum spherepoly_rad(PG_FUNCTION_ARGS); /* * Creates a spherical polygon (spoly) from an array of pair-consecutive * numbers (lng, lat), in degrees. */ -Datum spherepoly_deg(PG_FUNCTION_ARGS); +extern Datum spherepoly_deg(PG_FUNCTION_ARGS); /* * Creates a spherical polygon (spoly) from an array of spoint elements. */ -Datum spherepoly_from_point_array(PG_FUNCTION_ARGS); +extern Datum spherepoly_from_point_array(PG_FUNCTION_ARGS); /* * Input of a spherical polygon. */ -Datum spherepoly_in(PG_FUNCTION_ARGS); +extern Datum spherepoly_in(PG_FUNCTION_ARGS); /* * Checks whether two polygons are equal. */ -Datum spherepoly_equal(PG_FUNCTION_ARGS); +extern Datum spherepoly_equal(PG_FUNCTION_ARGS); /* * Checks whether two polygons are not equal. */ -Datum spherepoly_equal_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_equal_neg(PG_FUNCTION_ARGS); /* * Circumstance of a polygon. Returns circumference in radians * (float8 datum). */ -Datum spherepoly_circ(PG_FUNCTION_ARGS); +extern Datum spherepoly_circ(PG_FUNCTION_ARGS); /* * Count points (edges) of a polygon. */ -Datum spherepoly_npts(PG_FUNCTION_ARGS); +extern Datum spherepoly_npts(PG_FUNCTION_ARGS); /* * Returns area of a polygon. */ -Datum spherepoly_area(PG_FUNCTION_ARGS); +extern Datum spherepoly_area(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a point. */ -Datum spherepoly_cont_point(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_point(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a point. */ -Datum spherepoly_cont_point_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_point_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a point. */ -Datum spherepoly_cont_point_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_point_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a point. */ -Datum spherepoly_cont_point_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_point_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a circle. */ -Datum spherepoly_cont_circle(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_circle(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a circle. */ -Datum spherepoly_cont_circle_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a circle. */ -Datum spherepoly_cont_circle_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_circle_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a circle. */ -Datum spherepoly_cont_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a polygon. */ -Datum spherecircle_cont_poly(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_poly(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a polygon. */ -Datum spherecircle_cont_poly_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_poly_neg(PG_FUNCTION_ARGS); /* * Checks whether a circle contains a polygon. */ -Datum spherecircle_cont_poly_com(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_poly_com(PG_FUNCTION_ARGS); /* * Checks whether a circle doesn't contain a polygon. */ -Datum spherecircle_cont_poly_com_neg(PG_FUNCTION_ARGS); +extern Datum spherecircle_cont_poly_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a circle overlap. */ -Datum spherepoly_overlap_circle(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_circle(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a circle don't overlap. */ -Datum spherepoly_overlap_circle_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_circle_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a circle overlap. */ -Datum spherepoly_overlap_circle_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_circle_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a circle don't overlap. */ -Datum spherepoly_overlap_circle_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_circle_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a line. */ -Datum spherepoly_cont_line(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_line(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a line. */ -Datum spherepoly_cont_line_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_line_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains a line. */ -Datum spherepoly_cont_line_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_line_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain a line. */ -Datum spherepoly_cont_line_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a line overlap. */ -Datum spherepoly_overlap_line(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_line(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a line don't overlap. */ -Datum spherepoly_overlap_line_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_line_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a line overlap. */ -Datum spherepoly_overlap_line_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_line_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon and a line don't overlap. */ -Datum spherepoly_overlap_line_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_line_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains other polygon. */ -Datum spherepoly_cont_poly(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_poly(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain other polygon. */ -Datum spherepoly_cont_poly_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_poly_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains other polygon. */ -Datum spherepoly_cont_poly_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_poly_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain other polygon. */ -Datum spherepoly_cont_poly_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_poly_com_neg(PG_FUNCTION_ARGS); /* * Checks whether two polygons overlap. */ -Datum spherepoly_overlap_poly(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_poly(PG_FUNCTION_ARGS); /* * Checks whether two polygons don't overlap. */ -Datum spherepoly_overlap_poly_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_poly_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains an ellipse. */ -Datum spherepoly_cont_ellipse(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_ellipse(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain an ellipse. */ -Datum spherepoly_cont_ellipse_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_ellipse_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon contains an ellipse. */ -Datum spherepoly_cont_ellipse_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_ellipse_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon doesn't contain an ellipse. */ -Datum spherepoly_cont_ellipse_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_cont_ellipse_com_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a polygon. */ -Datum sphereellipse_cont_poly(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_poly(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a polygon. */ -Datum sphereellipse_cont_poly_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_poly_neg(PG_FUNCTION_ARGS); /* * Checks whether an ellipse contains a polygon. */ -Datum sphereellipse_cont_poly_com(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_poly_com(PG_FUNCTION_ARGS); /* * Checks whether an ellipse doesn't contain a polygon. */ -Datum sphereellipse_cont_poly_com_neg(PG_FUNCTION_ARGS); +extern Datum sphereellipse_cont_poly_com_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and an ellipse overlap. */ -Datum spherepoly_overlap_ellipse(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_ellipse(PG_FUNCTION_ARGS); /* * Checks whether a polygon and an ellipse don't overlap. */ -Datum spherepoly_overlap_ellipse_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_ellipse_neg(PG_FUNCTION_ARGS); /* * Checks whether a polygon and an ellipse overlap. */ -Datum spherepoly_overlap_ellipse_com(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_ellipse_com(PG_FUNCTION_ARGS); /* * Checks whether a polygon and an ellipse don't overlap. */ -Datum spherepoly_overlap_ellipse_com_neg(PG_FUNCTION_ARGS); +extern Datum spherepoly_overlap_ellipse_com_neg(PG_FUNCTION_ARGS); /* * Performs inverse transform on a polygon using an Euler transformation. */ -Datum spheretrans_poly(PG_FUNCTION_ARGS); +extern Datum spheretrans_poly(PG_FUNCTION_ARGS); /* * Performs inverse transform on a polygon using an Euler transformation. */ -Datum spheretrans_poly_inverse(PG_FUNCTION_ARGS); +extern Datum spheretrans_poly_inverse(PG_FUNCTION_ARGS); /* * State transition function for the aggregate function spoly(spoint). Never * call this function outside an aggregate function! Adds a point to a polygon. */ -Datum spherepoly_add_point(PG_FUNCTION_ARGS); +extern Datum spherepoly_add_point(PG_FUNCTION_ARGS); /* * Finalize function for adding spoints to a polygon. */ -Datum spherepoly_add_points_finalize(PG_FUNCTION_ARGS); +extern Datum spherepoly_add_points_finalize(PG_FUNCTION_ARGS); /* * Returns spoly as array of points */ -Datum spherepoly_get_array(PG_FUNCTION_ARGS); +extern Datum spherepoly_get_array(PG_FUNCTION_ARGS); /* * Checks whether a polygon is convex */ -Datum spherepoly_is_convex(PG_FUNCTION_ARGS); +extern Datum spherepoly_is_convex(PG_FUNCTION_ARGS); #endif diff --git a/src/sbuffer.h b/src/sbuffer.h index 57599ee..b16f152 100644 --- a/src/sbuffer.h +++ b/src/sbuffer.h @@ -3,89 +3,89 @@ /* Parser buffer declarations */ -#define STYPE_UNKNOWN 0 /* unknown type */ -#define STYPE_POINT 1 /* input is spherical type */ -#define STYPE_CIRCLE 2 /* input is spherical circle */ -#define STYPE_LINE 3 /* input is spherical line */ -#define STYPE_EULER 4 /* input is Euler transformation */ -#define STYPE_PATH 5 /* input is spherical path or polygon */ -#define STYPE_ELLIPSE 6 /* input is spherical ellipse */ -#define STYPE_BOX 7 /* input is spherical box */ +#define STYPE_UNKNOWN 0 /* unknown type */ +#define STYPE_POINT 1 /* input is spherical type */ +#define STYPE_CIRCLE 2 /* input is spherical circle */ +#define STYPE_LINE 3 /* input is spherical line */ +#define STYPE_EULER 4 /* input is Euler transformation */ +#define STYPE_PATH 5 /* input is spherical path or polygon */ +#define STYPE_ELLIPSE 6 /* input is spherical ellipse */ +#define STYPE_BOX 7 /* input is spherical box */ /* PGS_EULER_AXIS Euler axis */ -#define EULER_AXIS_X 1 /* x - axis for Euler transformation */ -#define EULER_AXIS_Y 2 /* y - axis for Euler transformation */ -#define EULER_AXIS_Z 3 /* z - axis for Euler transformation */ +#define EULER_AXIS_X 1 /* x - axis for Euler transformation */ +#define EULER_AXIS_Y 2 /* y - axis for Euler transformation */ +#define EULER_AXIS_Z 3 /* z - axis for Euler transformation */ -int sphere_yylex(); -void sphere_yyerror(const char *str); -void sphere_flush_scanner_buffer(void); +extern int sphere_yylex(); +extern void sphere_yyerror(const char *str); +extern void sphere_flush_scanner_buffer(void); /* Sets the data type */ -void set_spheretype(unsigned char st); +extern void set_spheretype(unsigned char st); /* Initialize the input buffer */ -void init_buffer(char *buffer); +extern void init_buffer(char *buffer); /* Resets the input buffer */ -void reset_buffer(void); +extern void reset_buffer(void); /* * Read the "offset" number of bytes from "buf" buffer. * Returns the number of read bytes. */ -int get_buffer(char *buf, int offset); +extern int get_buffer(char *buf, int offset); /* * Input of an angle. When is_deg > 0 then "a" is in degrees, * otherwise it's in radians. Returns the unique ID (position) of the angle. */ -int set_angle(unsigned char is_deg, double a); +extern int set_angle(unsigned char is_deg, double a); /* * Set the sign of an angle. "apos" is the angle. "s" is a sign of the angle * ( < 0 .. - , > 0 .. + ). Returns the unique ID (position) of the angle. */ -int set_angle_sign(int apos, int s); +extern int set_angle_sign(int apos, int s); /* * Creates a spherical point. "lngpos" is the ID of a longitude angle, "latpos" * is the ID of a latitude angle. Returns the unique ID (position) of the spherical * point. */ -int set_point(int lngpos, int latpos); +extern int set_point(int lngpos, int latpos); /* * Creates a spherical circle. "spos" is the ID of a spherical point, "rpos" * is the ID of a radius angle. */ -void set_circle(int spos, int rpos); +extern void set_circle(int spos, int rpos); /* * Sets the length of a spherical line. "length" is the ID of a length angle. */ -void set_line(int length); +extern void set_line(int length); /* * Creates an Euler transformation. "phi" is the ID of a first angle, * "theta" is the ID of a second angle, "psi" is the ID of a third angle, * "etype" is the three letter code of Euler transformation axes. */ -void set_euler(int phi, int theta, int psi, char *etype); +extern void set_euler(int phi, int theta, int psi, char *etype); /* * Creates a spherical ellipse. "r1" is the ID of a first radius angle, * "r2" is the ID of a second radius angle, "sp" is the ID of a spherical * point ( center ), "inc" is the ID of an inclination angle. */ -void set_ellipse(int r1, int r2, int sp, int inc); +extern void set_ellipse(int r1, int r2, int sp, int inc); /* * Returns the point parameters. "lng" is the pointer to a longitude * value, "lat" is the pointer to a latitude value. Returns 0 if user * input is a spherical point. */ -int get_point(double *lng, double *lat); +extern int get_point(double *lng, double *lat); /* * Returns the circle parameters. "lng" is pointer to a longitude @@ -93,7 +93,7 @@ int get_point(double *lng, double *lat); * "radius" is the pointer to the radius value. Returns 0 if user input * is a spherical circle. */ -int get_circle(double *lng, double *lat, double *radius); +extern int get_circle(double *lng, double *lat, double *radius); /* * Returns the ellipse parameters. "lng" is the pointer to a longitude value @@ -102,8 +102,8 @@ int get_circle(double *lng, double *lat, double *radius); * radius value, "inc" is the pointer to an inclination angle. Returns 0 if user * input is a spherical ellipse. */ -int get_ellipse(double *lng, double *lat, double *r1, - double *r2, double *inc); +extern int get_ellipse(double *lng, double *lat, double *r1, + double *r2, double *inc); /* * Returns the line parameters. "phi" is the pointer to the first angle @@ -112,8 +112,8 @@ int get_ellipse(double *lng, double *lat, double *r1, * "etype" is the pointer to the axes value of Euler transformation, "length" is * the pointer to the length value. Returns 0 if user input is a spherical line. */ -int get_line(double *phi, double *theta, double *psi, - unsigned char *etype, double *length); +extern int get_line(double *phi, double *theta, double *psi, + unsigned char *etype, double *length); /* * Returns the Euler transformation parameters. "phi" is the pointer to the @@ -122,20 +122,20 @@ int get_line(double *phi, double *theta, double *psi, * transformation, "etype" is the pointer to the axes value of Euler transformation. * Returns 0 if user input is an Euler transformation. */ -int get_euler(double *phi, double *theta, - double *psi, unsigned char *etype); +extern int get_euler(double *phi, double *theta, + double *psi, unsigned char *etype); /* * Returns the number of path elements. */ -int get_path_count(void); +extern int get_path_count(void); /* * Returns the elements of a path. "spos" is the number of element, "lng" is * the ID of longitude angle, "lat" is the ID of a latitude angle. Returns 0 * if user input is a path or a polygon and "spos" is valid. */ -int get_path_elem(int spos, double *lng, double *lat); +extern int get_path_elem(int spos, double *lng, double *lat); /* * Returns the elements of a box. "lng1" is the ID of the first longitude @@ -143,6 +143,6 @@ int get_path_elem(int spos, double *lng, double *lat); * the second longitude angle, "lat2" is the ID of the second latitude angle. * Returns 0 if user input is a box. */ -int get_box(double *lng1, double *lat1, double *lng2, double *lat2); +extern int get_box(double *lng1, double *lat1, double *lng2, double *lat2); #endif diff --git a/src/vector3d.h b/src/vector3d.h index 23ba9b9..47a5a82 100644 --- a/src/vector3d.h +++ b/src/vector3d.h @@ -10,9 +10,9 @@ */ typedef struct { - float8 x; /* x (-1.0 .. 1.0) */ - float8 y; /* y (-1.0 .. 1.0) */ - float8 z; /* z (-1.0 .. 1.0) */ + float8 x; /* x (-1.0 .. 1.0) */ + float8 y; /* y (-1.0 .. 1.0) */ + float8 z; /* z (-1.0 .. 1.0) */ } Vector3D; @@ -20,27 +20,28 @@ typedef struct * Calculate the cross product of two vectors. Puts * cross product of v1 and v2 into out and returns it. */ -void vector3d_cross(Vector3D *out, const Vector3D *v1, const Vector3D *v2); +extern void vector3d_cross(Vector3D *out, const Vector3D *v1, + const Vector3D *v2); /* * Checks equality of two vectors. */ -bool vector3d_eq(const Vector3D *a, const Vector3D *b); +extern bool vector3d_eq(const Vector3D *a, const Vector3D *b); /* * Calculate the scalar product of two vectors. */ -float8 vector3d_scalar(Vector3D *v1, Vector3D *v2); +extern float8 vector3d_scalar(Vector3D *v1, Vector3D *v2); /* * Calculate the length of a vector. */ -float8 vector3d_length(const Vector3D *v); +extern float8 vector3d_length(const Vector3D *v); -/* - * Calculate result + scalar*delta +/* + * Calculate result + scalar*delta */ -void vector3d_addwithscalar( - Vector3D *result, double scalar, const Vector3D *delta); +extern void vector3d_addwithscalar(Vector3D *result, double scalar, + const Vector3D *delta); #endif