Removed comments in some code, updated repoinfo

This commit is contained in:
Marcus Str. 2024-11-17 09:11:52 +01:00
parent 9631df0150
commit ca02337f23
4 changed files with 5 additions and 125 deletions

View File

@ -200,14 +200,6 @@ class mstr_layergen:
ptc_src.append(Image.open(p)) ptc_src.append(Image.open(p))
mstr_msg("layergen", "Layer sources selected") mstr_msg("layergen", "Layer sources selected")
"""
# OK! Load the mask
if self._is_completion == False:
mask = Image.open( mstr_datafolder + "_cache/" + str(self._latitude) + "-" + str(self._lat_number) + "_" + str(self._longitude) + "-" + str(self._lng_number) + "_" + self._tag + "-" + self._value + ".png" )
if self._is_completion == True:
mask = Image.open( mstr_datafolder + "_cache/" + str(self._latitude) + "-" + str(self._lat_number) + "_" + str(self._longitude) + "-" + str(self._lng_number) + "_tile-completion.png" )
"""
# Generate an edge mask from the original # Generate an edge mask from the original
osm_edge = mask.filter(ImageFilter.FIND_EDGES) osm_edge = mask.filter(ImageFilter.FIND_EDGES)
osm_edge = osm_edge.filter(ImageFilter.MaxFilter) osm_edge = osm_edge.filter(ImageFilter.MaxFilter)
@ -376,23 +368,6 @@ class mstr_layergen:
mstr_msg("layergen", "Generating adjacent fades") mstr_msg("layergen", "Generating adjacent fades")
adjfade = self.generate_adjacent_fades(mask) adjfade = self.generate_adjacent_fades(mask)
# Determine if there are any fades, and if so, fade those in first before we save the layer
"""
fade_fn = mstr_datafolder + "_cache/" + str(self._latitude) + "-" + str(self._lat_number) + "_" + str(self._longitude) + "-" + str(self._lng_number) + "_" + self._tag + "-" + self._value
if os.path.isfile(fade_fn + "_fade_top.png") == True:
fade = Image.open(fade_fn + "_fade_top.png")
layer_comp.alpha_composite(fade)
if os.path.isfile(fade_fn + "_fade_right.png") == True:
fade = Image.open(fade_fn + "_fade_right.png")
layer_comp.alpha_composite(fade)
if os.path.isfile(fade_fn + "_fade_bottom.png") == True:
fade = Image.open(fade_fn + "_fade_bottom.png")
layer_comp.alpha_composite(fade)
if os.path.isfile(fade_fn + "_fade_left.png") == True:
fade = Image.open(fade_fn + "_fade_left.png")
layer_comp.alpha_composite(fade)
"""
layer_comp.alpha_composite(adjfade) layer_comp.alpha_composite(adjfade)
mstr_msg("layergen", "Adjacent fading completed") mstr_msg("layergen", "Adjacent fading completed")
@ -726,16 +701,6 @@ class mstr_layergen:
tree_shadow = tree_shadow.filter(ImageFilter.GaussianBlur(radius=2)) tree_shadow = tree_shadow.filter(ImageFilter.GaussianBlur(radius=2))
tree_shadow.alpha_composite(trees) tree_shadow.alpha_composite(trees)
# Save this separately, so that we can blur buildings, but not the trees
#fn = mstr_datafolder + "_cache/" + str(self._latitude) + "-" + str(self._lat_number) + "_" + str(self._longitude) + "-" + str(self._lng_number) + "_" + self._tag + "-" + self._value + "_layer_building_trees.png"
#if os.path.isfile(fn) == True:
# extrees = Image.open(fn)
# extrees.alpha_composite(tree_shadow)
# extrees.save(fn)
#else:
# tree_shadow.save(fn)
# Let's try this one on for size # Let's try this one on for size
bld_comp = Image.new("RGBA", (self._imgsize, self._imgsize)) bld_comp = Image.new("RGBA", (self._imgsize, self._imgsize))
details = details.filter(ImageFilter.GaussianBlur(radius=1)) details = details.filter(ImageFilter.GaussianBlur(radius=1))

View File

@ -221,10 +221,6 @@ class mstr_orthographic:
# Let the user know # Let the user know
mstr_msg("orthographic", "Generating orthophoto " + str(grid_lat) + "-" + str(grid_lng)) mstr_msg("orthographic", "Generating orthophoto " + str(grid_lat) + "-" + str(grid_lng))
# Get the data
#osmxml.acquire_osm(cur_tile_y, cur_tile_x) # <- This acquires current OSM info
#mstr_msg("orthographic", "Acquired current OSM info from marstr.online repository")
# Check for work to be done # Check for work to be done
layers = self.determineLayerWork(osmxml) layers = self.determineLayerWork(osmxml)

View File

@ -46,86 +46,8 @@ class mstr_photogen:
# First, we walk through all layers and blend them on top of each other, in order # First, we walk through all layers and blend them on top of each other, in order
mstr_msg("photogen", "Merging layers") mstr_msg("photogen", "Merging layers")
"""
# Note if we added building shadows
bldg_shadow_added = False
# Shadow merging
bldg_shadow = Image.new("RGBA", (self._imgsize, self._imgsize))
if mstr_shadow_enabled == True:
for l in mstr_ortho_layers:
if l[0] == "building":
if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer_shadow.png"):
shd = Image.open(root_filename + l[0] + "-" + l[1] + "_layer_shadow.png")
shd = shd.filter(ImageFilter.GaussianBlur(radius=2))
bldg_shadow.alpha_composite(shd)
# Details merging
bldg_details = Image.new("RGBA", (self._imgsize, self._imgsize))
for l in mstr_ortho_layers:
if l[0] == "building":
if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer_details.png"):
dtl = Image.open(root_filename + l[0] + "-" + l[1] + "_layer_details.png")
dtl = dtl.filter(ImageFilter.GaussianBlur(radius=1))
bldg_details.alpha_composite(dtl)
# Building merging
bldg_main = Image.new("RGBA", (self._imgsize, self._imgsize))
for l in mstr_ortho_layers:
if l[0] == "building":
if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer.png"):
bld = Image.open(root_filename + l[0] + "-" + l[1] + "_layer.png")
bld = bld.filter(ImageFilter.GaussianBlur(radius=0.7))
bldg_main.alpha_composite(bld)
# Trees merging
tree_main = Image.new("RGBA", (self._imgsize, self._imgsize))
for l in mstr_ortho_layers:
if l[0] == "building":
if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer_building_trees.png"):
trs= Image.open(root_filename + l[0] + "-" + l[1] + "_layer_building_trees.png")
tree_main.alpha_composite(trs)
# Merge the building layers
bldg_final = Image.new("RGBA", (self._imgsize, self._imgsize))
bldg_final.alpha_composite(bldg_details)
#bldg_final.alpha_composite(bldg_shadow)
bldg_final.alpha_composite(tree_main)
bldg_final.alpha_composite(bldg_main)
"""
for l in layers: for l in layers:
self._tile.alpha_composite(l) self._tile.alpha_composite(l)
"""
if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer.png"):
# Need to divert in case we have shadows
if mstr_shadow_enabled == True:
# Make sure building shadows appear below forests
shdc = False
for s in mstr_shadow_casters:
if s[0] == l[0] and s[1] == l[1]:
shdc = True
break
if shdc == True:
if bldg_shadow_added == False:
self._tile.alpha_composite(bldg_shadow)
bldg_shadow_added = True
if os.path.isfile(root_filename + l[0] + "-" + l[1] + "_layer_shadow.png"):
if l[0] != "building":
sn = root_filename + l[0] + "-" + l[1] + "_layer_shadow.png"
s_layer = Image.open(sn)
self._tile.alpha_composite(s_layer)
if l[0] != "building":
# Complete the file name based on the template
fn = root_filename + l[0] + "-" + l[1] + "_layer.png"
# Open the layer
layer = Image.open(fn)
if l[0] == "leisure" and l[1] == "pitch":
layer = layer.filter(ImageFilter.GaussianBlur(radius=0.2))
# Converge the layer with this image
self._tile.alpha_composite(layer)
"""
# Drop the buildings on top
#self._tile.alpha_composite(bldg_final)
# When we have run through this loop, we will end up with a sandwiched # When we have run through this loop, we will end up with a sandwiched
@ -249,9 +171,6 @@ class mstr_photogen:
# We are now in posession of the final image. # We are now in posession of the final image.
# Scale to correct size.
#self._tile = self._tile.resize((mstr_photores, mstr_photores), Image.Resampling.BILINEAR)
# Contrast # Contrast
self._tile = ImageEnhance.Contrast(self._tile).enhance(1) self._tile = ImageEnhance.Contrast(self._tile).enhance(1)

View File

@ -101,21 +101,21 @@ Also in defines.py, you will find the single layers, along with their correspond
Very simple. Very simple.
First step: First step:
[codebox]python og.py LATITUDE LONGITUDE true[/codebox] python og.py LATITUDE LONGITUDE true
So for example So for example
[codebox]python main.py 51 7 true[codebox] python og.py 51 7 true
This will generate a complete dataset containing which sources to use in which quadrant of the image grid. This will generate a complete dataset containing which sources to use in which quadrant of the image grid.
Then: Then:
[codebox]python og.py LATITUDE LONGITUDE NUMBER_OF_SIMULTANEOUS_IMAGES_TO_PRODUCE[/codebox] python og.py LATITUDE LONGITUDE NUMBER_OF_SIMULTANEOUS_IMAGES_TO_PRODUCE
So for example So for example
[codebox]python main.py 51 7 32[codebox] python og.py 51 7 32
This will generate 32 "orthos" at once. Which number you can use highly depends on the performance of your hardware. This will generate 32 "orthos" at once. Which number you can use highly depends on the performance of your hardware.
@ -125,7 +125,7 @@ ATTENTION! This process will take a considerable amount of time due to the work
For X-Plane scenery, you will need to do this once step 2 is done: For X-Plane scenery, you will need to do this once step 2 is done:
[codebox]python main.py 51 7 xpscenery[codebox] python og.py 51 7 xpscenery
This will generate the terrain mesh and associate the textures with the mesh. This will generate the terrain mesh and associate the textures with the mesh.