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
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);
*/
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.
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);
#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
#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
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)
{
#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
{
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;
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);
/*
*/
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);
+
+
#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);
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;
*
**********************************************************************/
-#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))
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
*/
#include "../postgis_config.h"
#include "lwgeom_pg.h"
#include "liblwgeom.h"
-#include "liblwgeom_internal.h"
#include <math.h>
#include <float.h>
#include "../postgis_config.h"
#include "lwgeom_pg.h"
#include "liblwgeom.h"
-#include "liblwgeom_internal.h"
#include <math.h>
#include <float.h>
#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"
#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 <math.h>
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();
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();
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();
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();
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();
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();
#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"
#include "../postgis_config.h"
#include "lwgeom_geos.h"
#include "liblwgeom.h"
-#include "liblwgeom_internal.h"
#include "lwgeom_pg.h"
#include <string.h>