使用CTB处理后的地形数据,在访问上与CesiumLab处理过的有所不同,前者对于一个.terrain图块,在处理时使用了CTBZFileOutputStream(压缩)输出,发布地形数据时需要在服务器参数中做相应的处理。
一、基于nginx部署。
location /myterrain {
proxy_set_header Host http_host;
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
alias E:/models/terrain/myterrain;
location ~* \.terrain {
add_header Content-Encoding gzip;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
}
}
1、add_header 'Access-Control-Allow-Origin' '*';与add_header 'Access-Control-Allow-Credentials' 'true';项。
上述两项是为了要该虚拟目录响应跨域服务请求。
2、 location ~* .terrain$项。
上述项中包含的三项, add_header Content-Encoding gzip;项是设置服务端能够发送压缩编码类型。后面两项仍然是响应跨域,看起来重复设置,但缺少了一项,访问地形数据将出现问题。