| 2886 | */ |
| 2887 | |
| 2888 | GDALGridContext *GDALGridContextCreate(GDALGridAlgorithm eAlgorithm, |
| 2889 | const void *poOptions, GUInt32 nPoints, |
| 2890 | const double *padfX, const double *padfY, |
| 2891 | const double *padfZ, |
| 2892 | int bCallerWillKeepPointArraysAlive) |
| 2893 | { |
| 2894 | CPLAssert(poOptions); |
| 2895 | CPLAssert(padfX); |
| 2896 | CPLAssert(padfY); |
| 2897 | CPLAssert(padfZ); |
| 2898 | bool bCreateQuadTree = false; |
| 2899 | |
| 2900 | const unsigned int nPointCountThreshold = |
| 2901 | atoi(CPLGetConfigOption("GDAL_GRID_POINT_COUNT_THRESHOLD", "100")); |
| 2902 | |
| 2903 | // Starting address aligned on 32-byte boundary for AVX. |
| 2904 | float *pafXAligned = nullptr; |
| 2905 | float *pafYAligned = nullptr; |
| 2906 | float *pafZAligned = nullptr; |
| 2907 | |
| 2908 | void *poOptionsNew = nullptr; |
| 2909 | |
| 2910 | GDALGridFunction pfnGDALGridMethod = nullptr; |
| 2911 | |
| 2912 | switch (eAlgorithm) |
| 2913 | { |
| 2914 | case GGA_InverseDistanceToAPower: |
| 2915 | { |
| 2916 | const auto poOptionsOld = |
| 2917 | static_cast<const GDALGridInverseDistanceToAPowerOptions *>( |
| 2918 | poOptions); |
| 2919 | if (poOptionsOld->nSizeOfStructure != sizeof(*poOptionsOld)) |
| 2920 | { |
| 2921 | CPLError(CE_Failure, CPLE_AppDefined, |
| 2922 | "Wrong value of nSizeOfStructure member"); |
| 2923 | return nullptr; |
| 2924 | } |
| 2925 | poOptionsNew = |
| 2926 | CPLMalloc(sizeof(GDALGridInverseDistanceToAPowerOptions)); |
| 2927 | memcpy(poOptionsNew, poOptions, |
| 2928 | sizeof(GDALGridInverseDistanceToAPowerOptions)); |
| 2929 | |
| 2930 | const GDALGridInverseDistanceToAPowerOptions *const poPower = |
| 2931 | static_cast<const GDALGridInverseDistanceToAPowerOptions *>( |
| 2932 | poOptions); |
| 2933 | if (poPower->dfRadius1 == 0.0 && poPower->dfRadius2 == 0.0) |
| 2934 | { |
| 2935 | const double dfPower = poPower->dfPower; |
| 2936 | const double dfSmoothing = poPower->dfSmoothing; |
| 2937 | |
| 2938 | pfnGDALGridMethod = GDALGridInverseDistanceToAPowerNoSearch; |
| 2939 | if (dfPower == 2.0 && dfSmoothing == 0.0) |
| 2940 | { |
| 2941 | #ifdef HAVE_AVX_AT_COMPILE_TIME |
| 2942 | |
| 2943 | if (CPLTestBool( |
| 2944 | CPLGetConfigOption("GDAL_USE_AVX", "YES")) && |
| 2945 | CPLHaveRuntimeAVX()) |
no test coverage detected