cesium+ geoserverTerrainProvide+png展示3D高程图展示
一、发布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高程图展示的更多相关文章
- iOS 超大高清图展示策略 TileLayer 及 levelsOfDetailBias 分析
本次分析针对当下流行的中国地图图片处理,1亿像素,就是下面这张: 原图尺寸:11935x8554 文件大小:22.1MB 原始加载方式 首先,我们尝试一下直接加载的方式,看看效果会有多恐怖 效果请看下 ...
- WebGL展示3D房屋内景
原文地址:WebGL展示3D房屋内景 由于生活和工作上的原因,从年前开始一直到处奔波,没有太多的时间去关注和学习WebGL图形学相关的技术, 不过陆陆续续都有学习使用blender进行3D建模 ...
- XAML中用一字符即可展示漂亮的图型
XAML中用一字符即可展示漂亮的图型 例如:Symbol Icon: People http://www.geekchamp.com/icon-explorer/action-icons/icon?c ...
- 基于Echarts的股票K线图展示
发布时间:2018-10-31 技术:javascript+html5+canvas 概述 基于echarts的股票K线图展示,只需引用单个插件,通过简单配置,导入数据,即可实现炫酷复杂的K线 ...
- [py]flask动态展示主机内存图
echarts基础 需要借助这个图来绘制,动态内存图. 绘制步骤 写py脚本来入库日志 选取合适的echart,并观察图所需的数据格式 用flask返回这个静态的echarts 用flask写接口返回 ...
- flask+layui+echarts实现前端动态图展示数据
效果图: 该效果主要实现一个table展示数据,并在下方生成一个折线图. 实现方式: 1.首先需要对表格进行一个数据加载,这里用到了layui的table.render,具体用法可以参考 https: ...
- 【】(Git)用动图展示10大Git命令
1.说明 git merge.git rebase.git reset.git revert.git fetch.git pull.git reflog-- 你知道这些 git 命令执行的究竟是什么任 ...
- HTML 5 +CSS3 + 原生js 做(雪花全屏飘落 + 3d旋转图)
原文:HTML 5 +CSS3 + 原生js 做(雪花全屏飘落 + 3d旋转图) 3d旋转图:主要用css3中transform属性中的rotate,translate;以及用来做舞台效果的 pers ...
- Cesium原理篇:3D Tiles(1)渲染调度
Cesium在2016年3月份左右推出3D Tiles数据规范,在glTF基础上提供了LOD能力,定位就是Web环境下海量三维模型数据.虽然目前3D Tiles还是Beta阶段,有不少硬伤,但3D T ...
随机推荐
- xml ---DOM操作
package day03.xml; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; ...
- HTTP权威协议笔记-7.缓存
7.1 冗余的数据传输 缓存的作用:当客户端每次访问服务器,服务器都会返回一份相同文件,一些相同的字节会不断的在网络内传输,这样冗余的数据传输会耗尽昂贵的带宽,降低传输速度,加重Web服务器的负载. ...
- Android之TextView灵活使用(转载)
在项目中有无遇到过这样一种程况,例如文字"王明今年10岁了", 但是数字10是从网络返回的数据, 而你又想把这个文字写在xml中, 过往我的做法是分成3个TextView, 实现愚 ...
- win10 重装应用商店
管理员模式打开powershell 命令窗口,输入以下重装应用商店的命令.亲测有效,我刚安装回来了. Get-AppXPackage *WindowsStore* -AllUsers | Foreac ...
- WebKit的CSS扩展(WebKit是私有属性)
http://www.css88.com/webkit/-webkit-touch-callout/ -webkit-tap-highlight-color 是一个 不规范的属性(unsupporte ...
- golang中string以及slice之间的一些问题
好记性不如烂笔头o_O slice切片不会开辟新的空间 a := []int{0,1,2,3} b := make([]int, 8) b = a[:] b[2] = 9 fmt.Println(a) ...
- loadrunner --global schedule设置
- jquery api
1. clone()可以复制一个节点 2. .prop()方法为元素赋属性值非常方便. $("input").prop("disabled", false); ...
- 关于GC的几篇文章
http://msdn.microsoft.com/zh-cn/magazine/bb985010(en-us).aspx http://msdn.microsoft.com/zh-cn/magazi ...
- DirectX12 Samples 学习笔记 – PredicationQueries
一.效果 这是一个比较简单的sample,运行sample可以看到,当红橙色长方形完全覆盖白色正方形时,白色正方形不显示,其他情况,均显示白色正方形. 二.实现 Render主要由三个部分组成 1.F ...