[19102] | 1 | Index: ../trunk-jpl/src/c/classes/kriging/Observations.cpp
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/c/classes/kriging/Observations.cpp (revision 18914)
|
---|
| 4 | +++ ../trunk-jpl/src/c/classes/kriging/Observations.cpp (revision 18915)
|
---|
| 5 | @@ -627,31 +627,24 @@
|
---|
| 6 | double *obs = NULL;
|
---|
| 7 | Observation observation=Observation(x_interp,y_interp,0.);
|
---|
| 8 | std::vector<Observation> kNN;
|
---|
| 9 | -
|
---|
| 10 | - /*If radius is not provided or is 0, return all observations*/
|
---|
| 11 | - if(radius==0.)
|
---|
| 12 | - {
|
---|
| 13 | - kNN=(this->covertree->getRoot())->getObservations();
|
---|
| 14 | - }
|
---|
| 15 | - else
|
---|
| 16 | - {
|
---|
| 17 | - kNN=(this->covertree->kNearestNeighbors(observation, maxdata));
|
---|
| 18 | - //cout << "kNN's size: " << kNN.size() << endl;
|
---|
| 19 | -
|
---|
| 20 | - }
|
---|
| 21 | +
|
---|
| 22 | + kNN=(this->covertree->kNearestNeighbors(observation, maxdata));
|
---|
| 23 | + //cout << "kNN's size: " << kNN.size() << endl;
|
---|
| 24 |
|
---|
| 25 | //kNN is sort from closest to farthest neighbor
|
---|
| 26 | //searches for the first neighbor that is out of radius
|
---|
| 27 | //deletes and resizes the kNN vector
|
---|
| 28 | vector<Observation>::iterator it;
|
---|
| 29 | - for (it = kNN.begin(); it != kNN.end(); ++it) {
|
---|
| 30 | - //(*it).print();
|
---|
| 31 | - //cout << "\n" << (*it).distance(observation) << endl;
|
---|
| 32 | - if ((*it).distance(observation) > radius) {
|
---|
| 33 | - break;
|
---|
| 34 | + if(radius>0.){
|
---|
| 35 | + for (it = kNN.begin(); it != kNN.end(); ++it) {
|
---|
| 36 | + //(*it).print();
|
---|
| 37 | + //cout << "\n" << (*it).distance(observation) << endl;
|
---|
| 38 | + if ((*it).distance(observation) > radius) {
|
---|
| 39 | + break;
|
---|
| 40 | + }
|
---|
| 41 | }
|
---|
| 42 | + kNN.erase(it, kNN.end());
|
---|
| 43 | }
|
---|
| 44 | - kNN.erase(it, kNN.end());
|
---|
| 45 |
|
---|
| 46 | /*Allocate vectors*/
|
---|
| 47 | x = new double[kNN.size()];
|
---|
| 48 | @@ -660,7 +653,7 @@
|
---|
| 49 |
|
---|
| 50 | /*Loop over all observations and fill in x, y and obs*/
|
---|
| 51 | int i = 0;
|
---|
| 52 | - for (it = kNN.begin(); it != kNN.end(); ++it) {
|
---|
| 53 | + for(it = kNN.begin(); it != kNN.end(); ++it) {
|
---|
| 54 | (*it).WriteXYObs((*it), &x[i], &y[i], &obs[i]);
|
---|
| 55 | i++;
|
---|
| 56 | }
|
---|
| 57 | @@ -668,5 +661,5 @@
|
---|
| 58 | *px=x;
|
---|
| 59 | *py=y;
|
---|
| 60 | *pobs=obs;
|
---|
| 61 | - *pnobs = kNN.size();
|
---|
| 62 | + *pnobs = kNN.size();
|
---|
| 63 | }/*}}}*/
|
---|