| 2743 | /************************************************************************/ |
| 2744 | |
| 2745 | static void GDALGridJobProcess(void *user_data) |
| 2746 | { |
| 2747 | GDALGridJob *const psJob = static_cast<GDALGridJob *>(user_data); |
| 2748 | int (*pfnProgress)(GDALGridJob *psJob) = psJob->pfnProgress; |
| 2749 | const GUInt32 nXSize = psJob->nXSize; |
| 2750 | |
| 2751 | /* -------------------------------------------------------------------- */ |
| 2752 | /* Allocate a buffer of scanline size, fill it with gridded values */ |
| 2753 | /* and use GDALCopyWords() to copy values into output data array with */ |
| 2754 | /* appropriate data type conversion. */ |
| 2755 | /* -------------------------------------------------------------------- */ |
| 2756 | double *padfValues = |
| 2757 | static_cast<double *>(VSI_MALLOC2_VERBOSE(sizeof(double), nXSize)); |
| 2758 | if (padfValues == nullptr) |
| 2759 | { |
| 2760 | *(psJob->pbStop) = TRUE; |
| 2761 | if (pfnProgress != nullptr) |
| 2762 | pfnProgress(psJob); // To notify the main thread. |
| 2763 | return; |
| 2764 | } |
| 2765 | |
| 2766 | const GUInt32 nYStart = psJob->nYStart; |
| 2767 | const GUInt32 nYStep = psJob->nYStep; |
| 2768 | GByte *pabyData = psJob->pabyData; |
| 2769 | |
| 2770 | const GUInt32 nYSize = psJob->nYSize; |
| 2771 | const double dfXMin = psJob->dfXMin; |
| 2772 | const double dfYMin = psJob->dfYMin; |
| 2773 | const double dfDeltaX = psJob->dfDeltaX; |
| 2774 | const double dfDeltaY = psJob->dfDeltaY; |
| 2775 | const GUInt32 nPoints = psJob->nPoints; |
| 2776 | const double *padfX = psJob->padfX; |
| 2777 | const double *padfY = psJob->padfY; |
| 2778 | const double *padfZ = psJob->padfZ; |
| 2779 | const void *poOptions = psJob->poOptions; |
| 2780 | GDALGridFunction pfnGDALGridMethod = psJob->pfnGDALGridMethod; |
| 2781 | // Have a local copy of sExtraParameters since we want to modify |
| 2782 | // nInitialFacetIdx. |
| 2783 | GDALGridExtraParameters sExtraParameters = *psJob->psExtraParameters; |
| 2784 | const GDALDataType eType = psJob->eType; |
| 2785 | |
| 2786 | const int nDataTypeSize = GDALGetDataTypeSizeBytes(eType); |
| 2787 | const int nLineSpace = nXSize * nDataTypeSize; |
| 2788 | |
| 2789 | for (GUInt32 nYPoint = nYStart; nYPoint < nYSize; nYPoint += nYStep) |
| 2790 | { |
| 2791 | const double dfYPoint = dfYMin + (nYPoint + 0.5) * dfDeltaY; |
| 2792 | |
| 2793 | for (GUInt32 nXPoint = 0; nXPoint < nXSize; nXPoint++) |
| 2794 | { |
| 2795 | const double dfXPoint = dfXMin + (nXPoint + 0.5) * dfDeltaX; |
| 2796 | |
| 2797 | if ((*pfnGDALGridMethod)(poOptions, nPoints, padfX, padfY, padfZ, |
| 2798 | dfXPoint, dfYPoint, padfValues + nXPoint, |
| 2799 | &sExtraParameters) != CE_None) |
| 2800 | { |
| 2801 | CPLError(CE_Failure, CPLE_AppDefined, |
| 2802 | "Gridding failed at X position %lu, Y position %lu", |
no test coverage detected