40 void pal::Util::sort(
void **items,
int N,
bool ( *greater )(
void *l,
void *r ) )
46 unsigned int n =
static_cast< unsigned int >( N ), i = n / 2, parent, child;
68 if ( child + 1 < n && greater( items[child + 1], items[child] ) )
72 if ( greater( items[child], t ) )
74 items[parent] = items[child];
76 child = parent * 2 + 1;
89 QLinkedList<const GEOSGeometry *> *queue =
new QLinkedList<const GEOSGeometry *>;
90 QLinkedList<const GEOSGeometry *> *final_queue =
new QLinkedList<const GEOSGeometry *>;
92 const GEOSGeometry *geom =
nullptr;
94 queue->append( the_geom );
100 while ( !queue->isEmpty() )
102 geom = queue->takeFirst();
103 int type = GEOSGeomTypeId_r( geosctxt, geom );
106 case GEOS_MULTIPOINT:
107 case GEOS_MULTILINESTRING:
108 case GEOS_MULTIPOLYGON:
109 case GEOS_GEOMETRYCOLLECTION:
110 nGeom = GEOSGetNumGeometries_r( geosctxt, geom );
111 for ( i = 0; i < nGeom; i++ )
113 queue->append( GEOSGetGeometryN_r( geosctxt, geom, i ) );
117 case GEOS_LINESTRING:
119 final_queue->append( geom );
122 QgsDebugMsg( QStringLiteral(
"unexpected geometry type:%1" ).arg( type ) );
static QLinkedList< const GEOSGeometry * > * unmulti(const GEOSGeometry *the_geom)
static GEOSContextHandle_t getGEOSHandler()
static void sort(void **items, int N, bool(*greater)(void *l, void *r))
Sort an array of pointers.