Changeset 18915


Ignore:
Timestamp:
12/03/14 12:06:52 (10 years ago)
Author:
Mathieu Morlighem
Message:

BUG: fixed covertree

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/kriging/Observations.cpp

    r18912 r18915  
    628628    Observation observation=Observation(x_interp,y_interp,0.);
    629629    std::vector<Observation> kNN;
    630    
    631     /*If radius is not provided or is 0, return all observations*/
    632     if(radius==0.)
    633     {
    634         kNN=(this->covertree->getRoot())->getObservations();
    635     }
    636     else
    637     {
    638         kNN=(this->covertree->kNearestNeighbors(observation, maxdata));
    639                 //cout << "kNN's size: " << kNN.size() << endl;
    640                
    641     }
     630
     631         kNN=(this->covertree->kNearestNeighbors(observation, maxdata));
     632         //cout << "kNN's size: " << kNN.size() << endl;
    642633       
    643634        //kNN is sort from closest to farthest neighbor
     
    645636        //deletes and resizes the kNN vector
    646637        vector<Observation>::iterator it;
    647         for (it = kNN.begin(); it != kNN.end(); ++it) {
    648                 //(*it).print();
    649                 //cout << "\n" << (*it).distance(observation) << endl;
    650                 if ((*it).distance(observation) > radius) {
    651                         break;
    652                 }
    653         }
    654         kNN.erase(it, kNN.end());
     638        if(radius>0.){
     639                for (it = kNN.begin(); it != kNN.end(); ++it) {
     640                        //(*it).print();
     641                        //cout << "\n" << (*it).distance(observation) << endl;
     642                        if ((*it).distance(observation) > radius) {
     643                                break;
     644                        }
     645                }
     646                kNN.erase(it, kNN.end());
     647        }
    655648   
    656649        /*Allocate vectors*/
     
    661654        /*Loop over all observations and fill in x, y and obs*/
    662655        int i = 0;
    663         for (it = kNN.begin(); it != kNN.end(); ++it) {
     656        for(it = kNN.begin(); it != kNN.end(); ++it) {
    664657                (*it).WriteXYObs((*it), &x[i], &y[i], &obs[i]);
    665658                i++;
     
    669662    *py=y;
    670663    *pobs=obs;
    671         *pnobs = kNN.size();
    672 }/*}}}*/
     664         *pnobs = kNN.size();
     665}/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.