Commit 01e4a171 authored by Paul Ramsey's avatar Paul Ramsey

astyle --style=ansi --indent=tab=8


git-svn-id: http://svn.osgeo.org/postgis/trunk@3284 b70326c6-7e19-0410-871a-916f4a2858ee
parent ac378e71
......@@ -70,7 +70,8 @@ typedef struct
MemoryContext context;
const GEOSPreparedGeometry* prepared_geom;
GEOSGeometry* geom;
} PrepGeomHashEntry;
}
PrepGeomHashEntry;
/* Memory context hash table function prototypes */
uint32 mcxt_ptr_hasha(const void *key, Size keysize);
......@@ -90,7 +91,8 @@ static void PreparedCacheCheck(MemoryContext context);
#endif
/* Memory context definition must match the current version of PostgreSQL */
static MemoryContextMethods PreparedCacheContextMethods = {
static MemoryContextMethods PreparedCacheContextMethods =
{
NULL,
NULL,
NULL,
......@@ -103,7 +105,7 @@ static MemoryContextMethods PreparedCacheContextMethods = {
#ifdef MEMORY_CONTEXT_CHECKING
, PreparedCacheCheck
#endif
};
};
static void
PreparedCacheInit(MemoryContext context)
......@@ -128,9 +130,9 @@ PreparedCacheDelete(MemoryContext context)
POSTGIS_DEBUGF(3, "deleting geom object (%p) and prepared geom object (%p) with MemoryContext key (%p)", pghe->geom, pghe->prepared_geom, context);
/* Free them */
if( pghe->prepared_geom )
if ( pghe->prepared_geom )
GEOSPreparedGeom_destroy( pghe->prepared_geom );
if( pghe->geom )
if ( pghe->geom )
GEOSGeom_destroy( pghe->geom );
/* Remove the hash entry as it is no longer needed */
......@@ -281,15 +283,15 @@ GetPrepGeomCache(FunctionCallInfoData *fcinfo, PG_LWGEOM *pg_geom1, PG_LWGEOM *p
size_t pg_geom2_size = 0;
/* Make sure this isn't someone else's cache object. */
if( cache && cache->type != 2 ) cache = NULL;
if ( cache && cache->type != 2 ) cache = NULL;
if (!PrepGeomHash)
CreatePrepGeomHash();
if( pg_geom1 )
if ( pg_geom1 )
pg_geom1_size = VARSIZE(pg_geom1) + VARHDRSZ;
if( pg_geom2 )
if ( pg_geom2 )
pg_geom2_size = VARSIZE(pg_geom2) + VARHDRSZ;
if ( cache == NULL)
......@@ -418,7 +420,7 @@ GetPrepGeomCache(FunctionCallInfoData *fcinfo, PG_LWGEOM *pg_geom1, PG_LWGEOM *p
}
if( copy_keys && pg_geom1 )
if ( copy_keys && pg_geom1 )
{
/*
** If this is a new key (cache miss) we flip into the function
......@@ -428,18 +430,18 @@ GetPrepGeomCache(FunctionCallInfoData *fcinfo, PG_LWGEOM *pg_geom1, PG_LWGEOM *p
*/
POSTGIS_DEBUG(1, "GetPrepGeomCache: copying pg_geom1 into cache");
old_context = MemoryContextSwitchTo(fcinfo->flinfo->fn_mcxt);
if( cache->pg_geom1 )
if ( cache->pg_geom1 )
pfree(cache->pg_geom1);
cache->pg_geom1 = palloc(pg_geom1_size);
MemoryContextSwitchTo(old_context);
memcpy(cache->pg_geom1, pg_geom1, pg_geom1_size);
cache->pg_geom1_size = pg_geom1_size;
}
if( copy_keys && pg_geom2 )
if ( copy_keys && pg_geom2 )
{
POSTGIS_DEBUG(1, "GetPrepGeomCache: copying pg_geom2 into cache");
old_context = MemoryContextSwitchTo(fcinfo->flinfo->fn_mcxt);
if( cache->pg_geom2 )
if ( cache->pg_geom2 )
pfree(cache->pg_geom2);
cache->pg_geom2 = palloc(pg_geom2_size);
MemoryContextSwitchTo(old_context);
......
......@@ -51,15 +51,16 @@
typedef struct
{
char type;
PG_LWGEOM* pg_geom1;
PG_LWGEOM* pg_geom2;
PG_LWGEOM *pg_geom1;
PG_LWGEOM *pg_geom2;
size_t pg_geom1_size;
size_t pg_geom2_size;
int32 argnum;
const GEOSPreparedGeometry* prepared_geom;
GEOSGeometry* geom;
const GEOSPreparedGeometry *prepared_geom;
GEOSGeometry *geom;
MemoryContext context;
} PrepGeomCache;
}
PrepGeomCache;
/*
** Get the current cache, given the input geometries.
......
......@@ -38,7 +38,7 @@ RTREE_NODE *createTree(POINTARRAY *pointArray)
/*
* Create a leaf node for every line segment.
*/
for(i = 0; i < nodeCount; i++)
for (i = 0; i < nodeCount; i++)
{
nodes[i] = createLeafNode(pointArray, i);
}
......@@ -50,12 +50,12 @@ RTREE_NODE *createTree(POINTARRAY *pointArray)
*/
childNodes = nodeCount;
parentNodes = nodeCount / 2;
while(parentNodes > 0)
while (parentNodes > 0)
{
LWDEBUGF(3, "Merging %d children into %d parents.", childNodes, parentNodes);
i = 0;
while(i < parentNodes)
while (i < parentNodes)
{
nodes[i] = createInteriorNode(nodes[i*2], nodes[i*2+1]);
i++;
......@@ -63,7 +63,7 @@ RTREE_NODE *createTree(POINTARRAY *pointArray)
/*
* Check for an odd numbered final node.
*/
if(parentNodes * 2 < childNodes)
if (parentNodes * 2 < childNodes)
{
LWDEBUGF(3, "Shuffling child %d to parent %d", childNodes - 1, i);
......@@ -84,7 +84,8 @@ RTREE_NODE *createTree(POINTARRAY *pointArray)
/*
* Creates an interior node given the children.
*/
RTREE_NODE *createInteriorNode(RTREE_NODE *left, RTREE_NODE *right){
RTREE_NODE *createInteriorNode(RTREE_NODE *left, RTREE_NODE *right)
{
RTREE_NODE *parent;
LWDEBUGF(2, "createInteriorNode called for children %p, %p", left, right);
......@@ -114,7 +115,7 @@ RTREE_NODE *createLeafNode(POINTARRAY *pa, int startPoint)
LWDEBUGF(2, "createLeafNode called for point %d of %p", startPoint, pa);
if(pa->npoints < startPoint + 2)
if (pa->npoints < startPoint + 2)
{
lwerror("createLeafNode: npoints = %d, startPoint = %d", pa->npoints, startPoint);
}
......@@ -197,12 +198,13 @@ void freeTree(RTREE_NODE *root)
{
LWDEBUGF(2, "freeTree called for %p", root);
if(root->leftNode)
if (root->leftNode)
freeTree(root->leftNode);
if(root->rightNode)
if (root->rightNode)
freeTree(root->rightNode);
lwfree(root->interval);
if(root->segment) {
if (root->segment)
{
lwfree(root->segment->points->serialized_pointlist);
lwfree(root->segment->points);
lwgeom_release((LWGEOM *)root->segment);
......@@ -218,7 +220,7 @@ void clearCache(RTREE_POLY_CACHE *cache)
{
int i;
LWDEBUGF(2, "clearCache called for %p", cache);
for(i = 0; i < cache->ringCount; i++)
for (i = 0; i < cache->ringCount; i++)
{
freeTree(cache->ringIndices[i]);
}
......@@ -246,7 +248,7 @@ LWMLINE *findLineSegments(RTREE_NODE *root, double value)
result = NULL;
if(!isContained(root->interval, value))
if (!isContained(root->interval, value))
{
LWDEBUGF(3, "findLineSegments %p: not contained.", root);
......@@ -254,7 +256,7 @@ LWMLINE *findLineSegments(RTREE_NODE *root, double value)
}
/* If there is a segment defined for this node, include it. */
if(root->segment)
if (root->segment)
{
LWDEBUGF(3, "findLineSegments %p: adding segment %p %d.", root, root->segment, TYPE_GETTYPE(root->segment->type));
......@@ -267,16 +269,16 @@ LWMLINE *findLineSegments(RTREE_NODE *root, double value)
}
/* If there is a left child node, recursively include its results. */
if(root->leftNode)
if (root->leftNode)
{
LWDEBUGF(3, "findLineSegments %p: recursing left.", root);
tmp = findLineSegments(root->leftNode, value);
if(tmp)
if (tmp)
{
LWDEBUGF(3, "Found geom %p, type %d, dim %d", tmp, TYPE_GETTYPE(tmp->type), TYPE_GETZM(tmp->type));
if(result)
if (result)
result = mergeMultiLines(result, tmp);
else
result = tmp;
......@@ -284,16 +286,16 @@ LWMLINE *findLineSegments(RTREE_NODE *root, double value)
}
/* Same for any right child. */
if(root->rightNode)
if (root->rightNode)
{
LWDEBUGF(3, "findLineSegments %p: recursing right.", root);
tmp = findLineSegments(root->rightNode, value);
if(tmp)
if (tmp)
{
LWDEBUGF(3, "Found geom %p, type %d, dim %d", tmp, TYPE_GETTYPE(tmp->type), TYPE_GETZM(tmp->type));
if(result)
if (result)
result = mergeMultiLines(result, tmp);
else
result = tmp;
......@@ -316,11 +318,11 @@ LWMLINE *mergeMultiLines(LWMLINE *line1, LWMLINE *line2)
geoms = lwalloc(sizeof(LWGEOM *) * ngeoms);
j = 0;
for(i = 0; i < line1->ngeoms; i++, j++)
for (i = 0; i < line1->ngeoms; i++, j++)
{
geoms[j] = lwgeom_clone((LWGEOM *)line1->geoms[i]);
}
for(i = 0; i < line2->ngeoms; i++, j++)
for (i = 0; i < line2->ngeoms; i++, j++)
{
geoms[j] = lwgeom_clone((LWGEOM *)line2->geoms[i]);
}
......@@ -357,7 +359,7 @@ Datum LWGEOM_polygon_index(PG_FUNCTION_ARGS)
igeom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
yval = PG_GETARG_FLOAT8(1);
geom = lwgeom_deserialize(SERIALIZED_FORM(igeom));
if(TYPE_GETTYPE(geom->type) != POLYGONTYPE)
if (TYPE_GETTYPE(geom->type) != POLYGONTYPE)
{
lwgeom_release(geom);
PG_FREE_IF_COPY(igeom, 0);
......@@ -370,13 +372,13 @@ Datum LWGEOM_polygon_index(PG_FUNCTION_ARGS)
#if POSTGIS_DEBUG_LEVEL >= 3
POSTGIS_DEBUGF(3, "mline returned %p %d", mline, TYPE_GETTYPE(mline->type));
for(i = 0; i < mline->ngeoms; i++)
for (i = 0; i < mline->ngeoms; i++)
{
POSTGIS_DEBUGF(3, "geom[%d] %p %d", i, mline->geoms[i], TYPE_GETTYPE(mline->geoms[i]->type));
}
#endif
if(mline)
if (mline)
result = pglwgeom_serialize((LWGEOM *)mline);
POSTGIS_DEBUGF(3, "returning result %p", result);
......@@ -411,7 +413,7 @@ void populateCache(RTREE_POLY_CACHE *currentCache, LWGEOM *lwgeom, uchar *serial
LWDEBUGF(2, "populateCache called with cache %p geom %p", currentCache, lwgeom);
if(TYPE_GETTYPE(lwgeom->type) == MULTIPOLYGONTYPE)
if (TYPE_GETTYPE(lwgeom->type) == MULTIPOLYGONTYPE)
{
LWDEBUG(2, "populateCache MULTIPOLYGON");
mpoly = (LWMPOLY *)lwgeom;
......@@ -419,7 +421,7 @@ void populateCache(RTREE_POLY_CACHE *currentCache, LWGEOM *lwgeom, uchar *serial
/*
** Count the total number of rings.
*/
for( i = 0; i < mpoly->ngeoms; i++ )
for ( i = 0; i < mpoly->ngeoms; i++ )
{
nrings += mpoly->geoms[i]->nrings;
}
......@@ -429,16 +431,16 @@ void populateCache(RTREE_POLY_CACHE *currentCache, LWGEOM *lwgeom, uchar *serial
/*
** Load the exterior rings onto the ringIndices array first
*/
for( i = 0; i < mpoly->ngeoms; i++ )
for ( i = 0; i < mpoly->ngeoms; i++ )
{
currentCache->ringIndices[i] = createTree(mpoly->geoms[i]->rings[0]);
}
/*
** Load the interior rings (holes) onto ringIndices next
*/
for( j = 0; j < mpoly->ngeoms; j++ )
for ( j = 0; j < mpoly->ngeoms; j++ )
{
for( k = 1; k < mpoly->geoms[j]->nrings; k++ )
for ( k = 1; k < mpoly->geoms[j]->nrings; k++ )
{
currentCache->ringIndices[i] = createTree(mpoly->geoms[j]->rings[k]);
i++;
......@@ -455,7 +457,7 @@ void populateCache(RTREE_POLY_CACHE *currentCache, LWGEOM *lwgeom, uchar *serial
** Just load the rings on in order
*/
currentCache->ringIndices = lwalloc(sizeof(RTREE_NODE *) * poly->nrings);
for( i = 0; i < poly->nrings; i++ )
for ( i = 0; i < poly->nrings; i++ )
{
currentCache->ringIndices[i] = createTree(poly->rings[i]);
}
......@@ -490,14 +492,14 @@ RTREE_POLY_CACHE *retrieveCache(LWGEOM *lwgeom, uchar *serializedPoly, RTREE_POL
LWDEBUGF(2, "retrieveCache called with %p %p %p", lwgeom, serializedPoly, currentCache);
/* Make sure this isn't someone else's cache object. */
if( currentCache && currentCache->type != 1 ) currentCache = NULL;
if ( currentCache && currentCache->type != 1 ) currentCache = NULL;
if(!currentCache)
if (!currentCache)
{
LWDEBUG(3, "No existing cache, create one.");
return createCache();
}
if(!(currentCache->poly))
if (!(currentCache->poly))
{
LWDEBUG(3, "Cache contains no polygon, populating it.");
populateCache(currentCache, lwgeom, serializedPoly);
......@@ -506,13 +508,13 @@ RTREE_POLY_CACHE *retrieveCache(LWGEOM *lwgeom, uchar *serializedPoly, RTREE_POL
length = lwgeom_size(serializedPoly);
if(lwgeom_size(currentCache->poly) != length)
if (lwgeom_size(currentCache->poly) != length)
{
LWDEBUG(3, "Polygon size mismatch, creating new cache.");
clearCache(currentCache);
return currentCache;
}
if( memcmp(serializedPoly, currentCache->poly, length) )
if ( memcmp(serializedPoly, currentCache->poly, length) )
{
LWDEBUG(3, "Polygon mismatch, creating new cache.");
clearCache(currentCache);
......
......@@ -5,7 +5,8 @@ typedef struct
{
double min;
double max;
} INTERVAL;
}
INTERVAL;
/* Returns 1 if min < value <= max, 0 otherwise */
uint32 isContained(INTERVAL *interval, double value);
......@@ -24,8 +25,9 @@ typedef struct rtree_node
INTERVAL *interval;
struct rtree_node *leftNode;
struct rtree_node *rightNode;
LWLINE* segment;
} RTREE_NODE;
LWLINE *segment;
}
RTREE_NODE;
/* Creates an interior node given the children. */
RTREE_NODE *createInteriorNode(RTREE_NODE *left, RTREE_NODE *right);
......@@ -50,7 +52,8 @@ typedef struct
int ringCount;
int polyCount;
uchar *poly;
} RTREE_POLY_CACHE;
}
RTREE_POLY_CACHE;
/*
* Creates a new cachable index if needed, or returns the current cache if
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment