一、发布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. JS中offsetTop、clientTop、scrollTop、offsetTop各属性介绍

    这里是javascript中制作滚动代码的常用属性 页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;网页可见 ...

  2. DapperExtensions的基本用法

    介绍下使用Dapper-Extensions的基本语法 //实体类 DemoEntity entity = new DemoEntity(); //根据实体主键删除 this.Delete<De ...

  3. phpwind ecshop 用户整合

    phpwind ecshop 用户整合,其实很简单.但在网上搜到的尽是乱七八遭的方法,搞得很复杂. 原来公司做的phpwind 与 ecshop 结合的项目,别的同事已经把用户整合好了,当时我还不知道 ...

  4. vmware workstation 上创建的centos 7.2 ,新添加一块网卡。无法找到配置文件。

    在vmware workstation 11上,新建一个centos 7.2系统. 初装带有一个块网卡:能够在/etc/sysconfig/network-scripts/目录下找到相应的网卡配置文件 ...

  5. IDEA springMVC - hello world

    记录所学,防忘记... ide用IDEA,用maven管理依赖包 1.建立一个maven-webapp项目:File->New->Project 2.pom.xml <project ...

  6. Maven打包跳过测试

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

  7. Python 3.6.0的sqlite3模块无法执行VACUUM语句

    Python 3.6.0的sqlite3模块存在一个bug(见issue 29003),无法执行VACUUM语句. 一执行就出现异常: Traceback (most recent call last ...

  8. RequireJS基础(二)

    上一篇是把整个jQuery库作为一个模块.这篇来写一个自己的模块:选择器. 为演示方便这里仅实现常用的三种选择器id,className,attribute. RequireJS使用define来定义 ...

  9. 修改C# 新建类模板

    找到安装路径下的这个文件夹:D:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplatesCache\CSh ...

  10. VC++ 中CDC与HDC的区别以及二者之间的转换

    MFC类的前缀都是C开头的  H开头的大多数是句柄  这是为了助记,是编程读\写代码的好的习惯.  CDC中所有MFC的DC的基类.常用的CClientDC dc(this);就是CDC的子类(或称派 ...