In this section
- Civilisation Map render · youengineer-code-review / civilisation-map.css lines 422–458
- Civilisation Map render · youengineer-code-review / civilisation-map.html lines 1–107
- Civilisation Map geodesy · youengineer-code-review / civilisation-map.js lines 1–392
Civilisation Map
A style sheet in Youengineer Code Review. Served with the page at https://ventusltd.github.io/youengineer-code-review/.
renderyouengineer-code-review / civilisation-map.css · lines 422–458 of 458 (continued from section 728) · Entry point
- What it does
- Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage site_feasibility (topic 'maps-gis'): substation-to-site feasibility (terrain, LiDAR and connection evidence before design), a journey named in Ventus Ltd's brief.
- Downstream impact
- Used directly by 1 file: Civilisation Map (youengineer-code-review, https://ventusltd.github.io/youengineer-code-review/civilisation-map.html). It is itself an entry point, published at https://ventusltd.github.io/youengineer-code-review/.
- What it achieves
- No statement of purpose was found in the file, a README line naming it, or its name.
- Why it matters
- Loaded by the page of the same name at https://ventusltd.github.io/youengineer-code-review/civilisation-map.html.
- Application
- youengineer-code-review · / · style sheet
- Uses
- none found
- Used by
- loaded by Civilisation Map (stylesheet)
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- youengineer-code-review@929a6d4a955524122e4fd18bd3c85ceaf1a86c56 civilisation-map.css:422-458 · blob a237f816f0fb20d21a9fb583ae49b54faa992015 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: site_feasibility · users: IPP_developer, landowner_planner · canonical: unknown
body {
padding: 14px;
}
.atlas-grid {
grid-template-columns: 1fr;
padding: 18px;
}
.sidebar-stack {
grid-template-columns: 1fr 1fr;
}
#worldMap {
min-height: 440px;
}
}
@media (max-width: 720px) {
.sidebar-stack {
grid-template-columns: 1fr;
}
.stat-grid,
.button-row {
grid-template-columns: 1fr;
}
.map-toolbar {
align-items: stretch;
}
.region-buttons,
.map-toolbar {
display: grid;
}
}Civilisation Map
A web page in Youengineer Code Review that draws SVG graphics and reads inputs for site and unesco only. Published at https://ventusltd.github.io/youengineer-code-review/civilisation-map.html.
renderyouengineer-code-review / civilisation-map.html · lines 1–107 of 107 · Entry point
- What it does
- It draws its content. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage site_feasibility (topic 'maps-gis'): substation-to-site feasibility (terrain, LiDAR and connection evidence before design), a journey named in Ventus Ltd's brief.
- Inputs & outputs
- In: form fields (user input). Out: web page; SVG drawing.
- Downstream impact
- It is itself an entry point, published at https://ventusltd.github.io/youengineer-code-review/civilisation-map.html.
- What it achieves
- No statement of purpose was found in the file, a README line naming it, or its name.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- youengineer-code-review · / · page
- Uses
- Civilisation Map (stylesheet), Civilisation Map Data (script src), Civilisation Map (script src), Youengineer Code Review — Index Page (link)
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- youengineer-code-review@929a6d4a955524122e4fd18bd3c85ceaf1a86c56 civilisation-map.html:1-107 · blob 3bba9aac932049c107296271401d9d5626b974c3 · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: site_feasibility · users: IPP_developer, landowner_planner · canonical: unknown
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>YouEngineer Civilisation Atlas</title>
<link rel="stylesheet" href="civilisation-map.css" />
<script src="civilisation-map-data.js" defer></script>
<script src="civilisation-map.js" defer></script>
</head>
<body>
<main class="atlas-shell">
<header class="atlas-hero">
<p class="eyebrow">YouEngineer Mini Project 02</p>
<h1>Civilisation Atlas</h1>
<p>
A static GIS-style global map of ancient sites, world heritage inspiration points and creative technology locations. Built from local GeoJSON-style data with no external map API.
</p>
<nav class="nav-row" aria-label="Project navigation">
<a class="nav-link" href="index.html">Medusa Time Temple</a>
<a class="nav-link" href="#map">Open the map</a>
<a class="nav-link" href="https://github.com/Ventusltd/youengineer-code-review">View repository</a>
</nav>
</header>
<section class="atlas-grid" id="map" aria-label="Civilisation atlas interface">
<div class="sidebar-stack">
<aside class="control-panel" aria-label="Map controls">
<h2>Layer Control</h2>
<label class="form-line">
Search sites
<input id="siteSearch" type="search" placeholder="Try Egypt, Maya, Kyoto, temple, water..." />
</label>
<label class="layer-toggle">
<input id="unescoOnly" type="checkbox" />
<span>Show UNESCO starter sites only</span>
<span class="layer-swatch" style="background: #9e6b2e;"></span>
</label>
<div class="layer-list" id="layerList" aria-label="GeoJSON layer toggles"></div>
<div class="button-row">
<button type="button" id="randomSite">Random site</button>
<button type="button" id="resetMap">Reset map</button>
</div>
<div class="stat-grid" aria-label="Map statistics">
<div class="stat-card"><strong id="totalCount">0</strong><span>Total</span></div>
<div class="stat-card"><strong id="visibleCount">0</strong><span>Visible</span></div>
<div class="stat-card"><strong id="unescoCount">0</strong><span>UNESCO</span></div>
</div>
</aside>
<aside class="info-panel" aria-label="Selected site information">
<h2 id="selectedTitle">Select a site</h2>
<p id="selectedBody">Choose a marker on the map or a site in the list.</p>
<div class="site-meta" id="selectedMeta"></div>
<div class="prompt-box">
<p><strong>Student prompt:</strong> <span id="selectedPrompt">Explore how geography shapes civilisation.</span></p>
</div>
<h2>Visible Sites</h2>
<p class="small-note">The list updates with the search box, layer toggles and UNESCO filter.</p>
<div class="site-list" id="siteList" aria-label="Visible site list"></div>
</aside>
</div>
<section class="map-panel" aria-label="World map panel">
<div class="map-toolbar">
<h2>Static SVG World Map</h2>
<div class="region-buttons" aria-label="Region zoom controls">
<button type="button" data-region="world">World</button>
<button type="button" data-region="mediterranean">Mediterranean</button>
<button type="button" data-region="africa">Africa</button>
<button type="button" data-region="asia">Asia</button>
<button type="button" data-region="americas">Americas</button>
<button type="button" data-region="pacific">Pacific</button>
</div>
</div>
<div class="map-wrap">
<svg id="worldMap" viewBox="0 0 1000 500" role="img" aria-label="Global civilisation map plotted from longitude and latitude">
<rect width="1000" height="500" fill="transparent"></rect>
<g id="graticuleLayer" class="graticule"></g>
<g id="landLayer"></g>
<g id="markerLayer"></g>
<g id="labelLayer"></g>
</svg>
<div class="tooltip-card" id="tooltipCard" hidden></div>
</div>
</section>
</section>
<section class="code-quest" aria-label="Civilisation atlas code review tasks">
<h2>Code Review Quests</h2>
<ul>
<li>Inspect <code>civilisation-map-data.js</code> and add one new site using longitude and latitude.</li>
<li>Change one layer colour in <code>CIVILISATION_LAYER_CONFIG</code>.</li>
<li>Find <code>projectLonLat()</code> and explain how longitude and latitude become SVG coordinates.</li>
<li>Find <code>haversineKm()</code> and explain why distance on Earth is not the same as flat screen distance.</li>
<li>Turn one student prompt into a better question and commit the improvement.</li>
</ul>
</section>
</main>
</body>
</html>Civilisation Map
A JavaScript file in Youengineer Code Review that projects lon lat, creates SVG element, gets layer config and calculates great-circle distances and angles. Served with the page at https://ventusltd.github.io/youengineer-code-review/.
geodesyyouengineer-code-review / civilisation-map.js · lines 1–392 of 392 · Entry point · pattern getVisibleFeatures (shared by 2 files)
- What it does
- It draws its content. Defines 22 functions or classes, including escapeHTML, projectLonLat, haversineKm, createSvgElement, getLayerConfig. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage site_feasibility (topic 'maps-gis'): substation-to-site feasibility (terrain, LiDAR and connection evidence before design), a journey named in Ventus Ltd's brief.
- Downstream impact
- Used directly by 1 file: Civilisation Map (youengineer-code-review, https://ventusltd.github.io/youengineer-code-review/civilisation-map.html). It is itself an entry point, published at https://ventusltd.github.io/youengineer-code-review/.
- What it achieves
- It creates SVG element (`createSvgElement`), gets layer config (`getLayerConfig`) and gets feature text (`getFeatureText`). Defines `escapeHTML`, `projectLonLat`, `haversineKm` and 19 more. It responds to change, click and keydown events.
- Why it matters
- Loaded by the page of the same name at https://ventusltd.github.io/youengineer-code-review/civilisation-map.html.
- Application
- youengineer-code-review · / · script
- Uses
- none found
- Used by
- loaded by Civilisation Map (script src)
- Produces
- escapeHTML, projectLonLat, haversineKm, createSvgElement, getLayerConfig, getFeatureText, getVisibleFeatures, drawGraticule, drawSimpleContinents, buildLayerControls, renderMarkers, renderSiteList
- Defines here
- escapeHTML, projectLonLat, haversineKm, createSvgElement, getLayerConfig, getFeatureText, getVisibleFeatures, drawGraticule, drawSimpleContinents, buildLayerControls, renderMarkers, renderSiteList, renderInfoPanel, getNearestFeature, selectFeature, setViewForFeatures, setRegion, updateStats, renderAtlas, chooseRandomSite, resetMap, initAtlas
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- youengineer-code-review@929a6d4a955524122e4fd18bd3c85ceaf1a86c56 civilisation-map.js:1-392 · blob 068ab0a59a3386d88d09bf1d80500bc3990115ff · GitHub at these lines
- State
- achieves: name · context: readme_derived · stage: output · effects: dom · domain stage: site_feasibility · users: IPP_developer, landowner_planner · canonical: unknown
'use strict';
const MAP_WIDTH = 1000;
const MAP_HEIGHT = 500;
const SVG_NS = 'http://www.w3.org/2000/svg';
const atlas = {
layers: window.CIVILISATION_LAYER_CONFIG || [],
geojson: window.CIVILISATION_GEOJSON || { type: 'FeatureCollection', features: [] },
visibleLayers: new Set(),
selectedId: null,
search: '',
unescoOnly: false,
viewBox: [0, 0, MAP_WIDTH, MAP_HEIGHT]
};
const elements = {
map: document.getElementById('worldMap'),
graticule: document.getElementById('graticuleLayer'),
land: document.getElementById('landLayer'),
markers: document.getElementById('markerLayer'),
labels: document.getElementById('labelLayer'),
layerList: document.getElementById('layerList'),
siteList: document.getElementById('siteList'),
searchInput: document.getElementById('siteSearch'),
unescoOnly: document.getElementById('unescoOnly'),
totalCount: document.getElementById('totalCount'),
visibleCount: document.getElementById('visibleCount'),
unescoCount: document.getElementById('unescoCount'),
selectedTitle: document.getElementById('selectedTitle'),
selectedBody: document.getElementById('selectedBody'),
selectedMeta: document.getElementById('selectedMeta'),
selectedPrompt: document.getElementById('selectedPrompt'),
tooltipCard: document.getElementById('tooltipCard'),
resetButton: document.getElementById('resetMap'),
randomButton: document.getElementById('randomSite')
};
function escapeHTML(value) {
return String(value ?? '')
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
}
function projectLonLat(lon, lat) {
const x = ((lon + 180) / 360) * MAP_WIDTH;
const y = ((90 - lat) / 180) * MAP_HEIGHT;
return { x, y };
}
function haversineKm(a, b) {
const radiusKm = 6371;
const toRad = Math.PI / 180;
const lon1 = a.geometry.coordinates[0] * toRad;
const lat1 = a.geometry.coordinates[1] * toRad;
const lon2 = b.geometry.coordinates[0] * toRad;
const lat2 = b.geometry.coordinates[1] * toRad;
const dLat = lat2 - lat1;
const dLon = lon2 - lon1;
const sinLat = Math.sin(dLat / 2);
const sinLon = Math.sin(dLon / 2);
const h = sinLat * sinLat + Math.cos(lat1) * Math.cos(lat2) * sinLon * sinLon;
return radiusKm * 2 * Math.atan2(Math.sqrt(h), Math.sqrt(1 - h));
}
function createSvgElement(tag, attributes = {}) {
const node = document.createElementNS(SVG_NS, tag);
Object.entries(attributes).forEach(([key, value]) => node.setAttribute(key, value));
return node;
}
function getLayerConfig(layerId) {
return atlas.layers.find((layer) => layer.id === layerId) || atlas.layers[0];
}
function getFeatureText(feature) {
const p = feature.properties;
return [p.name, p.layer, p.civilisation, p.country, p.period, p.siteType, p.focus, p.studentPrompt].join(' ').toLowerCase();
}
function getVisibleFeatures() {
return atlas.geojson.features.filter((feature) => {
const p = feature.properties;
const layerIsVisible = atlas.visibleLayers.has(p.layer);
const searchMatches = !atlas.search || getFeatureText(feature).includes(atlas.search);
const unescoMatches = !atlas.unescoOnly || p.unesco;
return layerIsVisible && searchMatches && unescoMatches;
});
}
function drawGraticule() {
elements.graticule.innerHTML = '';
for (let lon = -180; lon <= 180; lon += 30) {
const { x } = projectLonLat(lon, 0);
elements.graticule.appendChild(createSvgElement('line', { x1: x, y1: 0, x2: x, y2: MAP_HEIGHT }));
}
for (let lat = -60; lat <= 60; lat += 30) {
const { y } = projectLonLat(0, lat);
elements.graticule.appendChild(createSvgElement('line', { x1: 0, y1: y, x2: MAP_WIDTH, y2: y }));
}
[-120, -60, 0, 60, 120].forEach((lon) => {
const { x } = projectLonLat(lon, -76);
const label = createSvgElement('text', { x, y: MAP_HEIGHT - 12, 'text-anchor': 'middle' });
label.textContent = `${lon}°`;
elements.graticule.appendChild(label);
});
}
function drawSimpleContinents() {
const shapes = [
'M130 120 C85 155 75 220 118 275 C155 330 118 395 165 440 C215 405 228 332 212 278 C250 238 238 167 190 133 Z',
'M250 120 C285 105 330 125 342 170 C314 210 320 254 355 292 C338 344 297 380 260 365 C278 302 235 254 240 200 Z',
'M450 130 C500 80 600 75 675 115 C735 150 785 190 770 250 C710 262 690 310 626 298 C586 340 512 318 506 260 C460 245 420 190 450 130 Z',
'M500 255 C548 250 585 288 590 345 C595 398 557 445 520 430 C500 383 472 342 483 292 Z',
'M720 300 C770 286 815 318 842 360 C804 383 760 382 726 350 Z',
'M805 150 C842 126 900 132 930 170 C900 198 842 198 810 178 Z'
];
elements.land.innerHTML = '';
shapes.forEach((d) => {
elements.land.appendChild(createSvgElement('path', { d, class: 'land-shape' }));
});
}
function buildLayerControls() {
elements.layerList.innerHTML = '';
atlas.layers.forEach((layer) => {
atlas.visibleLayers.add(layer.id);
const label = document.createElement('label');
label.className = 'layer-toggle';
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.checked = true;
checkbox.dataset.layerId = layer.id;
const text = document.createElement('span');
text.textContent = `${layer.icon} ${layer.label}`;
const swatch = document.createElement('span');
swatch.className = 'layer-swatch';
swatch.style.background = layer.colour;
checkbox.addEventListener('change', () => {
if (checkbox.checked) {
atlas.visibleLayers.add(layer.id);
} else {
atlas.visibleLayers.delete(layer.id);
}
if (atlas.selectedId && !getVisibleFeatures().some((feature) => feature.properties.id === atlas.selectedId)) {
atlas.selectedId = null;
}
renderAtlas();
});
label.appendChild(checkbox);
label.appendChild(text);
label.appendChild(swatch);
elements.layerList.appendChild(label);
});
}
function renderMarkers(features) {
elements.markers.innerHTML = '';
elements.labels.innerHTML = '';
features.forEach((feature) => {
const p = feature.properties;
const layer = getLayerConfig(p.layer);
const [lon, lat] = feature.geometry.coordinates;
const { x, y } = projectLonLat(lon, lat);
const group = createSvgElement('g', {
class: `site-marker ${atlas.selectedId === p.id ? 'is-selected' : ''}`,
tabindex: '0',
role: 'button',
'aria-label': p.name
});
group.appendChild(createSvgElement('circle', {
cx: x,
cy: y,
r: atlas.selectedId === p.id ? 10 : 7,
fill: layer.colour
}));
const icon = createSvgElement('text', { x, y: y + 0.5 });
icon.textContent = layer.icon;
group.appendChild(icon);
const title = createSvgElement('title');
title.textContent = `${p.name} — ${p.civilisation}`;
group.appendChild(title);
group.addEventListener('click', () => selectFeature(p.id));
group.addEventListener('keydown', (event) => {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
selectFeature(p.id);
}
});
elements.markers.appendChild(group);
if (atlas.selectedId === p.id) {
const label = createSvgElement('text', { x: x + 14, y: y - 12, class: 'site-label' });
label.textContent = p.name;
elements.labels.appendChild(label);
}
});
}
function renderSiteList(features) {
elements.siteList.innerHTML = '';
features
.slice()
.sort((a, b) => a.properties.name.localeCompare(b.properties.name))
.forEach((feature) => {
const p = feature.properties;
const layer = getLayerConfig(p.layer);
const button = document.createElement('button');
button.type = 'button';
button.className = atlas.selectedId === p.id ? 'is-active' : '';
button.innerHTML = `${escapeHTML(layer.icon)} <strong>${escapeHTML(p.name)}</strong><br><span class="small-note">${escapeHTML(p.civilisation)} · ${escapeHTML(p.country)}</span>`;
button.addEventListener('click', () => selectFeature(p.id, true));
elements.siteList.appendChild(button);
});
}
function renderInfoPanel(features) {
const selected = atlas.geojson.features.find((feature) => feature.properties.id === atlas.selectedId) || features[0];
if (!selected) {
elements.selectedTitle.textContent = 'No visible sites';
elements.selectedBody.textContent = 'Switch on a layer or clear the search filter.';
elements.selectedMeta.innerHTML = '';
elements.selectedPrompt.textContent = '';
elements.tooltipCard.hidden = true;
return;
}
atlas.selectedId = selected.properties.id;
const p = selected.properties;
const layer = getLayerConfig(p.layer);
elements.selectedTitle.textContent = p.name;
elements.selectedBody.textContent = `${p.civilisation}. ${p.siteType}. Focus: ${p.focus}.`;
elements.selectedMeta.innerHTML = '';
[
`${layer.icon} ${layer.label}`,
p.country,
p.period,
p.unesco ? 'UNESCO starter layer' : 'Non-UNESCO inspiration layer'
].forEach((text) => {
const chip = document.createElement('span');
chip.className = 'site-chip';
chip.textContent = text;
elements.selectedMeta.appendChild(chip);
});
const nearest = getNearestFeature(selected);
const distanceLine = nearest ? ` Nearest visible neighbour: ${nearest.feature.properties.name}, about ${Math.round(nearest.distanceKm).toLocaleString('en-GB')} km away.` : '';
elements.selectedPrompt.textContent = `${p.studentPrompt}${distanceLine}`;
elements.tooltipCard.hidden = false;
elements.tooltipCard.innerHTML = `<p><strong>${escapeHTML(p.name)}</strong>${escapeHTML(p.civilisation)} · ${escapeHTML(p.country)}</p>`;
}
function getNearestFeature(selected) {
const visible = getVisibleFeatures().filter((feature) => feature.properties.id !== selected.properties.id);
if (!visible.length) {
return null;
}
return visible
.map((feature) => ({ feature, distanceKm: haversineKm(selected, feature) }))
.sort((a, b) => a.distanceKm - b.distanceKm)[0];
}
function selectFeature(id, zoomToFeature = false) {
atlas.selectedId = id;
if (zoomToFeature) {
const feature = atlas.geojson.features.find((item) => item.properties.id === id);
if (feature) {
setViewForFeatures([feature], 150);
}
}
renderAtlas();
}
function setViewForFeatures(features, padding = 55) {
if (!features.length) {
setRegion('world');
return;
}
const points = features.map((feature) => projectLonLat(...feature.geometry.coordinates));
const minX = Math.max(0, Math.min(...points.map((point) => point.x)) - padding);
const minY = Math.max(0, Math.min(...points.map((point) => point.y)) - padding);
const maxX = Math.min(MAP_WIDTH, Math.max(...points.map((point) => point.x)) + padding);
const maxY = Math.min(MAP_HEIGHT, Math.max(...points.map((point) => point.y)) + padding);
const width = Math.max(120, maxX - minX);
const height = Math.max(90, maxY - minY);
atlas.viewBox = [minX, minY, width, height];
elements.map.setAttribute('viewBox', atlas.viewBox.join(' '));
}
function setRegion(region) {
const boxes = {
world: [0, 0, MAP_WIDTH, MAP_HEIGHT],
mediterranean: [485, 120, 185, 95],
africa: [430, 175, 235, 220],
asia: [560, 95, 320, 220],
americas: [100, 90, 300, 330],
pacific: [720, 120, 260, 310]
};
atlas.viewBox = boxes[region] || boxes.world;
elements.map.setAttribute('viewBox', atlas.viewBox.join(' '));
}
function updateStats(features) {
elements.totalCount.textContent = atlas.geojson.features.length;
elements.visibleCount.textContent = features.length;
elements.unescoCount.textContent = features.filter((feature) => feature.properties.unesco).length;
}
function renderAtlas() {
const features = getVisibleFeatures();
updateStats(features);
renderMarkers(features);
renderSiteList(features);
renderInfoPanel(features);
}
function chooseRandomSite() {
const features = getVisibleFeatures();
if (!features.length) {
return;
}
const index = Math.floor(Math.random() * features.length);
selectFeature(features[index].properties.id, true);
}
function resetMap() {
atlas.search = '';
atlas.unescoOnly = false;
elements.searchInput.value = '';
elements.unescoOnly.checked = false;
setRegion('world');
renderAtlas();
}
function initAtlas() {
buildLayerControls();
drawGraticule();
drawSimpleContinents();
setRegion('world');
atlas.selectedId = 'acropolis-athens';
elements.searchInput.addEventListener('input', () => {
atlas.search = elements.searchInput.value.trim().toLowerCase();
renderAtlas();
});
elements.unescoOnly.addEventListener('change', () => {
atlas.unescoOnly = elements.unescoOnly.checked;
renderAtlas();
});
elements.resetButton.addEventListener('click', resetMap);
elements.randomButton.addEventListener('click', chooseRandomSite);
document.querySelectorAll('[data-region]').forEach((button) => {
button.addEventListener('click', () => setRegion(button.dataset.region));
});
renderAtlas();
}
initAtlas();