Street Level: a replacement keeps its own state, and a posted view stands down

- Releasing a held viewer frees the old source's adapter without resetting
  the panel, so a replacement's error, outcome and armed OPEN survive; a
  cross-source replacement drops the old photo's details and marker.
- The action holds the open photo only for its own switch-off: a source
  switched by hand during the load stops it and reports cancelled.
- A posted view waiting on terrain watches the camera and stands down after a
  navigation or a globe press; a flat or straight-down camera asks no terrain.
- An arming link opens the panel without persisting the layout, and a posted
  view's street-level step runs as programmatic.
- An off-globe street_level point throws TypeError.
- zh-Hant uses the file's wording for the new strings; README and
  CURRENT-STATE count 35 tools.
This commit is contained in:
German Khokhlov committed 2026-11-11 16:05:26 +04:00
1 parent 45a33b54df
commit 4fd36c44e0
14 files changed
+391 -84

No files matched your search

+13 -1
View File
@@ -131,7 +131,13 @@ export function lookAtPoint(camera) {
*/
export async function groundedLookAt(camera, terrain, signal) {
if (typeof terrain?.getHeights !== 'function') return null;
if (!Number.isFinite(camera?.altitude_m) || !(camera.pitch_deg > -89))
// Looking down or at the horizon the point is the camera's own: the ground
// under it changes nothing, so it is not asked for.
if (
!Number.isFinite(camera?.altitude_m) ||
!(camera.pitch_deg > -89) ||
camera.pitch_deg > LOOK_AT_MIN_PITCH_DEG
)
return null;
let heights;
try {
@@ -381,6 +387,12 @@ export function createView({
// photos at X, also when the camera sits behind it. It is a pair: half
// of one is not mixed with the camera's other half.
const given = [latitude(streetLevel.lat), longitude(streetLevel.lon)];
// A coordinate given off the globe is an error, not a reason to guess.
for (const [index, key] of ['lat', 'lon'].entries())
if (streetLevel[key] != null && given[index] === undefined)
throw new TypeError(
`Street-level ${key} is not a valid coordinate: ${streetLevel[key]}`,
);
const seen = lookAtPoint(camera);
const [lat, lon] = given.includes(undefined) ? [seen.lat, seen.lon] : given;
street = Object.freeze({
+15
View File
@@ -208,6 +208,21 @@ test('street-level photos travel in the link, light their source and bring their
assert.equal(streetLevelFromParams(new URLSearchParams('sl=bing,1,2')), null);
assert.equal(streetLevelFromParams(new URLSearchParams('lat=1')), null);
assert.equal(createView({ camera: { lat: 1, lon: 2 } }).street_level, null);
// A point off the globe is refused, like an unknown source.
for (const bad of [
{ lat: 95, lon: 2 },
{ lat: 48, lon: 200 },
{ lat: Number.NaN, lon: 2 },
])
assert.throws(
() =>
createView({
camera: { lat: 1, lon: 2 },
street_level: { provider: 'mapillary', ...bad },
}),
TypeError,
JSON.stringify(bad),
);
// Half a point is not mixed with the camera's other half.
const half = createView({
camera: { lat: 1, lon: 2 },