private static int GetYFromSquare(MapSquare square, double zoom) { double latitude = square.BottomLatitude * Math.PI / 180.0; return((int)Math.Round((1.0f - (System.Math.Log(System.Math.Tan(latitude) + (1.0f / System.Math.Cos(latitude)))) / System.Math.PI) / 2f * (double)zoom)); }
private static int GetXFromSquare(MapSquare square, double zoom) { return((int)Math.Round(((square.LeftLongitude + 180.0) / 360.0) * (double)zoom)); }
public bool Contains(MapSquare otherSquare) { return(_topLatitude >= otherSquare.TopLatitude && _bottomLatitude <= otherSquare.BottomLatitude && _leftLongitude <= otherSquare.LeftLongitude && _rightLongitude >= otherSquare.RightLongitude); }
public MapTile(MapSquare square, double zoom) { _zoom = GetTileZoom(zoom); _xNumber = GetXFromSquare(square, Math.Pow(2, _zoom)); _yNumber = GetYFromSquare(square, Math.Pow(2, _zoom)); }
public bool Intersects(MapSquare otherSquare) { return((_topLatitude <= otherSquare.BottomLatitude && _bottomLatitude >= otherSquare.TopLatitude) && (_rightLongitude <= otherSquare.LeftLongitude && _leftLongitude >= otherSquare.RightLongitude)); }