一、发布png到geoserver的imagepyramid
// translate png to tif epsg:4326
File png = new File(pngPathStr);
BufferedImage sourcePng = ImageIO.read(new FileInputStream(png));
int pngWidth = sourcePng.getWidth();
int pngHeight = sourcePng.getHeight();
String outGeoTiffFormTransName = pngPathStr + "out.tif";
String comdTransPngToGTifWith4326 = "gdal_translate -a_srs EPSG:4326 -gcp 0 0 "+ west +" "+ north +" -gcp " + pngWidth + " 0 "+ east +" "+ north +" -gcp "+ pngWidth +" " + pngHeight +" " + east +" "+ south +" "+ pngPathStr +" "+ outGeoTiffFormTransName;
//gdal_translate -a_srs EPSG:4326 -gcp 0 0 -90 0 -gcp 256 0 -45 0 -gcp 256 256 -45 45 Lena.tif Lean.tiff
System.out.println(comdTransPngToGTifWith4326);
Process process1 = Runtime.getRuntime().exec(comdTransPngToGTifWith4326);
process1.waitFor();
process1.destroy(); //warp tif to geotiff epsg:4326
String warpGeotiffName = outGeoTiffFormTransName + "warp.tiff";
String comdWarpGEOtiff = "gdalwarp -s_srs EPSG:4326 -t_srs EPSG:4326 " + outGeoTiffFormTransName +" "+ warpGeotiffName;
//gdalwarp -s_srs EPSG:4326 -t_srs EPSG:4326 Lean.tiff
System.out.println(comdWarpGEOtiff);
Process process2 = Runtime.getRuntime().exec(comdWarpGEOtiff);
process2.waitFor();
process2.destroy(); //retile geoTiff in 4 level
String cutPngDirName = pngPathStr.substring(0, pngPathStr.lastIndexOf("."));
String addCutTiffDirCmd = "mkdir " +cutPngDirName;
Process process3 = Runtime.getRuntime().exec(addCutTiffDirCmd);
process3.waitFor();
process3.destroy();
String retileGeotiffCmd = "gdal_retile.py -v -r bilinear -levels 4 -ps 2048 2048 -co \"TILED=YES\" -targetDir "+ cutPngDirName +" "+warpGeotiffName;
//gdal_retile.py -v -r bilinear -levels 4 -ps 2048 2048 -co "TILED=YES" -targetDir lean LEAN.tiff
Process process4 = Runtime.getRuntime().exec(retileGeotiffCmd);
process4.waitFor();
process4.destroy(); //use geoserver restapi to add a workspace
String curlAddWorkSpanceCmd = "curl -v -u admin:geoserver -XPOST -H \"content-type: text/xml\" -d \"<workspace><name>toby</name></workspace>\" \"http://127.0.0.1:8090/geoserver/rest/workspaces\"";
//curl -v -u admin geoserver -XPOST -H "content-type: text/xml" -d "<workspace><name>toby</name></workspace>" "http://127.0.0.1:8090/geoserver/rest/workspaces"
Process process5 = Runtime.getRuntime().exec(curlAddWorkSpanceCmd);
process5.waitFor();
process5.destroy(); //add a imagepyramid WMS
String addImagepyramidCmd = "curl -v -u admin:geoserver -XPUT -H \"Context-type: text/plain\" -d \""+ cutPngDirName +"\" \"http://localhost:8090/geoserver/rest/workspaces/toby/coveragestores/poly-incremental/external.imagepyramid\"";
//curl -v -u admin:geoserver -XPUT -H "Context-type: text/plain" -d "file:/home/xschen/Downloads/lean" "http://localhost:8090/geoserver/rest/workspaces/toby/coveragestores/poly-incremental/external.imagepyramid"
Process process6 = Runtime.getRuntime().exec(addImagepyramidCmd);
process6.waitFor();
process6.destroy();

  二、前台的geoserverTerrainProvider配置使用

var terrainProvider = new Cesium.GeoserverTerrainProvider({
service: "WMS",
url : "http://127.0.0.1:8888/geoserver/kjtest/wms",//上面java中得到的WMSurl
layerName: "gt30e100n40",//上面java中的cutPngDirName
//layerName: "lean",
heightMapWidth: 65,
heightMapHeight: 65,
offset: 0,
highest: 40000,
hasStyledImage: true,
waterMask: true,
cesiumViewer: viewer,
formatArray: {
format : "image/bil",
postProcessArray : function(bufferIn, size,highest,lowest,offset) { var resultat;
var viewerIn = new DataView(bufferIn);
var littleEndianBuffer = new ArrayBuffer(size.height * size.width * 2);
var viewerOut = new DataView(littleEndianBuffer);
if (littleEndianBuffer.byteLength === bufferIn.byteLength) {
var temp, goodCell = 0, somme = 0;
for (var i = 0; i < littleEndianBuffer.byteLength; i += 2) {
temp = viewerIn.getInt16(i, false)-offset ;
if (temp > lowest && temp < highest) {
viewerOut.setInt16(i, temp, true);
somme += temp;
goodCell++;
} else {
var val = (goodCell == 0 ? 1 : somme / goodCell);
viewerOut.setInt16(i, val, true);
}
}
resultat = new Int16Array(littleEndianBuffer);
console.log(resultat);
}
return resultat;
}
}
});
viewer.terrainProvider = terrainProvider;

  或者使用cesium的

new Cesium.WebMapServiceImageryProvider({
url: geoserverWMSurl,//?号之前
layers: workspace:layerName//工作空间 : 发布图层的名称
});

最后使用nginx解决跨域问题。

nginx.config的配置信息如下:

# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid; events {
worker_connections ;
} http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout ;
types_hash_max_size ; include /etc/nginx/mime.types;
default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf; server {
listen 80 default_server;
listen [::]:80 default_server;
listen 8888;
server_name _;
root /usr/share/nginx/html; # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf; location ^~/em {
proxy_pass http://127.0.0.1:8081/em;
proxy_set_header Host $host:8888;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
} location ^~/demWordData {
proxy_pass http://127.0.0.1:8080/demWordData;
proxy_set_header Host $host:8888;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
} error_page 404 /404.html;
location = /40x.html {
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
} # Settings for a TLS enabled server.
#
# server {
# listen 443 ssl;
# listen [::]:443 ssl;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers PROFILE=SYSTEM;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# } }

欢迎大家来我的新家看一看 3wwang个人博客-记录走过的技术之路

cesium+ geoserverTerrainProvide+png展示3D高程图展示的更多相关文章

  1. iOS 超大高清图展示策略 TileLayer 及 levelsOfDetailBias 分析

    本次分析针对当下流行的中国地图图片处理,1亿像素,就是下面这张: 原图尺寸:11935x8554 文件大小:22.1MB 原始加载方式 首先,我们尝试一下直接加载的方式,看看效果会有多恐怖 效果请看下 ...

  2. WebGL展示3D房屋内景

      原文地址:WebGL展示3D房屋内景   由于生活和工作上的原因,从年前开始一直到处奔波,没有太多的时间去关注和学习WebGL图形学相关的技术, 不过陆陆续续都有学习使用blender进行3D建模 ...

  3. XAML中用一字符即可展示漂亮的图型

    XAML中用一字符即可展示漂亮的图型 例如:Symbol Icon: People http://www.geekchamp.com/icon-explorer/action-icons/icon?c ...

  4. 基于Echarts的股票K线图展示

    发布时间:2018-10-31   技术:javascript+html5+canvas   概述 基于echarts的股票K线图展示,只需引用单个插件,通过简单配置,导入数据,即可实现炫酷复杂的K线 ...

  5. [py]flask动态展示主机内存图

    echarts基础 需要借助这个图来绘制,动态内存图. 绘制步骤 写py脚本来入库日志 选取合适的echart,并观察图所需的数据格式 用flask返回这个静态的echarts 用flask写接口返回 ...

  6. flask+layui+echarts实现前端动态图展示数据

    效果图: 该效果主要实现一个table展示数据,并在下方生成一个折线图. 实现方式: 1.首先需要对表格进行一个数据加载,这里用到了layui的table.render,具体用法可以参考 https: ...

  7. 【】(Git)用动图展示10大Git命令

    1.说明 git merge.git rebase.git reset.git revert.git fetch.git pull.git reflog-- 你知道这些 git 命令执行的究竟是什么任 ...

  8. HTML 5 +CSS3 + 原生js 做(雪花全屏飘落 + 3d旋转图)

    原文:HTML 5 +CSS3 + 原生js 做(雪花全屏飘落 + 3d旋转图) 3d旋转图:主要用css3中transform属性中的rotate,translate;以及用来做舞台效果的 pers ...

  9. Cesium原理篇:3D Tiles(1)渲染调度

    Cesium在2016年3月份左右推出3D Tiles数据规范,在glTF基础上提供了LOD能力,定位就是Web环境下海量三维模型数据.虽然目前3D Tiles还是Beta阶段,有不少硬伤,但3D T ...

随机推荐

  1. Opencv配置问题_Error LNK2019

    终于配好opencv(Win7 64位+VS2013+opencv2.4.9),兴奋的写了第一个程序(当然是显示lena的玉照了): #include <opencv2\opencv.hpp&g ...

  2. 1117 冲刺一(Day 1)

    冲刺一(第一天) 项目需求确定 现阶段我们进行的项目是到店点餐系统.主要是开发手机端app为用户提供方便快捷的点餐服务.免去顾客到店后遇到因吃饭的人太多而找不到服务人员点餐的窘境.减少了服务人员因为忙 ...

  3. .NET获取根目录方法

    1.取得控制台应用程序的根目录方法 方法1.Environment.CurrentDirectory 取得或设置当前工作目录的完整限定路径 方法2.AppDomain.CurrentDomain.Ba ...

  4. 采集的GPS数据如何正确显示在arcgis和cad中

    利用GPS定位卫星,在全球范围内实时进行定位.导航的系统,称为全球卫星定位系统,简称GPS.GPS是由美国国防部研制建立的一种具有全方位.全天候.全时段.高精度的卫星导航系统,能为全球用户提供低成本. ...

  5. 怎么解决svn清理失败且路径显示乱码问题

    http://jingyan.baidu.com/article/295430f1d728830c7e0050f9.html 上面这个网址是百度经验给的方法,我也是参照这个方式解决了问题,虽然是解决了 ...

  6. matlab clear

    clear 删除工作空间中的项目,释放系统内存 语法: clear clear name clear name1 name2 name3... clear global name clear -reg ...

  7. O2O迈进智能时代 百度构建“服务生态”

    经历过山车式资本市场后,O2O领域正努力摆脱“低门槛”,或将迎来技术创新之争.在刚刚落幕的百度世界大会上,百度副总裁.百度糯米总经理曾良宣布:将以百度糯米.手机百度和百度地图为核心构建百度服务生态.在 ...

  8. php工作笔记6-手机端适应缩放

    1.静态页面

  9. sql 递归子查询

    select (SELECT (Case A1.AreaAbbr WHEN '' THEN A1.AreaName Else A1.AreaAbbr  END)+ ' ' FROM AreaLang ...

  10. Maven打包跳过测试

    运行mvn install时跳过Test 方法一: <project> [...] <build> <plugins> <plugin> <gro ...