nfc-web/web/plugins/geohash/geohash.py
2023-04-30 14:08:32 +03:00

12 lines
No EOL
506 B
Python

from pelican import signals
import geohash_tools as gh
def generate_geohash(generator):
for article in generator.articles:
if "location" in article.metadata:
lat, lon = [float(i) for i in article.metadata['location'].replace(' ', '').split(',')]
article.metadata['latlon'] = article.metadata['location'].replace(' ', '')
article.metadata['geohash'] = gh.encode(lat, lon, 11)
def register():
signals.article_generator_finalized.connect(generate_geohash)