Skip to content

Commit

Permalink
Update scripts to match latest version from MapRando ablet o use IGN …
Browse files Browse the repository at this point in the history
…contours for France
  • Loading branch information
utagawal committed Oct 20, 2024
1 parent f297152 commit f643101
Show file tree
Hide file tree
Showing 58 changed files with 877 additions and 1,238 deletions.
102 changes: 102 additions & 0 deletions IGN_urls.txt

Large diffs are not rendered by default.

24 changes: 15 additions & 9 deletions add_country.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@
import sys
import os
import subprocess
from scripts_hgt.get_hgt import get_hgt
from scripts_hgt.hgt_to_osm import hgt_to_osm
from get_contours import get_contours
import os, shutil, fnmatch
import subprocess
import time

country_name=sys.argv[1]
country_name_args=sys.argv[1]
style=sys.argv[2]
url=sys.argv[3]

start_time = time.perf_counter()
country_name_lower_case = country_name.lower().replace(" ", "_")
country_name_lower_case = country_name_args.lower().replace(" ", "_")
country_name_upper_case = country_name_lower_case.capitalize()


Expand All @@ -36,27 +34,35 @@
country_list.append([result[0],result[1],result[2]])
file_in.close()

id=f'{len(country_list)+1:02d}'


for idx, country in enumerate(country_list):
country_name=country[0].replace('#','')
if(country_name==country_name_args):
print("The country already exists")
sys.exit()

id=f'{int(country_list[len(country_list)-1][1])+1:02d}'


#File country
file_in = open("country.txt", "rt")

file_source = file_in.read()
file_modif = file_source+'\n#'+country_name+';'+id+';'+style+';'+url
file_modif = file_source+'\n'+country_name_args+';'+id+';'+style+';'+url+';1'
file_in.close()

file_out = open("country.txt", "wt")
file_out.write(file_modif)
file_out.close()

print("Start Add country"+country_name+ " "+id+ " "+" "+style,url)
print("Start Add country"+country_name_args+ " "+id+ " "+" "+style,url)

#Get contours
get_contours(country_name, url)
get_contours(country_name_args, url)

#Launch script
subprocess.run(["bash", "update_map.sh",country_name,id,style,url])
subprocess.run(["bash", "update_map.sh",country_name_args,id,style,url])
stop_time = time.perf_counter()

print("End Add country in "+time.strftime('%H:%M:%S', time.gmtime(stop_time - start_time)))
48 changes: 48 additions & 0 deletions ask_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/python
import sys
import os
import subprocess
from get_contours import get_contours
import os, shutil, fnmatch
import subprocess
import time

country_name_args=sys.argv[1]

country_list=[]

#File country
file_in = open("country.txt", "rt")

lines = file_in.readlines()
for line in lines:
result = line.split(";")
country_name=result[0].replace('#','')
add=0
if(country_name==country_name_args):
add=1
if(len(result)==4):
country_list.append([result[0],result[1],result[2],result[3],add+1])
else:
country_list.append([result[0],result[1],result[2],result[3],int(result[4])+add])

file_in.close()

file_out = open("country.txt", "wt")
file_modif="\n"
for idx, country in enumerate(country_list):
file_modif=file_modif+"\n"+country[0]+";"+country[1]+";"+country[2]+";"+country[3].strip()+";"+str(country[4])

file_out.write(file_modif.strip())
file_out.close()

for idx, country in enumerate(country_list):
country_name=country[0].replace('#','')
id=country[1]
style=country[2]
url=country[3]
if(country_name==country_name_args):
print("Update "+country_name+ " "+id+" "+style+" "+url)
#Launch script
subprocess.run(["bash", "download_osm.sh",country_name,id,style,url])
subprocess.run(["bash", "create_map.sh",country_name,id,style])
43 changes: 30 additions & 13 deletions check_dem_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,40 @@
import sys
import os
import subprocess
from scripts_hgt.get_hgt import get_hgt
from scripts_hgt.hgt_to_osm import hgt_to_osm
from get_contours import get_contours
import os, shutil, fnmatch
import subprocess
import time
import glob
import pathlib

dirList = os.listdir()
country_list=[]

#File country
file_in = open("country.txt", "rt")

lines = file_in.readlines()
for line in lines:
result = line.split(";")
country_list.append([result[0],result[1],result[2],result[3]])

file_in.close()

for idx, country in enumerate(country_list):
hasFilesDem=False
hasFilesDemWithId=False
country_name=country[0].replace("#",'')
id=country[1]
style=country[2]
url=country[3]
country_dir = "carte_"+country_name.replace(' ','_').lower()
for file in pathlib.Path(country_dir).glob("*.img"):
if(str(file).split("/")[1].startswith("55"+id)):
hasFilesDemWithId=True
if(str(file).split("/")[1].startswith("55")):
hasFilesDem=True
if(hasFilesDem==False):
print("Fichier "+country_name+ " "+id+" n'a pas de dem")
if(hasFilesDem==True and hasFilesDemWithId==False):
print("Fichier "+country_name+ " "+id+" n'a pas de dem avec le bon id")


for dir in dirList:
if(dir.startswith("carte_")):
hasFiles=False
for file in pathlib.Path(dir).glob("*.img"):
if(str(file).split("/")[1].startswith("88")):
hasFiles=True
if(hasFiles==False):
print(dir)

35 changes: 35 additions & 0 deletions check_folder_missing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/python
import sys
import os
import subprocess
import os, shutil, fnmatch
import subprocess
import time
import pathlib

country_list=[]

#File country
file_in = open("country.txt", "rt")

lines = file_in.readlines()
for line in lines:
result = line.split(";")
country_list.append([result[0],result[1],result[2],result[3]])

file_in.close()

for idx, country in enumerate(country_list):
hasFilesDem=False
hasFilesDemWithId=False
country_name=country[0].replace("#",'')
id=country[1]
style=country[2]
url=country[3]
country_dir = "carte_"+country_name.replace(' ','_').lower()
isDir = os.path.isdir(country_dir)
if(isDir==False):
print("Dir "+country_name+" missing")



23 changes: 23 additions & 0 deletions check_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/python
import sys
import os
import os, shutil, fnmatch
import subprocess
import time

country_list_id=[]

#File country
file_in = open("country.txt", "rt")

lines = file_in.readlines()
for line in lines:
result = line.split(";")
for element in country_list_id:
if(element[1]==result[1]):
print(result[0])
country_list_id.append([result[0],result[1]])


file_in.close()

39 changes: 39 additions & 0 deletions classement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/python
import sys
import os
import subprocess
from scripts_hgt.get_hgt import get_hgt
#from scripts_hgt.hgt_to_osm import hgt_to_osm
from get_contours import get_contours
import os, shutil, fnmatch
import subprocess
import time

country_dict={}

#File country
file_in = open("country.txt", "rt")

lines = file_in.readlines()
for line in lines:
result = line.split(";")
country_name=result[0].replace('#','')
if(len(result)==4):
if(result[0].startswith('#')):
country_dict[country_name]=1
else:
country_dict[country_name]=sys.maxsize
else:
if(result[0].startswith('#')):
country_dict[country_name]=int(result[4])
else:
country_dict[country_name]=sys.maxsize

file_in.close()

sorted_dict=dict(sorted(country_dict.items(), key=lambda item: item[1],reverse=True))
for country in sorted_dict:
if(sorted_dict[country]==sys.maxsize):
print(country)
else:
print(country + " -> "+str(sorted_dict[country]))
62 changes: 42 additions & 20 deletions country.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,51 @@
France;02;utagawa;https://download.geofabrik.de/europe/france-latest.osm.pbf
Suisse;03;utagawa;https://download.geofabrik.de/europe/switzerland-latest.osm.pbf
Italie;04;utagawa;https://download.geofabrik.de/europe/italy-latest.osm.pbf
Belgique;05;utagawa;https://download.geofabrik.de/europe/belgium-latest.osm.pbf
Espagne;06;utagawa;https://download.geofabrik.de/europe/spain-latest.osm.pbf
Reunion;07;utagawa;https://download.geofabrik.de/europe/france/reunion-latest.osm.pbf
Allemagne;08;utagawa;https://download.geofabrik.de/europe/germany-latest.osm.pbf
Luxembourg;09;utagawa;https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf
Midi-Pyrenees;10;utagawa;https://download.geofabrik.de/europe/france/midi-pyrenees-latest.osm.pbf
Languedoc;11;utagawa;https://download.geofabrik.de/europe/france/languedoc-roussillon-latest.osm.pbf
Haute-Normandie;12;utagawa;https://download.geofabrik.de/europe/france/haute-normandie-latest.osm.pbf
Liechtenstein;14;utagawa;https://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf
Rhone-Alpes;13;utagawa;https://download.geofabrik.de/europe/france/rhone-alpes-latest.osm.pbf
Andorre;19;utagawa;https://download.geofabrik.de/europe/andorra-latest.osm.pbf
Autriche;14;utagawa;https://download.geofabrik.de/europe/austria-latest.osm.pbf
Baleares;21;utagawa;https://download.geofabrik.de/europe/spain/islas-baleares-latest.osm.pbf
Belgique;05;utagawa;https://download.geofabrik.de/europe/belgium-latest.osm.pbf
Danemark;15;utagawa;https://download.geofabrik.de/europe/denmark-latest.osm.pbf
Pays-bas;16;utagawa;https://download.geofabrik.de/europe/netherlands-latest.osm.pbf
Portugal;17;utagawa;https://download.geofabrik.de/europe/portugal-latest.osm.pbf
Espagne;06;utagawa;https://download.geofabrik.de/europe/spain-latest.osm.pbf
France;02;utagawa;https://download.geofabrik.de/europe/france-latest.osm.pbf
FR-Alsace;34;utagawa;https://download.geofabrik.de/europe/france/alsace-latest.osm.pbf
FR-Aquitaine;35;utagawa;https://download.geofabrik.de/europe/france/aquitaine-latest.osm.pbf
FR-Auvergne;20;utagawa;https://download.geofabrik.de/europe/france/auvergne-latest.osm.pbf
FR-BasNormandie;36;utagawa;https://download.geofabrik.de/europe/france/basse-normandie-latest.osm.pbf
FR-Bourgogne;37;utagawa;https://download.geofabrik.de/europe/france/bourgogne-latest.osm.pbf
FR-Bretagne;32;utagawa;https://download.geofabrik.de/europe/france/bretagne-latest.osm.pbf
FR-Centre;38;utagawa;https://download.geofabrik.de/europe/france/centre-latest.osm.pbf
FR-Champagne;39;utagawa;https://download.geofabrik.de/europe/france/champagne-ardenne-latest.osm.pbf
FR-Corse;40;utagawa;https://download.geofabrik.de/europe/france/corse-latest.osm.pbf
FR-FrcheComte;41;utagawa;https://download.geofabrik.de/europe/france/franche-comte-latest.osm.pbf
FR-Guadeloupe;22;utagawa;https://download.geofabrik.de/europe/france/guadeloupe-latest.osm.pbf
FR-Guyane;42;utagawa;https://download.geofabrik.de/europe/france/guyane-latest.osm.pbf
FR-HteNormandie;12;utagawa;https://download.geofabrik.de/europe/france/haute-normandie-latest.osm.pbf
FR-IDF;43;utagawa;https://download.geofabrik.de/europe/france/ile-de-france-latest.osm.pbf
FR-Languedoc;11;utagawa;https://download.geofabrik.de/europe/france/languedoc-roussillon-latest.osm.pbf
FR-Limousin;44;utagawa;https://download.geofabrik.de/europe/france/limousin-latest.osm.pbf
FR-Lorraine;45;utagawa;https://download.geofabrik.de/europe/france/lorraine-latest.osm.pbf
FR-Martinique;23;utagawa;https://download.geofabrik.de/europe/france/martinique-latest.osm.pbf
FR-Mayotte;46;utagawa;https://download.geofabrik.de/europe/france/mayotte-latest.osm.pbf
FR-MidiPy;10;utagawa;https://download.geofabrik.de/europe/france/midi-pyrenees-latest.osm.pbf
FR-Nord-PdC;47;utagawa;https://download.geofabrik.de/europe/france/nord-pas-de-calais-latest.osm.pbf
FR-PACA;32;utagawa;https://download.geofabrik.de/europe/france/provence-alpes-cote-d-azur-latest.osm.pbf
FR-Pays-Loire;48;utagawa;https://download.geofabrik.de/europe/france/pays-de-la-loire-latest.osm.pbf
FR-Picardie;49;utagawa;https://download.geofabrik.de/europe/france/picardie-latest.osm.pbf
FR-Poitou;50;utagawa;https://download.geofabrik.de/europe/france/poitou-charentes-latest.osm.pbf
FR-Polynesie;24;utagawa;https://download.geofabrik.de/australia-oceania/polynesie-francaise-latest.osm.pbf
FR-Reunion;07;utagawa;https://download.geofabrik.de/europe/france/reunion-latest.osm.pbf
FR-Rhone-Alpes;13;utagawa;https://download.geofabrik.de/europe/france/rhone-alpes-latest.osm.pbf
Israel;18;utagawa;https://download.geofabrik.de/asia/israel-and-palestine-latest.osm.pbf
Andorre;19;utagawa;https://download.geofabrik.de/europe/andorra-latest.osm.pbf
Auvergne;20;utagawa;https://download.geofabrik.de/europe/france/auvergne-latest.osm.pbf
Baleares;21;utagawa;https://download.geofabrik.de/europe/spain/islas-baleares-latest.osm.pbf
Guadeloupe;22;utagawa;https://download.geofabrik.de/europe/france/guadeloupe-latest.osm.pbf
Martinique;23;utagawa;https://download.geofabrik.de/europe/france/martinique-latest.osm.pbf
Polynesie;24;utagawa;https://download.geofabrik.de/australia-oceania/polynesie-francaise-latest.osm.pbf
Italie;04;utagawa;https://download.geofabrik.de/europe/italy-latest.osm.pbf
Japon;25;utagawa;https://download.geofabrik.de/asia/japan-latest.osm.pbf
Liechtenstein;26;utagawa;https://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf
Luxembourg;09;utagawa;https://download.geofabrik.de/europe/luxembourg-latest.osm.pbf
Pays-bas;16;utagawa;https://download.geofabrik.de/europe/netherlands-latest.osm.pbf
Portugal;17;utagawa;https://download.geofabrik.de/europe/portugal-latest.osm.pbf
Royaume-Uni;31;utagawa;https://download.geofabrik.de/europe/united-kingdom-latest.osm.pbf
Seychelles;33;utagawa;https://download.geofabrik.de/africa/seychelles-latest.osm.pbf
Suisse;03;utagawa;https://download.geofabrik.de/europe/switzerland-latest.osm.pbf
US-midwest;27;utagawa;https://download.geofabrik.de/north-america/us-midwest-latest.osm.pbf
US-northeast;28;utagawa;https://download.geofabrik.de/north-america/us-northeast-latest.osm.pbf
US-south;29;utagawa;https://download.geofabrik.de/north-america/us-south-latest.osm.pbf
US-west;30;utagawa;https://download.geofabrik.de/north-america/us-west-latest.osm.pbf
Slovenie;51;utagawa;https://download.geofabrik.de/europe/slovenia-latest.osm.pbf
45 changes: 45 additions & 0 deletions create_all_maps_if_dem_missing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/python
import sys
import os
import subprocess
from get_contours import get_contours
import os, shutil, fnmatch
import subprocess
import time
import pathlib
from multiprocessing import Pool

def task(country):
hasFiles=False
country_name=country[0].replace("#",'')
id=country[1]
style=country[2]
url=country[3]
country_dir = "carte_"+country_name.replace(' ','_').lower()
for file in pathlib.Path(country_dir).glob("*.img"):
if(str(file).split("/")[1].startswith("55")):
hasFiles=True
if(hasFiles==False):
#Get contours
print("Update "+country_name+ " "+id+" "+style+" "+url)
get_contours(country_name, url)
#Launch script
subprocess.run(["bash", "create_map.sh",country_name,id,style])



if __name__ == '__main__':
country_list=[]
#File country
file_in = open("country.txt", "rt")

lines = file_in.readlines()
for line in lines:
result = line.split(";")
country_list.append([result[0],result[1],result[2],result[3]])

file_in.close()

with Pool(processes=3) as pool:
pool.map(task, country_list)

2 changes: 1 addition & 1 deletion create_dem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ mv -f gmapsupp.img ${name_file}${dm}.img

time_task

cd ..
cd ..
Loading

0 comments on commit f643101

Please sign in to comment.