Re-enabled download of elevation, activated proper code in orthographic.py

This commit is contained in:
Marcus Str. 2024-12-03 16:23:52 +01:00
parent c3b9c38b74
commit aae81c58e9
2 changed files with 2 additions and 94 deletions

View File

@ -456,27 +456,14 @@ class mstr_orthographic:
xpscn = mstr_xp_scenery(self._lat, self._long, maxlatlng[0], maxlatlng[1], self._vstep, self._latlngfld)
mstr_msg("orthographic", "[X-Plane] Scenery object instantiated")
# Generate the script
#xpscn.build_mesh_script()
#mstr_msg("orthographic", "[X-Plane] Mesh script written")
# Download LIDAR scan from our endpoint
#xpscn.acquire_elevation_data()
#mstr_msg("orthographic", "[X-Plane] LIDAR scan acquired")
# Download required XES data
#xpscn.acquire_xes_data()
#mstr_msg("orthographic", "[X-Plane] MeshTool XES data acquired")
xpscn.acquire_elevation_data()
mstr_msg("orthographic", "[X-Plane] Elevation data acquired")
# Generate the .ter files
xpscn.build_ter_files()
mstr_msg("orthographic", "[X-Plane] Terrain files (.ter) generated and written")
# Build mesh
#xpscn.build_mesh()
#xpscn._dsf_test()
#xpscn.build_and_convert_dsf()
# And lastly, generate the mesh
xpscn.generate_terrain_mesh()
mstr_msg("orthographic", "[X-Plane] Scenery mesh constructed")

View File

@ -360,85 +360,6 @@ class mstr_xp_scenery:
curpatch = curpatch + 1
# Let's check if this tile needs water beneath
"""
if self.does_ortho_have_water(str(lat) + "_" + str(lng)):
# Begin a new patch
with open(meshtxt, 'a') as textfile:
textfile.write("BEGIN_PATCH " + str(curpatch) + " 0.000000 -1.000000 2 5\r\n")
# Generate the ortho tile
for y in range(0,odiv):
for x in range(0,odiv):
# Coordinates
lat_b = round(base_lat + (y*latstep), 6)
lat_t = round(base_lat + ((y+1)*latstep), 6)
lng_l = round(base_lng + (x*lngstep), 6)
lng_r = round(base_lng + ((x+1)*lngstep), 6)
# Minimal adjustment
if x == 0:
lng_l = base_lng
if y == 0:
lat_b = base_lat
if y == 3:
lat_t = base_lat + self._vstep
if x == 3:
lng_r = base_lng + mstr_zl_18
# Corrections, just in case
if lat_b > self._lat + 1: lat_b = self._lat+1
if lat_t > self._lat + 1: lat_t = self._lat+1
if lng_l > self._lng + 1: lng_l = self._lng+1
if lng_r > self._lng + 1: lng_r = self._lng+1
hgt_bl_idx = self.find_height_for_coord([lat_b, lng_l])
hgt_br_idx = self.find_height_for_coord([lat_b, lng_r])
hgt_tr_idx = self.find_height_for_coord([lat_t, lng_r])
hgt_tl_idx = self.find_height_for_coord([lat_t, lng_l])
hgt_bl = round(self._demcoord[ hgt_bl_idx[0] ][ hgt_bl_idx[1] ][2] - .01, 6)
hgt_br = round(self._demcoord[ hgt_br_idx[0] ][ hgt_br_idx[1] ][2] - .01, 6)
hgt_tr = round(self._demcoord[ hgt_tr_idx[0] ][ hgt_tr_idx[1] ][2] - .01, 6)
hgt_tl = round(self._demcoord[ hgt_tl_idx[0] ][ hgt_tl_idx[1] ][2] - .01, 6)
# Coords of triangle vertices
# 0 - Longitude
# 1 - Latitude
# 2 - Height in m
t1_v1 = [ lng_r, lat_b, hgt_br ]
t1_v2 = [ lng_l, lat_t, hgt_tl ]
t1_v3 = [ lng_r, lat_t, hgt_tr ]
t2_v1 = [ lng_l, lat_t, hgt_tl ]
t2_v2 = [ lng_r, lat_b, hgt_br ]
t2_v3 = [ lng_l, lat_b, hgt_bl ]
# Write down the two triangles
t_str = ""
t_str = t_str + "BEGIN_PRIMITIVE 0\r\n"
t_str = t_str + "PATCH_VERTEX " + str(t1_v1[0]) + " " + str(t1_v1[1]) + " " + str(t1_v1[2]) + " 0.000015 0.000015\r\n"
t_str = t_str + "PATCH_VERTEX " + str(t1_v2[0]) + " " + str(t1_v2[1]) + " " + str(t1_v2[2]) + " 0.000015 0.000015\r\n"
t_str = t_str + "PATCH_VERTEX " + str(t1_v3[0]) + " " + str(t1_v3[1]) + " " + str(t1_v3[2]) + " 0.000015 0.000015\r\n"
t_str = t_str + "END_PRIMITIVE 0\r\n"
t_str = t_str + "BEGIN_PRIMITIVE 0\r\n"
t_str = t_str + "PATCH_VERTEX " + str(t2_v1[0]) + " " + str(t2_v1[1]) + " " + str(t2_v1[2]) + " 0.000015 0.000015\r\n"
t_str = t_str + "PATCH_VERTEX " + str(t2_v2[0]) + " " + str(t2_v2[1]) + " " + str(t2_v2[2]) + " 0.000015 0.000015\r\n"
t_str = t_str + "PATCH_VERTEX " + str(t2_v3[0]) + " " + str(t2_v3[1]) + " " + str(t2_v3[2]) + " 0.000015 0.000015\r\n"
t_str = t_str + "END_PRIMITIVE 0\r\n"
# Send to the file
with open(meshtxt, 'a') as textfile:
textfile.write(t_str)
# End this patch
with open(meshtxt, 'a') as textfile:
textfile.write("END PATCH\r\n")
# Increase patch number
curpatch = curpatch + 1
"""
# Find the next best matching height for a point