MCPcopy Create free account
hub / github.com/OSGeo/gdal / GDALGridContextCreateQuadTree

Function GDALGridContextCreateQuadTree

alg/gdalgrid.cpp:3424–3468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3422/************************************************************************/
3423
3424void GDALGridContextCreateQuadTree(GDALGridContext *psContext)
3425{
3426 const GUInt32 nPoints = psContext->nPoints;
3427 psContext->pasGridPoints = static_cast<GDALGridPoint *>(
3428 VSI_MALLOC2_VERBOSE(nPoints, sizeof(GDALGridPoint)));
3429 if (psContext->pasGridPoints != nullptr)
3430 {
3431 const double *const padfX = psContext->padfX;
3432 const double *const padfY = psContext->padfY;
3433
3434 // Determine point extents.
3435 CPLRectObj sRect;
3436 sRect.minx = padfX[0];
3437 sRect.miny = padfY[0];
3438 sRect.maxx = padfX[0];
3439 sRect.maxy = padfY[0];
3440 for (GUInt32 i = 1; i < nPoints; i++)
3441 {
3442 if (padfX[i] < sRect.minx)
3443 sRect.minx = padfX[i];
3444 if (padfY[i] < sRect.miny)
3445 sRect.miny = padfY[i];
3446 if (padfX[i] > sRect.maxx)
3447 sRect.maxx = padfX[i];
3448 if (padfY[i] > sRect.maxy)
3449 sRect.maxy = padfY[i];
3450 }
3451
3452 // Initial value for search radius is the typical dimension of a
3453 // "pixel" of the point array (assuming rather uniform distribution).
3454 psContext->sExtraParameters.dfInitialSearchRadius = sqrt(
3455 (sRect.maxx - sRect.minx) * (sRect.maxy - sRect.miny) / nPoints);
3456
3457 psContext->sExtraParameters.hQuadTree =
3458 CPLQuadTreeCreate(&sRect, GDALGridGetPointBounds);
3459
3460 for (GUInt32 i = 0; i < nPoints; i++)
3461 {
3462 psContext->pasGridPoints[i].psXYArrays = &(psContext->sXYArrays);
3463 psContext->pasGridPoints[i].i = i;
3464 CPLQuadTreeInsert(psContext->sExtraParameters.hQuadTree,
3465 psContext->pasGridPoints + i);
3466 }
3467 }
3468}
3469
3470/************************************************************************/
3471/* GDALGridContextFree() */

Callers 2

GDALGridContextCreateFunction · 0.85
GDALGridContextProcessFunction · 0.85

Calls 3

sqrtFunction · 0.85
CPLQuadTreeCreateFunction · 0.85
CPLQuadTreeInsertFunction · 0.85

Tested by

no test coverage detected