-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Began work on the tag translator for Zoomstack
- Loading branch information
1 parent
0155944
commit f087093
Showing
5 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# Path to your input geopackage | ||
input_geopackage="/opt/data/zoomstack/contours.gpkg" | ||
|
||
# Path to the generated grid shapefile | ||
grid_shapefile="/opt/data/zoomstack/uk_grid_50x50km.gpkg" | ||
|
||
# Output directory for the split geopackages | ||
output_dir="/opt/data/zoomstack/osm_contours" | ||
docker_dir="/app/data/zoomstack/osm_contours" | ||
|
||
# Read each feature (grid cell) from the grid shapefile | ||
ogrinfo -al -geom=NO ${grid_shapefile} | grep OGRFeature | cut -d' ' -f2 | while read feature_id; do | ||
# Define the output filename based on the feature ID | ||
output_geopackage="${output_dir}/contour_${feature_id}.gpkg" | ||
input_geopackage="${docker_dir}/contour_${feature_id}.gpkg" | ||
output_osm="${output_dir}/contour_${feature_id}.osm.pbf" | ||
|
||
# Use ogr2ogr to clip the input geopackage by the current grid cell and output to a new geopackage | ||
ogr2ogr -f GPKG ${output_geopackage} ${input_geopackage} -progress -clipsrc ${grid_shapefile} ${feature_id} | ||
|
||
# Use ogr2osm to make the final output file | ||
docker run -ti --rm -v /opt/:/app roelderickx/ogr2osm ${input_geopackage} -f --pbf -e 27700 -o ${output_osm} -t /app/dev/bikepackmaps/translations/bikepack_translator.py --id 11571092201 | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import os | ||
import sys | ||
sys.path.append(os.path.abspath('lib')) | ||
from tools import OSZoomStack, Splitter, Mkgmap, GetMaxOSMID, OSMMerge, OSMSort | ||
|
||
|
||
zoomstack_destination='./build/data/zoomstack' | ||
extract_bbox = [134340, 20297, 407049, 164276] | ||
osm_output = './build/data/great-britain-latest.osm.pbf' | ||
output_dir = './build/output' | ||
splitter_dir = './build/splitter' | ||
styles_dir = './style/mkgmap_styles' | ||
typ_file = './style/typ_files/mkgmap-typ-files/bikepack.txt' | ||
precomp_sea = './build/data/sea/sea-latest.zip' | ||
bounds = './build/data/bounds/bounds-latest.zip' | ||
merged_output = f'{output_dir}/merged.osm.pbf' | ||
|
||
sorted_output='/opt/dev/bikepackmaps/build/data/bikepack_osm_sorted.osm.pbf' | ||
# Split the file up into tiles for processing and then create the map | ||
splitter = Splitter(output_dir=splitter_dir, | ||
input_file=sorted_output, | ||
num_tiles=10 | ||
) | ||
splitter.run() | ||
|
||
# make_map = Mkgmap( | ||
# style_file=styles_dir, | ||
# style='bikepack', | ||
# gmapsupp=None, | ||
# output_dir=f'{output_dir}/Garmin', | ||
# typ_file=typ_file, | ||
# keep_going=None, | ||
# split_name_index=None, | ||
# merge_lines=None, | ||
# index=None, | ||
# nsis=None, | ||
# draw_priority='31', | ||
# location_autofill='is_in,nearest', | ||
# generate_sea=None, | ||
# precomp_sea=precomp_sea, | ||
# bounds=bounds, | ||
# # Note well that this has to be the last argument otherwise all those before it are ignored | ||
# read_config=f'{splitter_dir}/template.args',) | ||
# | ||
# make_map.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
# Path to your input geopackage | ||
input_geopackage="/opt/data/zoomstack/contours.gpkg" | ||
|
||
# Path to the generated grid shapefile | ||
grid_shapefile="/opt/data/zoomstack/uk_grid_50x50km.gpkg" | ||
|
||
# Output directory for the split geopackages | ||
output_dir="/opt/data/zoomstack/osm_contours" | ||
docker_dir="/app/data/zoomstack/osm_contours" | ||
COUNTER=0 | ||
|
||
# Read each feature (grid cell) from the grid shapefile | ||
ogrinfo -al ${grid_shapefile} | grep POLYGON | while read feature_id; do | ||
let COUNTER++ | ||
# Define the output filename based on the feature ID | ||
output_geopackage="${output_dir}/contour_${COUNTER}.gpkg" | ||
input_osm="${docker_dir}/contour_${COUNTER}.gpkg" | ||
output_osm="${docker_dir}/contour_${COUNTER}.osm.pbf" | ||
|
||
# Use ogr2ogr to clip the input geopackage by the current grid cell and output to a new geopackage | ||
#echo "ogr2ogr -f GPKG ${output_geopackage} ${input_geopackage} -progress -clipsrc '${feature_id}'" | ||
ogr2ogr -f GPKG ${output_geopackage} ${input_geopackage} -nlt LINESTRING -progress -clipsrc "${feature_id}" -skipfailures -makevalid | ||
|
||
# Use ogr2osm to make the final output file | ||
echo "Starting with : $(cat /opt/data/zoomstack/idfile)" | ||
docker run --rm -v /opt/:/app roelderickx/ogr2osm ${input_osm} -f --pbf -o ${output_osm} -t /app/dev/bikepackmaps/translations/bikepack_translator.py --positive-id --idfile /app/data/zoomstack/idfile --saveid /app/data/zoomstack/idfile | ||
echo "Ending with : $(cat /opt/data/zoomstack/idfile)" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# Define the directory containing the .pbf files | ||
input_directory="osm_contours" | ||
|
||
# Directory for sorted files | ||
sorted_directory="sorted_files" | ||
mkdir -p "$sorted_directory" | ||
|
||
# Sort each .pbf file in the input directory | ||
for input_file in "$input_directory"/*.pbf; do | ||
filename=$(basename "$input_file") | ||
sorted_file="$sorted_directory/sorted_$filename" | ||
echo "Sorting file $filename..." | ||
osmium sort "$input_file" --overwrite -o "$sorted_file" | ||
done | ||
|
||
echo "All files sorted." | ||
|
||
# Merge sorted files | ||
output_file="merged_contours.osm.pbf" | ||
sorted_files=$(ls "$sorted_directory"/*.osm.pbf) | ||
osmium merge $sorted_files --overwrite -o "$output_file" | ||
osmium sort $output_file --overwrite -o "sorted_$output_file" | ||
echo "Merge completed. Output file: sorted_$output_file" |