Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#491 Panorama angle of view wonky near poles #499

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 69 additions & 17 deletions src/essence/Basics/Viewer_/Photosphere.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,22 +486,64 @@ export default function (domEl, lookupPath, options, Map_) {
currentImageObj._center[1],
currentImageObj._center[0],
]

//==== Get bearing to north (in case north isn't up)
const contPt = Map_.map.latLngToContainerPoint(start)
const wOffset = contPt.x
const hOffset = contPt.y

//Find coordinates at map center and at another point one pixel below the center
const centerLatLong = Map_.map.containerPointToLatLng([
wOffset,
hOffset,
])
const pixelBelowCenterLatLong = Map_.map.containerPointToLatLng(
[wOffset, hOffset + 1]
)
let bearing = F_.bearingBetweenTwoLatLngs(
pixelBelowCenterLatLong.lat,
pixelBelowCenterLatLong.lng,
centerLatLong.lat,
centerLatLong.lng
)
bearing = (360 - bearing) % 360

//
let end
let rp
let line
let lineLength = (parseFloat(currentEl) + 90) * 1.6 + 10
let lineLength = Math.min(
(parseFloat(currentEl) + 90) * 1.6 + 10,
100
)

const crs = window.mmgisglobal.customCRS

let centerLngLat = { lng: start[1], lat: start[0] }
const centerEN = crs.project(centerLngLat)
const centerCoordsEN = [centerEN.x, centerEN.y]

//==== Min-line
let angleRad =
-(parseFloat(lastAz) - parseFloat(lastFov) / 2 + bearing) *
(Math.PI / 180)

rp = F_.rotatePoint(
{ x: 0, y: 1 },
{
y: 1,
x: 0,
},
[0, 0],
-(parseFloat(lastAz) - parseFloat(lastFov) / 2) *
(Math.PI / 180)
angleRad
)

end = [
geometry.coordinates[1] + rp.y,
geometry.coordinates[0] + rp.x,
]
if (crs) {
rp = crs.unproject({
x: rp.x + centerCoordsEN[0],
y: rp.y + centerCoordsEN[1],
})
rp = { x: rp.lng, y: rp.lat }
}
end = [rp.y, rp.x]

line = new L.Polyline([start, end], {
color: 'orange',
Expand All @@ -526,17 +568,27 @@ export default function (domEl, lookupPath, options, Map_) {
],
})

//==== Max-line
angleRad =
-(parseFloat(lastAz) + parseFloat(lastFov) / 2 + bearing) *
(Math.PI / 180)

rp = F_.rotatePoint(
{ x: 0, y: 1 },
{
y: 1,
x: 0,
},
[0, 0],
-(parseFloat(lastAz) + parseFloat(lastFov) / 2) *
(Math.PI / 180)
angleRad
)

end = [
geometry.coordinates[1] + rp.y,
geometry.coordinates[0] + rp.x,
]
if (crs) {
rp = crs.unproject({
x: rp.x + centerCoordsEN[0],
y: rp.y + centerCoordsEN[1],
})
rp = { x: rp.lng, y: rp.lat }
}
end = [rp.y, rp.x]

line = new L.Polyline([start, end], {
color: 'orange',
Expand Down
Loading