mirror of
https://github.com/tomasriveral/ReSSPublica.git
synced 2026-08-11 18:28:38 +02:00
feat: add count in bernReligionMap
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{"_default": {"1": {"date": "2026-01-01", "religionCount": {"1-1": 270, "1-2": 2, "1-3": 1, "1-4": 11, "1-5": 73, "1-6": 4, "1-7": 4, "1-8": 3, "1-9": 186, "1-10": 10, "1-11": 26, "2-12": 16, "2-13": 1, "2-14": 2, "3-15": 3, "3-16": 9, "3-17": 7, "3-18": 3, "4-0": 8, "5-0": 2, "6-0": 2, "7-0": 1, "8-0": 2, "9-0": 2}}}}
|
||||
@@ -2,7 +2,7 @@
|
||||
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
|
||||
<id>https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/feed/atom/de/gotteshauserNachReligionImKantonBern</id>
|
||||
<title>Gotteshäuser nach Religion im Kanton Bern</title>
|
||||
<updated>2026-06-18T14:56:22.734774+02:00</updated>
|
||||
<updated>2026-06-18T18:06:22.013240+02:00</updated>
|
||||
<author>
|
||||
<name>ReSSPublica</name>
|
||||
</author>
|
||||
@@ -13,7 +13,7 @@
|
||||
<id>1767265200.0</id>
|
||||
<title>Gotteshäuser nach Religion im Kanton Bern-2026-01-01</title>
|
||||
<updated>2026-01-01T00:00:00+01:00</updated>
|
||||
<content type="html"><img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-de-2026-01-01-2026-04-30.png" alt="Gotteshäuser nach Religion im Kanton Bern 2026-01-01"></content>
|
||||
<content type="html"><img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-de-2026-01-01-2026-04-30.png" alt="Gotteshäuser nach Religion im Kanton Bern 2026-01-01">evangelisch-reformiert (christlich): 270<br>lutherisch (christlich): 2<br>anglikanisch (christlich): 1<br>evangelische Migrationskirche (christlich): 11<br>römisch-katholisch (christlich): 73<br>christkatholisch (christlich): 4<br>orthodox (christlich): 4<br>orientalisch-orthodox (christlich): 3<br>freikirchlich (christlich): 186<br>mennonitisch (christlich): 10<br>christlich, weitere (christlich): 26<br>sunnitisch (islamisch): 16<br>schiitisch (islamisch): 1<br>islamisch, weitere (islamisch): 2<br>Theravada (buddhistisch): 3<br>Mahayana (buddhistisch): 9<br>Vajrayana (buddhistisch): 7<br>buddhistisch, weitere (buddhistisch): 3<br>hinduistisch: 8<br>jüdisch: 2<br>alevitisch: 2<br>Sikh: 1<br>Bahai: 2<br>weitere: 2<br></content>
|
||||
<published>2026-01-01T00:00:00+01:00</published>
|
||||
</entry>
|
||||
</feed>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
|
||||
<id>https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/feed/atom/fr/lieuDeCulteParReligionDansLeCantonDeBerne</id>
|
||||
<title>Lieu de culte par religion dans le canton de Berne</title>
|
||||
<updated>2026-06-18T14:56:22.733812+02:00</updated>
|
||||
<updated>2026-06-18T18:06:22.012315+02:00</updated>
|
||||
<author>
|
||||
<name>ReSSPublica</name>
|
||||
</author>
|
||||
@@ -13,7 +13,7 @@
|
||||
<id>1767265200.0</id>
|
||||
<title>Lieu de culte par religion dans le canton de Berne-2026-01-01</title>
|
||||
<updated>2026-01-01T00:00:00+01:00</updated>
|
||||
<content type="html"><img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-fr-2026-01-01-2026-04-30.png" alt="Lieu de culte par religion dans le canton de Berne 2026-01-01"></content>
|
||||
<content type="html"><img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-fr-2026-01-01-2026-04-30.png" alt="Lieu de culte par religion dans le canton de Berne 2026-01-01">réformé évangélique (Christianisme): 270<br>luthérien (Christianisme): 2<br>anglican (Christianisme): 1<br>évangélique, église de la migration (Christianisme): 11<br>catholique romain (Christianisme): 73<br>catholique chrétien (Christianisme): 4<br>orthodoxe (Christianisme): 4<br>orthodoxe oriental (Christianisme): 3<br>église libre (Christianisme): 186<br>mennonite (Christianisme): 10<br>autre (Christianisme): 26<br>sunnite (Islam): 16<br>chiite (Islam): 1<br>autre (Islam): 2<br>theravada (Bouddhisme ): 3<br>mahayana (Bouddhisme ): 9<br>vajrayana (Bouddhisme ): 7<br>autre (Bouddhisme ): 3<br>Hindouisme: 8<br>Judaïsme: 2<br>Alévisme: 2<br>Sikhisme: 1<br>Bahaïsme: 2<br>Autre tradition: 2<br></content>
|
||||
<published>2026-01-01T00:00:00+01:00</published>
|
||||
</entry>
|
||||
</feed>
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
<docs>https://github.com/tomasriveral/ReSSPublica</docs>
|
||||
<generator>python-feedgen</generator>
|
||||
<language>de</language>
|
||||
<lastBuildDate>Thu, 18 Jun 2026 14:56:22 +0200</lastBuildDate>
|
||||
<lastBuildDate>Thu, 18 Jun 2026 18:06:22 +0200</lastBuildDate>
|
||||
<item>
|
||||
<title>Gotteshäuser nach Religion im Kanton Bern-2026-01-01</title>
|
||||
<description><img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-de-2026-01-01-2026-04-30.png" alt="Gotteshäuser nach Religion im Kanton Bern 2026-01-01"></description>
|
||||
<description><img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-de-2026-01-01-2026-04-30.png" alt="Gotteshäuser nach Religion im Kanton Bern 2026-01-01">evangelisch-reformiert (christlich): 270<br>lutherisch (christlich): 2<br>anglikanisch (christlich): 1<br>evangelische Migrationskirche (christlich): 11<br>römisch-katholisch (christlich): 73<br>christkatholisch (christlich): 4<br>orthodox (christlich): 4<br>orientalisch-orthodox (christlich): 3<br>freikirchlich (christlich): 186<br>mennonitisch (christlich): 10<br>christlich, weitere (christlich): 26<br>sunnitisch (islamisch): 16<br>schiitisch (islamisch): 1<br>islamisch, weitere (islamisch): 2<br>Theravada (buddhistisch): 3<br>Mahayana (buddhistisch): 9<br>Vajrayana (buddhistisch): 7<br>buddhistisch, weitere (buddhistisch): 3<br>hinduistisch: 8<br>jüdisch: 2<br>alevitisch: 2<br>Sikh: 1<br>Bahai: 2<br>weitere: 2<br></description>
|
||||
<guid isPermaLink="false">1767265200.0</guid>
|
||||
<pubDate>Thu, 01 Jan 2026 00:00:00 +0100</pubDate>
|
||||
</item>
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
<docs>https://github.com/tomasriveral/ReSSPublica</docs>
|
||||
<generator>python-feedgen</generator>
|
||||
<language>fr</language>
|
||||
<lastBuildDate>Thu, 18 Jun 2026 14:56:22 +0200</lastBuildDate>
|
||||
<lastBuildDate>Thu, 18 Jun 2026 18:06:22 +0200</lastBuildDate>
|
||||
<item>
|
||||
<title>Lieu de culte par religion dans le canton de Berne-2026-01-01</title>
|
||||
<description><img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-fr-2026-01-01-2026-04-30.png" alt="Lieu de culte par religion dans le canton de Berne 2026-01-01"></description>
|
||||
<description><img src="https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-fr-2026-01-01-2026-04-30.png" alt="Lieu de culte par religion dans le canton de Berne 2026-01-01">réformé évangélique (Christianisme): 270<br>luthérien (Christianisme): 2<br>anglican (Christianisme): 1<br>évangélique, église de la migration (Christianisme): 11<br>catholique romain (Christianisme): 73<br>catholique chrétien (Christianisme): 4<br>orthodoxe (Christianisme): 4<br>orthodoxe oriental (Christianisme): 3<br>église libre (Christianisme): 186<br>mennonite (Christianisme): 10<br>autre (Christianisme): 26<br>sunnite (Islam): 16<br>chiite (Islam): 1<br>autre (Islam): 2<br>theravada (Bouddhisme ): 3<br>mahayana (Bouddhisme ): 9<br>vajrayana (Bouddhisme ): 7<br>autre (Bouddhisme ): 3<br>Hindouisme: 8<br>Judaïsme: 2<br>Alévisme: 2<br>Sikhisme: 1<br>Bahaïsme: 2<br>Autre tradition: 2<br></description>
|
||||
<guid isPermaLink="false">1767265200.0</guid>
|
||||
<pubDate>Thu, 01 Jan 2026 00:00:00 +0100</pubDate>
|
||||
</item>
|
||||
|
||||
@@ -28,12 +28,6 @@ def generateBernReligionMap(ASSETS, CACHE):
|
||||
|
||||
logger.info("Generating Religion map in Bern feed...")
|
||||
logger.info("Preparing data...")
|
||||
#ASIAN_HORNETS_DB_PATH = CACHE / "bernAsianHornet.json"
|
||||
#global db
|
||||
#global q
|
||||
#db = TinyDB(ASIAN_HORNETS_DB_PATH)
|
||||
#q = Query()
|
||||
|
||||
|
||||
# 1. Load data
|
||||
url = "https://geofiles.be.ch/geoportal/pub/download/RELIGION/religion_relstaet.parquet"
|
||||
@@ -101,6 +95,40 @@ def generateBernReligionMap(ASSETS, CACHE):
|
||||
)
|
||||
logger.debug(religions)
|
||||
|
||||
# we generate the count by each religion and store it in a database to log changes.
|
||||
|
||||
BERN_RELIGION_MAP_DB_PATH = CACHE / "bernReligionMapByReligionCount.json"
|
||||
|
||||
db = TinyDB(BERN_RELIGION_MAP_DB_PATH)
|
||||
q = Query()
|
||||
|
||||
|
||||
for start, end in trimesterRangesFrom(arbitraryStartDate):
|
||||
if db.contains(q.date == start.isoformat()):
|
||||
continue # we already calculated the entry for this date. We skip it.
|
||||
dbEntry = {
|
||||
"date": start.isoformat(),
|
||||
"religionCount": {}
|
||||
}
|
||||
# initialize with default values
|
||||
for religionID in religions.keys():
|
||||
dbEntry["religionCount"][str(religionID)] = 0
|
||||
# count
|
||||
for placeOfWorship in religionGeoDataFrame.itertuples():
|
||||
# again we must check against religions that don't have nkenn information
|
||||
try:
|
||||
placeOfWorship.nkenn_id
|
||||
dbEntry["religionCount"][f"{placeOfWorship.reltra_id}-{str(placeOfWorship.nkenn_id).split(".")[0]}"] += 1
|
||||
except:
|
||||
dbEntry["religionCount"][f"{placeOfWorship.reltra_id}-0"] += 1
|
||||
logger.info("Religion Count")
|
||||
logger.info(dbEntry["religionCount"])
|
||||
|
||||
db.upsert(dbEntry, q.date == start.isoformat())
|
||||
|
||||
|
||||
# we generate the map(s) now
|
||||
|
||||
# generate color palette (1 color by religion with similar religion similar color)
|
||||
palette = color_palette("husl", len(religions.keys()))
|
||||
color_map = {
|
||||
@@ -248,10 +276,19 @@ def generateBernReligionMap(ASSETS, CACHE):
|
||||
trimestrialEntry["date"] = start.isoformat() # there is no point have them different. On other feeds it's used for update date
|
||||
trimestrialEntry["source"] = "opendata.swiss"
|
||||
|
||||
countDataBase = db.get(q.date == start.isoformat())["religionCount"]
|
||||
|
||||
for lang in ["fr", "de"]:
|
||||
trimestrialEntry["url"] = f"https://opendata.swiss/{lang}/dataset/religionslandkarte"
|
||||
trimestrialEntry["title"] = f"{translatedPlacesOfWorshipInBern[lang]}-{start.isoformat()}"
|
||||
trimestrialEntry["text"] = f"<img src=\"https://raw.githubusercontent.com/tomasriveral/ReSSPublica/refs/heads/main/.cache/bernReligionMap-{lang}-{start.isoformat()}-{end.isoformat()}.png\" alt=\"{translatedPlacesOfWorshipInBern[lang]} {start.isoformat()}\">"
|
||||
|
||||
for religionID in religions.keys():
|
||||
|
||||
if religionID[2] == "0": # that means there is no nkenn
|
||||
trimestrialEntry["text"] += f"{religions[religionID][f"reltrat_reltra_{lang}"]}: {countDataBase[religionID]}<br>"
|
||||
else:
|
||||
trimestrialEntry["text"] += f"{religions[religionID][f"nkennt_nkenn_{lang}"]} ({religions[religionID][f"reltrat_reltra_{lang}"]}): {countDataBase[religionID]}<br>"
|
||||
feeds[lang].append(copy.deepcopy(trimestrialEntry))
|
||||
generateFeed(
|
||||
translatedPlacesOfWorshipInBern["fr"],
|
||||
|
||||
Reference in New Issue
Block a user