Fixed critical issue at which all natural:water was removed, which does not need to be the case for all orthos. Implemented new mechanism to check against existence of an empty file to selectively run the water removal mechanism.

This commit is contained in:
Marcus Str. 2025-02-02 13:32:35 +01:00
parent 8f08b3dfb3
commit b3d5fca112

View File

@ -531,59 +531,61 @@ class mstr_photogen:
# At ZL16 there seems to be an issue with water bodies, especially rivers (natural:water). # At ZL16 there seems to be an issue with water bodies, especially rivers (natural:water).
# Let's see if we can correct that # Let's see if we can correct that
# natural:water # These files will need to be generated after manual check of the orthos
ntrl_water = False if os.path.isfile(mstr_datafolder + "z_orthographic/data" + self._latlngfld + "/water/" + str(self._ty) + "_" + str(self._tx)) == True:
ntrl_idx = 0 # natural:water
for lyr in self._lyrnames: ntrl_water = False
if lyr[0] == "natural" and lyr[1] == "water": ntrl_idx = 0
ntrl_water = True for lyr in self._lyrnames:
break if lyr[0] == "natural" and lyr[1] == "water":
ntrl_idx = ntrl_idx + 1 ntrl_water = True
break
ntrl_idx = ntrl_idx + 1
if ntrl_water == True: if ntrl_water == True:
# We'll go through all layers and "shavve off" excess. # We'll go through all layers and "shavve off" excess.
# This way we can hopefully correct incorrect line and polygon renders. # This way we can hopefully correct incorrect line and polygon renders.
for l in range(0, len(layers)): for l in range(0, len(layers)):
if l < ntrl_idx: # <- We don't want to load the target layer itself if l < ntrl_idx: # <- We don't want to load the target layer itself
lyrpix = layers[l].load() lyrpix = layers[l].load()
wtr_pix = layers[ntrl_idx].load() wtr_pix = layers[ntrl_idx].load()
for y in range(0, self._tile.height): for y in range(0, self._tile.height):
for x in range(0, self._tile.width): for x in range(0, self._tile.width):
lp = lyrpix[x,y] lp = lyrpix[x,y]
wp = wtr_pix[x,y] wp = wtr_pix[x,y]
if lp[3] > 0: if lp[3] > 0:
a = 255 - lp[3] a = 255 - lp[3]
if a < wp[3]: if a < wp[3]:
c = (wp[0], wp[1], wp[2], a) c = (wp[0], wp[1], wp[2], a)
wtr_pix[x,y] = c wtr_pix[x,y] = c
# water:river # water:river
river_water = False river_water = False
river_idx = 0 river_idx = 0
for lyr in self._lyrnames: for lyr in self._lyrnames:
if lyr[0] == "water" and lyr[1] == "river": if lyr[0] == "water" and lyr[1] == "river":
river_water = True river_water = True
break break
river_idx = river_idx + 1 river_idx = river_idx + 1
if river_water == True: if river_water == True:
# We'll go through all layers and "shavve off" excess. # We'll go through all layers and "shavve off" excess.
# This way we can hopefully correct incorrect line and polygon renders. # This way we can hopefully correct incorrect line and polygon renders.
for l in range(0, len(layers)): for l in range(0, len(layers)):
if l < river_idx and l != ntrl_idx: # <- We don't want to load the target layer itself if l < river_idx and l != ntrl_idx: # <- We don't want to load the target layer itself
lyrpix = layers[l].load() lyrpix = layers[l].load()
wtr_pix = layers[river_idx].load() wtr_pix = layers[river_idx].load()
for y in range(0, self._tile.height): for y in range(0, self._tile.height):
for x in range(0, self._tile.width): for x in range(0, self._tile.width):
lp = lyrpix[x,y] lp = lyrpix[x,y]
wp = wtr_pix[x,y] wp = wtr_pix[x,y]
if lp[3] > 0: if lp[3] > 0:
a = 255 - lp[3] a = 255 - lp[3]
if a < wp[3]: if a < wp[3]:
c = (wp[0], wp[1], wp[2], a) c = (wp[0], wp[1], wp[2], a)
wtr_pix[x,y] = c wtr_pix[x,y] = c
return layers return layers