Skip to content

Commit

Permalink
Merge pull request #174 from hotosm/enhance/metadata_exports
Browse files Browse the repository at this point in the history
Dump export metadata to .zip file
  • Loading branch information
kshitijrajsharma authored Nov 21, 2023
2 parents 91d11dc + be2e432 commit e21154e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions API/api_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import shutil
import time
import zipfile
from datetime import datetime
from datetime import datetime as dt
from datetime import timezone

import requests
from celery import Celery
Expand Down Expand Up @@ -70,6 +72,15 @@ def process_raw_data(self, params):
# Compressing geojson file
zf.writestr("clipping_boundary.geojson", geom_dump)

utc_now = datetime.now(timezone.utc)
utc_offset = utc_now.strftime("%z")
# Adding metadata readme.txt
readme_content = f"Exported Timestamp (UTC{utc_offset}): {utc_now.strftime('%Y-%m-%d %H:%M:%S')}\n"
readme_content += "Exported through Raw-data-api (https://github.com/hotosm/raw-data-api) using OpenStreetMap data.\n"
readme_content += "Learn more about OpenStreetMap and its data usage policy : https://www.openstreetmap.org/about"

zf.writestr("Readme.txt", readme_content)

zf.close()
logging.debug("Zip Binding Done !")
else:
Expand Down

0 comments on commit e21154e

Please sign in to comment.