一、发布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. IplImage, CvMat, Mat 的关系和相互转换(转)

    (看到的一篇非常好的文章,讲opencv内部类之间的关系的.) opencv中常见的与图像操作有关的数据容器有Mat,cvMat和IplImage,这三种类型都可以代表和显示图像,但是,Mat类型侧重 ...

  2. 解决linux yum无法安装mysql

    yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1. 下载mysql的repo源 wget http://repo.mysql.com/mysql-com ...

  3. python 去掉列表(list)中的所有空元素

    while '' in listExample: listExample.remove('')

  4. android第二天(项目的组成结构)

    1:src文件夹分析: helloWorld----src(源码文件夹) MainActivity:主界面类----gen(自动生成的源码文件夹) R.java:对应res文件夹 下面又包含三个内部类 ...

  5. C++模板类继承的一个小技巧

    先说一下background前段时间想实现一个Sqlite localstorage的功能,对应不同的Model 实体有不同的table, 每一次sql操作的函数签名中会有model实体中的struc ...

  6. maven出现 -Dmaven.multiModuleProjectDirectory system propery错误

    1.使用myeclipse10整合maven插件时出现错误: -Dmaven.multiModuleProjectDirectory system propery is not set. Check ...

  7. SELinux查看、启用、关闭

    SELinux查看.启用.关闭 查看SELinux状态: 1./usr/sbin/sestatus -v      ##如果SELinux status参数为enabled即为开启状态 SELinux ...

  8. MapReduce 过程分析

    原文地址:http://blog.jobbole.com/81676/ 2.WordCount处理过程 上面给出了WordCount的设计思路和源码,但是没有深入细节,下面对WordCount进行更加 ...

  9. android SurfaceView中播放视频 按视频的原始比例播放

    OnPreparedListener mediaPlayerOnPreparedListener = new OnPreparedListener() { @Override public void ...

  10. Android Studio tips2

    Android不推荐把字符串进行硬编码,一般的做法是把字符串定义在laylout里,并在xml文件里对键值进行引用 例如<第一行代码>中 Hello word程序中"Hello ...