From ef5fba6345cde284ca99fff910a8a139060a4521 Mon Sep 17 00:00:00 2001 From: "Marcus Str." Date: Thu, 6 Feb 2025 19:01:58 +0100 Subject: [PATCH] Added mechanism to remember the resource used in case affected water tiles needed re-rendering. --- defines.py | 2 ++ layergen.py | 16 +++++++++++++--- orthographic.py | 15 +++++++++------ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/defines.py b/defines.py index de6c727..2d04335 100644 --- a/defines.py +++ b/defines.py @@ -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), diff --git a/layergen.py b/layergen.py index 6f040d7..988573d 100644 --- a/layergen.py +++ b/layergen.py @@ -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() diff --git a/orthographic.py b/orthographic.py index 3f5d316..cff1183 100644 --- a/orthographic.py +++ b/orthographic.py @@ -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)