[mapserver-commits] r8741 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Mon Mar 9 17:04:52 EDT 2009
Author: jlacroix
Date: 2009-03-09 17:04:52 -0400 (Mon, 09 Mar 2009)
New Revision: 8741
Modified:
trunk/mapserver/mapbits.c
trunk/mapserver/mapserver.h
trunk/mapserver/mapshape.h
trunk/mapserver/maptree.c
trunk/mapserver/maptree.h
Log:
Change mapbit.c bitmask type from char to new 32bit ms_bitarray
Modified: trunk/mapserver/mapbits.c
===================================================================
--- trunk/mapserver/mapbits.c 2009-03-09 21:03:31 UTC (rev 8740)
+++ trunk/mapserver/mapbits.c 2009-03-09 21:04:52 UTC (rev 8741)
@@ -10,7 +10,7 @@
*
******************************************************************************
* Copyright (c) 1996-2005 Regents of the University of Minnesota.
- *
+
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
@@ -36,24 +36,30 @@
#include <limits.h>
-/* #define msGetBit(array, index) (*((array) + (index)/CHAR_BIT) & ( 1 << ((index) % CHAR_BIT))) */
+/*
+ * Hardcoded size of our bit array.
+ * See function msGetNextBit for another hardcoded value.
+ */
+#define MS_ARRAY_BIT 32
+/* #define msGetBit(array, index) (*((array) + (index)/MS_ARRAY_BIT) & ( 1 << ((index) % MS_ARRAY_BIT))) */
+
size_t msGetBitArraySize(int numbits)
{
- return((numbits + CHAR_BIT - 1) / CHAR_BIT);
+ return((numbits + MS_ARRAY_BIT - 1) / MS_ARRAY_BIT);
}
-char *msAllocBitArray(int numbits)
+ms_bitarray msAllocBitArray(int numbits)
{
- char *array = calloc((numbits + CHAR_BIT - 1) / CHAR_BIT, sizeof(char));
+ ms_bitarray array = calloc((numbits + MS_ARRAY_BIT - 1) / MS_ARRAY_BIT, MS_ARRAY_BIT);
return(array);
}
-int msGetBit(char *array, int index)
+int msGetBit(ms_bitarray array, int index)
{
- array += index / CHAR_BIT;
- return (*array & (1 << (index % CHAR_BIT))) != 0; /* 0 or 1 */
+ array += index / MS_ARRAY_BIT;
+ return (*array & (1 << (index % MS_ARRAY_BIT))) != 0; /* 0 or 1 */
}
/*
@@ -63,16 +69,16 @@
** If hits end of bitmap without finding set bit, will return -1.
**
*/
-int msGetNextBit(char *array, int i, int size) {
+int msGetNextBit(ms_bitarray array, int i, int size) {
- register char b;
+ register ms_uint32 b;
while(i < size) {
- b = *(array + (i/CHAR_BIT));
- if( b && (b >> (i % CHAR_BIT)) ) {
+ b = *(array + (i/MS_ARRAY_BIT));
+ if( b && (b >> (i % MS_ARRAY_BIT)) ) {
/* There is something in this byte */
/* And it is not to the right of us */
- if( b & ( 1 << (i % CHAR_BIT)) ) {
+ if( b & ( 1 << (i % MS_ARRAY_BIT)) ) {
/* There is something at this bit! */
return i;
}
@@ -82,7 +88,7 @@
}
else {
/* Nothing in this byte, move to start of next byte */
- i += CHAR_BIT - (i % CHAR_BIT);
+ i += MS_ARRAY_BIT - (i % MS_ARRAY_BIT);
}
}
@@ -90,17 +96,17 @@
return -1;
}
-void msSetBit(char *array, int index, int value)
+void msSetBit(ms_bitarray array, int index, int value)
{
- array += index / CHAR_BIT;
+ array += index / MS_ARRAY_BIT;
if (value)
- *array |= 1 << (index % CHAR_BIT); /* set bit */
+ *array |= 1 << (index % MS_ARRAY_BIT); /* set bit */
else
- *array &= ~(1 << (index % CHAR_BIT)); /* clear bit */
+ *array &= ~(1 << (index % MS_ARRAY_BIT)); /* clear bit */
}
-void msFlipBit(char *array, int index)
+void msFlipBit(ms_bitarray array, int index)
{
- array += index / CHAR_BIT;
- *array ^= 1 << (index % CHAR_BIT); /* flip bit */
+ array += index / MS_ARRAY_BIT;
+ *array ^= 1 << (index % MS_ARRAY_BIT); /* flip bit */
}
Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h 2009-03-09 21:03:31 UTC (rev 8740)
+++ trunk/mapserver/mapserver.h 2009-03-09 21:04:52 UTC (rev 8741)
@@ -88,6 +88,9 @@
typedef uint32_t ms_uint32;
#endif
+/* ms_bitarray is used by the bit mask in mapbit.c */
+typedef ms_uint32 * ms_bitarray;
+
#include "maperror.h"
#include "mapprimitive.h"
#include "mapshape.h"
@@ -1773,11 +1776,11 @@
MS_DLL_EXPORT imageObj *msDrawReferenceMap(mapObj *map);
MS_DLL_EXPORT size_t msGetBitArraySize(int numbits); /* in mapbits.c */
-MS_DLL_EXPORT char *msAllocBitArray(int numbits);
-MS_DLL_EXPORT int msGetBit(char *array, int index);
-MS_DLL_EXPORT void msSetBit(char *array, int index, int value);
-MS_DLL_EXPORT void msFlipBit(char *array, int index);
-MS_DLL_EXPORT int msGetNextBit(char *array, int index, int size);
+MS_DLL_EXPORT ms_bitarray msAllocBitArray(int numbits);
+MS_DLL_EXPORT int msGetBit(ms_bitarray array, int index);
+MS_DLL_EXPORT void msSetBit(ms_bitarray array, int index, int value);
+MS_DLL_EXPORT void msFlipBit(ms_bitarray array, int index);
+MS_DLL_EXPORT int msGetNextBit(ms_bitarray array, int index, int size);
MS_DLL_EXPORT int msLayerInitItemInfo(layerObj *layer);
MS_DLL_EXPORT void msLayerFreeItemInfo(layerObj *layer);
Modified: trunk/mapserver/mapshape.h
===================================================================
--- trunk/mapserver/mapshape.h 2009-03-09 21:03:31 UTC (rev 8740)
+++ trunk/mapserver/mapshape.h 2009-03-09 21:04:52 UTC (rev 8741)
@@ -89,7 +89,7 @@
int *panRecOffset;
int *panRecSize;
- char *panRecLoaded;
+ ms_bitarray panRecLoaded;
int panRecAllLoaded;
double adBoundsMin[4];
@@ -165,7 +165,7 @@
int lastshape;
- char *status;
+ ms_bitarray status;
rectObj statusbounds; /* holds extent associated with the status vector */
int isopen;
Modified: trunk/mapserver/maptree.c
===================================================================
--- trunk/mapserver/maptree.c 2009-03-09 21:03:31 UTC (rev 8740)
+++ trunk/mapserver/maptree.c 2009-03-09 21:04:52 UTC (rev 8741)
@@ -378,7 +378,7 @@
return(treeNodeAddShapeId(tree->root, id, rect, tree->maxdepth));
}
-static void treeCollectShapeIds(treeNodeObj *node, rectObj aoi, char *status)
+static void treeCollectShapeIds(treeNodeObj *node, rectObj aoi, ms_bitarray status)
{
int i;
@@ -404,9 +404,9 @@
}
}
-char *msSearchTree(treeObj *tree, rectObj aoi)
+ms_bitarray msSearchTree(treeObj *tree, rectObj aoi)
{
- char *status=NULL;
+ ms_bitarray status=NULL;
status = msAllocBitArray(tree->numshapes);
if(!status) {
@@ -452,7 +452,7 @@
treeNodeTrim(tree->root);
}
-static void searchDiskTreeNode(SHPTreeHandle disktree, rectObj aoi, char *status)
+static void searchDiskTreeNode(SHPTreeHandle disktree, rectObj aoi, ms_bitarray status)
{
int i;
ms_int32 offset;
@@ -507,10 +507,10 @@
return;
}
-char *msSearchDiskTree(char *filename, rectObj aoi, int debug)
+ms_bitarray msSearchDiskTree(char *filename, rectObj aoi, int debug)
{
SHPTreeHandle disktree;
- char *status=NULL;
+ ms_bitarray status=NULL;
disktree = msSHPDiskTreeOpen (filename, debug);
if(!disktree) {
@@ -763,7 +763,7 @@
}
/* Function to filter search results further against feature bboxes */
-void msFilterTreeSearch(shapefileObj *shp, char *status, rectObj search_rect)
+void msFilterTreeSearch(shapefileObj *shp, ms_bitarray status, rectObj search_rect)
{
int i;
rectObj shape_rect;
Modified: trunk/mapserver/maptree.h
===================================================================
--- trunk/mapserver/maptree.h 2009-03-09 21:03:31 UTC (rev 8740)
+++ trunk/mapserver/maptree.h 2009-03-09 21:04:52 UTC (rev 8741)
@@ -85,13 +85,13 @@
MS_DLL_EXPORT void msTreeTrim(treeObj *tree);
MS_DLL_EXPORT void msDestroyTree(treeObj *tree);
-MS_DLL_EXPORT char *msSearchTree(treeObj *tree, rectObj aoi);
-MS_DLL_EXPORT char *msSearchDiskTree(char *filename, rectObj aoi, int debug);
+MS_DLL_EXPORT ms_bitarray msSearchTree(treeObj *tree, rectObj aoi);
+MS_DLL_EXPORT ms_bitarray msSearchDiskTree(char *filename, rectObj aoi, int debug);
MS_DLL_EXPORT treeObj *msReadTree(char *filename, int debug);
MS_DLL_EXPORT int msWriteTree(treeObj *tree, char *filename, int LSB_order);
-MS_DLL_EXPORT void msFilterTreeSearch(shapefileObj *shp, char *status, rectObj search_rect);
+MS_DLL_EXPORT void msFilterTreeSearch(shapefileObj *shp, ms_bitarray status, rectObj search_rect);
#ifdef __cplusplus
}
More information about the mapserver-commits
mailing list