Показать сообщение отдельно
  #1  
Старый 09.12.2009, 12:03
Аватар для movnet
movnet movnet вне форума
Начинающий
 
Регистрация: 24.07.2008
Сообщения: 127
Версия Delphi: Delphi 7
Репутация: 23
По умолчанию Помогите перевести код С# на Delphi

Помогите перевести код С# на Delphi!

class gmaps {
...
public Point tile(double lat, double lng, int zoom)
{
return new System.Drawing.Point(Xpixel(lng, zoom) / 256, Ypixel(lat, zoom));
}

public int Xpixel(double lng, int zoom)
{
// Instead of -180 to +180, we want 0 to 360
double dlng = this.lng.Value + 180.0;

// 256 = tile Width
double dxpixel = dlng / 360.0 * 256 * Math.Pow(2, 17 - zoom);
int xpixel = Convert.ToInt32(Math.Floor(dxpixel));
return xpixel;
}

public int Ypixel(double lat, int zoom)
{
// The 25 comes from 17 + (256=>2^8=>8) 17+8 = 25
// ypixelcenter = the middle y pixel (the equator) at this zoom level
double ypixelcenter = Math.Pow(2, 25 - zoom - 1);

// PI/360 == degrees -> radians
// The trig functions are done with radians
double dypixel = ypixelcenter - Math.Log(Math.Tan(lat * Math.PI / 360 + Math.PI / 4)) * ypixelcenter / Math.PI;
int ypixel = Convert.ToInt32(Math.Floor(dypixel));
return ypixel;
}
...
}
Ответить с цитированием