source:
issm/oecreview/Archive/18296-19100/ISSM-18914-18915.diff
Last change on this file was 19102, checked in by , 10 years ago | |
---|---|
File size: 1.9 KB |
-
../trunk-jpl/src/c/classes/kriging/Observations.cpp
627 627 double *obs = NULL; 628 628 Observation observation=Observation(x_interp,y_interp,0.); 629 629 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; 642 633 643 634 //kNN is sort from closest to farthest neighbor 644 635 //searches for the first neighbor that is out of radius 645 636 //deletes and resizes the kNN vector 646 637 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; 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 } 652 645 } 646 kNN.erase(it, kNN.end()); 653 647 } 654 kNN.erase(it, kNN.end());655 648 656 649 /*Allocate vectors*/ 657 650 x = new double[kNN.size()]; … … 660 653 661 654 /*Loop over all observations and fill in x, y and obs*/ 662 655 int i = 0; 663 for 656 for(it = kNN.begin(); it != kNN.end(); ++it) { 664 657 (*it).WriteXYObs((*it), &x[i], &y[i], &obs[i]); 665 658 i++; 666 659 } … … 668 661 *px=x; 669 662 *py=y; 670 663 *pobs=obs; 671 *pnobs = kNN.size();664 *pnobs = kNN.size(); 672 665 }/*}}}*/
Note:
See TracBrowser
for help on using the repository browser.