| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取影像文件 |
| | | /// </summary> |
| | | public static HttpResponseMessage GetTile(HttpRequestMessage Request, string path, int z, int x, int y) |
| | | { |
| | | string basePath = Path.Combine(LFData, path); |
| | | if (!Directory.Exists(basePath)) |
| | | { |
| | | throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.BadRequest, "路径不存在!")); |
| | | } |
| | | |
| | | string file = basePath + "\\" + z + "\\" + x + "\\" + y + ".png"; |
| | | if (!File.Exists(file)) |
| | | { |
| | | throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound, "文件不存在!")); |
| | | } |
| | | |
| | | return DownloadFile(file, y + ".png"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取影像文件,不存在返回空文件 |
| | | /// </summary> |
| | | public static HttpResponseMessage GetTile0(HttpRequestMessage Request, string path, int z, int x, int y) |
| | | { |
| | | string basePath = Path.Combine(LFData, path); |
| | | if (!Directory.Exists(basePath)) |
| | | { |
| | | throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.BadRequest, "路径不存在!")); |
| | | } |
| | | |
| | | string file = basePath + "\\" + z + "\\" + x + "\\" + y + ".png"; |
| | | if (!File.Exists(file)) |
| | | { |
| | | return DownloadFile(Tools.BaseDir + "\\Sources\\empty.png", y + ".png"); |
| | | } |
| | | |
| | | return DownloadFile(file, y + ".png"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 下载文件 |
| | | /// </summary> |
| | | public static HttpResponseMessage DownloadFile(string file, string fileName) |
| | |
| | | return response; |
| | | } |
| | | |
| | | #region 发送请求 |
| | | /// <summary> |
| | | /// Get请求 |
| | | /// </summary> |
| | |
| | | |
| | | return result; |
| | | } |
| | | #endregion |
| | | } |
| | | } |