FUNC: KEEPING FUNCTION: [translate(geometry, double precision, double precision, double precision)]
FUNC: KEEPING FUNCTION: [envelope(geometry)]
-FUNC: KEEPING FUNCTION: [max_distance(geometry, geometry)]
FUNC: KEEPING FUNCTION: [optimistic_overlap(geometry, geometry, double precision)]
FUNC: KEEPING FUNCTION: [segmentize(geometry, double precision)]
#include "lwgeom.h"
-//#define DEBUG
+#define DEBUG
Datum combine_box2d(PG_FUNCTION_ARGS);
Datum LWGEOM_mem_size(PG_FUNCTION_ARGS);
Datum LWGEOM_force_3d(PG_FUNCTION_ARGS);
Datum LWGEOM_force_collection(PG_FUNCTION_ARGS);
Datum LWGEOM_mindistance2d(PG_FUNCTION_ARGS);
+Datum LWGEOM_maxdistance2d_linestring(PG_FUNCTION_ARGS);
// internal
char * lwgeom_summary_recursive(char *serialized, int offset);
return mindist;
}
-
/*------------------------------------------------------------------*/
PG_FUNCTION_INFO_V1(combine_box2d);
}
// Minimum 2d distance between objects in geom1 and geom2.
-// Returns null if it doesnt exist (future null-safe version).
PG_FUNCTION_INFO_V1(LWGEOM_mindistance2d);
Datum LWGEOM_mindistance2d(PG_FUNCTION_ARGS)
{
PG_RETURN_FLOAT8(mindist);
}
+// Maximum 2d distance between linestrings.
+// Returns NULL if given geoms are not linestrings.
+// This is very bogus (or I'm missing its meaning)
+PG_FUNCTION_INFO_V1(LWGEOM_maxdistance2d_linestring);
+Datum LWGEOM_maxdistance2d_linestring(PG_FUNCTION_ARGS)
+{
+
+ LWGEOM *geom1;
+ LWGEOM *geom2;
+ LWLINE *line1;
+ LWLINE *line2;
+ double maxdist = 0;
+ int i;
+
+ geom1 = (LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+ line1 = lwline_deserialize(SERIALIZED_FORM(geom1));
+ if ( line1 == NULL ) PG_RETURN_NULL(); // not a linestring
+
+ geom2 = (LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
+ line2 = lwline_deserialize(SERIALIZED_FORM(geom2));
+ if ( line2 == NULL ) PG_RETURN_NULL(); // not a linestring
+
+ if (lwgeom_getSRID(geom1) != lwgeom_getSRID(geom2))
+ {
+ elog(ERROR,"Operation on two GEOMETRIES with different SRIDs\n");
+ PG_RETURN_NULL();
+ }
+
+ for (i=0; i<line1->points->npoints; i++)
+ {
+ POINT2D *p = (POINT2D *)getPoint(line1->points, i);
+ double dist = distance2d_pt_ptarray(p, line2->points);
+
+ if (dist > maxdist) maxdist = dist;
+ }
+
+ PG_RETURN_FLOAT8(maxdist);
+}
+
AS '@MODULE_FILENAME@', 'LWGEOM_mindistance2d'
LANGUAGE 'C' WITH (isstrict,iscachable);
+-- Maximum distance between linestrings. 2d only. Very bogus.
+CREATEFUNCTION max_distance(geometry,geometry)
+ RETURNS float8
+ AS '@MODULE_FILENAME@', 'LWGEOM_maxdistance2d_linestring'
+ LANGUAGE 'C' WITH (isstrict,iscachable);
+
------------------------------------------------------------------------