Skip to content

Commit

Permalink
vec tiles file generation script created
Browse files Browse the repository at this point in the history
  • Loading branch information
kauevestena committed Jan 17, 2024
1 parent fde9714 commit 38a830e
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 12 deletions.
15 changes: 8 additions & 7 deletions constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@
boundaries_md_path = "./data/boundaries_md.json"
workflows_path = '.github/workflows'

# folderpaths:
# data folderpaths:
improper_geoms_folderpath = 'data/improper_geoms'
disjointed_folderpath = 'data/disjointed'
versioning_folderpath = 'data/versioning'
other_footways_folderpath = 'data/other_footways'
tiles_folderpath = 'data/tiles'

other_footways_subcatecories = {
'stairways' : {'highway':['steps']},
'main' : {'highway':['footway','living_street'],'foot':['designated'],'footway': ['alley','path','yes']},
'potential' : {'highway':['path','track']},
'informal' : {'foot':['yes','permissive']},
'main_footways' : {'highway':['footway','living_street'],'foot':['designated'],'footway': ['alley','path','yes']},
'potential_footways' : {'highway':['path','track']},
'informal_footways' : {'foot':['yes','permissive']},
'pedestrian_areas' : {} #defined only by geometry type (Polygon,Multipolygon)
}

Expand Down Expand Up @@ -80,7 +81,7 @@
valid_values_path = 'quality_check/valid_tag_values.json'

# node homepage:
user_basepage_url = f'https://{USERNAME}.github.io/'.astype('string')
user_basepage_url = f'https://{USERNAME}.github.io/'
node_homepage_url = f'https://{USERNAME}.github.io/{REPO_NAME}/'
data_updating_url = f'https://{USERNAME}.github.io/{REPO_NAME}/data/data_updating.html'

Expand Down Expand Up @@ -117,8 +118,8 @@
# paths for other_footways subcategories:
for subcategory in other_footways_subcatecories:
subcategory_path = os.path.join(other_footways_folderpath, subcategory+data_format)
paths_dict['other_footways_subcategories'][subcategory] = subcategory
paths_dict['map_layers'][subcategory] = subcategory
paths_dict['other_footways_subcategories'][subcategory] = subcategory_path
paths_dict['map_layers'][subcategory] = subcategory_path


# max radius to cut off unconnected crossings and kerbs
Expand Down
2 changes: 0 additions & 2 deletions data_quality/check_wiki_keys.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import sys
sys.path.append('oswm_codebase')
from functions import *
# from constants import *


tags_dict = read_json('quality_check/feature_keys.json')

Expand Down
22 changes: 22 additions & 0 deletions generation/vec_tiles_gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import sys
sys.path.append('oswm_codebase')
from functions import *
import subprocess

docker_img = 'ghcr.io/osgeo/gdal:alpine-normal-latest'

create_folder_if_not_exists(tiles_folderpath)


print(paths_dict)

layers_dict = paths_dict['map_layers']

for layername in layers_dict:

outpath = os.path.join(tiles_folderpath,layername+'.pmtiles')

runstring = f'docker run --rm -v ./data:/data {docker_img} ogr2ogr -f PMTiles {outpath} {layers_dict[layername]} -dsco MINZOOM={TILES_MIN_ZOOM} -dsco MAXZOOM={TILES_MAX_ZOOM} -progress'

print(runstring)

10 changes: 8 additions & 2 deletions other/templates/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@
-49.1843181999999999 # EASTERNMOST LONGITUDE
)

# Set a midpoint for the map:
# Set a midpoint for the map AND A Z LEVEL FOR THE INITIAL ZOOM:
MID_LAT = -25.46075
MID_LGT = -49.26135
INITIAL_Z_LEVEL = 19

# MIN AND MAX ZOOM LEVELS FOR TILE GENERATION:
# (since there's the 100MB file size limit, for big datasets might be better to stay at 19 or even 18)
TILES_MIN_ZOOM = 12
TILES_MAX_ZOOM = 20


### MORE DELICATE ONES: (leave them unchanged by default)
Expand All @@ -45,4 +51,4 @@
OTHER_FOOTWAY_RULES = {'highway':['footway','steps','living_street','pedestrian','track','path'],'foot':['yes','designated','permissive'],'footway': ['alley','path','yes']}

# since we download all features containing the tags of the previous rule-set, if there's another tag hierarchically above, we should exclude those features:
OTHER_FOOTWAY_EXCLUSION_RULES = {'highway': ['trunk','motorway','primary','secondary','trunk_link','motorway_link','primary_link'],'access':['no','private']}
OTHER_FOOTWAY_EXCLUSION_RULES = {'highway': ['trunk','motorway','primary','secondary','trunk_link','motorway_link','primary_link'],'access':['no','private']}
1 change: 1 addition & 0 deletions other/templates/copy_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cp oswm_codebase/other/templates/config.py config.py
5 changes: 4 additions & 1 deletion special_updates.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# from constants import *
from functions import *
from shutil import rmtree, copytree
from shutil import rmtree, copytree, copy

"""
script reserved for eventual modifications that shall happen on all nodes
Expand All @@ -10,6 +10,9 @@
rmtree(workflows_path,ignore_errors=True)
copytree('./oswm_codebase/workflows',workflows_path)

# copying requirements.txt:
copy('./oswm_codebase/requirements.txt','./requirements.txt')

# resetting the boundaries:
remove_if_exists(boundaries_path)
remove_if_exists(boundaries_md_path)
Expand Down
2 changes: 2 additions & 0 deletions workflows/data_daily_updating.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:

- run: python oswm_codebase/filtering_adapting_data.py

- run: python oswm_codebase/generation/vec_tiles_gen.py

- run: python oswm_codebase/create_webmap.py

- run: python oswm_codebase/data_quality/tag_values_checking.py
Expand Down

0 comments on commit 38a830e

Please sign in to comment.