From: Paul Ramsey Date: Wed, 17 Sep 2014 21:46:37 +0000 (+0000) Subject: Remove many references to liblwgeom_internal.h outside liblwgeom, X-Git-Tag: 2.2.0rc1~842 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ff35f5aaa01f27dfbd71f77cc1077ee98ef1d656;p=postgis Remove many references to liblwgeom_internal.h outside liblwgeom, and quiet some nagging warnings. git-svn-id: http://svn.osgeo.org/postgis/trunk@12985 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/configure.ac b/configure.ac index 256e0dfba..f381763f2 100644 --- a/configure.ac +++ b/configure.ac @@ -34,7 +34,7 @@ dnl SQL Preprocessor dnl AC_PATH_PROG([CPPBIN], [cpp], []) if test "x$CPPBIN" != "x"; then - SQLPP="${CPPBIN} -traditional-cpp -P" + SQLPP="${CPPBIN} -traditional-cpp -w -P" else AC_PATH_PROG([GPP], [gpp_], []) if test "x$GPP" != "x"; then diff --git a/liblwgeom/cunit/cu_in_geojson.c b/liblwgeom/cunit/cu_in_geojson.c index d37137bc2..b9531d00a 100644 --- a/liblwgeom/cunit/cu_in_geojson.c +++ b/liblwgeom/cunit/cu_in_geojson.c @@ -26,8 +26,6 @@ static void do_geojson_test(const char * exp, char * in, char * exp_srs, int pre char * srs = NULL; size_t size; - has_bbox = has_bbox; /* unused */ - g = lwgeom_from_geojson(in, &srs); if ( ! g ) { fprintf(stderr, "\nIn: %s\nExp: %s\nObt: %s\n", in, exp, cu_error_msg); diff --git a/liblwgeom/liblwgeom.h.in b/liblwgeom/liblwgeom.h.in index 5d6ac29ba..2566beecb 100644 --- a/liblwgeom/liblwgeom.h.in +++ b/liblwgeom/liblwgeom.h.in @@ -168,6 +168,8 @@ */ extern int clamp_srid(int srid); +/* Raise an lwerror if srids do not match */ +void error_if_srid_mismatch(int srid1, int srid2); /** * Global functions for memory/logging handlers. @@ -1068,22 +1070,27 @@ extern float next_float_up(double d); extern double next_double_down(float d); extern double next_double_up(float d); -/* general utilities - 2D*/ -extern double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2); -extern double distance2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B); -extern LWGEOM *lw_dist2d_distancepoint(LWGEOM *lw1, LWGEOM *lw2,int srid,int mode); -extern LWGEOM *lw_dist2d_distanceline(LWGEOM *lw1, LWGEOM *lw2,int srid,int mode); -extern double lwgeom_mindistance2d(LWGEOM *lw1, LWGEOM *lw2); -extern double lwgeom_mindistance2d_tolerance(LWGEOM *lw1, LWGEOM *lw2, double tolerance); -extern double lwgeom_maxdistance2d(LWGEOM *lw1, LWGEOM *lw2); -extern double lwgeom_maxdistance2d_tolerance(LWGEOM *lw1, LWGEOM *lw2, double tolerance); -/* - 3D*/ +/* general utilities 2D */ +extern double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2); +extern double distance2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B); +extern LWGEOM* lwgeom_closest_line(LWGEOM *lw1, LWGEOM *lw2); +extern LWGEOM* lwgeom_furthest_line(LWGEOM *lw1, LWGEOM *lw2); +extern LWGEOM* lwgeom_closest_point(LWGEOM *lw1, LWGEOM *lw2); +extern LWGEOM* lwgeom_furthest_point(LWGEOM *lw1, LWGEOM *lw2); +extern double lwgeom_mindistance2d(LWGEOM *lw1, LWGEOM *lw2); +extern double lwgeom_mindistance2d_tolerance(LWGEOM *lw1, LWGEOM *lw2, double tolerance); +extern double lwgeom_maxdistance2d(LWGEOM *lw1, LWGEOM *lw2); +extern double lwgeom_maxdistance2d_tolerance(LWGEOM *lw1, LWGEOM *lw2, double tolerance); + +/* 3D */ extern double distance3d_pt_pt(const POINT3D *p1, const POINT3D *p2); extern double distance3d_pt_seg(const POINT3D *p, const POINT3D *A, const POINT3D *B); -extern LWGEOM *lw_dist3d_distancepoint(LWGEOM *lw1, LWGEOM *lw2,int srid,int mode); -extern LWGEOM *lw_dist3d_distanceline(LWGEOM *lw1, LWGEOM *lw2,int srid,int mode); + +extern LWGEOM* lwgeom_furthest_line_3d(LWGEOM *lw1, LWGEOM *lw2); +extern LWGEOM* lwgeom_closest_line_3d(LWGEOM *lw1, LWGEOM *lw2); +extern LWGEOM* lwgeom_closest_point_3d(LWGEOM *lw1, LWGEOM *lw2); + + extern double lwgeom_mindistance3d(LWGEOM *lw1, LWGEOM *lw2); extern double lwgeom_mindistance3d_tolerance(LWGEOM *lw1, LWGEOM *lw2, double tolerance); extern double lwgeom_maxdistance3d(LWGEOM *lw1, LWGEOM *lw2); diff --git a/liblwgeom/liblwgeom_internal.h b/liblwgeom/liblwgeom_internal.h index c4289a273..715ba682d 100644 --- a/liblwgeom/liblwgeom_internal.h +++ b/liblwgeom/liblwgeom_internal.h @@ -64,10 +64,6 @@ #define MAXFLOAT 3.402823466e+38F #endif -/* for the measure functions*/ -#define DIST_MAX -1 -#define DIST_MIN 1 - /* * this will change to NaN when I figure out how to * get NaN in a platform-independent way @@ -151,9 +147,6 @@ #define NDR 1 /* little endian */ extern char getMachineEndian(void); -/* Raise an lwerror if srids do not match */ -void error_if_srid_mismatch(int srid1, int srid2); - /* * Force dims diff --git a/liblwgeom/measures.c b/liblwgeom/measures.c index 87220d478..0bcd6ce2d 100644 --- a/liblwgeom/measures.c +++ b/liblwgeom/measures.c @@ -23,6 +23,31 @@ Initializing functions The functions starting the distance-calculation processses --------------------------------------------------------------------------------------------------------------*/ +LWGEOM * +lwgeom_closest_line(LWGEOM *lw1, LWGEOM *lw2) +{ + return lw_dist2d_distanceline(lw1, lw2, lw1->srid, DIST_MIN); +} + +LWGEOM * +lwgeom_furthest_line(LWGEOM *lw1, LWGEOM *lw2) +{ + return lw_dist2d_distanceline(lw1, lw2, lw1->srid, DIST_MAX); +} + +LWGEOM * +lwgeom_closest_point(LWGEOM *lw1, LWGEOM *lw2) +{ + return lw_dist2d_distancepoint(lw1, lw2, lw1->srid, DIST_MIN); +} + +LWGEOM * +lwgeom_furthest_point(LWGEOM *lw1, LWGEOM *lw2) +{ + return lw_dist2d_distancepoint(lw1, lw2, lw1->srid, DIST_MAX); +} + + void lw_dist2d_distpts_init(DISTPTS *dl, int mode) { diff --git a/liblwgeom/measures.h b/liblwgeom/measures.h index 10145f3fe..9d3f138f7 100644 --- a/liblwgeom/measures.h +++ b/liblwgeom/measures.h @@ -13,10 +13,12 @@ #include "liblwgeom_internal.h" +/* for the measure functions*/ +#define DIST_MAX -1 +#define DIST_MIN 1 -/** - -Structure used in distance-calculations +/** +* Structure used in distance-calculations */ typedef struct { @@ -30,8 +32,8 @@ typedef struct typedef struct { - double themeasure; /*a value calculated to compare distances*/ - int pnr; /*pointnumber. the ordernumber of the point*/ + double themeasure; /*a value calculated to compare distances*/ + int pnr; /*pointnumber. the ordernumber of the point*/ } LISTSTRUCT; @@ -41,7 +43,7 @@ typedef struct int lw_dist2d_comp(LWGEOM *lw1, LWGEOM *lw2, DISTPTS *dl); int lw_dist2d_distribute_bruteforce(LWGEOM *lwg1, LWGEOM *lwg2, DISTPTS *dl); int lw_dist2d_recursive(const LWGEOM *lwg1, const LWGEOM *lwg2, DISTPTS *dl); -int lw_dist2d_check_overlap(LWGEOM *lwg1,LWGEOM *lwg2); +int lw_dist2d_check_overlap(LWGEOM *lwg1, LWGEOM *lwg2); int lw_dist2d_distribute_fast(LWGEOM *lwg1, LWGEOM *lwg2, DISTPTS *dl); /* @@ -93,3 +95,10 @@ void lw_dist2d_distpts_init(DISTPTS *dl, int mode); */ double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3); +/* +* Geometry returning functions +*/ +LWGEOM* lw_dist2d_distancepoint(LWGEOM *lw1, LWGEOM *lw2, int srid, int mode); +LWGEOM* lw_dist2d_distanceline(LWGEOM *lw1, LWGEOM *lw2, int srid, int mode); + + diff --git a/liblwgeom/measures3d.c b/liblwgeom/measures3d.c index 82f21e08b..ced0806d6 100644 --- a/liblwgeom/measures3d.c +++ b/liblwgeom/measures3d.c @@ -18,16 +18,31 @@ #include "lwgeom_log.h" -/*------------------------------------------------------------------------------------------------------------ -Initializing functions -The functions starting the distance-calculation processses ---------------------------------------------------------------------------------------------------------------*/ + +LWGEOM * +lwgeom_closest_line_3d(LWGEOM *lw1, LWGEOM *lw2) +{ + return lw_dist3d_distanceline(lw1, lw2, lw1->srid, DIST_MIN); +} + +LWGEOM * +lwgeom_furthest_line_3d(LWGEOM *lw1, LWGEOM *lw2) +{ + return lw_dist3d_distanceline(lw1, lw2, lw1->srid, DIST_MAX); +} + +LWGEOM * +lwgeom_closest_point_3d(LWGEOM *lw1, LWGEOM *lw2) +{ + return lw_dist3d_distancepoint(lw1, lw2, lw1->srid, DIST_MIN); +} + /** Function initializing 3dshortestline and 3dlongestline calculations. */ LWGEOM * -lw_dist3d_distanceline(LWGEOM *lw1, LWGEOM *lw2,int srid,int mode) +lw_dist3d_distanceline(LWGEOM *lw1, LWGEOM *lw2, int srid, int mode) { double x1,x2,y1,y2, z1, z2; double initdistance = ( mode == DIST_MIN ? MAXFLOAT : -1.0); @@ -76,7 +91,7 @@ lw_dist3d_distanceline(LWGEOM *lw1, LWGEOM *lw2,int srid,int mode) Function initializing 3dclosestpoint calculations. */ LWGEOM * -lw_dist3d_distancepoint(LWGEOM *lw1, LWGEOM *lw2,int srid,int mode) +lw_dist3d_distancepoint(LWGEOM *lw1, LWGEOM *lw2, int srid, int mode) { double x,y,z; DISTPTS3D thedl; diff --git a/liblwgeom/measures3d.h b/liblwgeom/measures3d.h index a725d155e..2587125da 100644 --- a/liblwgeom/measures3d.h +++ b/liblwgeom/measures3d.h @@ -11,7 +11,7 @@ * **********************************************************************/ -#include "liblwgeom_internal.h" +#include "measures.h" #define DOT(u,v) (u.x * v.x + u.y * v.y + u.z * v.z) #define VECTORLENGTH(v) sqrt((v.x * v.x) + (v.y * v.y) + (v.z * v.z)) @@ -45,6 +45,12 @@ typedef struct PLANE3D; +/* +Geometry returning functions +*/ +LWGEOM * lw_dist3d_distancepoint(LWGEOM *lw1, LWGEOM *lw2,int srid,int mode); +LWGEOM * lw_dist3d_distanceline(LWGEOM *lw1, LWGEOM *lw2,int srid,int mode); + /* Preprocessing functions */ diff --git a/postgis/lwgeom_box.c b/postgis/lwgeom_box.c index 8f0bab74a..6ecae73b4 100644 --- a/postgis/lwgeom_box.c +++ b/postgis/lwgeom_box.c @@ -21,7 +21,6 @@ #include "../postgis_config.h" #include "lwgeom_pg.h" #include "liblwgeom.h" -#include "liblwgeom_internal.h" #include #include diff --git a/postgis/lwgeom_box3d.c b/postgis/lwgeom_box3d.c index 5f816e9d3..8b8cdef84 100644 --- a/postgis/lwgeom_box3d.c +++ b/postgis/lwgeom_box3d.c @@ -12,7 +12,6 @@ #include "../postgis_config.h" #include "lwgeom_pg.h" #include "liblwgeom.h" -#include "liblwgeom_internal.h" #include #include diff --git a/postgis/lwgeom_functions_analytic.c b/postgis/lwgeom_functions_analytic.c index 2816901dd..c1f999001 100644 --- a/postgis/lwgeom_functions_analytic.c +++ b/postgis/lwgeom_functions_analytic.c @@ -13,7 +13,7 @@ #include "postgres.h" #include "fmgr.h" #include "liblwgeom.h" -#include "liblwgeom_internal.h" +#include "liblwgeom_internal.h" /* For FP comparators. */ #include "lwgeom_pg.h" #include "math.h" #include "lwgeom_rtree.h" diff --git a/postgis/lwgeom_functions_basic.c b/postgis/lwgeom_functions_basic.c index 31fdcdd25..94a0406f8 100644 --- a/postgis/lwgeom_functions_basic.c +++ b/postgis/lwgeom_functions_basic.c @@ -16,7 +16,9 @@ #include "utils/array.h" #include "utils/geo_decls.h" -#include "liblwgeom_internal.h" +#include "../postgis_config.h" +#include "liblwgeom.h" +// #include "liblwgeom_internal.h" #include "lwgeom_pg.h" #include @@ -596,7 +598,7 @@ Datum LWGEOM_closestpoint(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - point = lw_dist2d_distancepoint(lwgeom1, lwgeom2, lwgeom1->srid, DIST_MIN); + point = lwgeom_closest_point(lwgeom1, lwgeom2); if (lwgeom_is_empty(point)) PG_RETURN_NULL(); @@ -630,7 +632,7 @@ Datum LWGEOM_shortestline2d(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - theline = lw_dist2d_distanceline(lwgeom1, lwgeom2, lwgeom1->srid, DIST_MIN); + theline = lwgeom_closest_line(lwgeom1, lwgeom2); if (lwgeom_is_empty(theline)) PG_RETURN_NULL(); @@ -664,7 +666,7 @@ Datum LWGEOM_longestline2d(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - theline = lw_dist2d_distanceline(lwgeom1, lwgeom2, lwgeom1->srid, DIST_MAX); + theline = lwgeom_furthest_line(lwgeom1, lwgeom2); if (lwgeom_is_empty(theline)) PG_RETURN_NULL(); @@ -836,7 +838,8 @@ Datum LWGEOM_closestpoint3d(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - point = lw_dist3d_distancepoint(lwgeom1, lwgeom2, lwgeom1->srid, DIST_MIN); + point = lwgeom_closest_point_3d(lwgeom1, lwgeom2); + // point = lw_dist3d_distancepoint(lwgeom1, lwgeom2, lwgeom1->srid, DIST_MIN); if (lwgeom_is_empty(point)) PG_RETURN_NULL(); @@ -871,7 +874,8 @@ Datum LWGEOM_shortestline3d(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - theline = lw_dist3d_distanceline(lwgeom1, lwgeom2, lwgeom1->srid, DIST_MIN); + theline = lwgeom_closest_line_3d(lwgeom1, lwgeom2); + // theline = lw_dist3d_distanceline(lwgeom1, lwgeom2, lwgeom1->srid, DIST_MIN); if (lwgeom_is_empty(theline)) PG_RETURN_NULL(); @@ -906,7 +910,8 @@ Datum LWGEOM_longestline3d(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - theline = lw_dist3d_distanceline(lwgeom1, lwgeom2, lwgeom1->srid, DIST_MAX); + theline = lwgeom_furthest_line_3d(lwgeom1, lwgeom2); + // theline = lw_dist3d_distanceline(lwgeom1, lwgeom2, lwgeom1->srid, DIST_MAX); if (lwgeom_is_empty(theline)) PG_RETURN_NULL(); diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c index f79ed6f6c..b1b32e782 100644 --- a/postgis/lwgeom_geos.c +++ b/postgis/lwgeom_geos.c @@ -34,7 +34,7 @@ #include "lwgeom_functions_analytic.h" /* for point_in_polygon */ #include "lwgeom_geos.h" -#include "liblwgeom_internal.h" +#include "liblwgeom.h" #include "lwgeom_rtree.h" #include "lwgeom_geos_prepared.h" diff --git a/postgis/lwgeom_geos_clean.c b/postgis/lwgeom_geos_clean.c index ea2942e40..ff7cebff9 100644 --- a/postgis/lwgeom_geos_clean.c +++ b/postgis/lwgeom_geos_clean.c @@ -42,7 +42,6 @@ #include "../postgis_config.h" #include "lwgeom_geos.h" #include "liblwgeom.h" -#include "liblwgeom_internal.h" #include "lwgeom_pg.h" #include