Extend line range to antipode (20k km), increase city limit to 100, and fix info panel layout

This commit is contained in:
(jenkins)
2026-03-16 20:50:35 +00:00
parent ad07a70125
commit f0767c798c
4 changed files with 224 additions and 48 deletions
+17 -7
View File
@@ -53,8 +53,8 @@ app.get('/api/line-of-sight', async (req, res) => {
try {
// Generate path points for visualization and spatial query
const pathPoints = [];
const totalDistance = 10000;
const steps = 20;
const totalDistance = 20000;
const steps = 40;
for (let i = 0; i <= steps; i++) {
const dist = (totalDistance * i) / steps;
@@ -65,7 +65,8 @@ app.get('/api/line-of-sight', async (req, res) => {
const query = `
WITH path AS (
SELECT ST_GeogFromText($1) as route
SELECT ST_GeogFromText($1) as route,
ST_MakePoint($3, $4)::geography as start_node
)
SELECT
id,
@@ -74,15 +75,21 @@ app.get('/api/line-of-sight', async (req, res) => {
country,
ST_Y(geom::geometry) as lat,
ST_X(geom::geometry) as lon,
ST_Distance(geom, (SELECT route FROM path)) / 1000 as distance_to_line_km,
ST_Distance(geom, (SELECT route FROM path)) / 1000 as distance_off_line_km,
ST_Distance(geom, (SELECT start_node FROM path)) / 1000 as distance_from_start_km,
ST_LineLocatePoint((SELECT route FROM path)::geometry, geom::geometry) as pos_on_line
FROM cities
WHERE ST_DWithin(geom, (SELECT route FROM path), $2 * 1000)
ORDER BY pos_on_line ASC
LIMIT 20;
LIMIT 100;
`;
const result = await pool.query(query, [lineWKT, toleranceKm]);
const result = await pool.query(query, [lineWKT, toleranceKm, startLon, startLat]);
console.log(`Found ${result.rows.length} conurbations near the line.`);
if (result.rows.length > 0) {
console.log('Sample result row:', result.rows[0]);
}
res.json({
success: true,
@@ -92,7 +99,10 @@ app.get('/api/line-of-sight', async (req, res) => {
tolerance_km: toleranceKm,
conurbations: result.rows.map(row => ({
...row,
distance_km: Math.round(row.distance_to_line_km)
name: row.name || 'Unknown',
country: row.country || 'Unknown',
distance_km: Math.round(row.distance_from_start_km),
off_line_km: Math.round(row.distance_off_line_km)
})),
line_coordinates: pathPoints
}