short RasterMapCache::LookupTerrainCacheFile(const long &SeekPos) { // put new value in slot tcpmin __int16 NewAlt = 0; long SeekRes; short Alt; if(!isMapLoaded()) return TERRAIN_INVALID; Lock(); SeekRes = zzip_seek(fpTerrain, SeekPos, SEEK_SET); if(SeekRes != SeekPos) { // error, not found! Alt = TERRAIN_INVALID; } else { if (zzip_fread(&NewAlt, 1, sizeof(__int16), fpTerrain) != sizeof(__int16)) Alt = TERRAIN_INVALID; else { // FIX HERE NETHERLAND Alt = max((short int)0,NewAlt); } } Unlock(); return Alt; }
void RasterMap::SetFieldRounding(double xr, double yr) { if (!isMapLoaded()) { return; } Xrounding = iround(xr/TerrainInfo.StepSize); Yrounding = iround(yr/TerrainInfo.StepSize); if (Xrounding<1) { Xrounding = 1; } fXrounding = 1.0/(Xrounding*TerrainInfo.StepSize); fXroundingFine = fXrounding*256.0; if (Yrounding<1) { Yrounding = 1; } fYrounding = 1.0/(Yrounding*TerrainInfo.StepSize); fYroundingFine = fYrounding*256.0; if ((Xrounding==1)&&(Yrounding==1)) { DirectFine = true; xlleft = (int)(TerrainInfo.Left*fXroundingFine)+128; xlltop = (int)(TerrainInfo.Top*fYroundingFine)-128; } else { DirectFine = false; } }
float RasterMap::GetFieldStepSize() { if (!isMapLoaded()) { return 0; } // this is approximate of course.. float fstepsize = (float)(250.0/0.0025*TerrainInfo.StepSize); return fstepsize; }
bool RasterMap::GetMapCenter(double *lon, double *lat) { if(!isMapLoaded()) return false; *lon = (TerrainInfo.Left + TerrainInfo.Right)/2; *lat = (TerrainInfo.Top + TerrainInfo.Bottom)/2; return true; }
//---------------------------------------------------------------------------- void GameRadar::setContainerWidget( IImage* image ) { if ( image && isInitialized() && isMapLoaded() ) { image->setRenderTexture( mapName, mapGroup ); image->setUVCoord(0,0,1.0,1.0); mContainerSize.x = (I32)image->getWidget()->getSize().x; mContainerSize.y = (I32)image->getWidget()->getSize().y; } }
void RasterMapRaw::SetFieldRounding(double xr, double yr) { RasterMap::SetFieldRounding(xr, yr); if (!isMapLoaded()) { return; } if ((Xrounding==1)&&(Yrounding==1)) { DirectFine = true; xlleft = (int)(TerrainInfo.Left*fXroundingFine)+128; xlltop = (int)(TerrainInfo.Top*fYroundingFine)-128; } else { DirectFine = false; } }
void RasterMap::SetFieldRounding(double xr, double yr) { if (!isMapLoaded()) { return; } Xrounding = iround(xr/TerrainInfo.StepSize); Yrounding = iround(yr/TerrainInfo.StepSize); if (Xrounding<1) { Xrounding = 1; } fXrounding = 1.0/(Xrounding*TerrainInfo.StepSize); fXroundingFine = fXrounding*256.0; if (Yrounding<1) { Yrounding = 1; } fYrounding = 1.0/(Yrounding*TerrainInfo.StepSize); fYroundingFine = fYrounding*256.0; DirectFine = false; }
// JMW rounding further reduces data as required to speed up terrain // display on low zoom levels short RasterMap::GetField(const double &Latitude, const double &Longitude) { if(isMapLoaded()) { if (DirectFine) { return _GetFieldAtXY((int)(Longitude*fXroundingFine)-xlleft, xlltop- (int)(Latitude*fYroundingFine)); } else { #if (WINDOWSPC>0) unsigned int ix = Real2Int((Longitude-TerrainInfo.Left)*fXrounding)*Xrounding; unsigned int iy = Real2Int((TerrainInfo.Top-Latitude)*fYrounding)*Yrounding; #else unsigned int ix = ((int)((Longitude-TerrainInfo.Left)*fXrounding)) *Xrounding; unsigned int iy = ((int)((TerrainInfo.Top-Latitude)*fYrounding))*Yrounding; #endif return _GetFieldAtXY(ix<<8, iy<<8); } } else { return TERRAIN_INVALID; } }