SDeAstis wrote in Sun Sep 19, 2021 6:09 pm:
Hi,
can somebody explain me why every time I run the tool all the previous DDS file are deleted?
Also the Orthophoto-saved is cleaned!
I lost 65GB of files!
Also with the --connect option avery istance ran deletes all the previous DDS! Is this a bug of the latest version?
I-BASSY answered:
Hello, it is strange because there is no deletion of files, but only the copy from the directories you used for saving to the directory of the operational scenario.
Remember the command you used that I verify?
I often use to save an external disk, at this point I wonder, if the external disk was correctly mounted?
Honestly I have never had news of file losses, but obviously there are many different situations that can perhaps give something abnormal, if I discover them I can intervene to correct.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 03 07:27:37 2022
@author: xxxx
"""
#------------------------------------------------------------------------------
# ASSUMPTION
#
# This file is dedicated to produce the fgfs download tiles command file
# A set file must contain :
# the departure coordinates
# the arrival coordinates
# the line betwenn departure and arrival is the euclidian straight line
#------------------------------------------------------------------------------
# CHAPTER 0 - LIBRARIES
#
import os
import math
from datetime import date
#-----------------------------------------------------------------------------
import os
# CHAPTER 1 : CALLED PARAMETERS
# # # ============
# # # photoscenery folder destination
scenery_folder="/home/xxxx/photoscenery"
print("scenery folder : " + str(scenery_folder))
# # # ============
# # # folder location destination
folder_location="./flightgear-photoscenery/"
print("folder location : " + str(folder_location))
# # # ============
# # # command file definition
flightgear_directory="/home/xxxx/Desktop/FLIGHTGEAR/ORTHO/"
print("flightgear directory : " + str(flightgear_directory))
# # ============
# departure name
dep_name="KORD"
# arrival name
arr_name="KLGA"
# the first point coordinates must be wester to the second point coordinates
# # ============
# # departure coordinates in decimals
long_dec_dep=-179.999999
lat_dec_dep=-89.999999
# # ============
# # arrival coordinates in decimals
long_dec_arr=179.999999
lat_dec_arr=89.999999
# # ============
# # departure coordinates in deg minutes seconds
long_dms_dep=-87.5417
lat_dms_dep=41.5843
# # ============
# # arrival coordinates in deg minutes seconds
long_dms_arr=-73.5230
lat_dms_arr=40.4630
# # ============
# # units choice
# 1 : decimals
# 2 : degrees minutes seconds
units=2
#-----------------------------------------------------------------------------
import os
# CHAPTER 2 : FUNCTIONS AND METHODS
# # ============
def dms_to_dec(dms) :
dms_abs=abs(dms)
dms_int=math.floor(dms_abs)
dms_int=dms_int
dms_min_int = math.floor((dms_abs - dms_int)*100)
dms_min_int=dms_min_int
dms_sec_int = math.floor((dms_abs - dms_int - (dms_min_int/100))*10000)
dms_sec_int=dms_sec_int
dec_sec = dms_sec_int / 60
dec_min = (dms_min_int + dec_sec) / 60
dec_abs = round((dms_int + dec_min),6)
if dms < 0 :
dec = -dec_abs
else :
dec = dec_abs
# debug_dialog
# print("dms_abs : " + str(dms_abs))
# print("dms_int : " + str(dms_int))
# print("dms_min_int : " + str(dms_min_int))
# print("dms_sec_int : " + str(dms_sec_int))
# print("dec_sec : " + str(dec_sec))
# print("dec_min : " + str(dec_min))
# print("dec_abs : " + str(dec_abs))
# print("dec : " + str(dec))
return dec
# # ============
def coord_to_gap(x) :
x_gap_int_min=math.floor(abs(x))
x_gap_int_max=x_gap_int_min + 1
x_gap_min=x_gap_int_min - 1
x_gap_max=x_gap_int_max + 1
if x < 0 :
x_gap_min_s = -x_gap_max
else :
x_gap_min_s = x_gap_min
if x < 0 :
x_gap_max_s = -x_gap_min
else :
x_gap_max_s = x_gap_max
list_return=(x_gap_min_s,x_gap_max_s)
# debug_dialog
# print("x_gap_int_min : ", x_gap_int_min)
# print("x_gap_int_max : ", x_gap_int_max)
# print("x_gap_min : ", x_gap_min)
# print("x_gap_max : ", x_gap_max)
# print("x_gap_min_s : ", x_gap_min_s)
# print("x_gap_max_s : ", x_gap_max_s)
# print("list_return : ", list_return)
return list_return
#-----------------------------------------------------------------------------
import os
# CHAPTER 3 : INTERNAL FILE PARAMETERS
# # # ============
# # # file definition
file_name="fgfs_way_" + str(dep_name) + "-" + str(arr_name) + ".sh"
print("file name : " + str(file_name))
file_name_path=str(flightgear_directory) + str(file_name)
print("file name path : " + str(file_name_path))
# # # ============
# # # coordonates translation
long_ddec_dep = dms_to_dec(long_dms_dep)
print("long_ddec_dep : " + str(long_dms_dep) + " to " + str(long_ddec_dep))
lat_ddec_dep = dms_to_dec(lat_dms_dep)
print("lat_ddec_dep : " + str(lat_dms_dep) + " to " + str(lat_ddec_dep))
long_ddec_arr = dms_to_dec(long_dms_arr)
print("long_ddec_arr : " + str(long_dms_arr) + " to " + str(long_ddec_arr))
lat_ddec_arr = dms_to_dec(lat_dms_arr)
print("lat_ddec_arr : " + str(lat_dms_arr) + " to " + str(lat_ddec_arr))
# # # ============
# # # coordinates definition
# # ============
# # departure coordinates
if units == 1 :
long_dep=long_dec_dep
else :
long_dep=long_ddec_dep
print("long_dep : " + str(long_dep))
if units == 1 :
lat_dep=lat_dec_dep
else :
lat_dep=lat_ddec_dep
print("lat_dep : " + str(lat_dep))
# # ============
# # arrival coordinates
if units == 1 :
long_arr=long_dec_arr
else :
long_arr=long_ddec_arr
print("long_arr : " + str(long_arr))
if units == 1 :
lat_arr=lat_dec_arr
else :
lat_arr=lat_ddec_arr
print("lat_arr : " + str(lat_arr))
# # # ============
# # # x, y coordinates definition
xd=long_dep
yd=lat_dep
xa=long_arr
ya=lat_arr
print("(xd, yd) : " + "(" + str(xd) + ", " + str(yd) + ")")
print("(xa, ya) : " + "(" + str(xa) + ", " + str(ya) + ")")
# # # ============
# # # y = ax + b , affine coefficients
a=((ya-yd)/(xa-xd))
b = -(xd*ya - xa*yd)/(xa-xd)
print("a : " + str(a) + ", b : " + str(b))
# angle between x_axis and trajectory line
alpha=math.atan(a)
print("alpha : " + str(alpha))
alpha_deg=math.degrees(alpha)
print("alpha_deg : " + str(alpha_deg))
# # # ============
# # # points suivants
# distance au point suivant
dec=3
x_delta = dec * math.cos(alpha)
print("x_delta : " + str(x_delta))
y_delta = dec * math.sin(alpha)
print("y_delta : " + str(y_delta))
# point suivant
x1 = xd + x_delta
print("x1 : " + str(x1))
y1 = yd + y_delta
print("y1 : " + str(y1))
# # # ============
# # # x, y gap coordinates
xd_gap=coord_to_gap(xd)
xd_gap_min=xd_gap[0]
xd_gap_max=xd_gap[1]
print("xd_gap : " + str(xd_gap_min) + " to " + str(xd_gap_max))
yd_gap=coord_to_gap(yd)
yd_gap_min=yd_gap[0]
yd_gap_max=yd_gap[1]
print("yd_gap : " + str(yd_gap_min) + " to " + str(yd_gap_max))
xa_gap=coord_to_gap(xa)
xa_gap_min=xa_gap[0]
xa_gap_max=xa_gap[1]
print("xa_gap : " + str(xa_gap_min) + " to " + str(xa_gap_max))
ya_gap=coord_to_gap(ya)
ya_gap_min=ya_gap[0]
ya_gap_max=ya_gap[1]
print("ya_gap : " + str(ya_gap_min) + " to " + str(ya_gap_max))
#-----------------------------------------------------------------------------
import os
# CHAPTER 4 : WRITING FILE
# Open file with write rights, if file doesn't exist, the file is created
file = open(file_name_path,"w+")
# # # ============
# # # file header
# bash
file.write("#/bin/bash\n\n")
# Creator
file.write("# My Name aka 'MyPseudo'\n")
dodate=date.today()
file.write("# " + str(dodate) + "\n")
file.write("\n")
# # # ============
# # # file main
file.write("#=================================================================\n")
# ------------ Write the file
file.write("# Destination folder location\n")
file.write("\n")
file.write("cd " + str(folder_location) + "\n")
file.write("\n")
file.write("#=================================================================\n")
# ------------
file.write("# Points coordinates\n")
file.write("\n")
file.write("# Departure name : " + str(dep_name) + "\n")
file.write("# Departure point coordinates\n")
file.write("# Longitude : " + str(long_dep) + "\n")
file.write("# Lattitude : " + str(lat_dep) + "\n")
file.write("\n")
file.write("# Arrival name : " + str(arr_name) + "\n")
file.write("# Arrival point coordinates\n")
file.write("# Longitude : " + str(long_arr) + "\n")
file.write("# Lattitude : " + str(lat_arr) + "\n")
file.write("\n")
file.write("\n")
file.write("# affine line : y = a.x + b\n")
file.write("# a : " + str(a) + "\n")
file.write("# b : " + str(b) + "\n")
file.write("\n")
file.write("#=================================================================\n")
# ------------
file.write("# Loading tiles\n")
file.write("\n")
file.write("# Loading tiles for departure\n")
file.write("echo \"Loading tiles for departure\"\n")
file.write("perl create_bbox.pl --latLL " + str(yd_gap_min) + " --lonLL " + str(xd_gap_min) + " --latUR " + str(yd_gap_max) + " --lonUR " + str(xd_gap_max) + " -- --cols 2 --scenery_folder " + str(scenery_folder) + "\n")
file.write("\n")
# # # ============
# # # while loop
# preparation
i=0
xi = xd + x_delta
yi = yd + y_delta
# loop
while xi < xa :
i = i + 1
# x{i}
# print("xi : " + str(x(i)))
print("step_" + str(i))
# x, y gap coordinates
xi_gap=coord_to_gap(xi)
xi_gap_min=xi_gap[0]
xi_gap_max=xi_gap[1]
print("xi_gap : " + str(xi_gap_min) + " to " + str(xi_gap_max))
yi_gap=coord_to_gap(yi)
yi_gap_min=yi_gap[0]
yi_gap_max=yi_gap[1]
print("yi_gap : " + str(yi_gap_min) + " to " + str(yi_gap_max))
file.write("# Loading tiles for step " + str(i) + "\n")
file.write("echo \"Loading tiles for step " + str(i) + "\"\n")
file.write("perl create_bbox.pl --latLL " + str(yi_gap_min) + " --lonLL " + str(xi_gap_min) + " --latUR " + str(yi_gap_max) + " --lonUR " + str(xi_gap_max) + " -- --cols 2 --scenery_folder " + str(scenery_folder) + "\n")
file.write("\n")
# print(xi)
xi = xi + x_delta
yi = yi + y_delta
else :
print("xi is no longer less than xa")
file.write("# Loading tiles for arrival\n")
file.write("echo \"Loading tiles for arrival\"\n")
file.write("perl create_bbox.pl --latLL " + str(ya_gap_min) + " --lonLL " + str(xa_gap_min) + " --latUR " + str(ya_gap_max) + " --lonUR " + str(xa_gap_max) + " -- --cols 2 --scenery_folder " + str(scenery_folder) + "\n")
file.write("\n")
#=============================================================================
# CHAPTER end : CLOSING FILE
# Close the file
file.close()
print("fgfs_way.py file completed")
Users browsing this forum: No registered users and 15 guests