当前位置: 首页 > news >正文

网站建设 年终总结温州做美食网站

网站建设 年终总结,温州做美食网站,正规网站建设制作,那家网站做的效果好xyz地图服务访问示例#xff1a;http://192.168.1.240:8081/gmserver/raster/xyz/firstWP:Imagery-raster/{z}/{x}/{y}.jpg 访问示例如下#xff1a; mbtiles目录结构 根据z#xff0c;x#xff0c;y获取对应mbtiles文件路径的工具方法 说明#xff1a;重点是使用getMb…xyz地图服务访问示例http://192.168.1.240:8081/gmserver/raster/xyz/firstWP:Imagery-raster/{z}/{x}/{y}.jpg 访问示例如下 mbtiles目录结构 根据zxy获取对应mbtiles文件路径的工具方法 说明重点是使用getMbtilesPath方法通过xyz获取mbtiles文件路径。 getTilesFile方法是通过图层因为我做的项目是mbtiles数据集绑定在图层上获取对应的mbtiles文件。 package com.gs.springboot.gmserver.util;import com.gs.springboot.gmserver.core.CommonConstants; import org.geoserver.catalog.LayerInfo; import org.geoserver.catalog.StoreInfo;import java.io.File; import java.io.Serializable; import java.util.Collection; import java.util.Map;/*** Desc mbtiles工具类*/ public class MbtilesUtil {/*** 根据zxy索引mbtiles文件所在目录** param z 层级* param x 行* param y 列* param rootPath mbtiles根目录* return java.lang.String*/public static String getMbtilesPath(int z, int x, int y, String rootPath) {int p 0;//文件级别的列号int q 0;//文件级别的行号int m 0;//文件夹级别的列号int n 0;//文件夹级别的行号if (z 8) {p 0;q 0;m 0;n 0;} else if (z 9) {double fileTotal Math.pow(2, 2 * (z - 8));//文件总数double tileTotal 65536 * fileTotal;//瓦片总数double maxTileNum Math.sqrt(tileTotal);//行和列坐标轴方向的瓦片个数行列相等double segmentNum Math.sqrt(fileTotal);//行和列分的段数即行和列坐标轴方向的mbtiles文件个数double tileNumOfEachMbtiles maxTileNum / segmentNum;//单个mbtiles的最大行列的瓦片数行列瓦片数相等p (int) (x / tileNumOfEachMbtiles);q (int) (y / tileNumOfEachMbtiles);if (z 9 || z 10) {m 0;n 0;} else {double dirTotal fileTotal / 16;//文件夹总数double segmentDirNum Math.sqrt(dirTotal);//行和列坐标轴方向的最大文件夹个数行列相等double tileNumOfEachDir segmentNum / segmentDirNum;//每段文件夹内的mbtiles的个数m (int) (p / tileNumOfEachDir);n (int) (q / tileNumOfEachDir);}}String mbtiles_file rootPath / z / m _ n / z _ p _ q .mbtiles;return mbtiles_file;}/*** 通过图层信息索引瓦片对应文件* param layerInfo 图层* param tilecol 列x* param tilerow 行y* param z 层级z* param format 后缀* return java.io.File*/public static File getTilesFile(LayerInfo layerInfo, int tilecol, int tilerow, Integer z, String format) {StoreInfo store layerInfo.getResource().getStore();String type store.getType();File file null;MapString, Serializable connectionParameters store.getConnectionParameters();for (String key : connectionParameters.keySet()) {if (key.contains(filePath)) {Serializable value connectionParameters.get(key);String rootPath (String) value;String tilesPath null;if (type.equals(CommonConstants.DataStoreType.TilesFolderRaster.getValue())|| type.equals(CommonConstants.DataStoreType.TilesFolderVector.getValue())|| type.equals(CommonConstants.DataStoreType.TilesFolderDEM_terrain.getValue())) {tilesPath rootPath / z / tilecol / tilerow . format;} else if (type.equals(CommonConstants.DataStoreType.TilesFolderDEM_png.getValue())) {tilesPath rootPath / z / tilecol / tilerow .png;}else if (type.equals(CommonConstants.DataStoreType.MbtilesFolderRaster.getValue())|| type.equals(CommonConstants.DataStoreType.MbtilesFolderVector.getValue())|| type.equals(CommonConstants.DataStoreType.MbtilesFolderDEM.getValue())) {tilesPath getMbtilesPath(z, tilecol, tilerow, rootPath);}file new File(tilesPath);if (file.exists() file.length() 0) {break;}}}return file;}}发布mbtiles地图服务的接口。 说明此处由于是项目的完整功能所以代码是通过图层名称获取mbtiles的文件你也可以将layer直接换成mbtiles数据集的根目录或者直接写死根目录。通过xyz就可以访问瓦片。 package com.gs.springboot.gmserver.tiles;import cn.hutool.core.io.file.FileNameUtil; import com.gs.springboot.gmserver.core.CommonConstants; import com.gs.springboot.gmserver.util.MbtilesUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.apache.commons.io.IOUtils; import org.geoserver.catalog.Catalog; import org.geoserver.catalog.LayerInfo; import org.geoserver.catalog.StoreInfo; import org.imintel.mbtiles4j.MBTilesReadException; import org.imintel.mbtiles4j.MBTilesReader; import org.imintel.mbtiles4j.Tile; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController;import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.util.concurrent.CompletableFuture;RestController Api(tags 栅格瓦片服务发布接口) public class RasterTilesController {Autowiredprivate Catalog catalog;GetMapping(/raster/xyz/{layer}/{z}/{x}/{y}.{format})ApiOperation(value 发布栅格Mbtiles文件夹数据XYZ服务)ApiImplicitParams({ApiImplicitParam(name layer, value 图层名称, dataType String, paramType path),ApiImplicitParam(name z, value z坐标, dataType int, paramType path),ApiImplicitParam(name x, value x坐标, dataType int, paramType path),ApiImplicitParam(name y, value y坐标, dataType int, paramType path),ApiImplicitParam(name format, value 格式, dataType String, paramType path)})public void publishXYZ(PathVariable(layer) String layer,PathVariable(z) int z,PathVariable(x) int x,PathVariable(y) int y,PathVariable(format) String format,HttpServletResponse response) {LayerInfo layerInfo catalog.getLayerByName(layer);StoreInfo store layerInfo.getResource().getStore();if (store.getConnectionParameters().get(scheme) ! null) {String scheme (String) store.getConnectionParameters().get(scheme);if (!CommonConstants.DataStoreScheme.XYZ.getValue().equals(scheme)) {y (1 z) - y - 1;//此处是将xyz转tms}}extracted(layerInfo, z, x, y, format, response);}private void extracted(LayerInfo layerInfo, int z, int x, int y, String format, HttpServletResponse response) {File file MbtilesUtil.getTilesFile(layerInfo, x, y, z, format);String prefix FileNameUtil.getSuffix(file);// 异步执行任务返回一个 CompletableFutureCompletableFutureVoid future CompletableFuture.runAsync(() - {InputStream data null;if (mbtiles.equals(prefix)) {MBTilesReader r null;Tile tile;try {r new MBTilesReader(file);tile r.getTile(z, x, y);} catch (MBTilesReadException e) {throw new RuntimeException(e);}data tile.getData();} try {if (png.equals(format) || jpg.equals(format)) {response.setContentType(image/ format);} else {response.setStatus(400);return;}ServletOutputStream oStream response.getOutputStream();IOUtils.copy(data, oStream);oStream.flush();oStream.close();} catch (IOException e) {throw new RuntimeException(e);}});// 等待 CompletableFuture 完成future.join();}}
http://www.zqtcl.cn/news/696639/

相关文章:

  • wap网站制作当阳网站建设电话
  • 服装电子商务网站建设3000字中装建设有限公司
  • 河南卓越建设工程有限公司网站怎么做垂直门户网站
  • 接单做网页的网站手机端app开发公司
  • 古田路9号设计网站在线制作图片拼图
  • 深圳网站开发ucreator售后服务 网站建设
  • 做网站的语北京比较好的it公司
  • 长春建站模板制作php项目开发案例源码
  • 绍兴seo外包公司山东网站建设优化
  • php做网站知乎境外网站icp备案
  • 做seo网站图片怎么优化地坪漆东莞网站建设技术支持
  • wordpress theme forest济南优化网站排名
  • 简述网站的制作步骤合肥网站建设需
  • 网站备案的程序哪里能买精准客户电话
  • 白云网站建设网站版式
  • 做美食有哪些网站科技公司介绍
  • 网站后台被百度蜘蛛抓取哪个做网站比较好
  • 企业建设网站的需求分析百度免费发布信息平台
  • 网站建设交易中心上海装修公司排行榜
  • 桂林论坛网站有哪些在线设计平台用户分析
  • wap网站的开发去加网 wordpress
  • 博客网站建设设计论文总结php mysql做网站登录
  • 海南智能网站建设公司wordpress 如何使用php版本号
  • 河南网站开发培训app 软件开发
  • 购物网站功能介绍一流的高密网站建设
  • 电影网站怎么做优化wordpress 去掉w
  • 永久网站空间标书制作员工资很低吗
  • 做网站用到ps么淘宝优惠网站怎么做
  • jsp 淘宝网站验证码 设计搜索引擎排名
  • pdf怎么做电子书下载网站北京成立公司