54 #define M_PI 3.14159265358979323846
58 #define M_PI_2 1.57079632679489661923
62 #define M_SQRT_2 0.707106781186547524401
66 #define M_SQRT2 1.41421356237309504880
72 void sort(
double* heap,
int* x,
int* y,
int N )
74 unsigned int n = N, i = n / 2, parent, child;
102 if ( child + 1 < n && heap[child + 1] > heap[child] )
106 if ( heap[child] > t )
108 heap[parent] = heap[child];
109 x[parent] = x[child];
110 y[parent] = y[child];
112 child = parent * 2 + 1;
125 void tabcpy(
int n,
const int*
const x,
const int*
const y,
126 const double*
const prob,
int *cx,
int *cy,
double *p )
130 for ( i = 0; i < n; i++ )
139 void sort(
void** items,
int N,
bool ( *greater )(
void *l,
void *r ) )
145 unsigned int n = (
unsigned int ) N, i = n / 2, parent, child;
159 if ( n == 0 )
return;
167 if ( child + 1 < n && greater( items[child + 1], items[child] ) )
171 if ( greater( items[child], t ) )
173 items[parent] = items[child];
175 child = parent * 2 + 1;
186 inline bool ptrGeomEq(
const GEOSGeometry *l,
const GEOSGeometry *r )
191 LinkedList<const GEOSGeometry*> *
unmulti(
const GEOSGeometry *the_geom )
193 LinkedList<const GEOSGeometry*> *queue =
new LinkedList<const GEOSGeometry*> (
ptrGeomEq );
194 LinkedList<const GEOSGeometry*> *final_queue =
new LinkedList<const GEOSGeometry*> (
ptrGeomEq );
196 const GEOSGeometry *geom;
198 queue->push_back( the_geom );
202 while ( queue->size() > 0 )
204 geom = queue->pop_front();
206 switch ( GEOSGeomTypeId_r( geosctxt, geom ) )
208 case GEOS_MULTIPOINT:
209 case GEOS_MULTILINESTRING:
210 case GEOS_MULTIPOLYGON:
211 nGeom = GEOSGetNumGeometries_r( geosctxt, geom );
212 for ( i = 0; i < nGeom; i++ )
214 queue->push_back( GEOSGetGeometryN_r( geosctxt, geom, i ) );
218 case GEOS_LINESTRING:
220 final_queue->push_back( geom );