Open Infrastructure Map, a view of infrastructure data in OpenStreetMap
Under construction power plants
Russ Garrett0aefdc5fe55f
diff --git a/main.py b/main.pyindex a158d08..0948f85 100644--- a/main.py+++ b/main.py@@ -151,4 +151,36 @@ async def plants_country(request, country):)[email protected]("/stats/area/{country}/plants/construction")+@country_required+@cache_for(3600)+async def plants_construction_country(request, country):+ gid = country[0]++ plants = await database.fetch_all(+ query="""SELECT osm_id, name, tags->'name:en' AS name_en, tags->'wikidata' AS wikidata,+ tags->'plant:method' AS method, tags->'operator' AS operator,+ tags->'start_date' AS start_date,+ convert_power(output) AS output,+ source, ST_GeometryType(geometry) AS geom_type+ FROM power_plant+ WHERE ST_Contains(+ (SELECT ST_Transform(geom, 3857) FROM countries.country_eez WHERE gid = :gid),+ geometry)+ AND tags -> 'construction:power' IS NOT NULL+ ORDER BY convert_power(output) DESC NULLS LAST, name ASC NULLS LAST """,+ values={"gid": gid},+ )++ return templates.TemplateResponse(+ "plants_country.html",+ {+ "construction": True,+ "request": request,+ "plants": plants,+ "country": country["union"],+ },+ )++import wikidata # noqadiff --git a/templates/country.html b/templates/country.htmlindex 6be7462..7a49bcf 100644--- a/templates/country.html+++ b/templates/country.html@@ -42,6 +42,7 @@ Statistics on the electricity network in {{country|country_name}} from OpenStree</table><p class="footnote">If multiple sources are listed for a power plant, only the first source is used in this breakdown.</p></div>+ <p><a href="{{url_for('plants_construction_country', country=country)}}">Show plants under construction</a></p>{% if power_lines.total > 1 %}{{ tables.power_lines_table(power_lines) }}{% endif %}diff --git a/templates/plants_country.html b/templates/plants_country.htmlindex 411f4a6..2ffdbda 100644--- a/templates/plants_country.html+++ b/templates/plants_country.html@@ -5,9 +5,9 @@{% elif source %}{% set pretty_source = source|replace("_"," ") %}{% endif %}-{% block title %}{{country}}{% if pretty_source %} {{pretty_source|title}}{% endif %} Power Plants{% endblock %}+{% block title %}{{country}}{% if pretty_source %} {{pretty_source|title}}{% endif %} Power Plants{% if construction%} under construction{% endif %}{% endblock %}{% block description -%}- List of{% if pretty_source%} {{pretty_source}}{% endif %} power plants in {{country|country_name}} from OpenStreetMap+ List of{% if pretty_source%} {{pretty_source}}{% endif %} power plants{% if construction %} under construction{% endif %} in {{country|country_name}} from OpenStreetMap{%- endblock %}{% block content -%}@@ -17,10 +17,16 @@{% endif %}{% if plants|length == 0 %}- <p>There are currently no power plants mapped in {{country|country_name}} on OpenStreetMap.</p>+ <p>There are currently no power plants+ {% if construction %}under construction{% endif %}+ mapped in {{country|country_name}} on OpenStreetMap.+ </p>{% else %}<table class="plants-table table-full-width">- <caption>All {{plants|length}} {% if pretty_source %}{{pretty_source}} {% endif %}power plants in {{country|country_name}}</caption>+ <caption>All {{plants|length}} {% if pretty_source %}{{pretty_source}} {% endif %}+ power plants+ {% if construction %}under construction{% endif %}+ in {{country|country_name}}</caption><thead><tr><th style="width: 300px">Name</th>@@ -33,6 +39,9 @@<th>Source</th>{% endif %}<th>Method</th>+ {% if construction %}+ <th>Completion Date</th>+ {% endif %}<th style="width: 100px">Wikidata</th></tr></thead>@@ -50,6 +59,9 @@<td>{{plant.source}}</td>{% endif %}<td>{{plant.method or ''}}</td>+ {% if construction %}+ <td>{{plant.start_date or ''}}</td>+ {% endif %}<td>{% if plant.wikidata %}<a href="https://www.wikidata.org/wiki/{{plant.wikidata}}" target="_blank">{{plant.wikidata}}</a>