Added mechanism to remember the resource used in case affected water tiles needed re-rendering.

This commit is contained in:
Marcus Str. 2025-02-06 19:01:58 +01:00
parent 9ee77b9032
commit ef5fba6345
3 changed files with 24 additions and 9 deletions

View File

@ -129,6 +129,7 @@ mstr_ortho_layers = [
("highway", "residential", 4),
("highway", "primary", 6),
("highway", "secondary", 3),
("highway", "trunk", 3)
("highway", "tertiary", 5),
("highway", "unclassified", 4),
("highway", "living_street", 3),
@ -239,6 +240,7 @@ mstr_mask_blur = [
# Z-Order 4
("highway", "motorway", 0.5),
("highway", "primary", 0.5),
("highway", "trunk", 0.5),
("highway", "secondary", 0.5),
("highway", "tertiary", 0.5),
("highway", "unclassified", 0.5),

View File

@ -67,9 +67,19 @@ class mstr_layergen:
self._latlngfld = latlngfld
# Set the resource to use
def set_resource(self, res):
self._resource = res
def load_resource(self):
self._resource = -1
fnlines = []
fn = mstr_datafolder + "z_orthographic/data/" + self._latlngfld + "/resdata"
with open(fn) as textfile:
fnlines = textfile.readlines()
for l in range(0, len(fnlines)):
linedata = fnlines[l].split(" ")
if linedata[0] == self._tag and linedata[1] == self._value:
self._resource = int(linedata[2])
break
# Tile info object
def open_tile_info(self):
self._tileinfo = mstr_tileinfo(self._latitude, self._longitude, self._lat_number, self._lng_number, self._latlngfld)
@ -654,7 +664,7 @@ class mstr_layergen:
# Highways and runways of any kind get some special treatment
if (self._tag == "highway" and self._value == "motorway") or (self._tag == "highway" and self._value == "primary") or (self._tag == "highway" and self._value == "secondary") or (self._tag == "highway" and self._value == "tertiary") or (self._tag == "aeroway" and self._value == "runway"):
if (self._tag == "highway" and self._value == "motorway") or (self._tag == "highway" and self._value == "primary") or (self._tag == "highway" and self._value == "secondary") or (self._tag == "highway" and self._value == "tertiary") or (self._tag == "aeroway" and self._value == "runway") or (self._tag == "highway" and self._value == "trunk"):
# We will now add some white lines for coolness
osm_edge = mask.filter(ImageFilter.FIND_EDGES)
mask_pix = osm_edge.load()

View File

@ -74,6 +74,14 @@ class mstr_orthographic:
rs = [ l[0], l[1], randrange(1, 16) ]
self._tile_resources.append(rs)
# Save to disk
fn = mstr_datafolder + "z_orthographic/data/" + self._latlngfld + "/resdata"
if os.path.isfile(fn) == False:
for rsd in range(0, len(self._tile_resources)):
line = self._tile_resources[rsd][0] + " " + self._tile_resources[rsd][1] + " " + str(self._tile_resources[rsd][2]) + "\r\n"
with open(fn, 'a') as textfile:
textfile.write(line)
# This will determine the vertical stepping in degrees in order to generate
# masks with a 1:1 square ratio. This is important as X-Plane textures for
@ -371,12 +379,7 @@ class mstr_orthographic:
lg.set_zoomlevel(self._zoomlevelfactor)
# Find resource to use
rs = -1
for r in self._tile_resources:
if r[0] == layer[0] and r[1] == layer[1]:
rs = r[2]
break
lg.set_resource(rs)
lg.load_resource()
#lg.open_tile_info()
lyr = lg.genlayer(mask, osmxml)