高层数据
<h1>高程数据导入</h1>
<h2>接口描述</h2>
<p>支持用户导入zip或.tif文件,gcs服务自行解析数据,进行高层数据切片Quantized Mesh(.terrain).导入成功后返回terrain url访问路径.</p>
<h2>请求示例</h2>
<pre><code class="language-json">{
&quot;tid&quot;: &quot;1234567890&quot;,
&quot;bid&quot;: &quot;9876543210&quot;,
&quot;method&quot;: &quot;importGem&quot;,
&quot;data&quot;: {
&quot;custom&quot;: {
&quot;gemFileName&quot;: &quot;高程&quot;,
&quot;fileType&quot;: &quot;zip&quot;,
&quot;totalSize&quot;:12312434,
&quot;option&quot;: 1,//开始上传,2上传完毕, 0取消上传.
}
}
}</code></pre>
<pre><code class="language-json">{
&quot;tid&quot;: &quot;saveGem&quot;,
&quot;bid&quot;: &quot;12123123123&quot;,
&quot;data&quot;: {
&quot;custom&quot;: {
&quot;currentSaveTotal&quot;:12312434,
&quot;totaltotalSize&quot;:121212124,
&quot;option&quot;: 1,//开始上传.
}
}
}</code></pre>
<h2>文件上传buf切片样例</h2>
<pre><code class="language-javaScript">function waitForBufferLow(ws, threshold = 16 * 1024 * 1024) {
return new Promise((resolve) =&gt; {
if (ws.bufferedAmount &lt; threshold) return resolve()
const check = () =&gt; {
if (ws.bufferedAmount &lt; threshold) {
resolve()
} else {
setTimeout(check, 10)
}
}
setTimeout(check, 10)
})
}
async function upload() {
if (!isConnected.value || !socket.value || socket.value.readyState !== WebSocket.OPEN) {
addLog(&#039;请先连接 WebSocket&#039;)
return
}
if (!selectedFile.value) {
addLog(&#039;请先选择文件&#039;)
return
}
if (isUploading.value) {
addLog(&#039;正在上传中,请稍候&#039;)
return
}
try {
isUploading.value = true
// 1) 发送 option=1 的 JSON
sendJsonOption(1)
// 2) 分片发送文件二进制
const file = selectedFile.value
const size = file.size
const step = chunkSize.value
let offset = 0
let index = 0
addLog(`开始分片上传,总大小 ${size} 字节,分片大小 ${step} 字节`)
while (offset &lt; size) {
const end = Math.min(offset + step, size)
const blob = file.slice(offset, end)
const buffer = await blob.arrayBuffer()
await waitForBufferLow(socket.value)
socket.value.send(buffer)
index += 1
addLog(`发送分片 #${index} [${offset}-${end}) (${end - offset} 字节)`)
offset = end
}
// 3) 发送 option=2 的 JSON
sendJsonOption(2)
addLog(&#039;文件发送完毕,已发送完成标记(option=2)&#039;)
} catch (err) {
addLog(`上传失败: ${err?.message || err}`)
} finally {
isUploading.value = false
}
}</code></pre>
<h2>返回示例</h2>
<p>当上传完毕,会针对上传文件进行处理,并返回当前进度.</p>
<pre><code class="language-json">{
&quot;tid&quot;: &quot;importGemProgress&quot;,
&quot;bid&quot;: &quot;9876543210&quot;,
&quot;code&quot;:0
&quot;data&quot;: {
&quot;progress&quot;:&quot;11&quot;,//0-100
&quot;path&quot;:&quot;&quot;,//导入成功后返回文件访问路径
&quot;msg&quot;:&quot;&quot;,//信息
&quot;status&quot;:1//0成功 1 进行中 2失败
}
}</code></pre>
<h1>高程数据获取</h1>
<p>获取gcs目前已经导入的,高层文件数据.</p>
<h2>请求示例</h2>
<pre><code class="language-json">{
&quot;tid&quot;: &quot;1234567890&quot;,
&quot;bid&quot;: &quot;9876543210&quot;,
&quot;method&quot;: &quot;getGem&quot;,
&quot;data&quot;: {}
}</code></pre>
<h2>返回示例</h2>
<pre><code class="language-json">{
&quot;tid&quot;: &quot;1234567890&quot;,
&quot;bid&quot;: &quot;9876543210&quot;,
&quot;method&quot;: &quot;getGem&quot;,
&quot;data&quot;: [
{
&quot;fileName&quot;: &quot;1&quot;,
&quot;uploadTime&quot;: 1254234534,
&quot;path&quot;: &quot;/data/gem/ddd&quot;
},
{
&quot;filename&quot;: &quot;2&quot;,
&quot;uploadTime&quot;: 1254234534,
&quot;path&quot;: &quot;/data/gem/ddd&quot;
},
]
}</code></pre>
<h1>高程文件删除</h1>
<p>删除高程文件</p>
<h2>请求示例</h2>
<pre><code class="language-json">{
&quot;tid&quot;: &quot;1234567890&quot;,
&quot;bid&quot;: &quot;9876543210&quot;,
&quot;method&quot;: &quot;deleteGem&quot;,
&quot;data&quot;: [&quot;fileName1&quot;,&quot;fileName2&quot;]
}</code></pre>
<h2>返回示例</h2>
<pre><code class="language-json">{
&quot;tid&quot;: &quot;1234567890&quot;,
&quot;bid&quot;: &quot;9876543210&quot;,
&quot;method&quot;: &quot;deleteGem&quot;,
&quot;data&quot;: {},
&quot;code&quot;:0
}</code></pre>
<h1>高层文件重命名</h1>
<h2>请求示例</h2>
<pre><code class="language-json">{
&quot;tid&quot;: &quot;1234567890&quot;,
&quot;bid&quot;: &quot;9876543210&quot;,
&quot;method&quot;: &quot;renameGem&quot;,
&quot;data&quot;:{
&quot;oldName&quot;:&quot;1212&quot;,
&quot;newName&quot;:&quot;&quot;
}
}</code></pre>
<h2>返回示例</h2>
<pre><code class="language-json">{
&quot;tid&quot;: &quot;1234567890&quot;,
&quot;bid&quot;: &quot;9876543210&quot;,
&quot;data&quot;:{
&quot;newPath&quot;:&quot;/data/dadats/sdta&quot;
}
&quot;code&quot;:0
}</code></pre>