-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnoaa_mbtiles.py
More file actions
executable file
·30 lines (24 loc) · 1.03 KB
/
noaa_mbtiles.py
File metadata and controls
executable file
·30 lines (24 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/python
"""Script to process the NOAA JSON MBtiles catalog and convert it to the XML catalog format
Part of the ChartCatalogs project
Copyright (c) 2019 Pavel Kalian
Licensed under GPLv2 or, at yoir will later version
"""
import sys
from ChartCatalogs import Chart, RncChartCatalog
from datetime import datetime
import dateutil.parser
import json
catalog = RncChartCatalog()
catalog.title = 'NOAA Raster Charts MBTiles'
with open(sys.argv[1]) as f:
data = json.load(f)
for tileset in data['quilted_tilesets']:
chart = Chart()
chart.chart_format = 'Sailing Chart, International Chart'
chart.url = "https:%s" % data['quilted_tilesets'][tileset]['url']
chart.number = data['quilted_tilesets'][tileset]['name'][-2:]
chart.title = "%s [%i MB]" % (data['quilted_tilesets'][tileset]['description'], data['quilted_tilesets'][tileset]['size'])
chart.zipfile_ts = dateutil.parser.parse(data['quilted_tilesets'][tileset]['updated'])
catalog.add_chart(chart)
catalog.print_xml(True)