va_end(ap);
}
-/* liblwgeom allocator callback - install the defaults (malloc/free/stdout/stderr) */
-/* TODO hook lwnotice/lwerr up to the GUI */
+/** liblwgeom allocator callback - install the defaults (malloc/free/stdout/stderr) */
+/**
+ TODO: hook lwnotice/lwerr up to the GUI
+ */
void lwgeom_init_allocators()
{
lwgeom_install_default_allocators();
}
-/*
+/**
* Escape input string suitable for COPY
*/
char *
escape_copy_string(char *str)
{
- /*
- * Escape the following characters by adding a preceding backslash
- * tab, backslash, cr, lf
- *
+ /**
+ * Escape the following characters by adding a preceding backslash
+ * tab, backslash, cr, lf
+ *
* 1. find # of escaped characters
- * 2. make new string
+ * 2. make new string
*
*/
while (*ptr)
{
- if ( *ptr == '\t' || *ptr == '\\' ||
- *ptr == '\n' || *ptr == '\r' )
+ if ( *ptr == '\t' || *ptr == '\\' ||
+ *ptr == '\n' || *ptr == '\r' )
toescape++;
ptr++;
}
while (*ptr)
{
if ( *ptr == '\t' || *ptr == '\\' ||
- *ptr == '\n' || *ptr == '\r' )
+ *ptr == '\n' || *ptr == '\r' )
*optr++='\\';
*optr++=*ptr++;
}
}
-/*
+/**
* Escape input string suitable for INSERT
*/
escape_insert_string(char *str)
{
/*
- * Escape single quotes by adding a preceding single quote
- *
+ * Escape single quotes by adding a preceding single quote
+ *
* 1. find # of characters
- * 2. make new string
+ * 2. make new string
*/
char *result;
-/*
+/**
* PIP(): crossing number test for a point in a polygon
* input: P = a point,
* V[] = vertex points of a polygon V[n+1] with V[n]=V[0]
for (i=0; i<n-1; i++)
{ /* edge from V[i] to V[i+1] */
if (((V[i].y <= P.y) && (V[i+1].y > P.y)) /* an upward crossing */
- || ((V[i].y > P.y) && (V[i+1].y <= P.y)))
+ || ((V[i].y > P.y) && (V[i+1].y <= P.y)))
{ /* a downward crossing */
double vt = (float)(P.y - V[i].y) / (V[i+1].y - V[i].y);
if (P.x < V[i].x + vt * (V[i+1].x - V[i].x)) /* P.x < intersect */
default:
pgis_logf(
- "Error: field %d has invalid or unknown field type (%d)",
- i, types[i]);
+ "Error: field %d has invalid or unknown field type (%d)",
+ i, types[i]);
return 0;
}
-
+
if (dump_format)
{
escval = escape_copy_string(val);
-/*
+/**
* formerly main()
*/
int
if ( schema && readshape == 1 )
{
stringbuffer_aprintf(sb_row, "SELECT AddGeometryColumn('%s','%s','%s','%d',",
- schema, table, geom, sr_id);
+ schema, table, geom, sr_id);
}
else if (readshape == 1)
{
stringbuffer_aprintf(sb_row, "SELECT AddGeometryColumn('','%s','%s','%d',",
- table, geom, sr_id);
+ table, geom, sr_id);
}
if (pgtype)
{ //pgtype will only be set if we are loading geometries
if ( schema )
{
asprintf(©sql, "COPY \"%s\".\"%s\" %s FROM stdin",
- schema, table, col_names);
+ schema, table, col_names);
}
else
{
asprintf(©sql, "COPY \"%s\" %s FROM stdin",
- table, col_names);
+ table, col_names);
}
pgis_copy_start(copysql);
free(copysql);
}
/**************************************************************
- *
+ *
* MAIN SHAPE OBJECTS SCAN
- *
+ *
**************************************************************/
while (cur_entity < num_entities - 1)
{
if ( schema )
{
stringbuffer_aprintf(sb_row, "INSERT INTO \"%s\".\"%s\" %s VALUES (",
- schema, table, col_names);
+ schema, table, col_names);
}
else
{
stringbuffer_aprintf(sb_row, "INSERT INTO \"%s\" %s VALUES (",
- table, col_names);
+ table, col_names);
}
}
if ( ! Insert_attributes(hDBFHandle,cur_entity) ) return 0;
default:
pgis_logf ("**** Type is NOT SUPPORTED, type id = %d ****",
- obj->nSHPType);
+ obj->nSHPType);
break;
}
ring->list[vi-vs].m = obj->padfM[vi];
area += (obj->padfX[vi] * obj->padfY[vn]) -
- (obj->padfY[vi] * obj->padfX[vn]);
+ (obj->padfY[vi] * obj->padfX[vn]);
}
/* Close the ring with first vertex */
/*---------------Drop the table--------------------------
* TODO: if the table has more then one geometry column
* the DROP TABLE call will leave spurious records in
- * geometry_columns.
+ * geometry_columns.
*
* If the geometry column in the table being dropped
* does not match 'the_geom' or the name specified with
- * -g an error is returned by DropGeometryColumn.
+ * -g an error is returned by DropGeometryColumn.
*
* The table to be dropped might not exist.
*
* or after pgsql reserved attribute names
*/
if ( name[0]=='_' ||
- ! strcmp(name,"gid") ||
- ! strcmp(name, "tableoid") ||
- ! strcmp(name, "cmax") ||
- ! strcmp(name, "xmax") ||
- ! strcmp(name, "cmin") ||
- ! strcmp(name, "primary") ||
- ! strcmp(name, "oid") ||
- ! strcmp(name, "ctid") )
+ ! strcmp(name,"gid") ||
+ ! strcmp(name, "tableoid") ||
+ ! strcmp(name, "cmax") ||
+ ! strcmp(name, "xmax") ||
+ ! strcmp(name, "cmin") ||
+ ! strcmp(name, "primary") ||
+ ! strcmp(name, "oid") ||
+ ! strcmp(name, "ctid") )
{
strcpy(name2+2, name);
name2[0] = '_';
Datum BOX3D_zmax(PG_FUNCTION_ARGS);
Datum BOX3D_combine(PG_FUNCTION_ARGS);
-/*
+/**
* BOX3D_in - takes a string rep of BOX3D and returns internal rep
*
* example:
}
nitems = sscanf(str,"BOX3D(%le %le %le ,%le %le %le)",
- &box->xmin, &box->ymin, &box->zmin,
- &box->xmax, &box->ymax, &box->zmax);
+ &box->xmin, &box->ymin, &box->zmin,
+ &box->xmax, &box->ymax, &box->zmax);
if (nitems != 6 )
{
nitems = sscanf(str,"BOX3D(%le %le ,%le %le)",
- &box->xmin, &box->ymin, &box->xmax, &box->ymax);
+ &box->xmin, &box->ymin, &box->xmax, &box->ymax);
if (nitems != 4)
{
pfree(box);
}
-/*
+/**
* Takes an internal rep of a BOX3D and returns a string rep.
*
* example:
result = (char *) palloc(size);
sprintf(result, "BOX3D(%.15g %.15g %.15g,%.15g %.15g %.15g)",
- bbox->xmin, bbox->ymin, bbox->zmin,
- bbox->xmax,bbox->ymax,bbox->zmax);
+ bbox->xmin, bbox->ymin, bbox->zmin,
+ bbox->xmax,bbox->ymax,bbox->zmax);
PG_RETURN_CSTRING(result);
}
-/*
+/**
* Takes an internal rep of a BOX3D and returns a string rep.
* but beginning with BOX(...) and with only 2 dimensions. This
* is a temporary hack to allow ST_Extent() to return a result
result = (char *) palloc(size);
sprintf(result, "BOX(%.15g %.15g,%.15g %.15g)",
- bbox->xmin, bbox->ymin,
- bbox->xmax,bbox->ymax);
+ bbox->xmin, bbox->ymin,
+ bbox->xmax,bbox->ymax);
PG_RETURN_CSTRING(result);
}
uchar *ser;
- /*
+ /**
* Alter BOX3D cast so that a valid geometry is always
* returned depending upon the size of the BOX3D. The
* code makes the following assumptions:
*/
if (box->xmin == box->xmax &&
- box->ymin == box->ymax)
+ box->ymin == box->ymax)
{
/* Construct and serialize point */
LWPOINT *point = make_lwpoint2d(-1, box->xmin, box->ymin);
ser = lwpoint_serialize(point);
}
else if (box->xmin == box->xmax ||
- box->ymin == box->ymax)
+ box->ymin == box->ymax)
{
LWLINE *line;
POINT2D *pts = palloc(sizeof(POINT2D)*2);
PG_RETURN_POINTER(result);
}
-/* Expand given box of 'd' units in all directions */
+/** Expand given box of 'd' units in all directions */
void
expand_box3d(BOX3D *box, double d)
{
PG_RETURN_POINTER(result);
}
-/*
+/**
* convert a PG_LWGEOM to BOX3D
*
* NOTE: the bounding box is *always* recomputed as the cache
maxpoint = lwgeom_deserialize(SERIALIZED_FORM(max));
if ( TYPE_GETTYPE(minpoint->type) != POINTTYPE ||
- TYPE_GETTYPE(maxpoint->type) != POINTTYPE )
+ TYPE_GETTYPE(maxpoint->type) != POINTTYPE )
{
elog(ERROR, "BOX3D_construct: args must be points");
PG_RETURN_NULL();
PG_RETURN_POINTER(result);
}
-/* min(a,b) */
+/** min(a,b) */
double
LWGEOM_Mind(double a, double b)
{
return b;
}
-/* max(a,b) */
+/** max(a,b) */
double
LWGEOM_Maxd(double a, double b)
{
#include <errno.h>
#include <ctype.h>
-/*
+/**
* Assign a number to the postgis statistics kind
*
* tgl suggested:
#define SHOW_DIGS_DOUBLE 15
#define MAX_DIGS_DOUBLE (SHOW_DIGS_DOUBLE + 6 + 1 + 3 +1)
-/*
+/**
* Default geometry selectivity factor
*/
#define DEFAULT_GEOMETRY_SEL 0.000005
-/*
+/**
* Default geometry join selectivity factor
*/
#define DEFAULT_GEOMETRY_JOINSEL 0.000005
-/*
+/**
* Define this to actually DO join selectivity
* (as contrary to just return the default JOINSEL value)
* Note that this is only possible when compiling postgis
#if ! REALLY_DO_JOINSEL
-/*
+/**
* JOIN selectivity in the GiST && operator
* for all PG versions
*/
Datum LWGEOM_gist_joinsel(PG_FUNCTION_ARGS)
{
POSTGIS_DEBUGF(2, "LWGEOM_gist_joinsel called (returning %f)",
- DEFAULT_GEOMETRY_JOINSEL);
+ DEFAULT_GEOMETRY_JOINSEL);
PG_RETURN_FLOAT8(DEFAULT_GEOMETRY_JOINSEL);
}
int
calculate_column_intersection(BOX2DFLOAT4 *search_box, GEOM_STATS *geomstats1, GEOM_STATS *geomstats2)
{
- /*
+ /**
* Calculate the intersection of two columns from their geomstats extents - return true
* if a valid intersection was found, false if there is no overlap
*/
return -1;
}
-/*
+/**
* JOIN selectivity in the GiST && operator
* for all PG versions
*/
BOX2DFLOAT4 search_box;
- /*
+ /**
* Join selectivity algorithm. To calculation the selectivity we
* calculate the intersection of the two column sample extents,
* sum the results, and then multiply by two since for each
if ( ! get_attstatsslot(stats1_tuple, 0, 0,
- STATISTIC_KIND_GEOMETRY, InvalidOid, NULL, NULL,
- (float4 **)gs1ptr, &geomstats1_nvalues) )
+ STATISTIC_KIND_GEOMETRY, InvalidOid, NULL, NULL,
+ (float4 **)gs1ptr, &geomstats1_nvalues) )
{
POSTGIS_DEBUG(3, " STATISTIC_KIND_GEOMETRY stats not found - returning default geometry join selectivity");
POSTGIS_DEBUG(3, " No statistics, returning default geometry join selectivity");
free_attstatsslot(0, NULL, 0, (float *)geomstats1,
- geomstats1_nvalues);
+ geomstats1_nvalues);
ReleaseSysCache(stats1_tuple);
PG_RETURN_FLOAT8(DEFAULT_GEOMETRY_JOINSEL);
}
if ( ! get_attstatsslot(stats2_tuple, 0, 0,
- STATISTIC_KIND_GEOMETRY, InvalidOid, NULL, NULL,
- (float4 **)gs2ptr, &geomstats2_nvalues) )
+ STATISTIC_KIND_GEOMETRY, InvalidOid, NULL, NULL,
+ (float4 **)gs2ptr, &geomstats2_nvalues) )
{
POSTGIS_DEBUG(3, " STATISTIC_KIND_GEOMETRY stats not found - returning default geometry join selectivity");
free_attstatsslot(0, NULL, 0, (float *)geomstats1,
- geomstats1_nvalues);
+ geomstats1_nvalues);
ReleaseSysCache(stats2_tuple);
ReleaseSysCache(stats1_tuple);
PG_RETURN_FLOAT8(DEFAULT_GEOMETRY_JOINSEL);
}
- /*
+ /**
* Setup the search box - this is the intersection of the two column
* extents.
*/
* multiply out the returned selectivity by the total number of rows.
*/
class_tuple = SearchSysCache(RELOID, ObjectIdGetDatum(relid1),
- 0, 0, 0);
+ 0, 0, 0);
if (HeapTupleIsValid(class_tuple))
{
class_tuple = SearchSysCache(RELOID, ObjectIdGetDatum(relid2),
- 0, 0, 0);
+ 0, 0, 0);
if (HeapTupleIsValid(class_tuple))
{
total_tuples = num1_tuples * num2_tuples;
rows_returned = 2 * ((num1_tuples * selectivity1) +
- (num2_tuples * selectivity2));
+ (num2_tuples * selectivity2));
POSTGIS_DEBUGF(3, "Rows from rel1: %f", num1_tuples * selectivity1);
POSTGIS_DEBUGF(3, "Rows from rel2: %f", num2_tuples * selectivity2);
/**************************** FROM POSTGIS ****************/
-/*
+/**
* This function returns an estimate of the selectivity
* of a search_box looking at data in the GEOM_STATS
* structure.
- *
+ * */
+ /**
* TODO: handle box dimension collapses (probably should be handled
* by the statistic generator, avoiding GEOM_STATS with collapsed
* dimensions)
* Search box completely miss histogram extent
*/
if ( box->xmax < geomstats->xmin ||
- box->xmin > geomstats->xmax ||
- box->ymax < geomstats->ymin ||
- box->ymin > geomstats->ymax )
+ box->xmin > geomstats->xmax ||
+ box->ymax < geomstats->ymin ||
+ box->ymin > geomstats->ymax )
{
POSTGIS_DEBUG(3, " search_box does not overlaps histogram, returning 0");
* Search box completely contains histogram extent
*/
if ( box->xmax >= geomstats->xmax &&
- box->xmin <= geomstats->xmin &&
- box->ymax >= geomstats->ymax &&
- box->ymin <= geomstats->ymin )
+ box->xmin <= geomstats->xmin &&
+ box->ymax >= geomstats->ymax &&
+ box->ymin <= geomstats->ymin )
{
POSTGIS_DEBUG(3, " search_box contains histogram, returning 1");
gain = AOI/cell_area;
POSTGIS_DEBUGF(4, " [%d,%d] cell val %.15f",
- x, y, val);
+ x, y, val);
POSTGIS_DEBUGF(4, " [%d,%d] AOI %.15f",
- x, y, AOI);
+ x, y, AOI);
POSTGIS_DEBUGF(4, " [%d,%d] gain %.15f",
- x, y, gain);
+ x, y, gain);
val *= gain;
POSTGIS_DEBUGF(4, " [%d,%d] adding %.15f to value",
- x, y, val);
+ x, y, val);
value += val;
}
* by both searc_box and feature. We should then
* divide our value by the number of cells in the virtual
* 'intersection' between average feature cell occupation
- * and occupation of the search_box. This is as
+ * and occupation of the search_box. This is as
* fuzzy as you understand it :)
*
* Consistency check: whenever the number of cells is
*
*/
overlapping_cells = (x_idx_max-x_idx_min+1) *
- (y_idx_max-y_idx_min+1);
+ (y_idx_max-y_idx_min+1);
avg_feat_cells = geomstats->avgFeatureCells;
POSTGIS_DEBUGF(3, " search_box overlaps %f cells", overlapping_cells);
return selectivity;
}
-/*
+/**
* This function should return an estimation of the number of
* rows returned by a query involving an overlap check
* ( it's the restrict function for the && operator )
/*
* We are working on two constants..
* TODO: check if expression is true,
- * returned set would be either
+ * returned set would be either
* the whole or none.
*/
if ( ! IsA(self, Var) )
if ( ! get_attstatsslot(stats_tuple, 0, 0,
- STATISTIC_KIND_GEOMETRY, InvalidOid, NULL, NULL,
- (float4 **)gsptr, &geomstats_nvalues) )
+ STATISTIC_KIND_GEOMETRY, InvalidOid, NULL, NULL,
+ (float4 **)gsptr, &geomstats_nvalues) )
{
POSTGIS_DEBUG(3, " STATISTIC_KIND_GEOMETRY stats not found - returning default geometry selectivity");
POSTGIS_DEBUGF(4, " %d read from stats", geomstats_nvalues);
POSTGIS_DEBUGF(4, " histo: xmin,ymin: %f,%f",
- geomstats->xmin, geomstats->ymin);
+ geomstats->xmin, geomstats->ymin);
POSTGIS_DEBUGF(4, " histo: xmax,ymax: %f,%f",
- geomstats->xmax, geomstats->ymax);
+ geomstats->xmax, geomstats->ymax);
POSTGIS_DEBUGF(4, " histo: cols: %f", geomstats->rows);
POSTGIS_DEBUGF(4, " histo: rows: %f", geomstats->cols);
POSTGIS_DEBUGF(4, " histo: avgFeatureArea: %f", geomstats->avgFeatureArea);
}
-/*
+/**
* This function is called by the analyze function iff
* the geometry_analyze() function give it its pointer
* (this is always the case so far).
*/
static void
compute_geometry_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc,
- int samplerows, double totalrows)
+ int samplerows, double totalrows)
{
MemoryContext old_context;
int i;
* Skip infinite geoms
*/
if ( ! finite(box.xmin) ||
- ! finite(box.xmax) ||
- ! finite(box.ymin) ||
- ! finite(box.ymax) )
+ ! finite(box.xmax) ||
+ ! finite(box.ymin) ||
+ ! finite(box.ymax) )
{
POSTGIS_DEBUGF(3, " skipped infinite geometry %d", i);
else
{
sample_extent->xmax = LWGEOM_Maxf(sample_extent->xmax,
- box.xmax);
+ box.xmax);
sample_extent->ymax = LWGEOM_Maxf(sample_extent->ymax,
- box.ymax);
+ box.ymax);
sample_extent->xmin = LWGEOM_Minf(sample_extent->xmin,
- box.xmin);
+ box.xmin);
sample_extent->ymin = LWGEOM_Minf(sample_extent->ymin,
- box.ymin);
+ box.ymin);
}
- /* TODO: ask if we need geom or bvol size for stawidth */
+ /** TODO: ask if we need geom or bvol size for stawidth */
total_width += geom->size;
total_boxes_area += (box.xmax-box.xmin)*(box.ymax-box.ymin);
#if USE_STANDARD_DEVIATION
/*
- * Add bvol coordinates to sum for standard deviation
+ * Add bvol coordinates to sum for standard deviation
* computation.
*/
sumLOWx += box.xmin;
#if USE_STANDARD_DEVIATION
POSTGIS_DEBUGF(3, " sample_extent: xmin,ymin: %f,%f",
- sample_extent->xmin, sample_extent->ymin);
+ sample_extent->xmin, sample_extent->ymin);
POSTGIS_DEBUGF(3, " sample_extent: xmax,ymax: %f,%f",
- sample_extent->xmax, sample_extent->ymax);
+ sample_extent->xmax, sample_extent->ymax);
/*
* Second scan:
POSTGIS_DEBUGF(3, " HIGy - avg:%f sd:%f", avgHIGy, sdHIGy);
histobox.xmin = LW_MAX((avgLOWx - SDFACTOR * sdLOWx),
- sample_extent->xmin);
+ sample_extent->xmin);
histobox.ymin = LW_MAX((avgLOWy - SDFACTOR * sdLOWy),
- sample_extent->ymin);
+ sample_extent->ymin);
histobox.xmax = LW_MIN((avgHIGx + SDFACTOR * sdHIGx),
- sample_extent->xmax);
+ sample_extent->xmax);
histobox.ymax = LW_MIN((avgHIGy + SDFACTOR * sdHIGy),
- sample_extent->ymax);
+ sample_extent->ymax);
POSTGIS_DEBUGF(3, " sd_extent: xmin,ymin: %f,%f",
- histobox.xmin, histobox.ymin);
+ histobox.xmin, histobox.ymin);
POSTGIS_DEBUGF(3, " sd_extent: xmax,ymax: %f,%f",
- histobox.xmin, histobox.ymax);
+ histobox.xmin, histobox.ymax);
/*
* Third scan:
box = (BOX2DFLOAT4 *)sampleboxes[i];
if ( box->xmin > histobox.xmax ||
- box->xmax < histobox.xmin ||
- box->ymin > histobox.ymax ||
- box->ymax < histobox.ymin )
+ box->xmax < histobox.xmin ||
+ box->ymin > histobox.ymax ||
+ box->ymax < histobox.ymin )
{
POSTGIS_DEBUGF(4, " feat %d is an hard deviant, skipped", i);
/*
* Set histogram extent as the intersection between
- * standard deviation based histogram extent
+ * standard deviation based histogram extent
* and computed sample extent after removal of
* hard deviants (there might be no hard deviants).
*/
POSTGIS_DEBUGF(3, " histogram_extent: xmin,ymin: %f,%f",
- histobox.xmin, histobox.ymin);
+ histobox.xmin, histobox.ymin);
POSTGIS_DEBUGF(3, " histogram_extent: xmax,ymax: %f,%f",
- histobox.xmax, histobox.ymax);
+ histobox.xmax, histobox.ymax);
geow = histobox.xmax - histobox.xmin;
vacuum_delay_point();
POSTGIS_DEBUGF(4, " feat %d box is %f %f, %f %f",
- i, box->xmax, box->ymax,
- box->xmin, box->ymin);
+ i, box->xmax, box->ymax,
+ box->xmin, box->ymin);
/* Find first overlapping column */
x_idx_min = (box->xmin-geomstats->xmin) / geow * cols;
if (y_idx_max >= rows) y_idx_max = rows-1;
POSTGIS_DEBUGF(4, " feat %d overlaps columns %d-%d, rows %d-%d",
- i, x_idx_min, x_idx_max, y_idx_min, y_idx_max);
+ i, x_idx_min, x_idx_max, y_idx_min, y_idx_max);
/*
* the {x,y}_idx_{min,max}
/*
* before adding to the total cells
- * we could decide if we really
+ * we could decide if we really
* want this feature to count
*/
total_boxes_cells += numcells;
return;
}
- /* what about null features (TODO) ? */
+ /** TODO: what about null features (TODO) */
geomstats->avgFeatureCells = (float4)total_boxes_cells/examinedsamples;
POSTGIS_DEBUGF(3, " histo: total_boxes_cells: %d", total_boxes_cells);
/*
- * Write the statistics data
+ * Write the statistics data
*/
stats->stakind[0] = STATISTIC_KIND_GEOMETRY;
stats->staop[0] = InvalidOid;
stats->stadistinct = -1.0;
POSTGIS_DEBUGF(3, " out: slot 0: kind %d (STATISTIC_KIND_GEOMETRY)",
- stats->stakind[0]);
+ stats->stakind[0]);
POSTGIS_DEBUGF(3, " out: slot 0: op %d (InvalidOid)", stats->staop[0]);
POSTGIS_DEBUGF(3, " out: slot 0: numnumbers %d", stats->numnumbers[0]);
POSTGIS_DEBUGF(3, " out: null fraction: %d/%d=%g", null_cnt, samplerows, stats->stanullfrac);
stats->stats_valid = true;
}
-/*
+/**
* This function will be called when the ANALYZE command is run
* on a column of the "geometry" type.
*
PG_RETURN_BOOL(true);
}
-/*
+/**
* Return the estimated extent of the table
* looking at gathered statistics (or NULL if
* no statistics have been gathered).
else
{
POSTGIS_DEBUGF(3, " schema:current_schema() table:%s column:%s",
- tbl, col);
+ tbl, col);
}
#endif
memcpy(box, ARR_DATA_PTR(array), sizeof(BOX2DFLOAT4));
POSTGIS_DEBUGF(3, " histogram extent = %g %g, %g %g", box->xmin,
- box->ymin, box->xmax, box->ymax);
+ box->ymin, box->xmax, box->ymax);
SPIcode = SPI_finish();
if (SPIcode != SPI_OK_FINISH )
#include <errno.h>
-/*
- * implementation GiST support and basic LWGEOM operations (like &&)
+/**
+ * @file implementation GiST support and basic LWGEOM operations (like &&)
*/
static int counter_intern = 0;
-/* GiST strategies (modified from src/include/access/rtree.h) */
+/** GiST strategies (modified from src/include/access/rtree.h) */
#define RTLeftStrategyNumber 1
#define RTOverLeftStrategyNumber 2
#define RTOverlapStrategyNumber 3
#define RTOverAboveStrategyNumber 12
-/*
+/**
* all the lwgeom_<same,overlpa,overleft,left,right,overright,overbelow,below,above,overabove,contained,contain>
* work the same.
* 1. get lwgeom1
}
result = DatumGetBool(DirectFunctionCall2(BOX2D_overlap,
- PointerGetDatum(&box1), PointerGetDatum(&box2)));
+ PointerGetDatum(&box1), PointerGetDatum(&box2)));
PG_FREE_IF_COPY(lwgeom1, 0);
PG_FREE_IF_COPY(lwgeom2, 1);
POSTGIS_DEBUGF(3, "GIST: lwgeom_overlap:\n(%f %f, %f %f) (%f %f %f %f) = %i",
- box1.xmin, box1.ymax, box1.xmax, box1.ymax,
- box2.xmin, box2.ymax, box2.xmax, box2.ymax,
- result
- );
+ box1.xmin, box1.ymax, box1.xmax, box1.ymax,
+ box2.xmin, box2.ymax, box2.xmax, box2.ymax,
+ result
+ );
PG_RETURN_BOOL(result);
}
result = DatumGetBool(DirectFunctionCall2(BOX2D_overleft,
- PointerGetDatum(&box1), PointerGetDatum(&box2)));
+ PointerGetDatum(&box1), PointerGetDatum(&box2)));
PG_FREE_IF_COPY(lwgeom1, 0);
PG_FREE_IF_COPY(lwgeom2, 1);
}
result = DatumGetBool(DirectFunctionCall2(BOX2D_left,
- PointerGetDatum(&box1), PointerGetDatum(&box2)));
+ PointerGetDatum(&box1), PointerGetDatum(&box2)));
PG_FREE_IF_COPY(lwgeom1, 0);
PG_FREE_IF_COPY(lwgeom2, 1);
}
result = DatumGetBool(DirectFunctionCall2(BOX2D_right,
- PointerGetDatum(&box1), PointerGetDatum(&box2)));
+ PointerGetDatum(&box1), PointerGetDatum(&box2)));
PG_FREE_IF_COPY(lwgeom1, 0);
PG_FREE_IF_COPY(lwgeom2, 1);
}
result = DatumGetBool(DirectFunctionCall2(BOX2D_overright,
- PointerGetDatum(&box1), PointerGetDatum(&box2)));
+ PointerGetDatum(&box1), PointerGetDatum(&box2)));
PG_FREE_IF_COPY(lwgeom1, 0);
PG_FREE_IF_COPY(lwgeom2, 1);
result = DatumGetBool(DirectFunctionCall2(BOX2D_overbelow,
- PointerGetDatum(&box1), PointerGetDatum(&box2)));
+ PointerGetDatum(&box1), PointerGetDatum(&box2)));
PG_FREE_IF_COPY(lwgeom1, 0);
PG_FREE_IF_COPY(lwgeom2, 1);
}
result = DatumGetBool(DirectFunctionCall2(BOX2D_below,
- PointerGetDatum(&box1), PointerGetDatum(&box2)));
+ PointerGetDatum(&box1), PointerGetDatum(&box2)));
PG_FREE_IF_COPY(lwgeom1, 0);
PG_FREE_IF_COPY(lwgeom2, 1);
}
result = DatumGetBool(DirectFunctionCall2(BOX2D_above,
- PointerGetDatum(&box1), PointerGetDatum(&box2)));
+ PointerGetDatum(&box1), PointerGetDatum(&box2)));
PG_FREE_IF_COPY(lwgeom1, 0);
PG_FREE_IF_COPY(lwgeom2, 1);
}
result = DatumGetBool(DirectFunctionCall2(BOX2D_overabove,
- PointerGetDatum(&box1), PointerGetDatum(&box2)));
+ PointerGetDatum(&box1), PointerGetDatum(&box2)));
PG_FREE_IF_COPY(lwgeom1, 0);
PG_FREE_IF_COPY(lwgeom2, 1);
}
result = DatumGetBool(DirectFunctionCall2(BOX2D_contained,
- PointerGetDatum(&box1), PointerGetDatum(&box2)));
+ PointerGetDatum(&box1), PointerGetDatum(&box2)));
PG_FREE_IF_COPY(lwgeom1, 0);
PG_FREE_IF_COPY(lwgeom2, 1);
}
result = DatumGetBool(DirectFunctionCall2(BOX2D_contain,
- PointerGetDatum(&box1), PointerGetDatum(&box2)));
+ PointerGetDatum(&box1), PointerGetDatum(&box2)));
PG_FREE_IF_COPY(lwgeom1, 0);
PG_FREE_IF_COPY(lwgeom2, 1);
rr = (BOX2DFLOAT4*) palloc(sizeof(BOX2DFLOAT4));
if ( ! getbox2d_p(SERIALIZED_FORM(in), rr) ||
- ! finite(rr->xmin) ||
- ! finite(rr->ymin) ||
- ! finite(rr->xmax) ||
- ! finite(rr->ymax) )
+ ! finite(rr->xmin) ||
+ ! finite(rr->ymin) ||
+ ! finite(rr->xmax) ||
+ ! finite(rr->ymax) )
{
POSTGIS_DEBUG(4, "found empty or infinite geometry");
#if POSTGIS_PGSQL_VERSION >= 82
gistentryinit(*retval, PointerGetDatum(rr),
- entry->rel, entry->page,
- entry->offset,
- FALSE);
+ entry->rel, entry->page,
+ entry->offset,
+ FALSE);
#else
gistentryinit(*retval, PointerGetDatum(rr),
- entry->rel, entry->page,
- entry->offset, sizeof(BOX2DFLOAT4),
- FALSE);
+ entry->rel, entry->page,
+ entry->offset, sizeof(BOX2DFLOAT4),
+ FALSE);
#endif
#if POSTGIS_PGSQL_VERSION >= 82
gistentryinit(*retval, (Datum) 0, entry->rel,
- entry->page, entry->offset, FALSE);
+ entry->page, entry->offset, FALSE);
#else
gistentryinit(*retval, (Datum) 0, entry->rel,
- entry->page, entry->offset, 0, FALSE);
+ entry->page, entry->offset, 0, FALSE);
#endif
}
}
/*
- ** First pull only a small amount of the tuple, enough to
+ ** First pull only a small amount of the tuple, enough to
** get the bounding box, if one exists.
** size = header + type + box2df4?
*/
/*
** If the bounding box exists, copy it into the working variable.
- ** If not, pull the full toasted data out, and call the standard box
+ ** If not, pull the full toasted data out, and call the standard box
** retrieval function, which will calculate the box from scratch.
*/
serialized_lwgeom = SERIALIZED_FORM(query);
if (GIST_LEAF(entry))
result = lwgeom_rtree_leaf_consistent((BOX2DFLOAT4 *)
- DatumGetPointer(entry->key), &box, strategy );
+ DatumGetPointer(entry->key), &box, strategy );
else
result = lwgeom_rtree_internal_consistent(
- (BOX2DFLOAT4 *) DatumGetPointer(entry->key),
- &box, strategy );
+ (BOX2DFLOAT4 *) DatumGetPointer(entry->key),
+ &box, strategy );
PG_FREE_IF_COPY(query, 1);
PG_RETURN_BOOL(result);
static bool
lwgeom_rtree_internal_consistent(BOX2DFLOAT4 *key, BOX2DFLOAT4 *query,
- StrategyNumber strategy)
+ StrategyNumber strategy)
{
bool retval;
case RTOverlapStrategyNumber: /*optimized for speed */
retval = (((key->xmax>= query->xmax) &&
- (key->xmin <= query->xmax)) ||
- ((query->xmax>= key->xmax) &&
- (query->xmin<= key->xmax)))
- &&
- (((key->ymax>= query->ymax) &&
- (key->ymin<= query->ymax)) ||
- ((query->ymax>= key->ymax) &&
- (query->ymin<= key->ymax)));
+ (key->xmin <= query->xmax)) ||
+ ((query->xmax>= key->xmax) &&
+ (query->xmin<= key->xmax)))
+ &&
+ (((key->ymax>= query->ymax) &&
+ (key->ymin<= query->ymax)) ||
+ ((query->ymax>= key->ymax) &&
+ (query->ymin<= key->ymax)));
#if POSTGIS_DEBUG_LEVEL >=4
if (counter_intern == 0)
{
POSTGIS_DEBUGF(4, "search bounding box is: <%.16g %.16g,%.16g %.16g> - size box2d= %ld",
- query->xmin,query->ymin,query->xmax,query->ymax,sizeof(BOX2DFLOAT4));
+ query->xmin,query->ymin,query->xmax,query->ymax,sizeof(BOX2DFLOAT4));
}
POSTGIS_DEBUGF(4, "%i:(int)<%.8g %.8g,%.8g %.8g>&&<%.8g %.8g,%.8g %.8g> %i",counter_intern,key->xmin,key->ymin,key->xmax,key->ymax,
- query->xmin,query->ymin,query->xmax,query->ymax, (int) retval);
+ query->xmin,query->ymin,query->xmax,query->ymax, (int) retval);
counter_intern++;
#endif
static bool
lwgeom_rtree_leaf_consistent(BOX2DFLOAT4 *key,
- BOX2DFLOAT4 *query, StrategyNumber strategy)
+ BOX2DFLOAT4 *query, StrategyNumber strategy)
{
bool retval;
break;
case RTOverlapStrategyNumber: /*optimized for speed */
retval = (((key->xmax>= query->xmax) &&
- (key->xmin <= query->xmax)) ||
- ((query->xmax>= key->xmax) &&
- (query->xmin<= key->xmax)))
- &&
- (((key->ymax>= query->ymax) &&
- (key->ymin<= query->ymax)) ||
- ((query->ymax>= key->ymax) &&
- (query->ymin<= key->ymax)));
+ (key->xmin <= query->xmax)) ||
+ ((query->xmax>= key->xmax) &&
+ (query->xmin<= key->xmax)))
+ &&
+ (((key->ymax>= query->ymax) &&
+ (key->ymin<= query->ymax)) ||
+ ((query->ymax>= key->ymax) &&
+ (query->ymin<= key->ymax)));
#if POSTGIS_DEBUG_LEVEL >= 4
/*keep track and report info about how many times this is called */
POSTGIS_DEBUGF(4, "%i:gist test (leaf) <%.6g %.6g,%.6g %.6g> && <%.6g %.6g,%.6g %.6g> --> %i",
- counter_leaf,key->xmin,key->ymin,key->xmax,key->ymax,
- query->xmin,query->ymin,query->xmax,query->ymax, (int) retval);
+ counter_leaf,key->xmin,key->ymin,key->xmax,key->ymax,
+ query->xmin,query->ymin,query->xmax,query->ymax, (int) retval);
counter_leaf++;
#endif
return(retval);
-/*
+/**
* The GiST Union method for boxes
* returns the minimal bounding box that encloses all the entries in entryvec
*/
}
-/*
+/**
* size of a box is width*height
* we do this in double precision because width and height can be very very small
* and it gives screwy results
return result;
}
-/*
+/**
* size of a box is width*height
* we do this in double precision because width and height can be very very small
* and it gives screwy results
-/*
+/**
** The GiST Penalty method for boxes
** As in the R-tree paper, we use change in area as our penalty metric
*/
return ( sa>sb ) ? 1 : -1;
}
-/*
+/**
** Equality method
*/
PG_FUNCTION_INFO_V1(LWGEOM_gist_same);
-/*
+/**
** The GiST PickSplit method
** New linear algorithm, see 'New Linear Node Splitting Algorithm for R-tree',
** C.H.Ang and T.C.Tan
cur = (BOX2DFLOAT4 *) DatumGetPointer(entryvec->vector[i].key);
if ( allisequal == true && (
- pageunion.xmax != cur->xmax ||
- pageunion.ymax != cur->ymax ||
- pageunion.xmin != cur->xmin ||
- pageunion.ymin != cur->ymin
- ) )
+ pageunion.xmax != cur->xmax ||
+ pageunion.ymax != cur->ymax ||
+ pageunion.xmin != cur->xmin ||
+ pageunion.ymin != cur->ymin
+ ) )
allisequal = false;
if (pageunion.xmax < cur->xmax)
else
{
Datum interLR = DirectFunctionCall2(BOX2D_intersects,
- PointerGetDatum(unionL), PointerGetDatum(unionR));
+ PointerGetDatum(unionL), PointerGetDatum(unionR));
Datum interBT = DirectFunctionCall2(BOX2D_intersects,
- PointerGetDatum(unionB), PointerGetDatum(unionT));
+ PointerGetDatum(unionB), PointerGetDatum(unionT));
float sizeLR, sizeBT;
- /*elog(NOTICE,"direction is abigeous"); */
+ /*elog(NOTICE,"direction is ambiguous"); */
sizeLR = size_box2d(interLR);
sizeBT = size_box2d(interBT);
}
-/* debug function */
+/** debug function */
Datum report_lwgeom_gist_activity(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(report_lwgeom_gist_activity);
Datum report_lwgeom_gist_activity(PG_FUNCTION_ARGS)
Datum LWGEOM_polygon_index(PG_FUNCTION_ARGS);
-/*
+/**
* Creates an rtree given a pointer to the point array.
* Must copy the point array.
*/
return root;
}
-/*
+/**
* Creates an interior node given the children.
*/
RTREE_NODE *createInteriorNode(RTREE_NODE *left, RTREE_NODE *right)
return parent;
}
-/*
+/**
* Creates a leaf node given the pointer to the start point of the segment.
*/
RTREE_NODE *createLeafNode(POINTARRAY *pa, int startPoint)
return parent;
}
-/*
+/**
* Creates an interval with the total extents of the two given intervals.
*/
INTERVAL *mergeIntervals(INTERVAL *inter1, INTERVAL *inter2)
return interval;
}
-/*
+/**
* Creates an interval given the min and max values, in arbitrary order.
*/
INTERVAL *createInterval(double value1, double value2)
return interval;
}
-/*
+/**
* Recursively frees the child nodes, the interval and the line before
* freeing the root node.
*/
}
-/*
+/**
* Free the cache object and all the sub-objects properly.
*/
void clearCache(RTREE_POLY_CACHE *cache)
}
-/*
+/**
* Retrieves a collection of line segments given the root and crossing value.
* The collection is a multilinestring consisting of two point lines
* representing the segments of the ring that may be crossed by the
return result;
}
-/* Merges two multilinestrings into a single multilinestring. */
+/** Merges two multilinestrings into a single multilinestring. */
LWMLINE *mergeMultiLines(LWMLINE *line1, LWMLINE *line2)
{
LWGEOM **geoms;
return (LWMLINE *)col;
}
-/*
+/**
* Returns 1 if min < value <= max, 0 otherwise. */
uint32 isContained(INTERVAL *interval, double value)
{
LWDEBUGF(3, "populateCache returning %p", currentCache);
}
-/*
+/**
* Creates a new cachable index if needed, or returns the current cache if
* it is applicable to the current polygon.
* The memory context must be changed to function scope before calling this