| | |
| | | |
| | | // http://localhost/ExportMap/terra/0/1/0.terrain?path=3d/terrain/dem/t |
| | | [Route("terra/{z}/{x}/{y}.terrain")] |
| | | [AcceptVerbs("GET", "POST")] |
| | | [HttpGet] |
| | | public HttpResponseMessage GetTerrain(int z, int x, int y, [FromUri]string path) |
| | | { |
| | | return WebUtils.GetTerrain(Request, path, z, x, y); |
| | |
| | | |
| | | // http://localhost/ExportMap/terra0/1/3/0.terrain?path=3d/terrain/dem/t |
| | | [Route("terra0/{z}/{x}/{y}.terrain")] |
| | | [AcceptVerbs("GET", "POST")] |
| | | [HttpGet] |
| | | public HttpResponseMessage GetTerrain0(int z, int x, int y, [FromUri]string path) |
| | | { |
| | | return WebUtils.GetTerrain0(Request, path, z, x, y); |
| | | } |
| | | |
| | | // http://localhost/ExportMap/tile/18/213517/107112.png?path=2d/tiles/0102 |
| | | [Route("tile/{z}/{x}/{y}.png")] |
| | | [HttpGet] |
| | | public HttpResponseMessage GetTile(int z, int x, int y, [FromUri]string path) |
| | | { |
| | | return WebUtils.GetTile(Request, path, z, x, y); |
| | | } |
| | | |
| | | // http://localhost/ExportMap/tile0/18/213517/107110.png?path=2d/tiles/0102 |
| | | [Route("tile0/{z}/{x}/{y}.png")] |
| | | [HttpGet] |
| | | public HttpResponseMessage GetTile0(int z, int x, int y, [FromUri]string path) |
| | | { |
| | | return WebUtils.GetTile0(Request, path, z, x, y); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /// <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 |
| | | } |
| | | } |