示例#1
0
/**
 * Prints the results to a stream
 * @param test Scores object to be printed
 * @param myout stream to be printed to
 */
void SetHandler::print(Scores& test, int label, ostream& myout) {
  vector<ResultHolder> outList(0);
  for (std::vector<DataSet*>::iterator it = subsets_.begin();
         it != subsets_.end(); ++it) {
    if ((*it)->getLabel() == label) {
      (*it)->print(test, outList);
    }
  }
  sort(outList.begin(), outList.end(), std::greater<ResultHolder> ());
  myout
      << "PSMId\tscore\tq-value\tposterior_error_prob\tpeptide\tproteinIds"
      << endl;
  for (std::vector<ResultHolder>::iterator it = outList.begin();
         it != outList.end(); ++it) {
    myout << *it << endl;
  }
}
示例#2
0
//width and heigth are in 'pixels'
vector<float> getElevations(float _lat,float _lng,int width,int height,float vscale,float rot, int waterDrop, int baseHeight, int stepSize){
	int tileNumber = 0;
	string tileName = "";
	ifstream file;
	vector<float> outList(width*height);

	file.open("../Terrain2STL-master/hgt_files/N44W070.hgt");

	int h;
	char number [2];

	int t = getTileIndex(_lat,_lng);

	//let's go with mercator space for now (Terrain2STL style)
	for(int x = 0; x<width; x++){
		for(int y = 0; y<height; y++){
			float u = (float)y/1200 - (float)height/1200;
			float v = (float)x/1200;

			u *= stepSize;
			v *= stepSize;

			//get the lat and lng for each point
			float lat = _lat + u*cos(rot) + v*sin(rot);
			float lng = _lng + v*cos(rot) - u*sin(rot);

			//interpolate - maybe skip for rot0=0?

			float elevations[2][2];
			for(int a = 0; a < 2; a++){		//x coord for Interpolation
				for(int b = 0; b < 2; b++){ //

					//interesting bit of code here.
					//floor(...)/1200 as no distortion but cannot handle tile edges
					//x+float() handles edges well but with distortion
					//lat+(float)b/1200
					float intlat = floor(lat*1200+b)/1200.0+0.000598907;	//magic number??
					float intlng = floor(lng*1200+a)/1200.0;
					//floor(lng*1200+a)/1200;

					if(getTileIndex(intlat, intlng)!=tileNumber){
						tileNumber = getTileIndex(intlat, intlng);
						tileName = getTile(intlat, intlng);

						file.close();
			      file.open(tileName.c_str(),ios::in|ios::binary);
					}

					int p = (int) (1201*(intlng-floor(intlng)));		//x or lng component
					p += (int)(1201*(ceil(intlat)-intlat))* 1201;	//y or lat component

					file.seekg(p*2,ios::beg);
			    file.read(number,2);
			    h = number[1];
			    if(h<0){
			      h = h+255;
			    }
			    h+= number[0]*256;
					if(h==0){
						h-= waterDrop/vscale;
					}
					elevations[a][b]= (float)h;
				}
			}
			float fracLat = lat-floor(lat*1200)/1200;
			float fracLng = lng-floor(lng*1200)/1200;
			fracLat *= 1200;
			fracLng *= 1200;
			float westLng = elevations[0][0]*(1-fracLat)  +  elevations[0][1]*fracLat;
			float eastLng = elevations[1][0]*(1-fracLat)  +  elevations[1][1]*fracLat;

			//not sure about this....
			float intHeight = westLng*(1-fracLng) + eastLng*fracLng;

			//if(t!=getTileIndex(lat,lng)){
			//	intHeight=0;
			//}
			//float intHeight = (elevations[0][0]+elevations[0][1]+elevations[1][0]+elevations[1][1])/4;
			outList.at(y*width+x) = intHeight*vscale+baseHeight;
		}
	}
	file.close();
	clog << "Done getting elevations\n";
	return outList;
}