Add master data center merge workflow

This commit is contained in:
2026-05-17 18:53:16 -07:00
parent 8fcbb18e37
commit 90e8b21423
10 changed files with 11892 additions and 9599 deletions

View File

@@ -10,7 +10,7 @@ import psycopg2
DB_NAME = "data_centers"
DC_TABLE = "public.us_dc_sample_geocoded"
DC_TABLE = "public.master_data_centers"
CABLES_TABLE = "public.internet_cables"
CITY_TABLE = "public.internet_city_dominance"
@@ -30,14 +30,14 @@ def load_data_centers(conn):
cur.execute(
f"""
select
id,
coalesce(provider, ''),
coalesce(facility_name, ''),
master_id,
source,
coalesce(operator, ''),
coalesce(name, ''),
coalesce(city, ''),
coalesce(state_code, ''),
coalesce(state, ''),
longitude,
latitude,
coalesce(geocode_source, '')
latitude
from {DC_TABLE}
where longitude is not null and latitude is not null
"""
@@ -45,13 +45,13 @@ def load_data_centers(conn):
return [
{
"id": r[0],
"provider": r[1],
"facility_name": r[2],
"city": r[3],
"state_code": r[4],
"lon": float(r[5]),
"lat": float(r[6]),
"geocode_source": r[7],
"source": r[1],
"operator": r[2],
"name": r[3],
"city": r[4],
"state": r[5],
"lon": float(r[6]),
"lat": float(r[7]),
}
for r in cur.fetchall()
]
@@ -181,10 +181,10 @@ def render_html(data_centers, cables_geojson, cities, output_path):
<label class="toggle"><input type="checkbox" id="tCities" checked> City dominance</label>
<h2>Data center source</h2>
<div class="row"><span><span class="swatch" style="background:#1f77b4"></span>IM3_Existing_DataCenters</span></div>
<div class="row"><span><span class="swatch" style="background:#2ca02c"></span>US Census Geocoder</span></div>
<div class="row"><span><span class="swatch" style="background:#ff7f0e"></span>Nominatim/OpenStreetMap</span></div>
<div class="row"><span><span class="swatch" style="background:#7f7f7f"></span>Other</span></div>
<div class="row"><span><span class="swatch" style="background:#2ca02c"></span>merged (curated + OSM)</span></div>
<div class="row"><span><span class="swatch" style="background:#1f77b4"></span>curated only</span></div>
<div class="row"><span><span class="swatch" style="background:#ff7f0e"></span>osm only</span></div>
<div class="row"><span><span class="swatch" style="background:#7f7f7f"></span>other</span></div>
<h2>City dominance</h2>
<div class="row"><span><span class="swatch" style="background:#9b59b6;border-radius:50%"></span>Sized by physical Tbps</span></div>
@@ -197,9 +197,9 @@ def render_html(data_centers, cables_geojson, cities, output_path):
const DATA = __PAYLOAD__;
function colorForSource(source) {
if (source === 'IM3_Existing_DataCenters') return '#1f77b4';
if (source === 'US Census Geocoder') return '#2ca02c';
if (source === 'Nominatim/OpenStreetMap') return '#ff7f0e';
if (source === 'merged') return '#2ca02c';
if (source === 'curated') return '#1f77b4';
if (source === 'osm') return '#ff7f0e';
return '#7f7f7f';
}
@@ -262,19 +262,19 @@ def render_html(data_centers, cables_geojson, cities, output_path):
for (const p of DATA.data_centers) {
const m = L.circleMarker([p.lat, p.lon], {
radius: 3,
color: colorForSource(p.geocode_source),
fillColor: colorForSource(p.geocode_source),
color: colorForSource(p.source),
fillColor: colorForSource(p.source),
fillOpacity: 0.85,
weight: 0.8,
});
const title = p.facility_name || p.id;
const provider = p.provider || '(unknown provider)';
const cityState = [p.city, p.state_code].filter(Boolean).join(', ');
const title = p.name || p.id;
const operator = p.operator || '(unknown operator)';
const cityState = [p.city, p.state].filter(Boolean).join(', ');
m.bindPopup(`
<strong>${esc(title)}</strong><br>
Provider: ${esc(provider)}<br>
Operator: ${esc(operator)}<br>
Location: ${esc(cityState)}<br>
Source: ${esc(p.geocode_source)}
Source: ${esc(p.source)}
`);
dcLayer.addLayer(m);
dcBounds.push([p.lat, p.lon]);