diff --git a/agrolib/interpolation/interpolation.cpp b/agrolib/interpolation/interpolation.cpp index 967fa015..531ad1a4 100644 --- a/agrolib/interpolation/interpolation.cpp +++ b/agrolib/interpolation/interpolation.cpp @@ -850,14 +850,11 @@ float shepardSearchNeighbour(vector &inputPoints, Crit3DInterpolationSettings* settings, vector &outputPoints) { - std::vector shepardNeighbourPoints; - - float radius; - unsigned int nrValid = 0; float shepardInitialRadius = computeShepardInitialRadius(settings->getPointsBoundingBoxArea(), unsigned(inputPoints.size()), SHEPARD_AVG_NRPOINTS); // define a first neighborhood inside initial radius + std::vector shepardNeighbourPoints; for (unsigned int i=0; i < inputPoints.size(); i++) { if (inputPoints[i].distance <= shepardInitialRadius && @@ -865,28 +862,35 @@ float shepardSearchNeighbour(vector &inputPoints, inputPoints[i].index != settings->getIndexPointCV()) { shepardNeighbourPoints.push_back(inputPoints[i]); - nrValid++; } } - if (shepardNeighbourPoints.size() <= SHEPARD_MIN_NRPOINTS) + // If the points are too few, double the check radius + if (shepardNeighbourPoints.size() < SHEPARD_MIN_NRPOINTS) { - nrValid = sortPointsByDistance(SHEPARD_MIN_NRPOINTS + 1, inputPoints, outputPoints); - if (nrValid > SHEPARD_MIN_NRPOINTS) - { - radius = outputPoints[SHEPARD_MIN_NRPOINTS].distance; - outputPoints.pop_back(); - } - else + float doubleRadius = shepardInitialRadius * 2; + for (unsigned int i=0; i < inputPoints.size(); i++) { - radius = outputPoints[nrValid-1].distance + float(EPSILON); + if (inputPoints[i].distance <= doubleRadius && + inputPoints[i].distance > shepardInitialRadius && + inputPoints[i].index != settings->getIndexPointCV()) + { + shepardNeighbourPoints.push_back(inputPoints[i]); + } } + shepardInitialRadius = doubleRadius; + } + + float radius; + if (shepardNeighbourPoints.size() < SHEPARD_MIN_NRPOINTS) + { + int nrPoints = sortPointsByDistance(SHEPARD_MIN_NRPOINTS, inputPoints, outputPoints); + radius = outputPoints[nrPoints-1].distance + float(EPSILON); } else if (shepardNeighbourPoints.size() > SHEPARD_MAX_NRPOINTS) { - nrValid = sortPointsByDistance(SHEPARD_MAX_NRPOINTS + 1, shepardNeighbourPoints, outputPoints); - radius = outputPoints[SHEPARD_MAX_NRPOINTS].distance; - outputPoints.pop_back(); + int nrPoints = sortPointsByDistance(SHEPARD_MAX_NRPOINTS, shepardNeighbourPoints, outputPoints); + radius = outputPoints[nrPoints-1].distance + float(EPSILON); } else { diff --git a/agrolib/interpolation/interpolationConstants.h b/agrolib/interpolation/interpolationConstants.h index d1805a21..d5324a06 100644 --- a/agrolib/interpolation/interpolationConstants.h +++ b/agrolib/interpolation/interpolationConstants.h @@ -3,8 +3,8 @@ #define MIN_REGRESSION_POINTS 5 #define PEARSONSTANDARDTHRESHOLD 0.1 - #define SHEPARD_MIN_NRPOINTS 4 - #define SHEPARD_AVG_NRPOINTS 7 + #define SHEPARD_MIN_NRPOINTS 5 + #define SHEPARD_AVG_NRPOINTS 8 #define SHEPARD_MAX_NRPOINTS 10 #ifndef _STRING_ diff --git a/agrolib/pragaProject/pragaShell.cpp b/agrolib/pragaProject/pragaShell.cpp index 8f793543..e8fa0cb1 100644 --- a/agrolib/pragaProject/pragaShell.cpp +++ b/agrolib/pragaProject/pragaShell.cpp @@ -900,7 +900,7 @@ int pragaBatch(PragaProject* myProject, QString scriptFileName) attachOutputToConsole(); #endif - myProject->logInfo("\nPRAGA v1.8.3"); + myProject->logInfo("\nPRAGA v2.0.0"); myProject->logInfo("Execute script: " + scriptFileName); if (scriptFileName == "")