Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions website/src/lib/getLongestLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import {
getElevationAtCoord,
getScaleFromCog,
Log,
PRE_VARIABLY_SCALED_TIFFS__COG_SCALE,
PRE_VARIABLY_SCALED_TIFFS__RUN_VERSION,
startLoadingSpinner,
VERSION,
} from './utils';

// Masks for unpacking bit-packed line of sight data.
Expand Down Expand Up @@ -246,7 +247,7 @@ async function findNearestCOGURLs(coordinate: LngLat) {
const cogFilenames = [];
for (const [filename, cog] of cogsIndex) {
const distance = coordinate.distanceTo(cog.centre);
const radius = cog.width / 2;
const radius = cog.width / 2 / PRE_VARIABLY_SCALED_TIFFS__COG_SCALE;
Log.debug(
`👀 Checking Longest Line COG: ${filename}`,
`with centre: ${cog.centre} and radius ${radius}`,
Expand Down Expand Up @@ -354,8 +355,9 @@ export function convertRasterXYToLngLat(
function getLongestLinesSource() {
const params = new URLSearchParams(self.location.search);
const source = params.get('longest_lines');
const version = PRE_VARIABLY_SCALED_TIFFS__RUN_VERSION;
if (!source) {
return `${CDN_BUCKET}/runs/${VERSION}/longest_lines_cogs`;
return `${CDN_BUCKET}/runs/${version}/longest_lines_cogs`;
} else {
return source;
}
Expand Down
3 changes: 2 additions & 1 deletion website/src/lib/renderLongestLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
aeqdProjectionString,
computeBBox,
disablePointer,
PRE_VARIABLY_SCALED_TIFFS__LINE_ANGLE,
rotate,
toRadians,
} from './utils.ts';
Expand Down Expand Up @@ -70,7 +71,7 @@ export async function render(lngLat: LngLat) {
console.log(longestLine);
}

longestLine.angle = longestLine.angle - 90;
longestLine.angle = longestLine.angle + PRE_VARIABLY_SCALED_TIFFS__LINE_ANGLE;

const θ = toRadians(longestLine.angle);
const dx = longestLine.distance * Math.cos(θ);
Expand Down
19 changes: 14 additions & 5 deletions website/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ export const MAP_SERVER = `https://${MAP_SERVER_SUBDOMAIN}.alltheviews.world`;
export const WORLD_PMTILES = 'world';
export const PMTILES_SERVER = `${MAP_SERVER}/runs/${VERSION}/pmtiles/${WORLD_PMTILES}`;

// All these `PRE_VARIABLY_SCALED_TIFFS__*` values are for old runs that didn't have variably scaled
// .tiffs. We're just using them whilst the latest run is the high refraction run,
// 'ryan-world2-run-refraction23', which produces notably longer lines of sight. Should we update the
// Top Ten list of longest lines?
export const PRE_VARIABLY_SCALED_TIFFS__RUN_VERSION = 'ryan-fullworld-raw';
// Should be `0`
export const PRE_VARIABLY_SCALED_TIFFS__COG_SCALE = 100;
// Should be `-90`
export const PRE_VARIABLY_SCALED_TIFFS__LINE_ANGLE = 0;

// This is for busting Cloudflare asset cache. Like for an updated `world.pmtiles`,
// longest lines index, etc.
export const CACHE_BUSTER = '?buster=18:36-30/04/2026';
export const CACHE_BUSTER = '?buster=17:47-25/08/2026';

export const EARTH_RADIUS = 6371_000.0;

Expand Down Expand Up @@ -194,11 +204,10 @@ export function setVectorVisibility(state: AppState, isVisible: boolean) {
}

export async function getElevationAtCoord(coord: LngLat) {
const base = 'https://api.elevationapi.com/api/Elevation';
const url = `${base}?lat=${coord.lat}&lon=${coord.lng}&dataSet=NASADEM`;
const base = 'https://www.elevation-api.eu/v1/elevation';
const url = `${base}/${coord.lat}/${coord.lng}`;
const result = await fetch(url);
const payload = await result.json();
return payload.geoPoints[0].elevation;
return await result.text();
}

export function getScaleFromCog(cog: GeoTIFFImage) {
Expand Down
Loading