Skip to content

Commit

Permalink
metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperknot committed Dec 27, 2023
1 parent a49d276 commit b5d6f5c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
31 changes: 24 additions & 7 deletions scripts/tile_gen/extract_mbtiles/extract_mbtiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sqlite3
import sys
from pathlib import Path
from pprint import pprint

import click

Expand Down Expand Up @@ -38,18 +39,34 @@ def cli(mbtiles_path: Path, dir_path: Path):
# assert_all_tiles_present(mbtiles_path, dir_path)

write_metadata(c, dir_path=dir_path)
conn.commit()

print('extract_mbtiles.py DONE')


def write_metadata(c, *, dir_path):
metadata = dict(c.execute('select name, value from metadata').fetchall())
metadata['name'] = 'OpenFreeMap'
metadata['description'] = 'https://openfreemap.org/'
metadata['attribution'] = (
'<a href="https://openfreemap.org/" target="_blank">OpenFreeMap</a> '
+ metadata['attribution']
)
json.dump(metadata, open(dir_path / 'metadata.json', 'w'), indent=2)
c.execute("update metadata set value='OpenFreeMap' where name='name'")
c.execute("update metadata set value='https://openfreemap.org' where name='description'")

if 'openfreemap' not in metadata['attribution']:
attr_str = (
'<a href="https://openfreemap.org/" target="_blank">OpenFreeMap</a> '
+ metadata['attribution']
)
c.execute("UPDATE metadata SET value = ? WHERE name = 'attribution'", (attr_str,))

if 'osm_date' not in metadata:
if 'planetiler:osm:osmosisreplicationtime' in metadata:
osm_date = metadata['planetiler:osm:osmosisreplicationtime'][:10]
c.execute('INSERT INTO metadata (name, value) VALUES (?, ?)', ('osm_date', osm_date))

metadata = dict(c.execute('select name, value from metadata').fetchall())
with open(dir_path / 'metadata.json', 'w') as fp:
json.dump(metadata, fp, indent=2)

with open(dir_path / 'osm_date', 'w') as fp:
fp.write(metadata['osm_date'])


def write_dedupl_files(c, *, dir_path):
Expand Down
5 changes: 3 additions & 2 deletions scripts/tile_gen/extract_mbtiles/out/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"bounds": "7.40921,43.72335,7.44864,43.75169",
"json": "{\"vector_layers\":[{\"id\":\"aeroway\",\"fields\":{\"ref\":\"String\",\"class\":\"String\"},\"minzoom\":12,\"maxzoom\":14},{\"id\":\"boundary\",\"fields\":{\"disputed\":\"Number\",\"admin_level\":\"Number\",\"maritime\":\"Number\"},\"minzoom\":0,\"maxzoom\":14},{\"id\":\"building\",\"fields\":{\"colour\":\"String\",\"render_height\":\"Number\",\"render_min_height\":\"Number\"},\"minzoom\":13,\"maxzoom\":14},{\"id\":\"housenumber\",\"fields\":{\"housenumber\":\"String\"},\"minzoom\":14,\"maxzoom\":14},{\"id\":\"landcover\",\"fields\":{\"subclass\":\"String\",\"class\":\"String\",\"_numpoints\":\"Number\"},\"minzoom\":13,\"maxzoom\":14},{\"id\":\"landuse\",\"fields\":{\"class\":\"String\"},\"minzoom\":6,\"maxzoom\":14},{\"id\":\"mountain_peak\",\"fields\":{\"rank\":\"Number\",\"class\":\"String\"},\"minzoom\":13,\"maxzoom\":14},{\"id\":\"park\",\"fields\":{\"name_int\":\"String\",\"name:ar\":\"String\",\"name:de\":\"String\",\"name_de\":\"String\",\"name:it\":\"String\",\"name\":\"String\",\"name:fr\":\"String\",\"name:en\":\"String\",\"name:eo\":\"String\",\"name:eu\":\"String\",\"class\":\"String\",\"name:zh\":\"String\",\"name:es\":\"String\",\"name_en\":\"String\",\"name:latin\":\"String\"},\"minzoom\":13,\"maxzoom\":14},{\"id\":\"place\",\"fields\":{\"name:fy\":\"String\",\"name_int\":\"String\",\"name:oc\":\"String\",\"name:bs\":\"String\",\"capital\":\"Number\",\"name:sk\":\"String\",\"name:ka\":\"String\",\"name:sl\":\"String\",\"name:ga\":\"String\",\"name:sr\":\"String\",\"name:kk\":\"String\",\"name:gd\":\"String\",\"name:sq\":\"String\",\"name:ca\":\"String\",\"name:kn\":\"String\",\"name:sv\":\"String\",\"name:ko\":\"String\",\"name_de\":\"String\",\"rank\":\"Number\",\"name:co\":\"String\",\"name:ku\":\"String\",\"name:cs\":\"String\",\"name:ta\":\"String\",\"name:latin\":\"String\",\"name:ar\":\"String\",\"name:ja\":\"String\",\"name:rm\":\"String\",\"name:az\":\"String\",\"name:ro\":\"String\",\"name:nl\":\"String\",\"name:fi\":\"String\",\"name:be\":\"String\",\"name:ru\":\"String\",\"name:no\":\"String\",\"name:bg\":\"String\",\"name\":\"String\",\"name:fr\":\"String\",\"name:br\":\"String\",\"name:hy\":\"String\",\"name:uk\":\"String\",\"name:id\":\"String\",\"name:ml\":\"String\",\"name:mk\":\"String\",\"name:mt\":\"String\",\"name:el\":\"String\",\"name:it\":\"String\",\"name:am\":\"String\",\"name:en\":\"String\",\"name:is\":\"String\",\"name:eo\":\"String\",\"name:et\":\"String\",\"name:eu\":\"String\",\"class\":\"String\",\"iso_a2\":\"String\",\"name:zh\":\"String\",\"name:es\":\"String\",\"name:th\":\"String\",\"name:te\":\"String\",\"name:la\":\"String\",\"name:lb\":\"String\",\"name:cy\":\"String\",\"name:pl\":\"String\",\"name:he\":\"String\",\"name:da\":\"String\",\"name:tr\":\"String\",\"name:pt\":\"String\",\"name:hi\":\"String\",\"name:de\":\"String\",\"name:lt\":\"String\",\"name:lv\":\"String\",\"name:hr\":\"String\",\"name:hu\":\"String\",\"name_en\":\"String\"},\"minzoom\":2,\"maxzoom\":14},{\"id\":\"poi\",\"fields\":{\"name:oc\":\"String\",\"name_int\":\"String\",\"name:sk\":\"String\",\"name:ka\":\"String\",\"name:sl\":\"String\",\"name:ga\":\"String\",\"name:sr\":\"String\",\"name:kk\":\"String\",\"name:sq\":\"String\",\"name:ca\":\"String\",\"name:sv\":\"String\",\"name:ko\":\"String\",\"name_de\":\"String\",\"name:co\":\"String\",\"name:ku\":\"String\",\"name:cs\":\"String\",\"name:latin\":\"String\",\"name:ar\":\"String\",\"name:ja\":\"String\",\"level\":\"Number\",\"name:rm\":\"String\",\"name:az\":\"String\",\"name:ro\":\"String\",\"name:nl\":\"String\",\"name:be\":\"String\",\"name:ru\":\"String\",\"name:fi\":\"String\",\"name\":\"String\",\"indoor\":\"Number\",\"name:fr\":\"String\",\"name:br\":\"String\",\"name:hy\":\"String\",\"name:uk\":\"String\",\"name:id\":\"String\",\"layer\":\"Number\",\"name:mk\":\"String\",\"name:el\":\"String\",\"name:it\":\"String\",\"name:en\":\"String\",\"name:eo\":\"String\",\"name:et\":\"String\",\"name:eu\":\"String\",\"class\":\"String\",\"name:zh\":\"String\",\"name:es\":\"String\",\"name:th\":\"String\",\"name:lb\":\"String\",\"name:cy\":\"String\",\"name:pl\":\"String\",\"name:da\":\"String\",\"name:he\":\"String\",\"name:tr\":\"String\",\"name:pt\":\"String\",\"name:de\":\"String\",\"name:lt\":\"String\",\"subclass\":\"String\",\"name:lv\":\"String\",\"name:hr\":\"String\",\"name:hu\":\"String\",\"name_en\":\"String\"},\"minzoom\":12,\"maxzoom\":14},{\"id\":\"transportation\",\"fields\":{\"brunnel\":\"String\",\"access\":\"String\",\"surface\":\"String\",\"bicycle\":\"String\",\"level\":\"Number\",\"ramp\":\"Number\",\"oneway\":\"Number\",\"layer\":\"Number\",\"horse\":\"String\",\"service\":\"String\",\"subclass\":\"String\",\"indoor\":\"Number\",\"class\":\"String\",\"foot\":\"String\"},\"minzoom\":7,\"maxzoom\":14},{\"id\":\"transportation_name\",\"fields\":{\"name_int\":\"String\",\"level\":\"Number\",\"route_2\":\"String\",\"route_1\":\"String\",\"layer\":\"Number\",\"network\":\"String\",\"ref\":\"String\",\"name_de\":\"String\",\"ref_length\":\"Number\",\"subclass\":\"String\",\"name\":\"String\",\"indoor\":\"Number\",\"class\":\"String\",\"name_en\":\"String\",\"name:latin\":\"String\"},\"minzoom\":12,\"maxzoom\":14},{\"id\":\"water\",\"fields\":{\"intermittent\":\"Number\",\"id\":\"Number\",\"class\":\"String\"},\"minzoom\":0,\"maxzoom\":14},{\"id\":\"water_name\",\"fields\":{\"name_int\":\"String\",\"name_de\":\"String\",\"name\":\"String\",\"intermittent\":\"Number\",\"name:en\":\"String\",\"class\":\"String\",\"name_en\":\"String\",\"name:latin\":\"String\"},\"minzoom\":14,\"maxzoom\":14},{\"id\":\"waterway\",\"fields\":{\"brunnel\":\"String\",\"intermittent\":\"Number\",\"class\":\"String\"},\"minzoom\":4,\"maxzoom\":14}]}",
"name": "OpenFreeMap",
"description": "https://openfreemap.org/",
"description": "https://openfreemap.org",
"attribution": "<a href=\"https://openfreemap.org/\" target=\"_blank\">OpenFreeMap</a> <a href=\"https://www.openmaptiles.org/\" target=\"_blank\">&copy; OpenMapTiles</a> <a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\">&copy; OpenStreetMap contributors</a>",
"version": "3.14.0",
"type": "baselayer",
Expand All @@ -16,5 +16,6 @@
"planetiler:buildtime": "2023-10-01T17:00:31.116Z",
"planetiler:osm:osmosisreplicationtime": "2023-12-07T21:21:32Z",
"planetiler:osm:osmosisreplicationseq": "3900",
"planetiler:osm:osmosisreplicationurl": "http://download.geofabrik.de/europe/monaco-updates"
"planetiler:osm:osmosisreplicationurl": "http://download.geofabrik.de/europe/monaco-updates",
"osm_date": "2023-12-07"
}
1 change: 1 addition & 0 deletions scripts/tile_gen/extract_mbtiles/out/osm_date
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023-12-07

0 comments on commit b5d6f5c

Please sign in to comment.