当前位置:网站首页>Cesium:cesiumlab makes image slices and loads slices
Cesium:cesiumlab makes image slices and loads slices
2022-06-13 04:40:00 【I don't seem to know you】
Main idea : utilize Cesium Can be based on tiff Image data and coordinate reference information to make image slices , And make use of Cesium Provided UrlTemplateImageryProvider Interface loaded into 3D scene .
TIF Image data preparation
CesiumLab The following formats of image data are supported , The following TIF Format image as an example .
TIF The image data preview is shown below ( If necessary, you can leave a message at the end of the text , Can help download ),16 Level image , A resolution of 4m, The coordinate system is WGS84 Longitude and latitude projection coordinate system , The format is *.tif Format . The background can be selected as transparent color when downloading , Otherwise, you need to process the white background after downloading .
The image data download directory is as follows ,
CesiumLab Making image tiles
Parameter setting
utilize CesiumLab Making image tiles , Need to provide image data + Coordinate reference file (prj File format is enough , The downloaded folder already contains ).
start-up CesiumLab After service , Select image slice , And select image data , Set coordinate reference information , Then select the output type as hash file , And set the output folder path .
meanwhile , Before slicing , You can set the transparent color rgb value , To avoid tif The image data has its own white edge / The black edge problem ( The premise is to clearly know that there is no data area rgb Pixel values , I deal with white edges here , adopt PS Pipette tool to get the white edge part rgb The value is 255,255,255), So you don't have to go through PS Or other software has handled it additionally .




Image slice
The image slicing folder after production is as follows ,layer.json and meta.json The file records the folder structure information of image slices , There is no need to care about the details .
The following is slice data , You can see clearly on the desktop , The white edge problem of raw data has been CesiumLab The software has handled it , The background color is transparent .
Compare the untreated , The background color still exists .
Publish image slices
Release of image slice data , In fact, it is the release of static resource data , Can pass Tomcat、Nginx、IIS And so on . The following Tomcat Server publishing as an example ,
Slice the cut image into a folder , Entire copy to Tomcat Of webapps Under the table of contents , Or through conf Under the server.xml Realize service publishing by file configuration . Copy it here directly to Tomcat Under the same level directory , be based on conf/catalina/localhost The configuration file is created separately under the directory . The profile information is as follows ,
<Context docBase="F:\Java-dependencies\apache-tomcat-9.0.43\zaozhuang"
path="/zaozhuang" reloadable="true"/>

Load image slice
Load image slice , adopt Cesium Provided UrlTemplateImageryProvider Interface , You can load image slices into a 3D scene , The sample code and loading effect are as follows , Attach the contrast effect of untreated white edge and treated white edge ,
Besides , In the sample code rectangle Four to parameter information corresponding to the parameter , It can be downloaded from txt Directly from the file ,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>14-Billboard Compression fuzzy problem </title>
<!-- introduce cesium Development resources -->
<script src="../../Build/Cesium/Cesium.js"></script>
<!-- introduce cesium Style resources -->
<style> @import url("../../Build/Cesium/Widgets/widgets.css"); html,body, #viewerContainer{
width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden; } </style>
</head>
<body>
<div id="viewerContainer"></div>
</body>
<script src="./utils/initCesiumViewer.js"></script>
<script> function loadGeoJson(_viewer){
// load geojson const promise = Cesium.GeoJsonDataSource.load("./data/zaozhuang.json", {
}); promise.then(function (dataSource) {
_viewer.dataSources.add(dataSource); _viewer.zoomTo(dataSource); let entities = dataSource.entities.values; entities.some(function (value, index, arrat) {
value.polygon.fill = false; value.polygon.outline = true; value.polygon.outlineColor = Cesium.Color.SKYBLUE; }) }) } function loadCesiumLabImageTiles(_viewer){
let labImageTiles = new Cesium.UrlTemplateImageryProvider({
url: 'http://localhost:8010/zaozhuang/zz_tiles/{z}/{x}/{y}.png', rectangle:Cesium.Rectangle.fromDegrees( 116.805696177188 , 34.462626856461, 117.826845335666, 35.320719164506), }) // add to CesiumLab Sliced tiles _viewer.imageryLayers.addImageryProvider(labImageTiles) } function loadCesiumLabTransImageTiles(_viewer){
let labImageTiles = new Cesium.UrlTemplateImageryProvider({
url: 'http://localhost:8010/zaozhuang/zzt_tiles/{z}/{x}/{y}.png', rectangle:Cesium.Rectangle.fromDegrees( 116.805696177188 , 34.462626856461, 117.826845335666, 35.320719164506), }) // add to CesiumLab Sliced tiles _viewer.imageryLayers.addImageryProvider(labImageTiles) } // Initialize 3D scene const viewer = initCesiumViewer("viewerContainer",{
_hideGlobe:true, _defineBgImage:false, }); viewer.imageryLayers.removeAll(true); // load geojson Boundary data loadGeoJson(viewer); // load CesiumLab Made image slices // loadCesiumLabImageTiles(viewer);// Image slices with unprocessed white edges loadCesiumLabTransImageTiles(viewer);// Processed image slices with white edges </script>
</html>


边栏推荐
- 记录一次排查问题的经过——视频通话无法接起
- Basic syntax example for go
- SQL notes
- Mysql database installation
- Catalan number
- Serial communication learning
- php 18 首页的文章列表功能实现
- Get parameters on link
- Notes on software test for programmers -- basic knowledge of software development, operation and maintenance
- PHP development 16 exit module
猜你喜欢

Express framework knowledge - Art template template, cookie, session

Collection of wrong questions in soft test -- morning questions in the first half of 2011

C盘无损移动文件

Tree array explanation

Applet - uniapp realizes the functions of two-dimensional code picture pop-up and picture saving

【Flutter 问题系列第 67 篇】在 Flutter 中使用 Get 插件在 Dialog 弹窗中不能二次跳转路由问题的解决方案

利用Javeswingjdbc基於mvc設計系統

ACM ICPC

Li Kou brush question 338 Bit count

【Try to Hack】upload-labs通关(暂时写到12关)
随机推荐
JS, how to add grid style
PHP development 16 exit module
Colab使用教程(超级详细版)及Colab Pro/Pro+评测
ES6 learning
php 18 首页的文章列表功能实现
2022道路运输企业安全生产管理人员操作证考试题库及答案
PHP security development 15 user password modification module
正态分布(高斯分布)
利用Javeswingjdbc基於mvc設計系統
[chapter 67 of the flutter problem series] the solution to the problem that the get plug-in cannot jump to the route twice in the dialog pop-up window in flutter
Crawler scrapy framework learning 2
如何只用4步,实现一个自定义JDBC驱动?
Latex operation
Redis master-slave replication, sentinel mode, cluster
MySQL索引
Clear timer failure
Get parameters on link
Implementation of homepage header function in PHP development blog system
Common terms of electromagnetic compatibility
Suffix Automaton