From adcf86cc70ad57b00cba8dc4d3a2c015d50e4e86 Mon Sep 17 00:00:00 2001 From: marstr Date: Sun, 1 Sep 2024 11:13:11 +0200 Subject: [PATCH] RC2 Release - amended stream rendering, corrected street line adding, check for existence of ZL16 tiles so that work can continue at a later stage --- layergen.py | 8 ++++++- tiledb.py | 2 +- tilegen.py | 64 ++++++++++++++++++++++++++++------------------------- 3 files changed, 42 insertions(+), 32 deletions(-) diff --git a/layergen.py b/layergen.py index 39cc85c..d25a772 100644 --- a/layergen.py +++ b/layergen.py @@ -293,6 +293,12 @@ class mstr_layergen: osm_edge = osm_edge.filter(ImageFilter.BoxBlur(radius=2)) layer_border = self.genborder(osm_edge, "landuse", "meadow") layer_comp.alpha_composite(layer_border) + # Give streams a more natural look + if self._tag == "waterway" and (self._value == "stream" or self._value == "river"): + osm_edge = osm_edge.filter(ImageFilter.ModeFilter(size=15)) + osm_edge = osm_edge.filter(ImageFilter.BoxBlur(radius=2)) + layer_border = self.genborder(osm_edge, "natural", "wetland") + layer_comp.alpha_composite(layer_border) # Store layer @@ -502,7 +508,7 @@ class mstr_layergen: mstr_msg("mstr_layergen", "Shadow layer completed") # 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 == "unclassified") 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"): # We will now add some white lines for coolness mask_pix = osm_edge.load() layer_comp_pix = layer_comp.load() diff --git a/tiledb.py b/tiledb.py index c8b7363..9c81c50 100644 --- a/tiledb.py +++ b/tiledb.py @@ -53,7 +53,7 @@ class mstr_tiledb: # Insert an airport with ICAO code def insert_icao(self, icao, tv, th, lat, lng): - self._conn.execute("INSERT INTO airports VALUES ('"+icao+"', "+tv+", "+th+", "+lat+", "+lng+");") + self._conn.execute("INSERT INTO airports VALUES ('"+icao+"', "+str(tv)+", "+str(th)+", "+str(lat)+", "+str(lng)+");") # Commit a query or a number of queries diff --git a/tilegen.py b/tilegen.py index e1fbc0f..bdb1e13 100644 --- a/tilegen.py +++ b/tilegen.py @@ -67,43 +67,47 @@ class mstr_tilegen: # OK... so. Let's finish this. for lt in range(1, steps_lat): for ln in range(1, steps_lng): - # Find out which tiles to process - tiles = findZL16tiles(cur_lat, cur_lng) - - # Generate the ZL16 image - zl16 = Image.new("RGB", (mstr_photores, mstr_photores)) - - # Walk through this array - xpos = 0 - ypos = int(scaled_res*3) - for i in range(0, 3): - for j in range(0, 3): - # We may run into situations where ask for tiles that don't exist... - # Let's make sure we can continue - fpath = mstr_datafolder + "Tiles\\" + str(self._lat) + "_" + str(self._lng) + "\\Textures\\" + str(tiles[i][j][0]) + "_" + str(tiles[i][j][1]) + ".jpg" - if os.path.isfile( fpath ): - tlimg = Image.open(fpath) - tlimg = tlimg.resize((scaled_res,scaled_res), Image.Resampling.BILINEAR) - zl16.paste(tlimg, (xpos, ypos)) - xpos = xpos + scaled_res - xpos = 0 - ypos = ypos - scaled_res + # Check if we need to do something + if os.path.isfile(mstr_datafolder + "Tiles\\" + str(self._lat) + "_" + str(self._lng) + "\\Textures\\" + str(self._lat) + "-" + str(ln) + "_" + str(self._lng) + "-" + str(lt) + "_OG16.jpg") == False: + + mstr_msg("mstr_tilegen", "Generating missing zoom level 16 ortho " + str(self._lat) + "-" + str(ln) + "_" + str(self._lng) + "-" + str(lt) + "_OG16.jpg") + + # Find out which tiles to process + tiles = findZL16tiles(cur_lat, cur_lng) - # Now save this image - zl16.save(mstr_datafolder + "Tiles\\" + str(self._lat) + "_" + str(self._lng) + "\\Textures\\" + str(self._lat) + "-" + str(ln) + "_" + str(self._lng) + "-" + str(lt) + "_OG16.jpg", format='JPEG', subsampling=0, quality=100) + # Generate the ZL16 image + zl16 = Image.new("RGB", (mstr_photores, mstr_photores)) - # Store a terrain file - dmt = self._findWidthOfLongitude(a_lat) * mstr_zl_16 - ter_content = """A + # Walk through this array + xpos = 0 + ypos = int(scaled_res*3) + for i in range(0, 3): + for j in range(0, 3): + # We may run into situations where ask for tiles that don't exist... + # Let's make sure we can continue + fpath = mstr_datafolder + "Tiles\\" + str(self._lat) + "_" + str(self._lng) + "\\Textures\\" + str(tiles[i][j][0]) + "_" + str(tiles[i][j][1]) + ".jpg" + if os.path.isfile( fpath ): + tlimg = Image.open(fpath) + tlimg = tlimg.resize((scaled_res,scaled_res), Image.Resampling.BILINEAR) + zl16.paste(tlimg, (xpos, ypos)) + xpos = xpos + scaled_res + xpos = 0 + ypos = ypos - scaled_res + + # Now save this image + zl16.save(mstr_datafolder + "Tiles\\" + str(self._lat) + "_" + str(self._lng) + "\\Textures\\" + str(self._lat) + "-" + str(ln) + "_" + str(self._lng) + "-" + str(lt) + "_OG16.jpg", format='JPEG', subsampling=0, quality=100) + + # Store a terrain file + dmt = self._findWidthOfLongitude(a_lat) * mstr_zl_16 + ter_content = """A 800 TERRAIN LOAD_CENTER """ + str(a_lat) + " " + str(a_lng) + " " + str(dmt) + " " + "../Textures/" + str(self._lat) + "-" + str(ln) + "_" + str(self._lng) + "-" + str(lt) + "_OG_16.jpg"+""" NO_ALPHA""" - with open(mstr_datafolder + "\\Tiles\\"+str(self._lat)+"_"+str(self._lng)+"\\terrain\\"+str(self._lat)+"_"+str(lt)+"-"+str(self._lng)+"-"+str(ln)+"_OG16.ter", 'w') as textfile: - textfile.write(ter_content) - mstr_msg("mstr_tilegen", "Wrote .ter file") - + with open(mstr_datafolder + "\\Tiles\\"+str(self._lat)+"_"+str(self._lng)+"\\terrain\\"+str(self._lat)+"_"+str(lt)+"-"+str(self._lng)+"-"+str(ln)+"_OG16.ter", 'w') as textfile: + textfile.write(ter_content) + mstr_msg("mstr_tilegen", "Wrote .ter file") # Adjust a_lng = a_lng + (mstr_zl_16 * 4) -- 2.30.2