function addPlottingSpan(viewer: CesiumViewer, currentPole: any, pole: any, firstPole: boolean) {
if (currentPole.id === pole.id) return;
let pole1Position = currentPole.position.getValue();
let pole2Position = pole.position.getValue();
let cart1 = new Cartesian3(pole1Position.x, pole1Position.y, pole1Position.z);
let cart2 = new Cartesian3(pole2Position.x, pole2Position.y, pole2Position.z);
const ellipsoid = Ellipsoid.WGS84;
const cartographic1 = ellipsoid.cartesianToCartographic(cart1);
const cartographic2 = ellipsoid.cartesianToCartographic(cart2);
cartographic1.height += 5;
cartographic2.height += 5;
const pole1 = ellipsoid.cartographicToCartesian(cartographic1);
const pole2 = ellipsoid.cartographicToCartesian(cartographic2);
let offsetX = Math.abs(pole1.x - pole2.x);
let offsetY = Math.abs(pole1.y - pole2.y);
let distance = Math.sqrt((offsetX * offsetX) + (offsetY + offsetY));
let angle1 = Math.cos(offsetX/distance) * 57.295779513;
angle1 = 90
let crossarm = 8;
let crossarmRadius = crossarm / 2;
let x = crossarmRadius * Math.cos(angle1)
let y = crossarmRadius * Math.sin(angle1)
let pole1WireAttachment1 = new Cartesian3(pole1.x + x, pole1.y + y, pole1.z)
let pole1WireAttachment2 = new Cartesian3(pole1.x - x, pole1.y - y, pole1.z);
let pole2WireAttachment1 = new Cartesian3(pole2.x + x, pole2.y + y, pole2.z)
let pole2WireAttachment2 = new Cartesian3(pole2.x - x, pole2.y - y, pole2.z);
let midspan = viewer?.entities.add({
polyline: {
positions: [pole1, pole2],
width: 3,
material: new PolylineOutlineMaterialProperty({
color: Color.BLACK,
outlineWidth: 2
}),
},
});
viewer?.entities.add({
polyline: {
positions: [pole1WireAttachment1, pole2WireAttachment1],
width: 3,
material: new PolylineOutlineMaterialProperty({
color: Color.BLACK,
outlineWidth: 2
}),
},
});
viewer?.entities.add({
polyline: {
positions: [pole1WireAttachment2, pole2WireAttachment2],
width: 3,
material: new PolylineOutlineMaterialProperty({
color: Color.BLACK,
outlineWidth: 2
}),
},
});
return midspan;
}
I am trying to figure out why the z values for each wire would be at different heights even though I give them the same z value. Do I have to normalize the coordinates or something to that degree?
The wire on the top of the pole is in the correct position. However when I add the offsets to the 2nd and 3rd polylines, the polylines are in the right location but at different heights.