Пример #1
0
 public static TileRequest LatLongToTile(GeoPoint point, int zLevel)
 {
   return new TileRequest
   {
     X = (int) Math.Floor(LongitudeToX(point.Longitude)*Math.Pow(2, zLevel)/TileSize),
     Y = (int) Math.Floor(LatitudeToY(point.Latitude)*Math.Pow(2, zLevel)/TileSize),
     Z = zLevel
   };
 }
Пример #2
0
 public object Get(GetTileRequests request)
 {
     var point = new GeoPoint
       {
     Latitude = request.Latitude,
     Longitude = request.Longitude
       };
       return TileRequest.LatLongToTiles(point);
 }
Пример #3
0
        /// <summary>
        ///   This is the NorthWest Corner of the tile
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        /// <returns></returns>
        private static GeoPoint ToLatLong(double x, double y, double z)
        {
            var newPoint = new GeoPoint();
              var n = Math.PI - ((2.0*Math.PI*y)/Math.Pow(2.0, z));

              newPoint.Longitude = (float) ((x/Math.Pow(2.0, z)*360.0) - 180.0);
              newPoint.Latitude = (float) (180.0/Math.PI*Math.Atan(Math.Sinh(n)));

              return newPoint;
        }
Пример #4
0
 public static List<TileRequest> LatLongToTiles(GeoPoint point)
 {
   return Enumerable.Range(0, LowestLevel).Select(index => LatLongToTile(point, index)).ToList();
 }