初始化Json数据转换对象
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
json:可以是json对象也可以是json的网络地址或者是Cesium.Resource对象
|
Members
数据是否准备完成
Methods
static GisEye.JsonConverter.getPositions(json, usePerPositionHeight, height) → Cesium.PolygonHierarchy|Array.<Cesium.PolygonHierarchy>|Array.<Cesium.Cartesian3>|Array.<Array.<Cartesian3>>|Cartesian3
获取单个要素的geometry,点线面分别转为对应的cesium支持的格式
Name | Type | Default | Description |
---|---|---|---|
json |
object |
需要获取坐标点的json数据,可以是geojson或者是esrijson的数据格式,针对单个要素的数据处理 |
|
usePerPositionHeight |
bool |
false
|
optional
是否采用每个点的高度值,这种适用于三维的点的geojson数据 |
height |
Array | Number | undefined |
传入的高度值可以是一个固定的值或者是一串高度值, 如果传入的高度值长度不够采用最后一个高度补全,对于多线多面可能会出现 每一串点的高度会重复使用的问题 |
Returns:
返回点线面的数据结构
返回通过primitive方式加载的collection
Name | Type | Description |
---|---|---|
style |
function | undefined |
样式回调 |
scene |
Cesium.Scene |
数据过滤回调 |
filter |
function | undefined |
数据过滤回调 |
Returns:
Example:
var converter=new GisEye.JsonConverter({json:'./statics/SampleData/lineData/streamline.json'})
let primitives=converter.getCollection(function(fe){
return {
height:10,
polyline:{
material:Cesium.Material.fromType(Cesium.Material.ColorType,{
color:Cesium.Color.fromRandom()
})
},
label:{
text:fe.properties.ARCID+""
}
}
})
primitives.then(p=>{
viewer.scene.primitives.add(p)
})
获取数据源
Name | Type | Description |
---|---|---|
name |
string |
数据源名称可缺省,默认为guid的字符串 |
filter |
function | undefined |
返回值为bool值的筛选函数 入参为geojson格式的要素对象 |
style |
Object | function |
样式对象或者方法,入参为geojson格式的要素对象 |
Returns:
返回自定义数据源或者undefined
Example:
var converter=new GisEye.JsonConverter({json:'./data.json'})
var source=converter.getDataSource("mySource",function(feature){
return feature.properties.type&&feature.properties.type==="3"
},function(feature){
return {
usePerPositionHeight:false,//是否强制采用每个点的高度
height:10,//设置固定高度,优先判断是否采用每个点的高度值
polyline:{
material:Cesium.Color.RED,
width:3
}
}
})
viewer.dataSources.add(source) //完成加载
根据筛选条件获取要素
Name | Type | Description |
---|---|---|
filter |
function |
对数据过滤的方法,返回值应为布尔值,如果不设置返回所有的要素 |
Returns:
返回过滤后的geojson格式的要素对象数组