Compare commits
9 Commits
e38dd4d029
...
b7e0249757
Author | SHA1 | Date | |
---|---|---|---|
b7e0249757 | |||
67540c1808 | |||
a888969c5d | |||
6bd3778ad9 | |||
0007343353 | |||
e6da82c76c | |||
d8962ff3cc | |||
7958e40494 | |||
00f1a40e2a |
@ -517,7 +517,7 @@ async function setSplitDirection(v, id, isoff = false, entityId) {
|
|||||||
thatD.textShow = thatP.textShow
|
thatD.textShow = thatP.textShow
|
||||||
}
|
}
|
||||||
if (thatP.label && thatP.labelShow) {
|
if (thatP.label && thatP.labelShow) {
|
||||||
thatP.label.entity.show = true
|
thatP.labelShow = true
|
||||||
}
|
}
|
||||||
if (thatD.label) {
|
if (thatD.label) {
|
||||||
thatD.label.options.ground = false
|
thatD.label.options.ground = false
|
||||||
|
@ -56,7 +56,7 @@ function html(that) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<span class="label">固定大小</span>
|
<span class="label" style="flex: 0 0 60px;">固定大小</span>
|
||||||
<input class="btn-switch" type="checkbox" @model="scaleByDistance">
|
<input class="btn-switch" type="checkbox" @model="scaleByDistance">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,22 +9,15 @@ function html(that) {
|
|||||||
<span class="label">名称</span>
|
<span class="label">名称</span>
|
||||||
<input class="input" maxlength="40" type="text" @model="name">
|
<input class="input" maxlength="40" type="text" @model="name">
|
||||||
</div>
|
</div>
|
||||||
<div class="col" style="flex: 0 0 54%;">
|
<div class="col" style="flex: 0 0 56%;">
|
||||||
<div>
|
<div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col input-select-unit-box">
|
<div class="col input-select-unit-box">
|
||||||
<span class="label">原始长度:</span>
|
<div class="input-select-unit"></div>
|
||||||
<input class="input input-text" readonly="readonly" type="text" style="flex: 0 0 130px;" @model="length">
|
<input class="input input-text" readonly="readonly" type="text" style="flex: 0 0 130px;" @model="length">
|
||||||
<div class="input-select-unit"></div>
|
<div class="input-select-unit"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="col input-select-fit-unit-box">
|
|
||||||
<span class="label">拟合长度:</span>
|
|
||||||
<input class="input input-text" readonly="readonly" type="text" style="flex: 0 0 130px;" @model="fitLength">
|
|
||||||
<div class="input-select-fit-unit"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -58,6 +58,7 @@ class CurvelineObject extends Base {
|
|||||||
this.options.extend = options.extend || false
|
this.options.extend = options.extend || false
|
||||||
this.options['length-unit'] = options['length-unit'] || '米'
|
this.options['length-unit'] = options['length-unit'] || '米'
|
||||||
this.options['fit-length-unit'] = options['fit-length-unit'] || '米'
|
this.options['fit-length-unit'] = options['fit-length-unit'] || '米'
|
||||||
|
this.options['words-name'] = options['words-name'] || '空间长度'
|
||||||
this.options['extend-width'] =
|
this.options['extend-width'] =
|
||||||
options['extend-width'] || options['extend-width'] === 0
|
options['extend-width'] || options['extend-width'] === 0
|
||||||
? options['extend-width']
|
? options['extend-width']
|
||||||
@ -116,6 +117,7 @@ class CurvelineObject extends Base {
|
|||||||
this.options.attributeType = options.attributeType || 'richText'
|
this.options.attributeType = options.attributeType || 'richText'
|
||||||
this.operate = {}
|
this.operate = {}
|
||||||
this.nodePoints = []
|
this.nodePoints = []
|
||||||
|
this.unitNum = 0
|
||||||
this.Dialog = _Dialog
|
this.Dialog = _Dialog
|
||||||
if (!this.options.positions || this.options.positions.length < 2) {
|
if (!this.options.positions || this.options.positions.length < 2) {
|
||||||
this._error = '线段最少需要两个坐标!'
|
this._error = '线段最少需要两个坐标!'
|
||||||
@ -172,6 +174,8 @@ class CurvelineObject extends Base {
|
|||||||
|
|
||||||
set length(v) {
|
set length(v) {
|
||||||
this.options.length = v
|
this.options.length = v
|
||||||
|
//判断数值是否大于1000m
|
||||||
|
|
||||||
this._elms.length &&
|
this._elms.length &&
|
||||||
this._elms.length.forEach(item => {
|
this._elms.length.forEach(item => {
|
||||||
item.value = v
|
item.value = v
|
||||||
@ -194,22 +198,57 @@ class CurvelineObject extends Base {
|
|||||||
return this.options['length-unit']
|
return this.options['length-unit']
|
||||||
}
|
}
|
||||||
set lengthUnit(v) {
|
set lengthUnit(v) {
|
||||||
|
this.unitNum++
|
||||||
this.options['length-unit'] = v
|
this.options['length-unit'] = v
|
||||||
this._elms.lengthUnit &&
|
this._elms.lengthUnit &&
|
||||||
this._elms.lengthUnit.forEach(item => {
|
this._elms.lengthUnit.forEach(item => {
|
||||||
item.value = v
|
item.value = v
|
||||||
})
|
})
|
||||||
if (this.options.lengthByMeter) {
|
if (this.options.lengthByMeter) {
|
||||||
|
if (this.unitNum > 2) {
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case '米':
|
case '米':
|
||||||
this.length = this.options.lengthByMeter
|
this.length = this.noseToTail ? this.options.fitLengthByMeter : this.options.lengthByMeter
|
||||||
|
|
||||||
break
|
break
|
||||||
case '千米':
|
case '千米':
|
||||||
this.length = (this.options.lengthByMeter / 1000).toFixed(5)
|
this.length = this.noseToTail ? (this.options.fitLengthByMeter / 1000).toFixed(5) : (this.options.lengthByMeter / 1000).toFixed(5)
|
||||||
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
this.length = this.options.lengthByMeter
|
this.length = this.noseToTail ? this.options.fitLengthByMeter : this.options.lengthByMeter
|
||||||
|
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
let length = this.noseToTail ? this.options.fitLengthByMeter : this.options.lengthByMeter
|
||||||
|
this.lengthUnit = length > 1000 || length == 1000 ? '千米' : '米'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get wordsName() {
|
||||||
|
return this.options['words-name']
|
||||||
|
}
|
||||||
|
set wordsName(v) {
|
||||||
|
this.options['words-name'] = v
|
||||||
|
this._elms.wordsName &&
|
||||||
|
this._elms.wordsName.forEach(item => {
|
||||||
|
item.value = v
|
||||||
|
})
|
||||||
|
|
||||||
|
let _this = this
|
||||||
|
if (!this.noseToTail) {
|
||||||
|
this.computeDistance(
|
||||||
|
this.smoothHandle(this.options.positions),
|
||||||
|
2,
|
||||||
|
v
|
||||||
|
).then(res => {
|
||||||
|
_this.options.lengthByMeter = res
|
||||||
|
_this.lengthUnit = this.options['length-unit']
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
let fromDegreesArray = this.renewPositions(this.options.positions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,8 +349,28 @@ class CurvelineObject extends Base {
|
|||||||
)
|
)
|
||||||
this.renewPolygon(fromDegreesArray)
|
this.renewPolygon(fromDegreesArray)
|
||||||
}
|
}
|
||||||
|
this.lengthUnit = this.options['length-unit']
|
||||||
|
// if (v) {
|
||||||
|
// if (this.options.fitLengthByMeter > 1000 || this.options.fitLengthByMeter == 1000) {
|
||||||
|
// let dom = document.getElementsByClassName('input-select-unit')[1]
|
||||||
|
// dom && dom.querySelectorAll('dd')[1] && dom.querySelectorAll('dd')[1].click()
|
||||||
|
// } else {
|
||||||
|
// let dom = document.getElementsByClassName('input-select-unit')[1]
|
||||||
|
// dom && dom.querySelectorAll('dd')[0] && dom.querySelectorAll('dd')[0].click()
|
||||||
|
// }
|
||||||
|
|
||||||
|
// } else {
|
||||||
|
// if (this.options.lengthByMeter > 1000 || this.options.lengthByMeter == 1000) {
|
||||||
|
// let dom = document.getElementsByClassName('input-select-unit')[1]
|
||||||
|
// dom && dom.querySelectorAll('dd')[1] && dom.querySelectorAll('dd')[1].click()
|
||||||
|
// } else {
|
||||||
|
// let dom = document.getElementsByClassName('input-select-unit')[1]
|
||||||
|
// dom && dom.querySelectorAll('dd')[0] && dom.querySelectorAll('dd')[0].click()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
get heightMode() {
|
get heightMode() {
|
||||||
return this.options.heightMode ? this.options.heightMode : 0
|
return this.options.heightMode ? this.options.heightMode : 0
|
||||||
}
|
}
|
||||||
@ -349,11 +408,11 @@ class CurvelineObject extends Base {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
this.options.lengthByMeter = this.computeDistance2(
|
// this.options.lengthByMeter = this.computeDistance2(
|
||||||
this.smoothHandle(this.options.positions),
|
// this.smoothHandle(this.options.positions),
|
||||||
2,
|
// 2,
|
||||||
ground
|
// ground
|
||||||
)
|
// )
|
||||||
this.lengthUnit = this.lengthUnit
|
this.lengthUnit = this.lengthUnit
|
||||||
this._elms.heightMode && (this._elms.heightMode.value = heightModeName)
|
this._elms.heightMode && (this._elms.heightMode.value = heightModeName)
|
||||||
this._elms.heightModeObject && (this._elms.heightModeObject.legp_searchActive(
|
this._elms.heightModeObject && (this._elms.heightModeObject.legp_searchActive(
|
||||||
@ -1157,12 +1216,25 @@ class CurvelineObject extends Base {
|
|||||||
CurvelineObject.createLabel(that)
|
CurvelineObject.createLabel(that)
|
||||||
// that.entity.polyline.positionsLngLat = positions
|
// that.entity.polyline.positionsLngLat = positions
|
||||||
that.renewPolygon(fromDegreesArray)
|
that.renewPolygon(fromDegreesArray)
|
||||||
that.options.lengthByMeter = that.computeDistance2(that.smoothHandle(positions), 2, ground)
|
// that.options.lengthByMeter = that.computeDistance2(that.smoothHandle(positions), 2, ground)
|
||||||
|
// that.lengthUnit = that.options['length-unit']
|
||||||
|
// syncData(that.sdk, that.options.id)
|
||||||
|
// if (that.options.show) {
|
||||||
|
// setSplitDirection(0, that.options.id)
|
||||||
|
// }
|
||||||
|
|
||||||
|
that.computeDistance(
|
||||||
|
that.smoothHandle(positions),
|
||||||
|
2,
|
||||||
|
that.options['words-name']
|
||||||
|
).then(res => {
|
||||||
|
that.options.lengthByMeter = res
|
||||||
that.lengthUnit = that.options['length-unit']
|
that.lengthUnit = that.options['length-unit']
|
||||||
syncData(that.sdk, that.options.id)
|
syncData(that.sdk, that.options.id)
|
||||||
if (that.options.show) {
|
if (that.options.show) {
|
||||||
setSplitDirection(0, that.options.id)
|
setSplitDirection(0, that.options.id)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// if (this.options['nose-to-tail']) {
|
// if (this.options['nose-to-tail']) {
|
||||||
// let array = []
|
// let array = []
|
||||||
@ -1389,6 +1461,50 @@ class CurvelineObject extends Base {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let nameData = [
|
||||||
|
{
|
||||||
|
name: '空间长度',
|
||||||
|
value: '空间长度'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '投影长度',
|
||||||
|
value: '投影长度'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '地表长度',
|
||||||
|
value: '地表长度'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
let nameDataLegpObject = legp(
|
||||||
|
this._DialogObject._element.content.getElementsByClassName(
|
||||||
|
'input-select-unit-box'
|
||||||
|
)[0],
|
||||||
|
'.input-select-unit'
|
||||||
|
)
|
||||||
|
if (nameDataLegpObject) {
|
||||||
|
nameDataLegpObject.legp_search(nameData)
|
||||||
|
let nameDataLegpElm = this._DialogObject._element.content
|
||||||
|
.getElementsByClassName('input-select-unit')[0]
|
||||||
|
.getElementsByTagName('input')[0]
|
||||||
|
this._elms.wordsName = [nameDataLegpElm]
|
||||||
|
nameDataLegpElm.value = this.options['words-name']
|
||||||
|
for (let i = 0; i < nameData.length; i++) {
|
||||||
|
if (nameData[i].value === nameDataLegpElm.value) {
|
||||||
|
nameDataLegpObject.legp_searchActive(nameData[i].value)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nameDataLegpElm.addEventListener('input', () => {
|
||||||
|
for (let i = 0; i < nameData.length; i++) {
|
||||||
|
if (nameData[i].value === nameDataLegpElm.value) {
|
||||||
|
this.wordsName = nameData[i].value
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 原始长度单位
|
// 原始长度单位
|
||||||
let unitData = [
|
let unitData = [
|
||||||
{
|
{
|
||||||
@ -1405,12 +1521,13 @@ class CurvelineObject extends Base {
|
|||||||
this._DialogObject._element.content.getElementsByClassName(
|
this._DialogObject._element.content.getElementsByClassName(
|
||||||
'input-select-unit-box'
|
'input-select-unit-box'
|
||||||
)[0],
|
)[0],
|
||||||
'.input-select-unit'
|
'.input-select-unit',
|
||||||
|
1
|
||||||
)
|
)
|
||||||
if (unitDataLegpObject) {
|
if (unitDataLegpObject) {
|
||||||
unitDataLegpObject.legp_search(unitData)
|
unitDataLegpObject.legp_search(unitData)
|
||||||
let unitDataLegpElm = this._DialogObject._element.content
|
let unitDataLegpElm = this._DialogObject._element.content
|
||||||
.getElementsByClassName('input-select-unit')[0]
|
.getElementsByClassName('input-select-unit')[1]
|
||||||
.getElementsByTagName('input')[0]
|
.getElementsByTagName('input')[0]
|
||||||
this._elms.lengthUnit = [unitDataLegpElm]
|
this._elms.lengthUnit = [unitDataLegpElm]
|
||||||
unitDataLegpElm.value = this.options['length-unit']
|
unitDataLegpElm.value = this.options['length-unit']
|
||||||
@ -1431,45 +1548,45 @@ class CurvelineObject extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 拟合长度单位
|
// 拟合长度单位
|
||||||
let fitUnitData = [
|
// let fitUnitData = [
|
||||||
{
|
// {
|
||||||
name: '米',
|
// name: '米',
|
||||||
value: '米'
|
// value: '米'
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
name: '千米',
|
// name: '千米',
|
||||||
value: '千米'
|
// value: '千米'
|
||||||
}
|
// }
|
||||||
]
|
// ]
|
||||||
|
|
||||||
let fitUnitDataLegpObject = legp(
|
// let fitUnitDataLegpObject = legp(
|
||||||
this._DialogObject._element.content.getElementsByClassName(
|
// this._DialogObject._element.content.getElementsByClassName(
|
||||||
'input-select-fit-unit-box'
|
// 'input-select-fit-unit-box'
|
||||||
)[0],
|
// )[0],
|
||||||
'.input-select-fit-unit'
|
// '.input-select-fit-unit'
|
||||||
)
|
// )
|
||||||
if (fitUnitDataLegpObject) {
|
// if (fitUnitDataLegpObject) {
|
||||||
fitUnitDataLegpObject.legp_search(fitUnitData)
|
// fitUnitDataLegpObject.legp_search(fitUnitData)
|
||||||
let fitUnitDataLegpElm = this._DialogObject._element.content
|
// let fitUnitDataLegpElm = this._DialogObject._element.content
|
||||||
.getElementsByClassName('input-select-fit-unit')[0]
|
// .getElementsByClassName('input-select-fit-unit')[0]
|
||||||
.getElementsByTagName('input')[0]
|
// .getElementsByTagName('input')[0]
|
||||||
this._elms.fitLengthUnit = [fitUnitDataLegpElm]
|
// this._elms.fitLengthUnit = [fitUnitDataLegpElm]
|
||||||
fitUnitDataLegpElm.value = this.options['fit-length-unit']
|
// fitUnitDataLegpElm.value = this.options['fit-length-unit']
|
||||||
for (let i = 0; i < fitUnitData.length; i++) {
|
// for (let i = 0; i < fitUnitData.length; i++) {
|
||||||
if (fitUnitData[i].value === fitUnitDataLegpElm.value) {
|
// if (fitUnitData[i].value === fitUnitDataLegpElm.value) {
|
||||||
fitUnitDataLegpObject.legp_searchActive(fitUnitData[i].value)
|
// fitUnitDataLegpObject.legp_searchActive(fitUnitData[i].value)
|
||||||
break
|
// break
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
fitUnitDataLegpElm.addEventListener('input', () => {
|
// fitUnitDataLegpElm.addEventListener('input', () => {
|
||||||
for (let i = 0; i < fitUnitData.length; i++) {
|
// for (let i = 0; i < fitUnitData.length; i++) {
|
||||||
if (fitUnitData[i].value === fitUnitDataLegpElm.value) {
|
// if (fitUnitData[i].value === fitUnitDataLegpElm.value) {
|
||||||
this.fitLengthUnit = fitUnitData[i].value
|
// this.fitLengthUnit = fitUnitData[i].value
|
||||||
break
|
// break
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
|
|
||||||
let lineTypeData = [
|
let lineTypeData = [
|
||||||
{
|
{
|
||||||
@ -1848,6 +1965,29 @@ class CurvelineObject extends Base {
|
|||||||
|
|
||||||
|
|
||||||
// 计算长度
|
// 计算长度
|
||||||
|
// let array = []
|
||||||
|
// for (let i = 0; i < fromDegreesArray.length; i += 3) {
|
||||||
|
// array.push({
|
||||||
|
// lng: fromDegreesArray[i],
|
||||||
|
// lat: fromDegreesArray[i + 1],
|
||||||
|
// alt: fromDegreesArray[i + 2]
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// this.options.fitLengthByMeter = this.computeDistance2(
|
||||||
|
// array,
|
||||||
|
// 2,
|
||||||
|
// ground
|
||||||
|
// )
|
||||||
|
// this.fitLengthUnit = this.options['fit-length-unit']
|
||||||
|
// this.options.lengthByMeter = this.computeDistance2(this.smoothHandle(positions), 2, ground)
|
||||||
|
// this.lengthUnit = this.options['length-unit']
|
||||||
|
|
||||||
|
|
||||||
|
if (
|
||||||
|
(this.options['nose-to-tail'] &&
|
||||||
|
this.options['nose-to-tail'] !== 'false') ||
|
||||||
|
(this.options.smooth && this.options.smooth !== 'false')
|
||||||
|
) {
|
||||||
let array = []
|
let array = []
|
||||||
for (let i = 0; i < fromDegreesArray.length; i += 3) {
|
for (let i = 0; i < fromDegreesArray.length; i += 3) {
|
||||||
array.push({
|
array.push({
|
||||||
@ -1856,14 +1996,43 @@ class CurvelineObject extends Base {
|
|||||||
alt: fromDegreesArray[i + 2]
|
alt: fromDegreesArray[i + 2]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.options.fitLengthByMeter = this.computeDistance2(
|
// this.options.fitLengthByMeter = this.computeDistance(
|
||||||
|
// array,
|
||||||
|
// 2,
|
||||||
|
// ground
|
||||||
|
// )
|
||||||
|
let _this = this
|
||||||
|
this.computeDistance(
|
||||||
array,
|
array,
|
||||||
2,
|
2,
|
||||||
ground
|
this.options['words-name']
|
||||||
)
|
).then(res => {
|
||||||
this.fitLengthUnit = this.options['fit-length-unit']
|
_this.options.fitLengthByMeter = res
|
||||||
this.options.lengthByMeter = this.computeDistance2(this.smoothHandle(positions), 2, ground)
|
_this.lengthUnit = _this.options['length-unit']
|
||||||
this.lengthUnit = this.options['length-unit']
|
})
|
||||||
|
} else {
|
||||||
|
let _this = this
|
||||||
|
this.computeDistance(
|
||||||
|
_this.smoothHandle(positions),
|
||||||
|
2,
|
||||||
|
this.options['words-name']
|
||||||
|
).then(res => {
|
||||||
|
_this.options.fitLengthByMeter = res
|
||||||
|
_this.lengthUnit = _this.options['length-unit']
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
let _this = this
|
||||||
|
this.computeDistance(
|
||||||
|
this.smoothHandle(positions),
|
||||||
|
2,
|
||||||
|
this.options['words-name']
|
||||||
|
).then(res => {
|
||||||
|
_this.options.lengthByMeter = res
|
||||||
|
_this.lengthUnit = this.options['length-unit']
|
||||||
|
})
|
||||||
|
|
||||||
return fromDegreesArray
|
return fromDegreesArray
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ function html() {
|
|||||||
<input class="input" maxlength="40" type="text" @model="name">
|
<input class="input" maxlength="40" type="text" @model="name">
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<button class="anchor btn" @click="setAnchorPoint">调整锚点</button>
|
<button class="anchor btn">调整锚点</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -24,7 +24,7 @@ class GroundImage extends Base {
|
|||||||
* @param options.flipe.x=false {boolean} 绕X轴翻转
|
* @param options.flipe.x=false {boolean} 绕X轴翻转
|
||||||
* @param options.flipe.y=false {boolean} 绕Y轴翻转
|
* @param options.flipe.y=false {boolean} 绕Y轴翻转
|
||||||
* @param options.url {string} 图片地址
|
* @param options.url {string} 图片地址
|
||||||
* @param {Array.<object>} options.positions 经纬度和高度的列表,值交替 [{lon,lat,alt},...]
|
* @param {Array.<object>} options.position 经纬度和高度的列表,值交替 [{lon,lat,alt},...]
|
||||||
* @param _Dialog {object} 弹框事件
|
* @param _Dialog {object} 弹框事件
|
||||||
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
* @param _Dialog.confirmCallBack {function} 弹框确认时的回调
|
||||||
* */
|
* */
|
||||||
@ -35,8 +35,8 @@ class GroundImage extends Base {
|
|||||||
this.options.url = options.url
|
this.options.url = options.url
|
||||||
this.options.angle = options.angle || 0
|
this.options.angle = options.angle || 0
|
||||||
this.options.scale = (options.scale || options.scale === 0) ? options.scale : 1
|
this.options.scale = (options.scale || options.scale === 0) ? options.scale : 1
|
||||||
this.options.positions = options.positions
|
this.options.position = options.position
|
||||||
this.options.offset = { x: 0.5, y: 0.5 }
|
this.options.offset = options.offset || { x: 0.5, y: 0.5 }
|
||||||
|
|
||||||
this.options.flipe = options.flipe || {}
|
this.options.flipe = options.flipe || {}
|
||||||
this.options.flipe.x = this.options.flipe.x || false
|
this.options.flipe.x = this.options.flipe.x || false
|
||||||
@ -49,7 +49,7 @@ class GroundImage extends Base {
|
|||||||
this.Dialog = _Dialog
|
this.Dialog = _Dialog
|
||||||
this._elms = {};
|
this._elms = {};
|
||||||
this.previous = {
|
this.previous = {
|
||||||
positions: { ...this.options.positions }
|
position: { ...this.options.position }
|
||||||
}
|
}
|
||||||
this._EventBinding = new EventBinding()
|
this._EventBinding = new EventBinding()
|
||||||
this.event = new MouseEvent(this.sdk)
|
this.event = new MouseEvent(this.sdk)
|
||||||
@ -62,6 +62,32 @@ class GroundImage extends Base {
|
|||||||
}
|
}
|
||||||
set offset(v) {
|
set offset(v) {
|
||||||
this.options.offset = v
|
this.options.offset = v
|
||||||
|
const img = new Image();
|
||||||
|
img.crossOrigin = 'Anonymous';
|
||||||
|
img.src = this.replaceHost(this.options.url, this.options.host);
|
||||||
|
img.onload = () => {
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
|
||||||
|
// 设置画布大小
|
||||||
|
canvas.width = img.width * 2;
|
||||||
|
canvas.height = img.height * 2;
|
||||||
|
|
||||||
|
// 绘制图像
|
||||||
|
if (this.flipeX) {
|
||||||
|
ctx.scale(1, -1);
|
||||||
|
ctx.translate(0, -canvas.height)
|
||||||
|
}
|
||||||
|
if (this.flipeY) {
|
||||||
|
ctx.scale(-1, 1);
|
||||||
|
ctx.translate(-canvas.width, 0);
|
||||||
|
}
|
||||||
|
ctx.drawImage(img, img.width - (img.width * this.options.offset.x), img.height - (img.height * this.options.offset.y));
|
||||||
|
this.entity.rectangle.material = new Cesium.ImageMaterialProperty({
|
||||||
|
image: canvas,
|
||||||
|
transparent: true
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get angle() {
|
get angle() {
|
||||||
@ -97,14 +123,15 @@ class GroundImage extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
|
img.crossOrigin = 'Anonymous';
|
||||||
img.src = this.replaceHost(this.options.url, this.options.host);
|
img.src = this.replaceHost(this.options.url, this.options.host);
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
|
|
||||||
// 设置画布大小
|
// 设置画布大小
|
||||||
canvas.width = img.width;
|
canvas.width = img.width * 2;
|
||||||
canvas.height = img.height;
|
canvas.height = img.height * 2;
|
||||||
|
|
||||||
// 绘制图像
|
// 绘制图像
|
||||||
if (this.flipeX) {
|
if (this.flipeX) {
|
||||||
@ -115,7 +142,7 @@ class GroundImage extends Base {
|
|||||||
ctx.scale(-1, 1);
|
ctx.scale(-1, 1);
|
||||||
ctx.translate(-canvas.width, 0);
|
ctx.translate(-canvas.width, 0);
|
||||||
}
|
}
|
||||||
ctx.drawImage(img, 0, 0);
|
ctx.drawImage(img, img.width - (img.width * this.options.offset.x), img.height - (img.height * this.options.offset.y));
|
||||||
this.entity && (this.entity.rectangle.material = new Cesium.ImageMaterialProperty({
|
this.entity && (this.entity.rectangle.material = new Cesium.ImageMaterialProperty({
|
||||||
image: canvas,
|
image: canvas,
|
||||||
transparent: true
|
transparent: true
|
||||||
@ -140,14 +167,15 @@ class GroundImage extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
|
img.crossOrigin = 'Anonymous';
|
||||||
img.src = this.replaceHost(this.options.url, this.options.host);
|
img.src = this.replaceHost(this.options.url, this.options.host);
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
|
|
||||||
// 设置画布大小
|
// 设置画布大小
|
||||||
canvas.width = img.width;
|
canvas.width = img.width * 2;
|
||||||
canvas.height = img.height;
|
canvas.height = img.height * 2;
|
||||||
|
|
||||||
// 绘制图像
|
// 绘制图像
|
||||||
if (this.flipeX) {
|
if (this.flipeX) {
|
||||||
@ -158,7 +186,7 @@ class GroundImage extends Base {
|
|||||||
ctx.scale(-1, 1);
|
ctx.scale(-1, 1);
|
||||||
ctx.translate(-canvas.width, 0);
|
ctx.translate(-canvas.width, 0);
|
||||||
}
|
}
|
||||||
ctx.drawImage(img, 0, 0);
|
ctx.drawImage(img, img.width - (img.width * this.options.offset.x), img.height - (img.height * this.options.offset.y));
|
||||||
this.entity.rectangle.material = new Cesium.ImageMaterialProperty({
|
this.entity.rectangle.material = new Cesium.ImageMaterialProperty({
|
||||||
image: canvas,
|
image: canvas,
|
||||||
transparent: true
|
transparent: true
|
||||||
@ -174,12 +202,12 @@ class GroundImage extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async create() {
|
async create() {
|
||||||
// let gap = Math.abs(Math.cos(Math.PI/180 * this.options.positions.lat)) * (0.0001*this.options.scale)
|
// let gap = Math.abs(Math.cos(Math.PI/180 * this.options.position.lat)) * (0.0001*this.options.scale)
|
||||||
// let fromDegreesArray = [
|
// let fromDegreesArray = [
|
||||||
// this.options.positions.lng - 0.05, this.options.positions.lat - 0.05,
|
// this.options.position.lng - 0.05, this.options.position.lat - 0.05,
|
||||||
// this.options.positions.lng + 0.05, this.options.positions.lat - 0.05,
|
// this.options.position.lng + 0.05, this.options.position.lat - 0.05,
|
||||||
// this.options.positions.lng + 0.05, this.options.positions.lat + 0.05,
|
// this.options.position.lng + 0.05, this.options.position.lat + 0.05,
|
||||||
// this.options.positions.lng - 0.05, this.options.positions.lat + 0.05,
|
// this.options.position.lng - 0.05, this.options.position.lat + 0.05,
|
||||||
// ]
|
// ]
|
||||||
let response = await fetch(this.replaceHost(this.options.url, this.options.host), {
|
let response = await fetch(this.replaceHost(this.options.url, this.options.host), {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
@ -192,14 +220,15 @@ class GroundImage extends Base {
|
|||||||
// let arrayBuffer = await data.arrayBuffer()
|
// let arrayBuffer = await data.arrayBuffer()
|
||||||
// const str = String.fromCharCode(...new Uint8Array(arrayBuffer));
|
// const str = String.fromCharCode(...new Uint8Array(arrayBuffer));
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
|
img.crossOrigin = 'Anonymous';
|
||||||
img.src = this.replaceHost(this.options.url, this.options.host);
|
img.src = this.replaceHost(this.options.url, this.options.host);
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
|
|
||||||
// 设置画布大小
|
// 设置画布大小
|
||||||
canvas.width = img.width;
|
canvas.width = img.width * 2;
|
||||||
canvas.height = img.height;
|
canvas.height = img.height * 2;
|
||||||
// 绘制图像
|
// 绘制图像
|
||||||
if (this.flipeX) {
|
if (this.flipeX) {
|
||||||
ctx.scale(1, -1);
|
ctx.scale(1, -1);
|
||||||
@ -209,14 +238,14 @@ class GroundImage extends Base {
|
|||||||
ctx.scale(-1, 1);
|
ctx.scale(-1, 1);
|
||||||
ctx.translate(-canvas.width, 0);
|
ctx.translate(-canvas.width, 0);
|
||||||
}
|
}
|
||||||
ctx.drawImage(img, 0, 0);
|
ctx.drawImage(img, img.width - (img.width * this.options.offset.x), img.height - (img.height * this.options.offset.y));
|
||||||
|
|
||||||
this.entity = this.sdk.viewer.entities.add({
|
this.entity = this.sdk.viewer.entities.add({
|
||||||
id: this.options.id,
|
id: this.options.id,
|
||||||
show: this.options.show,
|
show: this.options.show,
|
||||||
rectangle: {
|
rectangle: {
|
||||||
coordinates: new Cesium.CallbackProperty(() => {
|
coordinates: new Cesium.CallbackProperty(() => {
|
||||||
let gap = Math.abs(Math.cos(Math.PI / 180 * this.options.positions.lat)) * (0.0001 * this.options.scale)
|
let gap = Math.abs(Math.cos(Math.PI / 180 * this.options.position.lat)) * (0.0001 * this.options.scale)
|
||||||
let offset = {
|
let offset = {
|
||||||
x: this.flipeY ? Math.abs(this.options.offset.x - 1) : this.options.offset.x,
|
x: this.flipeY ? Math.abs(this.options.offset.x - 1) : this.options.offset.x,
|
||||||
y: this.flipeX ? Math.abs(this.options.offset.y - 1) : this.options.offset.y,
|
y: this.flipeX ? Math.abs(this.options.offset.y - 1) : this.options.offset.y,
|
||||||
@ -225,19 +254,29 @@ class GroundImage extends Base {
|
|||||||
lng: offset.x * ((0.0001 * this.options.scale) * 2),
|
lng: offset.x * ((0.0001 * this.options.scale) * 2),
|
||||||
lat: Math.abs(offset.y - 1) * (gap * 2)
|
lat: Math.abs(offset.y - 1) * (gap * 2)
|
||||||
}
|
}
|
||||||
|
// let point1 = [this.options.position.lng - offset.lng + 360, this.options.position.lat - offset.lat];
|
||||||
|
// let point2 = [(this.options.position.lng - offset.lng) + ((0.0001 * this.options.scale) * 2) + 360, (this.options.position.lat - offset.lat) + (gap * 2)];
|
||||||
|
// let midpoint = turf.point([point1[0]+point2[0]/2, point1[1]+point2[1]/2]);
|
||||||
|
// let rotatedPot = turf.transformRotate(midpoint, -Number(this.options.angle), {pivot: [this.options.position.lng, this.options.position.lat]});
|
||||||
|
// console.log(midpoint.geometry.coordinates, rotatedPot.geometry.coordinates, this.options.position)
|
||||||
|
// let fromDegreesArray = [
|
||||||
|
// rotatedPot.geometry.coordinates[0]-(0.0001 * this.options.scale), rotatedPot.geometry.coordinates[1]-(0.0001 * this.options.scale),
|
||||||
|
// rotatedPot.geometry.coordinates[0]+(0.0001 * this.options.scale), rotatedPot.geometry.coordinates[1]+(0.0001 * this.options.scale),
|
||||||
|
|
||||||
|
// ]
|
||||||
let fromDegreesArray = [
|
let fromDegreesArray = [
|
||||||
this.options.positions.lng - offset.lng, this.options.positions.lat - offset.lat,
|
// this.options.position.lng - offset.lng, this.options.position.lat - offset.lat,
|
||||||
(this.options.positions.lng - offset.lng) + ((0.0001 * this.options.scale) * 2), (this.options.positions.lat - offset.lat) + (gap * 2),
|
// (this.options.position.lng - offset.lng) + ((0.0001 * this.options.scale) * 2), (this.options.position.lat - offset.lat) + (gap * 2),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// this.options.positions.lng - (0.0001 * this.options.scale), this.options.positions.lat - gap,
|
this.options.position.lng - (0.0001 * this.options.scale), this.options.position.lat - gap,
|
||||||
// // this.options.positions.lng + 0.05, this.options.positions.lat - 0.05,
|
// this.options.position.lng + 0.05, this.options.position.lat - 0.05,
|
||||||
// this.options.positions.lng + (0.0001 * this.options.scale), this.options.positions.lat + gap,
|
this.options.position.lng + (0.0001 * this.options.scale), this.options.position.lat + gap,
|
||||||
// // this.options.positions.lng - 0.05, this.options.positions.lat + 0.05,
|
// this.options.position.lng - 0.05, this.options.position.lat + 0.05,
|
||||||
]
|
]
|
||||||
|
|
||||||
return Cesium.Rectangle.fromDegrees(...fromDegreesArray)
|
return Cesium.Rectangle.fromDegrees(...fromDegreesArray)
|
||||||
@ -281,7 +320,7 @@ class GroundImage extends Base {
|
|||||||
// 编辑框
|
// 编辑框
|
||||||
async edit(state) {
|
async edit(state) {
|
||||||
let _this = this
|
let _this = this
|
||||||
this.originalOptions = { ...this.options }
|
this.originalOptions = this.deepCopyObj(this.options)
|
||||||
if (this._DialogObject && this._DialogObject.close) {
|
if (this._DialogObject && this._DialogObject.close) {
|
||||||
this._DialogObject.close()
|
this._DialogObject.close()
|
||||||
this._DialogObject = null
|
this._DialogObject = null
|
||||||
@ -312,16 +351,19 @@ class GroundImage extends Base {
|
|||||||
this.Dialog.removeCallBack && this.Dialog.removeCallBack()
|
this.Dialog.removeCallBack && this.Dialog.removeCallBack()
|
||||||
},
|
},
|
||||||
closeCallBack: () => {
|
closeCallBack: () => {
|
||||||
|
this.previous = null
|
||||||
this.reset()
|
this.reset()
|
||||||
// this.entity.style = new Cesium.Cesium3DTileStyle({
|
// this.entity.style = new Cesium.Cesium3DTileStyle({
|
||||||
// color: "color('rgba(255,255,255," + this.newData.transparency + ")')",
|
// color: "color('rgba(255,255,255," + this.newData.transparency + ")')",
|
||||||
// show: true,
|
// show: true,
|
||||||
// });
|
// });
|
||||||
this.positionEditing = false
|
|
||||||
if (anchorSetDialogObject && anchorSetDialogObject.close) {
|
if (anchorSetDialogObject && anchorSetDialogObject.close) {
|
||||||
anchorSetDialogObject.close()
|
anchorSetDialogObject.close()
|
||||||
}
|
}
|
||||||
this.Dialog.closeCallBack && this.Dialog.closeCallBack()
|
this.Dialog.closeCallBack && this.Dialog.closeCallBack()
|
||||||
|
YJ.Measure.SetMeasureStatus(false)
|
||||||
|
this.positionEditing = false
|
||||||
},
|
},
|
||||||
showCallBack: (show) => {
|
showCallBack: (show) => {
|
||||||
this.show = show
|
this.show = show
|
||||||
@ -491,17 +533,17 @@ class GroundImage extends Base {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this._positionEditing = status
|
this._positionEditing = status
|
||||||
this.previous = {
|
|
||||||
positions: { ...this.options.positions }
|
|
||||||
}
|
|
||||||
if (status === true) {
|
if (status === true) {
|
||||||
|
this.previous = {
|
||||||
|
position: { ...this.options.position }
|
||||||
|
}
|
||||||
this.tip && this.tip.destroy()
|
this.tip && this.tip.destroy()
|
||||||
this.tip = new MouseTip('点击鼠标左键确认,右键取消', this.sdk)
|
this.tip = new MouseTip('点击鼠标左键确认,右键取消', this.sdk)
|
||||||
this.event.mouse_move((movement, cartesian) => {
|
this.event.mouse_move((movement, cartesian) => {
|
||||||
let positions = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
let position = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||||
this.options.positions.lng = positions.lng
|
this.options.position.lng = position.lng
|
||||||
this.options.positions.lat = positions.lat
|
this.options.position.lat = position.lat
|
||||||
this.options.positions.alt = positions.alt
|
this.options.position.alt = position.alt
|
||||||
this.tip.setPosition(
|
this.tip.setPosition(
|
||||||
cartesian,
|
cartesian,
|
||||||
movement.endPosition.x,
|
movement.endPosition.x,
|
||||||
@ -509,21 +551,22 @@ class GroundImage extends Base {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
this.event.mouse_left((movement, cartesian) => {
|
this.event.mouse_left((movement, cartesian) => {
|
||||||
let positions = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
let position = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||||
this.options.positions.lng = positions.lng
|
this.options.position.lng = position.lng
|
||||||
this.options.positions.lat = positions.lat
|
this.options.position.lat = position.lat
|
||||||
this.options.positions.alt = positions.alt
|
this.options.position.alt = position.alt
|
||||||
this.event.mouse_move(() => { })
|
this.event.mouse_move(() => { })
|
||||||
this.event.mouse_left(() => { })
|
this.event.mouse_left(() => { })
|
||||||
this.event.mouse_right(() => { })
|
this.event.mouse_right(() => { })
|
||||||
this.event.gesture_pinck_start(() => { })
|
this.event.gesture_pinck_start(() => { })
|
||||||
this.event.gesture_pinck_end(() => { })
|
this.event.gesture_pinck_end(() => { })
|
||||||
|
this.previous = null
|
||||||
this.positionEditing = false
|
this.positionEditing = false
|
||||||
})
|
})
|
||||||
this.event.mouse_right((movement, cartesian) => {
|
this.event.mouse_right((movement, cartesian) => {
|
||||||
this.options.positions.lng = this.previous.positions.lng
|
this.options.position.lng = this.previous.position.lng
|
||||||
this.options.positions.lat = this.previous.positions.lat
|
this.options.position.lat = this.previous.position.lat
|
||||||
this.options.positions.alt = this.previous.positions.alt
|
this.options.position.alt = this.previous.position.alt
|
||||||
this.positionEditing = false
|
this.positionEditing = false
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -533,16 +576,16 @@ class GroundImage extends Base {
|
|||||||
let endTime = new Date()
|
let endTime = new Date()
|
||||||
if (endTime - startTime >= 500) {
|
if (endTime - startTime >= 500) {
|
||||||
// 长按取消
|
// 长按取消
|
||||||
this.options.positions.lng = this.previous.positions.lng
|
this.options.position.lng = this.previous.position.lng
|
||||||
this.options.positions.lat = this.previous.positions.lat
|
this.options.position.lat = this.previous.position.lat
|
||||||
this.options.positions.alt = this.previous.positions.alt
|
this.options.position.alt = this.previous.position.alt
|
||||||
this.positionEditing = false
|
this.positionEditing = false
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let positions = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
let position = this.cartesian3Towgs84(cartesian, this.sdk.viewer)
|
||||||
this.options.positions.lng = positions.lng
|
this.options.position.lng = position.lng
|
||||||
this.options.positions.lat = positions.lat
|
this.options.position.lat = position.lat
|
||||||
this.options.positions.alt = positions.alt
|
this.options.position.alt = position.alt
|
||||||
this.event.mouse_move(() => { })
|
this.event.mouse_move(() => { })
|
||||||
this.event.mouse_left(() => { })
|
this.event.mouse_left(() => { })
|
||||||
this.event.mouse_right(() => { })
|
this.event.mouse_right(() => { })
|
||||||
@ -562,9 +605,17 @@ class GroundImage extends Base {
|
|||||||
this.event.gesture_pinck_end(() => { })
|
this.event.gesture_pinck_end(() => { })
|
||||||
}
|
}
|
||||||
this.tip && this.tip.destroy()
|
this.tip && this.tip.destroy()
|
||||||
this.options.positions.lng = this.previous.positions.lng
|
if (!this.previous) {
|
||||||
this.options.positions.lat = this.previous.positions.lat
|
this.previous = {
|
||||||
this.options.positions.alt = this.previous.positions.alt
|
position: { ...this.options.position }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.options.position.lng = this.previous.position.lng
|
||||||
|
this.options.position.lat = this.previous.position.lat
|
||||||
|
this.options.position.alt = this.previous.position.alt
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,8 +647,8 @@ class GroundImage extends Base {
|
|||||||
if (this.options.position) {
|
if (this.options.position) {
|
||||||
position = { ...this.options.position }
|
position = { ...this.options.position }
|
||||||
}
|
}
|
||||||
else if (this.options.positions) {
|
else if (this.options.position) {
|
||||||
position = { ...this.options.positions[0] }
|
position = { ...this.options.position[0] }
|
||||||
}
|
}
|
||||||
else if (this.options.center) {
|
else if (this.options.center) {
|
||||||
position = { ...this.options.center }
|
position = { ...this.options.center }
|
||||||
@ -630,14 +681,14 @@ class GroundImage extends Base {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let gap = Math.abs(Math.cos(Math.PI / 180 * this.options.positions.lat)) * (0.0001 * this.options.scale)
|
let gap = Math.abs(Math.cos(Math.PI / 180 * this.options.position.lat)) * (0.0001 * this.options.scale)
|
||||||
let fromDegreesArray = [
|
let fromDegreesArray = [
|
||||||
[this.options.positions.lng - (0.0001 * this.options.scale), this.options.positions.lat - gap],
|
[this.options.position.lng - (0.0001 * this.options.scale), this.options.position.lat - gap],
|
||||||
[this.options.positions.lng + (0.0001 * this.options.scale), this.options.positions.lat + gap],
|
[this.options.position.lng + (0.0001 * this.options.scale), this.options.position.lat + gap],
|
||||||
]
|
]
|
||||||
let positionArray = []
|
let positionArray = []
|
||||||
let height = 0
|
let height = 0
|
||||||
let position = this.options.positions
|
let position = this.options.position
|
||||||
let point1 = Cesium.Cartesian3.fromDegrees(position.lng, position.lat, 0);
|
let point1 = Cesium.Cartesian3.fromDegrees(position.lng, position.lat, 0);
|
||||||
let point2 = Cesium.Cartesian3.fromDegrees(position.lng, position.lat, 10000000);
|
let point2 = Cesium.Cartesian3.fromDegrees(position.lng, position.lat, 10000000);
|
||||||
let direction = Cesium.Cartesian3.subtract(point2, point1, new Cesium.Cartesian3());
|
let direction = Cesium.Cartesian3.subtract(point2, point1, new Cesium.Cartesian3());
|
||||||
@ -680,9 +731,14 @@ class GroundImage extends Base {
|
|||||||
if (!this.entity) {
|
if (!this.entity) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.name = this.originalOptions.name
|
this.options = this.deepCopyObj(this.originalOptions)
|
||||||
this.angle = this.originalOptions.angle
|
this.name = this.options.name
|
||||||
this.scale = this.originalOptions.scale
|
this.angle = this.options.angle
|
||||||
|
this.scale = this.options.scale
|
||||||
|
this.offset = this.options.offset
|
||||||
|
this.flipeX = this.options.flipe.x
|
||||||
|
this.flipeY = this.options.flipe.y
|
||||||
|
this.show = this.options.show
|
||||||
}
|
}
|
||||||
|
|
||||||
async remove() {
|
async remove() {
|
||||||
@ -699,9 +755,9 @@ class GroundImage extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setPosition(v) {
|
setPosition(v) {
|
||||||
this.options.positions.lng = v.position.lng
|
this.options.position.lng = v.position.lng
|
||||||
this.options.positions.lat = v.position.lat
|
this.options.position.lat = v.position.lat
|
||||||
this.options.positions.alt = v.position.alt
|
this.options.position.alt = v.position.alt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ class eventBinding {
|
|||||||
let Event = []
|
let Event = []
|
||||||
let isEvent = false
|
let isEvent = false
|
||||||
let removeName = []
|
let removeName = []
|
||||||
|
let blurEvent = () => { }
|
||||||
if (!elements[i] || !elements[i].attributes) {
|
if (!elements[i] || !elements[i].attributes) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -36,7 +37,8 @@ class eventBinding {
|
|||||||
Event.push((e) => {
|
Event.push((e) => {
|
||||||
let value = e.target.value
|
let value = e.target.value
|
||||||
if (e.target.type == 'number') {
|
if (e.target.type == 'number') {
|
||||||
if (e.data != '.' && (e.data != '-' || e.target.value)) {
|
let str = e.target.value + ''
|
||||||
|
if (e.data != '.' && (e.data != '-' || e.target.value) && !(str.charAt(str.length - 1) == '0' && e.target.value.toString().includes('.')) && e.target.value != '0') {
|
||||||
value = Number(value)
|
value = Number(value)
|
||||||
if((e.target.max) && value>Number(e.target.max)) {
|
if((e.target.max) && value>Number(e.target.max)) {
|
||||||
value = Number(e.target.max)
|
value = Number(e.target.max)
|
||||||
@ -57,6 +59,22 @@ class eventBinding {
|
|||||||
that[m.value] = value
|
that[m.value] = value
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
blurEvent = (e) => {
|
||||||
|
let value = e.target.value
|
||||||
|
if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) {
|
||||||
|
value = Number(value)
|
||||||
|
if ((e.target.max) && value > Number(e.target.max)) {
|
||||||
|
value = Number(e.target.max)
|
||||||
|
}
|
||||||
|
if ((e.target.min) && value < Number(e.target.min)) {
|
||||||
|
value = Number(e.target.min)
|
||||||
|
}
|
||||||
|
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
|
||||||
|
value = Number(e.target.dataset.min)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
that[m.value] = value
|
||||||
|
}
|
||||||
if(elements[i].nodeName=='IMG') {
|
if(elements[i].nodeName=='IMG') {
|
||||||
elements[i].src = that[m.value]
|
elements[i].src = that[m.value]
|
||||||
}
|
}
|
||||||
@ -114,6 +132,7 @@ class eventBinding {
|
|||||||
Event[t](e)
|
Event[t](e)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
elements[i].addEventListener('blur', blurEvent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import LabelObject from '../LabelObject'
|
|||||||
import MouseEvent from '../../../Event/index'
|
import MouseEvent from '../../../Event/index'
|
||||||
import MouseTip from '../../../MouseTip'
|
import MouseTip from '../../../MouseTip'
|
||||||
import Controller from '../../../Controller/index'
|
import Controller from '../../../Controller/index'
|
||||||
import { syncData } from '../../../Global/MultiViewportMode'
|
import { syncData, get3DView } from '../../../Global/MultiViewportMode'
|
||||||
import { legp } from '../../Element/datalist'
|
import { legp } from '../../Element/datalist'
|
||||||
import { getFontList, getFontFamilyName } from '../../Element/fontSelect'
|
import { getFontList, getFontFamilyName } from '../../Element/fontSelect'
|
||||||
import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen'
|
import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen'
|
||||||
@ -291,14 +291,16 @@ class PolylineObject extends Base {
|
|||||||
2,
|
2,
|
||||||
v
|
v
|
||||||
).then(res => {
|
).then(res => {
|
||||||
|
// _this.options.lengthByMeter = res
|
||||||
|
// if (res > 1000 || res == 1000) {
|
||||||
|
// _this.length = (res / 1000).toFixed(5)
|
||||||
|
// _this.lengthUnit = '千米'
|
||||||
|
// } else {
|
||||||
|
// _this.length = res
|
||||||
|
// _this.lengthUnit = '米'
|
||||||
|
// }
|
||||||
_this.options.lengthByMeter = res
|
_this.options.lengthByMeter = res
|
||||||
if (res > 1000 || res == 1000) {
|
_this.lengthUnit = _this.options['length-unit']
|
||||||
_this.length = (res / 1000).toFixed(5)
|
|
||||||
_this.lengthUnit = '千米'
|
|
||||||
} else {
|
|
||||||
_this.length = res
|
|
||||||
_this.lengthUnit = '米'
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
let fromDegreesArray = this.renewPositions(this.options.positions)
|
let fromDegreesArray = this.renewPositions(this.options.positions)
|
||||||
@ -483,24 +485,25 @@ class PolylineObject extends Base {
|
|||||||
)
|
)
|
||||||
this.renewPolygon(fromDegreesArray)
|
this.renewPolygon(fromDegreesArray)
|
||||||
}
|
}
|
||||||
if (v) {
|
this.lengthUnit = this.options['length-unit']
|
||||||
if (this.options.fitLengthByMeter > 1000 || this.options.fitLengthByMeter == 1000) {
|
// if (v) {
|
||||||
let dom = document.getElementsByClassName('input-select-unit')[1]
|
// if (this.options.fitLengthByMeter > 1000 || this.options.fitLengthByMeter == 1000) {
|
||||||
dom && dom.querySelectorAll('dd')[1] && dom.querySelectorAll('dd')[1].click()
|
// let dom = document.getElementsByClassName('input-select-unit')[1]
|
||||||
} else {
|
// dom && dom.querySelectorAll('dd')[1] && dom.querySelectorAll('dd')[1].click()
|
||||||
let dom = document.getElementsByClassName('input-select-unit')[1]
|
// } else {
|
||||||
dom && dom.querySelectorAll('dd')[0] && dom.querySelectorAll('dd')[0].click()
|
// let dom = document.getElementsByClassName('input-select-unit')[1]
|
||||||
}
|
// dom && dom.querySelectorAll('dd')[0] && dom.querySelectorAll('dd')[0].click()
|
||||||
|
// }
|
||||||
|
|
||||||
} else {
|
// } else {
|
||||||
if (this.options.lengthByMeter > 1000 || this.options.lengthByMeter == 1000) {
|
// if (this.options.lengthByMeter > 1000 || this.options.lengthByMeter == 1000) {
|
||||||
let dom = document.getElementsByClassName('input-select-unit')[1]
|
// let dom = document.getElementsByClassName('input-select-unit')[1]
|
||||||
dom && dom.querySelectorAll('dd')[1] && dom.querySelectorAll('dd')[1].click()
|
// dom && dom.querySelectorAll('dd')[1] && dom.querySelectorAll('dd')[1].click()
|
||||||
} else {
|
// } else {
|
||||||
let dom = document.getElementsByClassName('input-select-unit')[1]
|
// let dom = document.getElementsByClassName('input-select-unit')[1]
|
||||||
dom && dom.querySelectorAll('dd')[0] && dom.querySelectorAll('dd')[0].click()
|
// dom && dom.querySelectorAll('dd')[0] && dom.querySelectorAll('dd')[0].click()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
get smooth() {
|
get smooth() {
|
||||||
@ -1323,6 +1326,7 @@ class PolylineObject extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static create(that) {
|
static create(that) {
|
||||||
|
|
||||||
let ground
|
let ground
|
||||||
if (that.heightMode == 2) {
|
if (that.heightMode == 2) {
|
||||||
ground = true
|
ground = true
|
||||||
@ -1439,9 +1443,17 @@ class PolylineObject extends Base {
|
|||||||
var groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight)
|
var groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight)
|
||||||
repeatX *= groundResolution / cameraHeight / (param.space * (canvasEle.width / canvasEle.height * 5) + 1);
|
repeatX *= groundResolution / cameraHeight / (param.space * (canvasEle.width / canvasEle.height * 5) + 1);
|
||||||
// if (entity.polyline.material.oriRepeat) {
|
// if (entity.polyline.material.oriRepeat) {
|
||||||
|
|
||||||
|
if (that.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) {
|
||||||
let speed = repeatX / entity.polyline.oriRepeat
|
let speed = repeatX / entity.polyline.oriRepeat
|
||||||
entity.polyline.oriSpeed = speed
|
entity.polyline.oriSpeed = speed
|
||||||
entity.polyline.oriRepeatX = repeatX
|
entity.polyline.oriRepeatX = repeatX
|
||||||
|
} else {
|
||||||
|
let sdk3d = get3DView()
|
||||||
|
let sdk3dEntity = sdk3d.viewer.entities.getById(that.options.id)
|
||||||
|
entity.polyline.oriSpeed = sdk3dEntity.polyline.oriSpeed
|
||||||
|
entity.polyline.oriRepeatX = sdk3dEntity.polyline.oriRepeatX
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1453,8 +1465,21 @@ class PolylineObject extends Base {
|
|||||||
getSceenLine(entity, options, canvasEle) {
|
getSceenLine(entity, options, canvasEle) {
|
||||||
let point1 = new Cesium.Cartesian2(0, this.sdk.viewer.canvas.clientHeight)
|
let point1 = new Cesium.Cartesian2(0, this.sdk.viewer.canvas.clientHeight)
|
||||||
let point2 = new Cesium.Cartesian2(this.sdk.viewer.canvas.clientWidth / 2, this.sdk.viewer.canvas.clientHeight)
|
let point2 = new Cesium.Cartesian2(this.sdk.viewer.canvas.clientWidth / 2, this.sdk.viewer.canvas.clientHeight)
|
||||||
var cartesian1 = this.sdk.viewer.scene.pickPosition(point1)
|
// var cartesian1 = this.sdk.viewer.scene.pickPosition(point1)
|
||||||
var cartesian2 = this.sdk.viewer.scene.pickPosition(point2)
|
// var cartesian2 = this.sdk.viewer.scene.pickPosition(point2)
|
||||||
|
|
||||||
|
let ray = this.sdk.viewer.camera.getPickRay(point1);
|
||||||
|
let cartesian1 = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene);
|
||||||
|
|
||||||
|
let ray2 = this.sdk.viewer.camera.getPickRay(point2);
|
||||||
|
let cartesian2 = this.sdk.viewer.scene.globe.pick(ray2, this.sdk.viewer.scene);
|
||||||
|
// if (!cartesian1 || !cartesian2) {
|
||||||
|
// let ray = this.sdk.viewer.camera.getPickRay(point1);
|
||||||
|
// cartesian1 = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene);
|
||||||
|
|
||||||
|
// let ray2 = this.sdk.viewer.camera.getPickRay(point2);
|
||||||
|
// cartesian2 = this.sdk.viewer.scene.globe.pick(ray2, this.sdk.viewer.scene);
|
||||||
|
// }
|
||||||
|
|
||||||
var distance = Cesium.Cartesian3.distance(cartesian1, cartesian2);
|
var distance = Cesium.Cartesian3.distance(cartesian1, cartesian2);
|
||||||
|
|
||||||
@ -1466,6 +1491,7 @@ class PolylineObject extends Base {
|
|||||||
500000 // 半径(距离)
|
500000 // 半径(距离)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率)
|
// 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率)
|
||||||
var drawingBufferWidth = this.sdk.viewer.canvas.clientWidth;
|
var drawingBufferWidth = this.sdk.viewer.canvas.clientWidth;
|
||||||
var drawingBufferHeight = this.sdk.viewer.canvas.clientHeight;
|
var drawingBufferHeight = this.sdk.viewer.canvas.clientHeight;
|
||||||
@ -1479,7 +1505,14 @@ class PolylineObject extends Base {
|
|||||||
repeatX = undefined;
|
repeatX = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) {
|
||||||
return repeatX
|
return repeatX
|
||||||
|
} else {
|
||||||
|
let sdk3d = get3DView()
|
||||||
|
let sdk3dEntity = sdk3d.viewer.entities.getById(this.options.id)
|
||||||
|
return sdk3dEntity.polyline.oriRepeatX
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 编辑框
|
* 编辑框
|
||||||
@ -1529,6 +1562,9 @@ class PolylineObject extends Base {
|
|||||||
}
|
}
|
||||||
this.nodePoints = []
|
this.nodePoints = []
|
||||||
this.positionEditing = false
|
this.positionEditing = false
|
||||||
|
YJ.Measure.SetMeasureStatus(false)
|
||||||
|
this.event && this.event.destroy()
|
||||||
|
this.tip && this.tip.destroy()
|
||||||
},
|
},
|
||||||
showCallBack: show => {
|
showCallBack: show => {
|
||||||
this.options.show = show
|
this.options.show = show
|
||||||
|
@ -21,6 +21,7 @@ class eventBinding {
|
|||||||
let Event = []
|
let Event = []
|
||||||
let isEvent = false
|
let isEvent = false
|
||||||
let removeName = []
|
let removeName = []
|
||||||
|
let blurEvent = ()=>{}
|
||||||
if (!elements[i] ||!elements[i].attributes) {
|
if (!elements[i] ||!elements[i].attributes) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -37,6 +38,26 @@ class eventBinding {
|
|||||||
let value = e.target.value
|
let value = e.target.value
|
||||||
if (e.target.type == 'number') {
|
if (e.target.type == 'number') {
|
||||||
if (e.data != '.' && (e.data != '-' || e.target.value)) {
|
if (e.data != '.' && (e.data != '-' || e.target.value)) {
|
||||||
|
let v = Number(value)
|
||||||
|
if((e.target.max) && v>Number(e.target.max)) {
|
||||||
|
value = Number(e.target.max)
|
||||||
|
}
|
||||||
|
if((e.target.min) && v<Number(e.target.min)) {
|
||||||
|
value = Number(e.target.min)
|
||||||
|
}
|
||||||
|
if((e.target.dataset.min) && v<Number(e.target.dataset.min)) {
|
||||||
|
value = Number(e.target.dataset.min)
|
||||||
|
}
|
||||||
|
that[m.value] = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
that[m.value] = value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
blurEvent = (e) => {
|
||||||
|
let value = e.target.value
|
||||||
|
if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) {
|
||||||
value = Number(value)
|
value = Number(value)
|
||||||
if ((e.target.max) && value > Number(e.target.max)) {
|
if ((e.target.max) && value > Number(e.target.max)) {
|
||||||
value = Number(e.target.max)
|
value = Number(e.target.max)
|
||||||
@ -47,13 +68,9 @@ class eventBinding {
|
|||||||
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
|
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
|
||||||
value = Number(e.target.dataset.min)
|
value = Number(e.target.dataset.min)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
that[m.value] = value
|
that[m.value] = value
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
that[m.value] = value
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if(elements[i].nodeName=='IMG') {
|
if(elements[i].nodeName=='IMG') {
|
||||||
elements[i].src = that[m.value]
|
elements[i].src = that[m.value]
|
||||||
}
|
}
|
||||||
@ -111,6 +128,9 @@ class eventBinding {
|
|||||||
Event[t](e)
|
Event[t](e)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
elements[i].addEventListener('blur', (e) => {
|
||||||
|
blurEvent(e)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ class eventBinding {
|
|||||||
let Event = []
|
let Event = []
|
||||||
let isEvent = false
|
let isEvent = false
|
||||||
let removeName = []
|
let removeName = []
|
||||||
|
let blurEvent = () => { }
|
||||||
if (!elements[i] || !elements[i].attributes) {
|
if (!elements[i] || !elements[i].attributes) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -37,11 +38,11 @@ class eventBinding {
|
|||||||
let value = e.target.value
|
let value = e.target.value
|
||||||
if (e.target.type == 'number') {
|
if (e.target.type == 'number') {
|
||||||
if (e.data != '.' && (e.data != '-' || e.target.value)) {
|
if (e.data != '.' && (e.data != '-' || e.target.value)) {
|
||||||
value = Number(value)
|
let v = Number(value)
|
||||||
if((e.target.max) && value>Number(e.target.max)) {
|
if ((e.target.max) && v > Number(e.target.max)) {
|
||||||
value = Number(e.target.max)
|
value = Number(e.target.max)
|
||||||
}
|
}
|
||||||
if((e.target.min) && value<Number(e.target.min)) {
|
if ((e.target.min) && v < Number(e.target.min)) {
|
||||||
value = Number(e.target.min)
|
value = Number(e.target.min)
|
||||||
}
|
}
|
||||||
that[m.value] = value
|
that[m.value] = value
|
||||||
@ -51,6 +52,24 @@ class eventBinding {
|
|||||||
that[m.value] = value
|
that[m.value] = value
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
blurEvent = (e) => {
|
||||||
|
let value = e.target.value
|
||||||
|
if (e.target.value || (e.target.dataset.null !== 'undefined' && e.target.dataset.null !== '' && !Boolean(e.target.dataset.null))) {
|
||||||
|
value = Number(value)
|
||||||
|
if ((e.target.max) && value > Number(e.target.max)) {
|
||||||
|
value = Number(e.target.max)
|
||||||
|
}
|
||||||
|
if ((e.target.min) && value < Number(e.target.min)) {
|
||||||
|
value = Number(e.target.min)
|
||||||
|
}
|
||||||
|
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
|
||||||
|
value = Number(e.target.dataset.min)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
that[m.value] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (elements[i].nodeName == 'IMG') {
|
if (elements[i].nodeName == 'IMG') {
|
||||||
elements[i].src = that[m.value]
|
elements[i].src = that[m.value]
|
||||||
}
|
}
|
||||||
@ -108,6 +127,9 @@ class eventBinding {
|
|||||||
Event[t](e)
|
Event[t](e)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
elements[i].addEventListener('blur', (e) => {
|
||||||
|
blurEvent(e)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,8 @@ class eventBinding {
|
|||||||
else {
|
else {
|
||||||
Event.push((e) => {
|
Event.push((e) => {
|
||||||
let value = e.target.value
|
let value = e.target.value
|
||||||
if (e.target.type == 'number') {
|
let str = e.target.value + ''
|
||||||
|
if (e.target.type == 'number' && !(str.charAt(str.length - 1) == '0' && e.target.value.toString().includes('.'))) {
|
||||||
value = Number(value)
|
value = Number(value)
|
||||||
}
|
}
|
||||||
that[m.value] = value
|
that[m.value] = value
|
||||||
|
@ -45,8 +45,14 @@ class EventBinding {
|
|||||||
let value = e.target.value
|
let value = e.target.value
|
||||||
value = Number(value)
|
value = Number(value)
|
||||||
if (e.data != '.' && (e.data != '-' || e.target.value)) {
|
if (e.data != '.' && (e.data != '-' || e.target.value)) {
|
||||||
if (((!e.target.max) && (!e.target.min)) || ((value <= Number(e.target.max)) && value >= Number(e.target.min))) {
|
if ((e.target.max) && value > Number(e.target.max)) {
|
||||||
that[m.value] = value
|
value = Number(e.target.max)
|
||||||
|
}
|
||||||
|
if ((e.target.min) && value < Number(e.target.min)) {
|
||||||
|
value = Number(e.target.min)
|
||||||
|
}
|
||||||
|
if ((e.target.dataset.min) && value < Number(e.target.dataset.min)) {
|
||||||
|
value = Number(e.target.dataset.min)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import { open as projConvertOpen, close as projConvertClose } from './projConver
|
|||||||
import { open as projectionConvertOpen, close as projectionConvertClose } from './projectionConvert'
|
import { open as projectionConvertOpen, close as projectionConvertClose } from './projectionConvert'
|
||||||
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../Global/global'
|
import { setActiveViewer, closeRotateAround, closeViewFollow } from '../Global/global'
|
||||||
import FlowPictureMaterialProperty from '../Obj/Materail/FlowPictureMaterialProperty'
|
import FlowPictureMaterialProperty from '../Obj/Materail/FlowPictureMaterialProperty'
|
||||||
|
import { syncData, get3DView } from '../Global/MultiViewportMode'
|
||||||
|
|
||||||
class Tools {
|
class Tools {
|
||||||
/**
|
/**
|
||||||
@ -646,25 +647,52 @@ class Tools {
|
|||||||
// dashSize: newParam.dashSize,
|
// dashSize: newParam.dashSize,
|
||||||
space: newParam.space,
|
space: newParam.space,
|
||||||
scale: new Cesium.CallbackProperty(function () {
|
scale: new Cesium.CallbackProperty(function () {
|
||||||
var oriPositions = entity.polyline.positions.getValue();
|
|
||||||
|
if (that.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) {
|
||||||
|
let oriPositions = entity.polyline.positions.getValue();
|
||||||
|
|
||||||
if (!Cesium.defined(oriPositions)) {
|
if (!Cesium.defined(oriPositions)) {
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
var distance = 0;
|
let distance = 0;
|
||||||
for (var i = 0; i < oriPositions.length - 1; ++i) {
|
for (let i = 0; i < oriPositions.length - 1; ++i) {
|
||||||
distance += Cesium.Cartesian3.distance(oriPositions[i], oriPositions[i + 1]);
|
distance += Cesium.Cartesian3.distance(oriPositions[i], oriPositions[i + 1]);
|
||||||
}
|
}
|
||||||
//屏幕坐标
|
//屏幕坐标
|
||||||
let point1 = new Cesium.Cartesian2(0, that.sdk.viewer.canvas.clientHeight)
|
let point1 = new Cesium.Cartesian2(0, that.sdk.viewer.canvas.clientHeight)
|
||||||
let point2 = new Cesium.Cartesian2(that.sdk.viewer.canvas.clientWidth / 2, that.sdk.viewer.canvas.clientHeight)
|
let point2 = new Cesium.Cartesian2(that.sdk.viewer.canvas.clientWidth / 2, that.sdk.viewer.canvas.clientHeight)
|
||||||
var cartesian1 = that.sdk.viewer.scene.pickPosition(point1)
|
let cartesian1 = that.sdk.viewer.scene.pickPosition(point1)
|
||||||
var cartesian2 = that.sdk.viewer.scene.pickPosition(point2)
|
let cartesian2 = that.sdk.viewer.scene.pickPosition(point2)
|
||||||
if (cartesian1 && cartesian2) {
|
if (cartesian1 && cartesian2) {
|
||||||
var distance2 = Cesium.Cartesian3.distance(cartesian1, cartesian2);
|
let distance2 = Cesium.Cartesian3.distance(cartesian1, cartesian2);
|
||||||
repeatX = distance2 * 2 / distance
|
repeatX = distance2 * 2 / distance
|
||||||
}
|
}
|
||||||
return repeatX;
|
return repeatX;
|
||||||
|
} else {
|
||||||
|
let sdk3d = get3DView()
|
||||||
|
let sdk3dEntity = sdk3d.viewer.entities.getById(that.options.id)
|
||||||
|
let oriPositions = sdk3dEntity.polyline.positions.getValue();
|
||||||
|
|
||||||
|
if (!Cesium.defined(oriPositions)) {
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
let distance = 0;
|
||||||
|
for (let i = 0; i < oriPositions.length - 1; ++i) {
|
||||||
|
distance += Cesium.Cartesian3.distance(oriPositions[i], oriPositions[i + 1]);
|
||||||
|
}
|
||||||
|
//屏幕坐标
|
||||||
|
let point1 = new Cesium.Cartesian2(0, sdk3d.viewer.canvas.clientHeight)
|
||||||
|
let point2 = new Cesium.Cartesian2(sdk3d.viewer.canvas.clientWidth / 2, sdk3d.viewer.canvas.clientHeight)
|
||||||
|
let cartesian1 = sdk3d.viewer.scene.pickPosition(point1)
|
||||||
|
let cartesian2 = sdk3d.viewer.scene.pickPosition(point2)
|
||||||
|
if (cartesian1 && cartesian2) {
|
||||||
|
let distance2 = Cesium.Cartesian3.distance(cartesian1, cartesian2);
|
||||||
|
repeatX = distance2 * 2 / distance
|
||||||
|
}
|
||||||
|
return repeatX;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -730,33 +758,36 @@ class Tools {
|
|||||||
image: canvasEle,
|
image: canvasEle,
|
||||||
speed: options.speed,
|
speed: options.speed,
|
||||||
repeat: new Cesium.CallbackProperty(function () {
|
repeat: new Cesium.CallbackProperty(function () {
|
||||||
var positionProperty = entity.polyline.positions;
|
|
||||||
var positions = positionProperty.getValue(that.sdk.viewer.clock.currentTime);
|
if (that.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) {
|
||||||
|
let positionProperty = entity.polyline.positions;
|
||||||
|
let positions = positionProperty.getValue(that.sdk.viewer.clock.currentTime);
|
||||||
|
|
||||||
if (!Cesium.defined(positions)) {
|
if (!Cesium.defined(positions)) {
|
||||||
return new Cesium.Cartesian2(1.0, 1.0);
|
return new Cesium.Cartesian2(1.0, 1.0);
|
||||||
// return 1.0;
|
// return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var distance = 0;
|
let distance = 0;
|
||||||
for (var i = 0; i < positions.length - 1; ++i) {
|
for (let i = 0; i < positions.length - 1; ++i) {
|
||||||
|
// if (that.sdk.viewer.scene.mode===Cesium.SceneMode.SCENE2D){}
|
||||||
distance += Cesium.Cartesian3.distance(positions[i], positions[i + 1]);
|
distance += Cesium.Cartesian3.distance(positions[i], positions[i + 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var repeatX = distance / entity.polyline.width.getValue();
|
let repeatX = distance / entity.polyline.width.getValue();
|
||||||
// 根据地图缩放程度调整repeatX
|
// 根据地图缩放程度调整repeatX
|
||||||
var cameraHeight = that.sdk.viewer.camera.positionCartographic.height;
|
let cameraHeight = that.sdk.viewer.camera.positionCartographic.height;
|
||||||
var boundingSphere = new Cesium.BoundingSphere(
|
let boundingSphere = new Cesium.BoundingSphere(
|
||||||
new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标
|
new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标
|
||||||
500000 // 半径(距离)
|
500000 // 半径(距离)
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率)
|
// 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率)
|
||||||
var drawingBufferWidth = that.sdk.viewer.canvas.clientWidth;
|
let drawingBufferWidth = that.sdk.viewer.canvas.clientWidth;
|
||||||
var drawingBufferHeight = that.sdk.viewer.canvas.clientHeight;
|
let drawingBufferHeight = that.sdk.viewer.canvas.clientHeight;
|
||||||
|
|
||||||
// 使用 getPixelSize 方法获取包围球在屏幕上的像素大小
|
// 使用 getPixelSize 方法获取包围球在屏幕上的像素大小
|
||||||
var groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight)
|
let groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight)
|
||||||
let result
|
let result
|
||||||
if (groundResolution > 700) {
|
if (groundResolution > 700) {
|
||||||
repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1);
|
repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1);
|
||||||
@ -775,6 +806,61 @@ class Tools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
let sdk3d = get3DView()
|
||||||
|
let sdk3dEntity = sdk3d.viewer.entities.getById(that.options.id)
|
||||||
|
let positionProperty = sdk3dEntity.polyline.positions;
|
||||||
|
let positions = positionProperty.getValue(sdk3d.viewer.clock.currentTime);
|
||||||
|
|
||||||
|
if (!Cesium.defined(positions)) {
|
||||||
|
return new Cesium.Cartesian2(1.0, 1.0);
|
||||||
|
// return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
let distance = 0;
|
||||||
|
for (let i = 0; i < positions.length - 1; ++i) {
|
||||||
|
// if (that.sdk.viewer.scene.mode===Cesium.SceneMode.SCENE2D){}
|
||||||
|
distance += Cesium.Cartesian3.distance(positions[i], positions[i + 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
let repeatX = distance / sdk3dEntity.polyline.width.getValue();
|
||||||
|
// 根据地图缩放程度调整repeatX
|
||||||
|
let cameraHeight = sdk3d.viewer.camera.positionCartographic.height;
|
||||||
|
let boundingSphere = new Cesium.BoundingSphere(
|
||||||
|
new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标
|
||||||
|
500000 // 半径(距离)
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率)
|
||||||
|
let drawingBufferWidth = sdk3d.viewer.canvas.clientWidth;
|
||||||
|
let drawingBufferHeight = sdk3d.viewer.canvas.clientHeight;
|
||||||
|
|
||||||
|
// 使用 getPixelSize 方法获取包围球在屏幕上的像素大小
|
||||||
|
let groundResolution = sdk3d.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight)
|
||||||
|
let result
|
||||||
|
if (groundResolution > 700) {
|
||||||
|
repeatX *= groundResolution / cameraHeight / (options.space * (canvasEle.width / canvasEle.height * 5) + 1);
|
||||||
|
// if (entity.polyline.material.oriRepeat) {
|
||||||
|
let speed = repeatX / sdk3dEntity.polyline.oriRepeat
|
||||||
|
sdk3dEntity.polyline.oriSpeed = speed
|
||||||
|
sdk3dEntity.polyline.oriRepeatX = repeatX
|
||||||
|
// } else {
|
||||||
|
// entity.polyline.material.oriRepeat = repeatX
|
||||||
|
// }
|
||||||
|
beforeSpeed = speed
|
||||||
|
repeat = repeatX
|
||||||
|
result = new Cesium.Cartesian2(repeatX, speed || 1.0)
|
||||||
|
} else {
|
||||||
|
result = new Cesium.Cartesian2(repeat || sdk3dEntity.polyline.oriRepeatX, beforeSpeed || sdk3dEntity.polyline.oriSpeed)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// return repeatX;
|
// return repeatX;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -787,8 +873,13 @@ class Tools {
|
|||||||
getSceenLine(entity, options, canvasEle) {
|
getSceenLine(entity, options, canvasEle) {
|
||||||
let point1 = new Cesium.Cartesian2(0, this.sdk.viewer.canvas.clientHeight)
|
let point1 = new Cesium.Cartesian2(0, this.sdk.viewer.canvas.clientHeight)
|
||||||
let point2 = new Cesium.Cartesian2(this.sdk.viewer.canvas.clientWidth / 2, this.sdk.viewer.canvas.clientHeight)
|
let point2 = new Cesium.Cartesian2(this.sdk.viewer.canvas.clientWidth / 2, this.sdk.viewer.canvas.clientHeight)
|
||||||
var cartesian1 = this.sdk.viewer.scene.pickPosition(point1)
|
// var cartesian1 = this.sdk.viewer.scene.pickPosition(point1)
|
||||||
var cartesian2 = this.sdk.viewer.scene.pickPosition(point2)
|
// var cartesian2 = this.sdk.viewer.scene.pickPosition(point2)
|
||||||
|
let ray = this.sdk.viewer.camera.getPickRay(point1);
|
||||||
|
let cartesian1 = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene);
|
||||||
|
|
||||||
|
let ray2 = this.sdk.viewer.camera.getPickRay(point2);
|
||||||
|
let cartesian2 = this.sdk.viewer.scene.globe.pick(ray2, this.sdk.viewer.scene);
|
||||||
|
|
||||||
var distance = Cesium.Cartesian3.distance(cartesian1, cartesian2);
|
var distance = Cesium.Cartesian3.distance(cartesian1, cartesian2);
|
||||||
|
|
||||||
@ -813,7 +904,14 @@ class Tools {
|
|||||||
repeatX = undefined;
|
repeatX = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.sdk.viewer.scene.mode === Cesium.SceneMode.SCENE3D) {
|
||||||
return repeatX
|
return repeatX
|
||||||
|
} else {
|
||||||
|
let sdk3d = get3DView()
|
||||||
|
let sdk3dEntity = sdk3d.viewer.entities.getById(this.options.id)
|
||||||
|
return sdk3dEntity.polyline.oriRepeatX
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*创建直箭头图片*/
|
/*创建直箭头图片*/
|
||||||
|
Reference in New Issue
Block a user