Made forest lines look much more natural, adjusted coloring of some roads and streets, corrected layering, added graphical patch files to make some natural features look more realistic.
BIN
Textures/landuse/grass/brd/b5.png
Normal file
After Width: | Height: | Size: 4.2 MiB |
BIN
Textures/landuse/grass/ptc/b5_p1.png
Normal file
After Width: | Height: | Size: 1.7 MiB |
BIN
Textures/landuse/grass/ptc/b5_p2.png
Normal file
After Width: | Height: | Size: 1.6 MiB |
BIN
Textures/tile/completion/p1.png
Normal file
After Width: | Height: | Size: 3.9 MiB |
BIN
Textures/tile/completion/p2.png
Normal file
After Width: | Height: | Size: 4.0 MiB |
BIN
Textures/tile/completion/p3.png
Normal file
After Width: | Height: | Size: 4.1 MiB |
BIN
Textures/tile/completion/p4.png
Normal file
After Width: | Height: | Size: 3.0 MiB |
BIN
Textures/tile/completion/p5.png
Normal file
After Width: | Height: | Size: 485 KiB |
BIN
Textures/tile/completion/p6.png
Normal file
After Width: | Height: | Size: 3.4 MiB |
BIN
Textures/tile/completion/p7.png
Normal file
After Width: | Height: | Size: 3.0 MiB |
14
defines.py
@ -95,6 +95,7 @@ mstr_ortho_layers = [
|
|||||||
("landuse", "farmyard", "landuse", "farmland"),
|
("landuse", "farmyard", "landuse", "farmland"),
|
||||||
("landuse", "military", "landuse", "residential-boundary"),
|
("landuse", "military", "landuse", "residential-boundary"),
|
||||||
# Z-Order 2
|
# Z-Order 2
|
||||||
|
("highway", "service", 6),
|
||||||
("waterway", "river", 10),
|
("waterway", "river", 10),
|
||||||
("waterway", "stream", 10),
|
("waterway", "stream", 10),
|
||||||
("leisure", "nature_reserve", "landuse", "forest"),
|
("leisure", "nature_reserve", "landuse", "forest"),
|
||||||
@ -113,10 +114,9 @@ mstr_ortho_layers = [
|
|||||||
("highway", "primary", 25),
|
("highway", "primary", 25),
|
||||||
("highway", "secondary", 13),
|
("highway", "secondary", 13),
|
||||||
("highway", "tertiary", 20),
|
("highway", "tertiary", 20),
|
||||||
("highway", "unclassified", 12),
|
("highway", "unclassified", 17),
|
||||||
("highway", "living_street", 12),
|
("highway", "living_street", 12),
|
||||||
("highway", "residential", 12),
|
("highway", "residential", 12),
|
||||||
("highway", "service", 6),
|
|
||||||
("highway", "footway", 4),
|
("highway", "footway", 4),
|
||||||
("railway", "rail", 5),
|
("railway", "rail", 5),
|
||||||
# Z-Order 5
|
# Z-Order 5
|
||||||
@ -176,11 +176,11 @@ mstr_mask_blur = [
|
|||||||
("highway", "primary", 5),
|
("highway", "primary", 5),
|
||||||
("highway", "secondary", 5),
|
("highway", "secondary", 5),
|
||||||
("highway", "tertiary", 5),
|
("highway", "tertiary", 5),
|
||||||
("highway", "unclassified", 10),
|
("highway", "unclassified", 5),
|
||||||
("highway", "living_street", 10),
|
("highway", "living_street", 5),
|
||||||
("highway", "residential", 10),
|
("highway", "residential", 5),
|
||||||
("highway", "service", 5),
|
("highway", "service", 3),
|
||||||
("highway", "footway", 5),
|
("highway", "footway", 3),
|
||||||
("highway", "track", 3),
|
("highway", "track", 3),
|
||||||
("highway", "path", 3),
|
("highway", "path", 3),
|
||||||
("railway", "rail", 4),
|
("railway", "rail", 4),
|
||||||
|
@ -58,4 +58,11 @@ def findZL16tiles(v, h):
|
|||||||
tr.append(tl)
|
tr.append(tl)
|
||||||
tiles.append(tr)
|
tiles.append(tr)
|
||||||
|
|
||||||
return tiles
|
return tiles
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
def in_circle(center_x, center_y, radius, x, y):
|
||||||
|
square_dist = (center_x - x) ** 2 + (center_y - y) ** 2
|
||||||
|
return square_dist <= radius ** 2
|
59
layergen.py
@ -16,11 +16,12 @@ import glob
|
|||||||
import os
|
import os
|
||||||
from random import randrange
|
from random import randrange
|
||||||
import random
|
import random
|
||||||
from PIL import Image, ImageFilter
|
from PIL import Image, ImageFilter, ImageDraw, ImagePath
|
||||||
from defines import *
|
from defines import *
|
||||||
from log import *
|
from log import *
|
||||||
from tiledb import *
|
from tiledb import *
|
||||||
from osmxml import *
|
from osmxml import *
|
||||||
|
from functions import *
|
||||||
|
|
||||||
class mstr_layergen:
|
class mstr_layergen:
|
||||||
|
|
||||||
@ -204,6 +205,27 @@ class mstr_layergen:
|
|||||||
osm_edge = osm_edge.filter(ImageFilter.MaxFilter)
|
osm_edge = osm_edge.filter(ImageFilter.MaxFilter)
|
||||||
mstr_msg("mstr_layergen", "Edge mask generated")
|
mstr_msg("mstr_layergen", "Edge mask generated")
|
||||||
|
|
||||||
|
# This adds some natural looking shapes to these types of features
|
||||||
|
if self._value == "forest" or self._value == "nature_reserve":
|
||||||
|
epx = osm_edge.load()
|
||||||
|
imgd = ImageDraw.Draw(osm_mask)
|
||||||
|
|
||||||
|
# Walk through a grid of 200x200 - on the edge image
|
||||||
|
for y in range(0, osm_mask.height, int(osm_mask.height/200)):
|
||||||
|
for x in range(0, osm_mask.width, int(osm_mask.width/200)):
|
||||||
|
px = epx[x,y]
|
||||||
|
if px[3] == 255:
|
||||||
|
rx = randrange(30,60)
|
||||||
|
ry = randrange(30,60)
|
||||||
|
f = randrange(1,10)
|
||||||
|
|
||||||
|
# Do some magic
|
||||||
|
if f != 5:
|
||||||
|
imgd.ellipse((x-int(rx/2), y-int(ry/2), x+rx, y+ry), fill="black")
|
||||||
|
if f == 3 or f == 7:
|
||||||
|
imgd.ellipse((x-int(rx/2), y-int(ry/2), x+rx, y+ry), fill=(0,0,0,0))
|
||||||
|
|
||||||
|
|
||||||
# We need to change the image in certain conditions
|
# We need to change the image in certain conditions
|
||||||
if self._value == "hedge" and self._tag == "barrier":
|
if self._value == "hedge" and self._tag == "barrier":
|
||||||
osm_mask = osm_edge
|
osm_mask = osm_edge
|
||||||
@ -229,6 +251,18 @@ class mstr_layergen:
|
|||||||
layer.alpha_composite( ptc_src[imgid], ( randrange(l, r), randrange(t, b) ) )
|
layer.alpha_composite( ptc_src[imgid], ( randrange(l, r), randrange(t, b) ) )
|
||||||
mstr_msg("mstr_layergen", "Layer image generated")
|
mstr_msg("mstr_layergen", "Layer image generated")
|
||||||
|
|
||||||
|
|
||||||
|
# Here we need to do some magic to make some features look more natural
|
||||||
|
if (self._tag == "landuse" and self._value == "meadow") or (self._tag == "natural" and self._value == "grassland") or (self._tag == "natural" and self._value == "heath"):
|
||||||
|
amt = randrange(1,3)
|
||||||
|
for i in range(1, amt):
|
||||||
|
ptc = randrange(1, 7)
|
||||||
|
img = Image.open(mstr_datafolder + "Textures\\tile\\completion\\p" + str(ptc)+".png")
|
||||||
|
lx = randrange( int(layer.width/20), layer.width - (int(layer.width/20)) - img.width )
|
||||||
|
ly = randrange( int(layer.width/20), layer.width - (int(layer.width/20)) - img.width )
|
||||||
|
layer.alpha_composite( img, (lx, ly) )
|
||||||
|
|
||||||
|
|
||||||
# We now need to add the seamless border
|
# We now need to add the seamless border
|
||||||
layer.alpha_composite( brd_src )
|
layer.alpha_composite( brd_src )
|
||||||
mstr_msg("mstr_layergen", "Layer image completed")
|
mstr_msg("mstr_layergen", "Layer image completed")
|
||||||
@ -259,17 +293,6 @@ class mstr_layergen:
|
|||||||
layer_border = self.genborder(osm_edge, "landuse", "meadow")
|
layer_border = self.genborder(osm_edge, "landuse", "meadow")
|
||||||
layer_comp.alpha_composite(layer_border)
|
layer_comp.alpha_composite(layer_border)
|
||||||
|
|
||||||
# If this is the completion layer, we may add some aditional patches to the image
|
|
||||||
# for more realism
|
|
||||||
if self._is_completion == True:
|
|
||||||
cl = randrange(1, 10)
|
|
||||||
for i in range(1, cl):
|
|
||||||
p = randrange(1, 2)
|
|
||||||
ptc = Image.open(mstr_datafolder + "Textures\\tile\\completion\\p"+str(p)+".png")
|
|
||||||
rdx = randrange(1, self._imgsize-1-ptc.width)
|
|
||||||
rdy = randrange(1, self._imgsize-1-ptc.height)
|
|
||||||
layer_comp.alpha_composite(ptc, (rdx, rdy))
|
|
||||||
|
|
||||||
|
|
||||||
# Store layer
|
# Store layer
|
||||||
if self._is_completion == False:
|
if self._is_completion == False:
|
||||||
@ -403,9 +426,15 @@ class mstr_layergen:
|
|||||||
if self._tag == "railway":
|
if self._tag == "railway":
|
||||||
d = randrange(41, 61)
|
d = randrange(41, 61)
|
||||||
layer_comp_pix[x, y] = ( d,d,d,a[3] )
|
layer_comp_pix[x, y] = ( d,d,d,a[3] )
|
||||||
if self._tag == "highway":
|
if self._tag == "highway" and self._value != "motorway":
|
||||||
d = randrange(160,180)
|
d = randrange(140,160)
|
||||||
layer_comp_pix[x, y] = ( d,d,d,a[3] )
|
layer_comp_pix[x, y] = ( d,d,d,a[3] )
|
||||||
|
if self._tag == "highway" and self._value == "motorway":
|
||||||
|
d = randrange(1,20)
|
||||||
|
r = 86-d
|
||||||
|
g = 97-d
|
||||||
|
b = 106-d
|
||||||
|
layer_comp_pix[x, y] = ( r,g,b,a[3] )
|
||||||
if self._tag == "waterway" and (self._value == "stream" or self._value == "river"):
|
if self._tag == "waterway" and (self._value == "stream" or self._value == "river"):
|
||||||
d = randrange(1, 15)
|
d = randrange(1, 15)
|
||||||
layer_comp_pix[x, y] = ( 129-d, 148-d, 159-d, a[3] )
|
layer_comp_pix[x, y] = ( 129-d, 148-d, 159-d, a[3] )
|
||||||
@ -462,7 +491,7 @@ class mstr_layergen:
|
|||||||
mstr_msg("mstr_layergen", "Shadow layer completed")
|
mstr_msg("mstr_layergen", "Shadow layer completed")
|
||||||
|
|
||||||
# Highways and runways of any kind get some special treatment
|
# Highways and runways of any kind get some special treatment
|
||||||
if (self._tag == "highway" and self._value == "motorway") or (self._tag == "aeroway" and self._value == "runway"):
|
if (self._tag == "highway" and self._value == "motorway") or (self._tag == "highway" and self._value == "unclassified") or (self._tag == "aeroway" and self._value == "runway"):
|
||||||
# We will now add some white lines for coolness
|
# We will now add some white lines for coolness
|
||||||
mask_pix = osm_edge.load()
|
mask_pix = osm_edge.load()
|
||||||
layer_comp_pix = layer_comp.load()
|
layer_comp_pix = layer_comp.load()
|
||||||
|
@ -26,6 +26,8 @@ from osmxml import *
|
|||||||
from defines import *
|
from defines import *
|
||||||
from log import *
|
from log import *
|
||||||
from PIL import Image, ImageFilter, ImageDraw, ImagePath
|
from PIL import Image, ImageFilter, ImageDraw, ImagePath
|
||||||
|
from random import randrange
|
||||||
|
import random
|
||||||
|
|
||||||
class mstr_maskgen:
|
class mstr_maskgen:
|
||||||
|
|
||||||
@ -174,7 +176,7 @@ class mstr_maskgen:
|
|||||||
if mstr_ortho_layers[i][0] == self._tag and mstr_ortho_layers[i][1] == self._value:
|
if mstr_ortho_layers[i][0] == self._tag and mstr_ortho_layers[i][1] == self._value:
|
||||||
idx = i
|
idx = i
|
||||||
break
|
break
|
||||||
imgd.line(pts, fill="#000000", width=mstr_ortho_layers[idx][2])
|
imgd.line(pts, fill="#000000", width=mstr_ortho_layers[idx][2], joint="curve")
|
||||||
|
|
||||||
# Save image
|
# Save image
|
||||||
mask_img.save(mstr_datafolder + "_cache\\" + fstr + "_" + self._tag + "-" + self._value + ".png")
|
mask_img.save(mstr_datafolder + "_cache\\" + fstr + "_" + self._tag + "-" + self._value + ".png")
|
||||||
@ -184,7 +186,7 @@ class mstr_maskgen:
|
|||||||
|
|
||||||
#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "natural", "bare_rock")
|
#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "natural", "bare_rock")
|
||||||
#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "highway", "track")
|
#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "highway", "track")
|
||||||
#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "landuse", "forest")
|
#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "landuse", "forest", False)
|
||||||
#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "natural", "water")
|
#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "natural", "water")
|
||||||
#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "leisure", "golf_course")
|
#mg = mstr_maskgen([51, 1, 7, 1], 0.0100691262567974, "leisure", "golf_course")
|
||||||
#mg = mstr_maskgen([51, 2, 7, 5], 0.0100691262567974, "boundary", "administrative", "admin_level", ["6"])
|
#mg = mstr_maskgen([51, 2, 7, 5], 0.0100691262567974, "boundary", "administrative", "admin_level", ["6"])
|
||||||
|
@ -118,7 +118,11 @@ class mstr_orthographic:
|
|||||||
os.makedirs(self._output + "/Tiles/"+str(self._lat)+"_"+str(self._long)+"\\terrain")
|
os.makedirs(self._output + "/Tiles/"+str(self._lat)+"_"+str(self._long)+"\\terrain")
|
||||||
mstr_msg("mstr_orthographic", "Created tile terrain folder")
|
mstr_msg("mstr_orthographic", "Created tile terrain folder")
|
||||||
|
|
||||||
|
curlyr = 1
|
||||||
for layer in layers:
|
for layer in layers:
|
||||||
|
# Let the user know
|
||||||
|
mstr_msg("mstr_orthographic", "Processing layer " + str(curlyr) + " of " + str(len(layers)))
|
||||||
|
|
||||||
# Generate the mask
|
# Generate the mask
|
||||||
mg = mstr_maskgen( [self._lat, cur_tile_y, self._long, cur_tile_x], self._vstep, layer[0], layer[1], layer[2] )
|
mg = mstr_maskgen( [self._lat, cur_tile_y, self._long, cur_tile_x], self._vstep, layer[0], layer[1], layer[2] )
|
||||||
mg._build_mask()
|
mg._build_mask()
|
||||||
@ -126,6 +130,7 @@ class mstr_orthographic:
|
|||||||
# Generate the layer
|
# Generate the layer
|
||||||
lg = mstr_layergen(layer[0], layer[1], self._lat, cur_tile_y, self._long, cur_tile_x, layer[2])
|
lg = mstr_layergen(layer[0], layer[1], self._lat, cur_tile_y, self._long, cur_tile_x, layer[2])
|
||||||
lg.genlayer()
|
lg.genlayer()
|
||||||
|
curlyr = curlyr+1
|
||||||
mstr_msg("mstr_orthographic", "All layers created")
|
mstr_msg("mstr_orthographic", "All layers created")
|
||||||
|
|
||||||
# We should have all layers now.
|
# We should have all layers now.
|
||||||
|
@ -73,7 +73,7 @@ class mstr_photogen:
|
|||||||
# aforementioned fix:
|
# aforementioned fix:
|
||||||
if emptyspace == True:
|
if emptyspace == True:
|
||||||
# Choose a suitable layer type
|
# Choose a suitable layer type
|
||||||
lt = [5,14,15]
|
lt = [6,14,17]
|
||||||
pick = randrange(0,len(lt)-1)
|
pick = randrange(0,len(lt)-1)
|
||||||
ltp = lt[pick]
|
ltp = lt[pick]
|
||||||
tag = mstr_ortho_layers[ltp][0]
|
tag = mstr_ortho_layers[ltp][0]
|
||||||
|